// JavaScript Document
// Darren George
var xmlHttp;

//get the xmlHttpRequest javascript
//object needed for communicating
//with the server
//n.b. supports all modern browsers
function GetXmlHttpObject()
  {
  var xmlHttp = null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
  return xmlHttp;
  }
  
//given a url sends a HTTP
//GET request to the server
function MakeServerRequest(url)
  {
  xmlHttp = GetXmlHttpObject();
  
  xmlHttp.onreadystatechange = GetServerResponse; 
  xmlHttp.open("GET", url, true); 
  xmlHttp.send(null);    
  }

//a callback function that
//returns the output of the 
//requested PHP script on
//the server
function GetServerResponse()
  {
  if(xmlHttp.readyState == 4) 
    { 
    if(xmlHttp.status == 200)
      {
      //server has processed the request
      //and the return value from the server
      //is stored within the responseXML or 
      //responseText property of the global
      //xmlHttp object         
      DisplayServerResponse(xmlHttp.responseXML);
      }  
    else
      {
      //server has not processed the request
      return;
      }
    }   
  }  

