//---- ServerRequest ----
function ServerRequest()
{
	
	this.Callback = null;
	if(ServerRequest.arguments.length >= 1)
	{
		this.Callback = ServerRequest.arguments[0];
	}
	this.Load = ServerRequest_Load;
}

function ServerRequest_Load(url, data)
{
	var async = true;
	if(ServerRequest_Load.arguments.length >= 3)
	{
		async = ServerRequest_Load.arguments[2];
	}

	// initialise xml request
	var xmlHttp = null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

	if(xmlHttp == null)
	{
		alert("Your browser does not support AJAX!");
	}
	else
	{
		oThis = this;
		xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4)
			{
				if(oThis.Callback != null)
				{
					oThis.Callback(xmlHttp.responseText);
				}
			}
		};

		if(data == null)
		{
			xmlHttp.open("GET", url, async, null, null);
			xmlHttp.setRequestHeader("Connection", "Keep-Alive");
			xmlHttp.send(null);
		}
		else
		{
			data = data.replace(/ /gi, "+");
			data = data.replace(/\n/gi, "+");
			xmlHttp.open("POST", url, async);
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			//xmlHttp.setRequestHeader("Content-length", data.length);
			//xmlHttp.setRequestHeader("Connection", "Keep-Alive");
			xmlHttp.send(data);
		}
	}
}
