// JavaScript Document
/**
 *=-------------------------------------------------------=
 * getNewHTTPObject
 *=-------------------------------------------------------=
 * This function is here just to create a new
 * XmlHttpRequest object.
 */
function getNewHTTPObject()
{
    var xmlhttp;

    /** Special IE only code ... */
    /*@cc_on
      @if (@_jscript_version >= 5)
          try
          {
              xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
          }
          catch (e)
          {
              try
              {
                  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
              }
              catch (E)
              {
                  xmlhttp = false;
              }
         }
      @else
         xmlhttp = false;
    @end @*/

    /** Every other browser on the planet */
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
    {
        try
        {
            xmlhttp = new XMLHttpRequest();
        }
        catch (e)
        {
            xmlhttp = false;
        }
    }

    return xmlhttp;
}

/**
 *=-------------------------------------------------------=
 * onLoadFunction
 *=-------------------------------------------------------=
 * We call this function when the page loads, and it starts
 * two asynchronous Ajax requests to race2.php.
 */
var xml1;
function internetError()
{
    var url;
    var path;
    url = protocol+"//"+hostname;
    if (pathname.search("index.php") > 0) { path=pathname.replace("index.php","itest.php");} 
    else {path=pathname+"itest.php";}
    if (port != "") {url=url+":"+port};
    url = url+path; 
    httpRequest = getNewHTTPObject();
    session_id = document.getElementById("sid").value;
    httpRequest.open('GET', url+'?sid='+session_id+'&inet=false', true);
    httpRequest.onreadystatechange = function () {processRequest(); } ;
    httpRequest.send('');
}

function internetOk()
{
    var url;
    var path;
    url = protocol+"//"+hostname;
    if (pathname.search("index.php") > 0) { path=pathname.replace("index.php","itest.php");} 
    else {path=pathname+"itest.php";}
    if (port != "") {url=url+":"+port};
    url = url+path; 
    httpRequest = getNewHTTPObject();
    session_id = document.getElementById("sid").value;
    httpRequest.open('GET', url+'?sid='+session_id+'&inet=true', true);
    httpRequest.onreadystatechange = function () {processRequest(); } ;
    httpRequest.send('');
}

/**
 *=-------------------------------------------------------=
 * handleResponse1
 *=-------------------------------------------------------=
 * This handles the response from the first ajax request.
 * It puts the returned string in the <div> element
 * with th eid 'fudgecicles'
 */
function processRequest()
{ 
    if (httpRequest.readyState == 4)
    {
        //alert(httpRequest.responseText);
        done = true;
    }
}
