var request = null;
/*构建Request对象的封装函数
参数:
reqType：HTTP请求类型，例如GET或POST。
url：服务器端程序的URL。
asynch：是否异步发送请求。
respHandle：处理响应的函数名。
可选的第五个参数，表示为arguments[4]，是POST请求要发送的数据。
*/
function httpRequest(reqType,url,asynch,respHandle){
	//基于Mozilla的浏览器
	if(window.XMLHttpRequest){
		request = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		request = new ActiveXObject("Msxml2.XMLHTTP");
		if(!request){
			request = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	//检测request是否是null
	//如果ActiveXObject还没有被初始化
	if(request){
		//如果reqType参数是POST，那么函数的第五个参数是POSTed的数据
		if(reqType.toLowerCase() != "post"){
			initReq(reqType,url,asynch,respHandle);
		}else{
			//POSTed的数据
			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 the application's features!");
	}
}
/*初始化已经构建的Request对象*/
function initReq(reqType,url,bool,respHandle){
	try{//document.write(url);
		/*指定处理HTTP响应的函数*/
		request.onreadystatechange = respHandle;
		request.open(reqType,url,bool);
		//如果reqType参数是post，那么函数的第五个参数是POSTed的数据
		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.\nError detail:"+errv.message);
	}
}