function ajaxRequest()
{}

ajaxRequest.prototype.xhr = null;
ajaxRequest.prototype.request = null;
ajaxRequest.prototype.callback = null;
ajaxRequest.prototype.timeout = null;
ajaxRequest.cbParams = null;

ajaxRequest.prototype.getData = function(request, cb, timeout)
{
	this.callback = cb;

//	if (! request.match(/https?:\/\//i))
//		request = "http://" + document.location.hostname + "/" + request;

	this.request = request.substring(0, request.indexOf("//") + 2) +
		request.substring(request.indexOf("//") + 2).replace(/\/+/,"/");

	this.request += "&_ts=" + (new Date()).getTime();
//alert(this.request);
	try
	{
		this.xhr = (window.XMLHttpRequest ? new XMLHttpRequest() :
//				new ActiveXObject("MSXML2.XMLHTTP"));
				new ActiveXObject("Microsoft.XMLHTTP"));
	}
	catch (e)
	{
		var	w = window.open("/IEsettings.mdg?noHdrFtr=true&noLogout=true&error=true","settings","width=600,height=600,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,dependent=yes");
		w.focus();

		return;
	}

	var	_this = this;

	this.xhr.onreadystatechange = function() {_this.getDataCallback()};
	this.xhr.open("GET", this.request, true);
	this.xhr.send(null);

	if (typeof(timeout) != "undefined")
		this.timeout = setTimeout(function() {_this.abort()}, timeout);
}

ajaxRequest.prototype.setCallbackParam = function(p)
{
	if (this.cbParams == null)
		this.cbParams = new Array();

	this.cbParams[this.cbParams.length] = p;
}

ajaxRequest.prototype.getDataCallback = function()
{
	if (this.xhr.readyState == 4 && this.xhr.status == 200)
	{
		clearTimeout(this.timeout);
//alert(this.xhr.responseText);
		// remove \n and \s from the beginning and end and \r from everywhere

		var	xml = this.xhr.responseText.replace(/^\n*/,"").replace(/\n*$/,"").replace(/\r/g,"").replace(/^\s*|\s*$/g,"");

		this.callback(xml, this.cbParams);

		delete this.xhr;
	}
}

ajaxRequest.prototype.abort = function()
{
	// try/catch needed due to IE6 bug handling abort() call

    try 
	{   
		clearTimeout(this.timeout);
		this.xhr.onreadystatechange = null;
		this.xhr.abort();
	}
	catch (e)
	{
//		alert("An AJAX abort() error has been caught. Please report this to Customer Service.");
	}
//	alert("connection timed out");
	this.callback("ERROR: request timeout", this.cbParams);
}
