   
   
   var request = null;
   
   /* 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: Wheather to send the request asynchronously or not 
      respHandle: the name of the function which will handle the request
      any fifthe parementers, represented as arguments[4], are tje data a {pst reqiest os designed to send    
   */
      
      
   function httpRequest(reqType,url,asynch,respHandle){
   	//Mozila-based browsers
   	if(window.XMLHttpRequest){
   		request = new XMLHttpRequest();
   	} else if (window.ActiveXObject) {
   		request = new ActiveXObject("Msxml2.XMLHTTP");
   		if (!request){
   			request = new ActiveXObject("Microsoft.XMLHTTP");
   		}
   	}
   	//very unlikely but we test for a null request
   	//if neither AvtiveXObject was initialized
   	if (request) {
   		if (reqType.toLowerCase() != "post"){
   			initReq(reqType,url,asynch,respHandle);
   		} else {
   			var args = arguments[4];
   			if (args != null && args.length > 0 ){
   				initReq(reqType, url, asynch, respHandle, args);
   			}
   		} 

   	} else {
   		alert ('your browser does not permit to use of all or some features of this application.');
   	}
   }
   	
   
   
   function initReq(reqType, url, bool, respHandle){
   	try{
  		request.onreadystatechange=respHandle;
   		request.open(reqType,url,bool);
   		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 ('error contacting server !!\n\nerror detail:\n\n'+errv.message);
   	}
   }
   
   
   
   

