// straight out of the w3school tutorial except for three places

var xmlHttp

function queryLDAP(str)
{
if (str.length==0)
{ 
  return
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
return
}

// ********** Line 1 ********************
// the PHP program that is called
var url="getstatus.php"
// **************************************
// ********** Line 2 ********************
// The URL has the field name added to it  
url=url+"?Email="+str
// **************************************

url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

} // fxn  queryLDAP


function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 

   // ******************************************************
   // *********** Line 3 ***********************************
   results = xmlHttp.responseText.split(",");


   // one way of putting data back into an input field
   document.entry.First_Name.value = results[0];

   // a 2nd way of putting data back into an input field
   document.getElementById('Middle_Name').value = results[1];
   document.getElementById('Last_Name').value = results[2];
   document.getElementById('Phone').value = results[3];

   // ******************************************************
   // Take the info returned by the PHP program

   //  first, middle, last

   // And put it back into the form
} // if completed

} // fxn  stateChanged() 



function GetXmlHttpObject()
{ 
var objXMLHttp=null

// **************************************
// *** Browser Dependent Code ***********
// **************************************
if (window.XMLHttpRequest)
{
   objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
try
{
  objXMLHttp=new ActiveXObject("Msxml2.XMLHTTP")
}
catch(e)
{
 try
 {
   objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
   window.status = ""
 }
 catch(e)
 {
     objXMLHttp = new XMLHttpRequest() 
     window.status = ""
 }
} // catch
} // else if

// **************************************
// *** End Browser Dependent Code *******
// **************************************
return objXMLHttp
} // fxn  GetXmlHttpObject()
