var xmlHttpObj;
var xhrTimeout;

function httpRequestObject()
{
	var xmlhttp=false;

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	return xmlhttp;
}

function sendRequest( method, url, showResultIn, requestTimeout, showResponse)
{
	xmlHttpObj	=	httpRequestObject();
	xhrTimeout=setTimeout("ajaxTimeout('"+showResultIn+"');", requestTimeout);

	xmlHttpObj.open( method, url,true);


	xmlHttpObj.onreadystatechange	=	function() {
									//if (xmlHttpObj.readyState==4 && xmlHttpObj.status == 200) {
									  if (xmlHttpObj.readyState==4) {
										clearTimeout(xhrTimeout);
										if( xmlHttpObj.responseText.length > 0) {
											document.getElementById( showResultIn).style.display = '';
											if(!showResponse)
												document.getElementById( showResultIn).innerHTML	=	xmlHttpObj.responseText;
										} else {
												document.getElementById( showResultIn).style.display = 'none';
										}
									}

								}
	xmlHttpObj.send(null);
}

function ajaxTimeout( showResultIn){
   xmlHttpObj.abort();
   document.getElementById( showResultIn).style.display = 'none';
   alert("The AJAX request timed out.  Did you lose network "+
         "connectivity for some reason?");
   // Note that at this point you could try to send a notification to the
   // server that things failed, using the same xhr object.
}