/* Library:
1. The user calls ajaxRequest, passing the php filename, to set up and send the request.
2. ajaxReq also sets ajaxResponse as the function to respond to the results.
3. ajaxResponse checks the response code, then calls ajaxCallback to process the results.
4. The user sets ajaxCallback to the name of the function to process the results when the event handler is setup.
*/
// Global variables for the request object and user function name to process the response
var ajaxReq = false, ajaxCallBack;

// Function to setup the request
function ajaxRequest(fileName)
{ try {ajaxReq = new XMLHttpRequest(); } // try Firefox, Opera, others
  catch(error)
  { try { ajaxReq = new ActiveXObject("Microsoft.XMLHTTP"); } // try IE 5 and lower
    catch(error) { return false;
  } }
  ajaxReq.onreadystatechange = ajaxResponse;
  ajaxReq.open("GET", fileName);
  ajaxReq.send(null);
}
// Function to wait for response and call the specified call back function
function ajaxResponse()
{ if (ajaxReq.readyState !=4) return;
  if (ajaxReq.status == 200)
  { if (ajaxCallBack) ajaxCallBack();
  }else alert("Request failed: " + ajaxReq.statusText);
  return true;
}
