var http = false;

window.onbeforeunload = HandleUnload;
function HandleUnload()
{
	if(http)
		http.abort();
}

function HTTPSendRequest(url, callback_fn)
{
	if(!http)
		http = HTTPCreateRequestObject();
	if(http)
	{
		http.open('get', url);
		http.onreadystatechange = function() { HTTPHandleResponse(callback_fn); };
		try {
			http.send(null);
		}
		catch(e) {
		}
	}
}

function HTTPCreateRequestObject()
{
	var thehttp = false;
	if(typeof(XMLHttpRequest) != "undefined")
	{
		try {
			thehttp = new XMLHttpRequest();
		}
		catch(e) {
			thehttp = false;
		}
	}
	if(!thehttp)
	{
		try {
			thehttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			thehttp = false;
		}
	}
	if(!thehttp)
	{
		try {
			thehttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e) {
			thehttp = false;
		}
	}
	if(!thehttp && window.createRequest)
	{
		try {
			thehttp = new window.createRequest();
		}
		catch(e) {
			thehttp = false;
		}
	}
	return thehttp;
}

function HTTPHandleResponse(callback_fn)
{
	if(http.readyState == 4)
		callback_fn(http.responseText);
}
