function AjaxRequest(url, postInfo, async, fnSuccess, fnFail)
{
	var xmlHttp = GetXMLHttpRequest();
	xmlHttp.open("POST", url, async);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", postInfo.length);
	xmlHttp.setRequestHeader("Connection", "close");
	
	if(async)
	{
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200 )
			{
				fnSuccess(xmlHttp.responseText);
			}
			else if( xmlHttp.readyState == 4 && xmlHttp.status != 200)
			{
				if(fnFail != null)
				{
					fnFail();
				}
			}
		}
		xmlHttp.send(postInfo);
	}
	else
	{
		xmlHttp.send(postInfo);
		return xmlHttp.responseText;
	}
}

function GetXMLHttpRequest()
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer pre IE7
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	return xmlHttp;
}
