/*            Jasper's xmlHttpRequest script               */
/*                                                         */
/*       ***PLEASE DO NOT REMOVE THIS MESSAGE***           */
/*                                                         */
/*        works under just about any browser :D            */
/*        (including IE 5.5 and higher )                   */
/*                                                         */
/* available from gmh.ugtech.net/downloadws/request.js     */
/*                                                         */
/*               VERSION 2.0                               */
/*                                                         */
/*    syntax:                                              */
/*     request(method, url, arguments, todo)               */
/*       --> Request a page with an XMLHttpRquest object   */
/*            using the specified method, which must       */
/*            be supplied as a string (such as "GET")      */
/*            currently GET and POST are supported         */
/*           url is the url that will be requested         */
/*           arguments is a string containing the          */
/*            arguments that are to be sent alongside the  */
/*            request. Parse as follows:                   */
/*             argname1=argvalue1&argname2=argvalue2&...   */
/*           todo is the function that will be called      */
/*            once there is a response. It must take one   */
/*            argument (an xmlHttpRequest object, which    */
/*            you can .responseXml or .responseText to     */
/*            evaluate the response                        */
/*                                                         */
/*     doNothing may be given as parameter for todo,       */
/*     it means the response will not be used in any way   */
/*     and you will also not know when (and if) your       */
/*     request is completed                                */
/*                                                         */
/*     FUNCTIONS AND GLOBAL VARS USED IN SCRIPT:           */
/*                                                         */
/*     function request(method, url, args, todo)           */
/*     function doNothing(result)                          */
/*                                                         */
/*          ===NOTICE===                                   */
/*      I do not require you to put my name on your        */
/*      website to use it, but I do appreciate it.         */
/*      I do want you to keep my comments in it. You       */
/*      may add that you modified the script if you did.   */
/*      If necessary for speed you can take the guide      */
/*      out (everything starting from syntax ending        */
/*      just before this notice), but I do require you     */
/*      to keep the rest.                                  */
/*                                                         */
/*         Jasper Horn                                     */
/*           jasperhorn [AT] gmail [DOT] com               */
/*            (success building your web application)      */
/*                                                         */

function request(method, url, args, todo)
{
	if (method == "GET")
	{
		url += "?" + args;
		args = null;
	}
	
	var XHRequest;
	
	if (window.XMLHttpRequest)
	{	
		XHRequest = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		XHRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	XHRequest.open(method, url, true);
	
	if (method == "POST")
	{
		XHRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		XHRequest.setRequestHeader("Content-length", args.length);
		XHRequest.setRequestHeader("Connection", "close");
	}

	XHRequest.onreadystatechange = function ()
	{
		if (XHRequest.readyState == 4)
		{
			if (XHRequest.status == 200)
			{
				busy = false;
				todo(XHRequest);
			}
			else
			{
				alert("Problem retrieving XML data");
			}
		}
	}
	
	XHRequest.send(args);

	return true;
}

function doNothing(result)
{
}

/*        End of Jasper's xmlHttpRequest script           */