

/** INCLUDE GUARD **/ if(!window.xmlhttp_js_included) { window.xmlhttp_js_included = true;

// Takes a hash table and returns a string for use with the 'vars' parameter
// for sendRequest.
function prepareRequest(hashTable)
{
    var ret = '';
    
    for(key in hashTable) {
        
        if(ret.length)
            ret += '&';
        
        var value = hashTable[key];
        
        if(window.escape) {
            
            key = escape(key);
            value = escape(value);
        }
        
        ret += key + '=' + value; 
    }
    
    return ret;
}

// url is the url to make the request to.
// vars is passed as the POST data (raw string form).
// onComplete is a function that is called once the response is recieved from
// the server.
function sendRequest(url, vars, onComplete, callbackParam)
{
    var request = window.XMLHttpRequest ? new XMLHttpRequest() : (new ActiveXObject("Microsoft.XMLHTTP"));
        // Changed from (new ActiveXObject("Msxml2.XMLHTTP") as per: http://blogs.msdn.com/ie/archive/2006/01/23/516393.aspx
    
    request.open("POST", url, true);
    request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    request.setRequestHeader("Pragma", "ajax");
     
    request.onreadystatechange = function()
    {
        try {
            
            if(request.readyState == 4 && request.status == 200) {
                
                if(onComplete)
                    onComplete(request.responseText, callbackParam);
            }
            
        } catch(e)
        {
        
        }
    }
    
    request.send(vars);
}

/** INCLUDE GUARD **/ }

