function initReq(reqType,url,bool){

    try{

        /* Specify the function that will handle the 

        HTTP response */

        request.open(reqType,url,bool);    
        request.onreadystatechange=handleResponse;
        
        if(reqType.toLowerCase() == "post") {
            request.setRequestHeader("Content-Type",
                        "application/x-www-form-urlencoded; charset=UTF-8");
            request.send(arguments[3]);
        } else {
            request.send(null);
        }
    } catch (errv) {

        alert(

                "The application cannot contact the server "+

                "at the moment. "+

                "Please try again in a few seconds."+errv.message );

    }

}

/* Wrapper function for constructing a request object.

 Parameters:

  reqType: The HTTP request type, such as GET or POST.

  url: The URL of the server program.

  asynch: Whether to send the request asynchronously or not. */

function httpRequest(reqType,url,asynch){

    //Mozilla-based browsers

    if(window.XMLHttpRequest){

        request = new XMLHttpRequest(  );

    } else if (window.ActiveXObject){

        request=new ActiveXObject("Msxml2.XMLHTTP");

        if (! request){

            request=new ActiveXObject("Microsoft.XMLHTTP");

        }

     }

    //the request could still be null if neither ActiveXObject

    //initialization succeeded

    if(request){

       
       
        if(reqType.toLowerCase() != "post") {
            initReq(reqType,url,asynch);
        }  else {
            //the POSTed data
            var args = arguments[3];
            if(args != null && args.length > 0){
                initReq(reqType,url,asynch,args);
            }
        }
    } else {

        alert("Your browser does not permit the use of all "+

              "of this application's features!");}

}
