// AJAX类
function AJAXRequest() {
	var xmlObj = false;
	var CBfunc,ObjSelf;
	ObjSelf=this;
	try { xmlObj=new XMLHttpRequest; }
	catch(e) {
		try { xmlObj=new ActiveXObject("MSXML2.XMLHTTP"); }
		catch(e2) {
			try { xmlObj=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(e3) { xmlObj=false; }
		}
	}
	if (!xmlObj){
		alert("Your browser does not permit the use of all "+
              "of this application's features!");
		return false;
		}
	this.method="POST";
	this.url;
	this.async=true;
	this.content="";
	this.callback=function(cbobj) {return;};
	this.error=function(cbobj){
		if(xmlObj.readyState==4){
			if(xmlObj.status==502||xmlObj.status==12031){
				alert("服务器链接失败，或者没有找到服务器！");
				}else if(xmlObj.status==0){
					alert("您的请求产生了错误，错误信息如下：\n\n代码："+xmlObj.status
							+"\n描述：Ajax对象已建立，但是尚未初始化（尚未调用open方法）!");
				}else if(xmlObj.status==1){
					alert("您的请求产生了错误，错误信息如下：\n\n代码："+xmlObj.status
							+"\n描述：Ajax对象已建立，尚未调用send方法");
				}else if(xmlObj.status==2){
					alert("您的请求产生了错误，错误信息如下：\n\n代码："+xmlObj.status
							+"\n描述：Ajax.send方法已调用，但是当前的状态及http头未知.\n可能是由于您正在脱机工作！");
				}else if(xmlObj.status==3){
					alert("您的请求产生了错误，错误信息如下：\n\n代码："+xmlObj.status
							+"\n描述：已接收部分数据，因为响应及http头不全，这时通过responseBody和responseText获取部分数据会出现错误.");
				}else{
					alert("您的请求产生了错误，错误信息如下：\n\n代码："
							+xmlObj.status+"\n描述："+xmlObj.statusText+"\n"+xmlObj.responseText );					
				}
			}
		return;
		};
	this.send=function() {
		if(!this.method||!this.url||!this.async) return false;
		xmlObj.open (this.method, this.url, this.async);
		if(this.method.toLowerCase()=="post") xmlObj.setRequestHeader("Content-Type",
                        "application/x-www-form-urlencoded; charset=UTF-8");
		xmlObj.onreadystatechange=function() {
			if(xmlObj.readyState==4) {
				if(xmlObj.status==200) {
					ObjSelf.callback(xmlObj);
					}else{
					ObjSelf.error(xmlObj);
					}
				}
			//alert(xmlObj.readyState);
			}
		if(this.method.toLowerCase()=="post") xmlObj.send(this.content);
		else xmlObj.send(null);
		}
}

