var XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHttp.3.0', 'MSXML2.XMLHttp.2.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'];
var request = null;
function httpRequest(reqType,url,asynch,respHandle){
    try
    {
        request = new XMLHttpRequest();
    }
    catch(e)
    {
    }
    if(!request)
    {
        var progidsLength = XMLHTTP_PROGIDS.length;
        for(var i=0; i<progidsLength; ++i)
        {
            var progid = XMLHTTP_PROGIDS[i];
            try
            {
                request = new ActiveXObject(progid);
            }
            catch(e)
            {
            }

            if(request)
            {
                XMLHTTP_PROGIDS = [progid];
                break;
            }
        }
    }
    if(request) {
        if(reqType.toLowerCase(  ) != "post") {
            initReq(reqType,url,asynch,respHandle);
        }  else {
            //the POSTed data
            var args = arguments[4];
            if(args != null && args.length > 0){
                initReq(reqType,url,asynch,respHandle,args);
            }
        }
    } else {
        alert("Your browser does not permit the use of all "+
              "of this application's features!");
    }
}
/* Initialize a request object that is already constructed */
function initReq(reqType,url,bool,respHandle){
    try{
        /* Specify the function that will handle the HTTP response */
        request.onreadystatechange=respHandle;
        request.open(reqType,url,bool);
        //if the reqType parameter is POST, then the
        //5th argument to the function is the POSTed data
        if(reqType.toLowerCase(  ) == "post") {
            request.setRequestHeader("Content-Type",
                    "application/x-www-form-urlencoded; charset=UTF-8");
            request.send(arguments[4]);
        }  else {
            request.send(null);
        }

    } catch (errv) {
        alert(
        "The application cannot contact "+
        "the server at the moment. "+
        "Please try again in a few seconds.\\n"+
        "Error detail: "+errv.message);
    }
}


