<!-- ********************************************************************************** -->
//Title:           OBA Ajax Foundation
//Description: Foundation routines for Ajax applications.
//Created:      11/7/2006 KMK 
<!-- ********************************************************************************** -->

<!-- ********************************************************************************** -->
// Create the XMLHttpRequest object allowing asyncronous communication with the server
<!-- ********************************************************************************** -->
var xmlHttp;
function createXMLHttpRequest()
{
    if (window.ActiveXObject)
	   {xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");} 
    else if (window.XMLHttpRequest)
	          {xmlHttp = new XMLHttpRequest();}
}

<!-- ********************************************************************************** -->
// Parse the results returned from the server
// Note:  this routine requires that the following variables exist and are set before it is called
//       "div_id":  the id of the div area to update
//       "write_as":  how to write the response - as InnerHTML or TextNode
<!-- ********************************************************************************** -->
function parseResults()
{
	var responseDiv = document.getElementById(div_id);
	
	if (write_as == "TextNode")
	   {
		// clear the any information currently displayed in the shopping cart area
       if (responseDiv.hasChildNodes()) 
	      {responseDiv.removeChild(responseDiv.childNodes[0]);}
	   // Write the response text from the photo cart script into the shopping cart area
       var responseText = document.createTextNode(xmlHttp.responseText);
       responseDiv.appendChild(responseText);
	   }
	else
	   {responseDiv.innerHTML=xmlHttp.responseText;}
}

<!-- ********************************************************************************** -->
// Check for server response to our communication.  When a response is received call  
// 'parseResults()' to process the response.
<!-- ********************************************************************************** -->
function handleStateChange() 
{
    if (xmlHttp.readyState == 4)
	   {
        if (xmlHttp.status == 200)
		   {
		   if (parse_as == "")
			  {parseResults();}
		   else
			  {parseLDAPResults();}
		   }
        }
}
