function httpRequest()
{
	try
	{
		req = new XMLHttpRequest();
	}
	catch(Errror1)
	{
		try
		{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(Error2)
		{
			try
			{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(Error3)
			{
				req = false;
			}
		}
	}
	return req;
}

function aGET(url, query, req)
{
	myRand = parseInt(Math.random() * 99999999);
	req.open("GET", url+'?'+query+'&rand='+myRand, true);
	req.send(null);
}

function aPOST(url, query, req)
{
	req.open("POST", url, true);
	req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	req.send(query);
}

function CallBack(callback, ReturnItem)
{
	eval(callback + '(ReturnItem)');
}

function Ajax(url, query, callback, reqtype, getxml, waitpanel, loaingGIF)
{
	var Myhttp = httpRequest();
	Myhttp.onreadystatechange = function()
	{
		if(Myhttp.readyState == 4)
		{
			if(Myhttp.status == 200)
			{
			var ReturnItem = Myhttp.responseText;
			if(getxml==1)
			{
				ReturnItem = Myhttp.responseXML;
			}
			CallBack(callback, ReturnItem);
			}
		}
		else
		{
			var panel = document.getElementById(waitpanel);
			panel.innerHTML = '<img src="'+ loaingGIF +'" />';
		}
	}
	if(reqtype=='post')
	{
		aPOST(url, query, Myhttp);
	}
	else
	{
		aGET(url, query, Myhttp);
	}
}

function Ajax_noLoading(url, query, callback, reqtype, getxml)
{
	var Myhttp = httpRequest();
	Myhttp.onreadystatechange = function()
	{
		if(Myhttp.readyState == 4)
		{
			if(Myhttp.status == 200)
			{
			var ReturnItem = Myhttp.responseText;
			if(getxml==1)
			{
				ReturnItem = Myhttp.responseXML;
			}
			CallBack(callback, ReturnItem);
			}
		}
	}
	if(reqtype=='post')
	{
		aPOST(url, query, Myhttp);
	}
	else
	{
		aGET(url, query, Myhttp);
	}
}