// stores the reference to the XMLHttpRequest object
var xmlHttpS = createXmlHttpRequestObject(); 

var nm;
// retrieves the XMLHttpRequest object
function createXmlHttpRequestObject() 
{	
  // will store the reference to the XMLHttpRequest object
  var xmlHttpS;
  // if running Internet Explorer
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttpS = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) 
    {
      xmlHttpS = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try 
    {
      xmlHttpS = new XMLHttpRequest();
    }
    catch (e) 
    {
      xmlHttpS = false;
    }
  }
  // return the created object or display an error message
  if (!xmlHttpS)
 
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttpS;
}

// make asynchronous HTTP request using the XMLHttpRequest object 
function processS()
{ nm=0;
  // proceed only if the xmlHttp object isn't busy
  if (xmlHttpS.readyState == 4 || xmlHttpS.readyState == 0)
  {
    // retrieve the name typed by the user on the form
    name = encodeURIComponent(document.getElementById("myNameS").value);
    if(name.length > 0) {
    xmlHttpS.open("GET", "ac2S.php?name=" + name, true);  
	}
    // define the method to handle server responses
    xmlHttpS.onreadystatechange = handleServerResponseS;
    // make the server request
    xmlHttpS.send(null);
  }
}
function process2S()
{ nm=1;
  // proceed only if the xmlHttp object isn't busy
  if (xmlHttpS.readyState == 4 || xmlHttpS.readyState == 0)
  {
    // retrieve the name typed by the user on the form
    name = encodeURIComponent(document.getElementById("CountyNameS").value);
    if(name.length > 0) {
    xmlHttpS.open("GET", "ac22S.php?name=" + name, true);  
	}
    // define the method to handle server responses
    xmlHttpS.onreadystatechange = handleServerResponseS;
    // make the server request
    xmlHttpS.send(null);
  }
}
// executed automatically when a message is received from the server
function handleServerResponseS(inpval) 
{
  // move forward only if the transaction has completed
  if (xmlHttpS.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttpS.status == 200) 
    {
      if (!nm)
      document.getElementById("divMessageS").innerHTML = xmlHttpS.responseText;
      else 
      document.getElementById("divMessage2S").innerHTML = xmlHttpS.responseText;
    } 
    else 
    {
      alert("There was a problem accessing the server: " + xmlHttpS.statusText);
    }
  }
}
