/*try
{
 var requester = new XMLHttpRequest();
}
catch (error)
{
 try
 {
   var requester = new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (error)
 {
   return false;
 }
}*/
function Requester()
{
	this.action = null;
	this.XML = null;
	this.commInterface = null;

	// Initialise XMLHttpRequest object
	this.resetXMLHR();

	return true;
}
Requester.prototype.resetXMLHR = function()
{
	var self = this;

	if (this.commInterface != null && this.commInterface.readyState != 0 && this.commInterface.readyState != 4)
	{
		this.commInterface.abort();
	}

	try
	{
		this.commInterface = new XMLHttpRequest();
	}
	catch (error)
	{
		try
		{
			this.commInterface = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (error)
		{
			return false;
		}
	}

	this.commInterface.onreadystatechange = function()
		{
			self.executeAction();

			return true;
		};

	return true;
}

Requester.prototype.executeAction = function()
{
	// If XMLHR object has finished retrieving the data
	if (this.commInterface.readyState == 4)
	{
		// If the data was retrieved successfully
		try
		{
			if (this.commInterface.status == 200)
			{
				this.responseText = this.commInterface.requestXML;
				this.action();
			}
			// IE returns status = 0 on some occasions, so ignore
			else if (this.commInterface.status != 0)
			{
				alert("There was an error while retrieving the URL: " + this.commInterface.statusText);
			}
		}
		catch (error)
		{
		}
	}

	return true;
}

Requester.prototype.setAction = function(actionFunction)
{
	this.action = actionFunction;

	return true;
}
Requester.prototype.loadURL = function(URL, CGI)
{
	requester.resetXMLHR();
	requester.commInterface.open("GET", URL + "?" + CGI);
	requester.commInterface.send(null);

	return true;
}
Requester.prototype.getText = function()
{
	return this.commInterface.responseText;
}
