function HttpRequest() 
{
    this.serverRequest = null;
    this.callback = null;
}

/*** make a GET request to a server document. 
*    url = the document to open, 
*    processFunc = a function callback that is passed the response text from the url if the request succeeds.
*/
HttpRequest.prototype.getTextFromServer = function(url, processFunc)
{
	//prevent caching of url
    url += ((url.indexOf('?') + 1) ? '&' : '?' ) + 'date=' + (new Date()).getTime();

    if (window.XMLHttpRequest) 
    {        
        this.serverRequest = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {   // branch for IE/Windows ActiveX version
        this.serverRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (this.serverRequest) 
    {    
        var self = this;

        this.serverRequest.onreadystatechange = function()
        {
            if (self.serverRequest.readyState == 4) 
            { 
                if (self.serverRequest.status == 200) 
                { 
                    processFunc(self.serverRequest.responseText); 
                } 
                else 
                { 
                    //alert('There was a problem retrieving the data from URL ' + url + ': ' + self.serverRequest.status);
                } 
            }
        }
        
        this.serverRequest.open("GET", url, true);
        this.serverRequest.send(null);
        return true;
    } 
    
    return false;
}

/*** make a GET request to a server document. 
 *   url = the document to open, 
 *   processFunc = a function callback that is passed the response XML from the url if the request succeeds.
 */
HttpRequest.prototype.getXMLFromServer = function(url, processFunc)
{
	//prevent caching of url
    url += ((url.indexOf('?') + 1) ? '&' : '?' ) + 'date=' + (new Date()).getTime();  //prevent caching of url
   
    if (window.XMLHttpRequest) 
    {        
        this.serverRequest = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {   // branch for IE/Windows ActiveX version
        this.serverRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (this.serverRequest) 
    {    
        var self = this;

        this.serverRequest.onreadystatechange = function()
        {
            if (self.serverRequest.readyState == 4) 
            { 
                if (self.serverRequest.status == 200) 
                { 
                    processFunc(self.serverRequest.responseXML); 
                } 
                else 
                { 
                    //alert('There was a problem retrieving the XML data from URL ' + url + ': ' + self.serverRequest.statusText);
                } 
            }
        }
        
        this.serverRequest.open("GET", url, true);
        this.serverRequest.send(null);
        return true;
    } 
    
    return false;
}

/*** make a POST request to a server document. 
 *   url = the document to open, 
 *   postString = a string of to attach to the POST (e.g."id=5&a=2"), 
 *   processFunc = a function callback that is passed the response text from the url if the request succeeds.
 */
HttpRequest.prototype.postToServerText = function(url, postString, processFunc)
{    
 	//prevent caching of url
    url += ((url.indexOf('?') + 1) ? '&' : '?' ) + 'date=' + (new Date()).getTime();  //prevent caching of url

    if (window.XMLHttpRequest) 
    {        
        this.serverRequest = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {   // branch for IE/Windows ActiveX version
        this.serverRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (this.serverRequest) 
    {    
        var self = this;

        this.serverRequest.onreadystatechange = function()
        {
            if (self.serverRequest.readyState == 4) 
            { 
                if (self.serverRequest.status == 200) 
                { 
                    processFunc(self.serverRequest.responseText); 
                } 
                else 
                { 
                    //alert('There was a problem posting data to the URL ' + url + ': ' + self.serverRequest.status);
                } 
            }
        }
        
        this.serverRequest.open("POST", url, true);
        this.serverRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        this.serverRequest.send(postString);
        return true;
    } 
    
    return false;
}



/*** make a POST request to a server document. 
 *   url = the document to open, 
 *   postString = a string of to attach to the POST (e.g."id=5&a=2"), 
 *   processFunc = a function callback that is passed the response XML from the url if the request succeeds.
 */
HttpRequest.prototype.postToServerXML = function(url, postString, processFunc)
{    
	//prevent caching of url
    url += ((url.indexOf('?') + 1) ? '&' : '?' ) + 'date=' + (new Date()).getTime();  //prevent caching of url

    if (window.XMLHttpRequest) 
    {        
        this.serverRequest = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {   // branch for IE/Windows ActiveX version
        this.serverRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (this.serverRequest) 
    {    
        var self = this;

        this.serverRequest.onreadystatechange = function()
        {
            if (self.serverRequest.readyState == 4) 
            { 
                if (self.serverRequest.status == 200) 
                { 
                    processFunc(self.serverRequest.responseXML); 
                } 
                else 
                { 
                    //alert('There was a problem posting XML data to URL ' + url + ': ' + self.serverRequest.statusText);
                } 
            }
        }
        
        this.serverRequest.open("POST", url, true);
        this.serverRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        this.serverRequest.send(postString);
        return true;
    } 
    
    return false;
}
