var DTAjax=function(){
this.onGet=function(rc){}
this.onReadyStateChange=function(id,xmlHttpObj){};
this.xmlHttpObj=this.getXmlHttpObj();
this.xmlHttpObj.onreadystatechange = this.getReadyStateChangeHandle(this);
this.onReadyStateChange=function(id,xmlHttpObj){};
}
DTAjax.prototype.xmlHttpObj=null;
DTAjax.prototype.postStr="";
DTAjax.prototype.addPostData=function(name,value)
{
	if(!this.postStr){
		this.postStr=name+"="+escape(value);
	}
	else{
		this.postStr+="&"+name+"="+escape(value);
	}
}

DTAjax.prototype.getReadyStateChangeHandle=function(obj){
	return function(){
		obj.onReadyStateChange(obj.xmlHttpObj.readyState,obj.xmlHttpObj);
		if(obj.xmlHttpObj.readyState==4){
			obj.onGet(unescape(obj.xmlHttpObj.responseText));
		}
	}
}

DTAjax.prototype.getStringFromUrl=function(method,url,syn){
	if(url.indexOf("?")>=0){
		url=url+"&"+Math.random(1)
	}
	else{
		url=url+"?a="+Math.random(1)
	}
	if(/get/i.test(method)){
		this.xmlHttpObj.open("GET", url, syn);
		this.xmlHttpObj.send(null);
	}
	else{
		this.xmlHttpObj.open("POST", url, syn);
		this.xmlHttpObj.setRequestHeader("Content-Length",this.postStr.length);  
		this.xmlHttpObj.setRequestHeader("Content-type","application/x-www-form-urlencoded;CharSet=GB2312");   
		this.xmlHttpObj.send(this.postStr);
		
	}
}
DTAjax.prototype.getXmlHttpObj=function(){
	var obj;
	if(window.XMLHttpRequest){    
	   obj = new XMLHttpRequest();         
	   if(obj.overrideMimeType){    
		   obj.overrideMimeType("text/xml");    
	   }    
	}else if(window.ActiveXObject){    
		try{    
			 obj = new ActiveXObject("Msxml2.XMLHTTP");    
		}catch(e){    
			  try{    
				   obj = new ActiveXObject("Microsoft.XMLHTTP");    
			  }catch(e){}    
		}     
	} 
	return obj; 
}
DTAjax.prototype.distroy = function(){
    this.xmlHttpObj = null;
    this.postStr = null;
}

var DealAjaxRet = function(str)
{
    if(str.indexOf("state=1&") == 0)
    {
        alert(str.substr(12));
        return true;
    }
    else if(str.indexOf("state=0&") == 0)
    {
        alert(str.substr(12));
        return false;
    }
    else
    {
        alert(str);
        return false;
    }
}
