function AsyncRequest(){
    this.method;            //This is the form method (GET or POST).
    this.url;               //The url to request.
    this.cache = false;     //GET requests are cached by default. 
    this.data;				//This variable holds the form data in the form of a querystring without the leading "?".
    this.callback;          //This will hold the callback function if the asynchronous call responds successfully.
    this.onError = null;	//This will hold a reference to a function to call in case of an error.
   
    //The XmlHttp request object. It does all of the asynchronous sending, receiving, and state handling.
    this.xmlHttp = new function(){ 
        try{
            return new ActiveXObject("Msxml2.XMLHTTP"); 
        }catch(e){}
        try{ 
            return new ActiveXObject("Microsoft.XMLHTTP"); 
        }catch(e){}
        try{ 
            return new XMLHttpRequest(); 
        }catch(e){}
        alert("XMLHttpRequest not supported. Please contact technical support.");
        return null;
    }
    
    //This function handles sending the data via an XmlHttp transport.
    //Notice that (this) is passed in with the function. 
    //This will allow the XmlHttp object to properly handle its readyState.
    this.send = function(){ with(this) { 
        if (method == "GET"){
            if (data.left(1) != '?'){
				url = url + "?" + data;
			}else{
				url = url + data;
			}
            xmlHttp.open(method, url, true);
        }else{
            xmlHttp.open(method, url, true);
        }
        xmlHttp.onreadystatechange = function(){
			if (xmlHttp.readyState == 4){
                var responseText = xmlHttp.responseText;
                switch (xmlHttp.status){
                    case 404:
                        if (onError == null){
							alert('Page Not Found. The requested url \'' + url + '\' could not be found.');
						}else{
							onError('Page Not Found. The requested url \'' + url + '\' could not be found.');
						}
                        break;
                    case 405:
						if (onError == null){
							alert('Cannot post form data to this page. The requested url \'' + url + '\' could be missing.');
						}else{
							onError('Cannot post form data to this page. The requested url \'' + url + '\' could be missing.');
						}
                        break;
                    case 500:
                        if (onError == null){
							alert(responseText); //This will spit out the entire error received from the called page.
						}else{
							onError(responseText);
						}
                        break;
                    case 200:
                        if (responseText.indexOf('Error:') > -1 || responseText.indexOf('Debug:') > -1){
							if (onError == null){
								alert(responseText); //This is for custom debugging. Insert Error: or Debug: on the called page's response.
							}else{
								onError(responseText);
							}
                        }else{
                            callback(responseText); //Success! Call the user-defined handler and pass in the response text.
                        }
                        break;
					default:
						if (onError == null){
							alert('Undefined error code: ' + xmlHttp.status + '. Please report this to technical support');
							alert(responseText);
						}else{
							onError(responseText);
						}
                        break;
                }
            }
        }
        xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        if (!cache && method != "POST"){
            xmlHttp.setRequestHeader('If-Modified-Since', 'Fri, 5 Dec 1980 00:00:00 GMT');
        }
        if (method == "GET"){
            xmlHttp.send(null);
        }else{
            xmlHttp.send(data);
        }
    }}
}