/*************************************
How to include in your web pages:
		<script type="text/javascript" language="JavaScript" src="exajax.js"></script>

Included callable functions:
		- AjaxGetURL(url)
		- AjaxPostURL(url, argstring)

Functions that must be supplied:
		- AjaxRequestComplete(contentstring)
		- AjaxPostComplete(contentstring)

*************************************/

function AjaxGetURL(sURL)
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		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;
			}
		}
	}
	xmlHttp.onreadystatechange = function() { AjaxStateChangeGet(xmlHttp); };
	xmlHttp.open("GET", sURL, true);
	xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 1985 00:00:00 GMT");
	xmlHttp.send(null);
}

function AjaxStateChangeGet(hRequest)
{
	if (hRequest.readyState == 4)
	{
		if (hRequest.status == 200)
		{
			AjaxRequestComplete(hRequest.responseText);
		}
		else
		{
			// Failed
		}
	}
}


function AjaxPostURL(sURL, sPostData)
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		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;
			}
		}
	}
	xmlHttp.onreadystatechange = function() { AjaxStateChangePost(xmlHttp); };
	xmlHttp.open("POST", sURL, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.send(sPostData);

}

function AjaxStateChangePost(hRequest)
{
	if (hRequest.readyState == 4)
	{
		if (hRequest.status == 200)
		{
			AjaxPostComplete(hRequest.responseText);
		}
		else
		{
			// Failed
		}
	}
}

