/******************************************************************************/
/* Begin AJAX functions
/******************************************************************************/

function createXMLHttpRequest()
{
	try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
	try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	try { return new XMLHttpRequest(); } catch(e) {}
	alert("XMLHttpRequest not supported");
	return null;
}

/******************************************************************************/
// 	Function:		ajax_request
//
//	Description:	Performs asynchronous call to server side script.
//
//	Parameters:		
//
//	thePage				The server-side page to call.  This function only performs
//						GET calls, not POST, so thePage variable must include
//						any variables in the querystring.
//
//	timeoutHandler		Function to handle timeout.
//
//	responseHandler		Function to handler server response.  Must take 
//						a single string parameter.
//
//
/******************************************************************************/

function ajax_request(thePage, responseHandler, timeoutHandler)
{
	var requestTimer = setTimeout(timeoutHandler, 3000);
	
	var req = createXMLHttpRequest();
	req.onreadystatechange = function() {

		if (req.readyState != 4)
			return;
	
		clearTimeout(requestTimer);
		if (req.status != 200)  
		{
			alert("Error");
			return;
		}

		var data = req.responseText;
		responseHandler(data);
	};
		
	req.open("GET", thePage, true);	 
	req.send(null);
}

