//lael 赢动ajax简易版1.0
//时间: 2006-12-19
//http://www.gzyd.net http://hi.baidu.com/lael80
function Ajax(){
	var _C = this;//当前实例
	
	var ie = window.navigator.userAgent.indexOf("MSIE") != -1;

	this.XmlHttp = null;
	this.XmlMethod = "GET";
	this.XmlAsync = true;//异步
	this.CallBackFunc = null;//回调函数
	this.FuncArguments = new Array;//传入到回调的参数
	this.Create = function(){
		try{
			if(ie){
				try{
	    		    this.XmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}catch(e){
					this.XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");			
				}
	    	 }else{
    	    	this.XmlHttp=new XMLHttpRequest();
		     }
			 return true;
		}catch(e2){
			return false;
		}
	}
	//执行
	this.Send = function(url, data){
		try{
			for(var i = 2; i < arguments.length; i ++){
				this.FuncArguments[i - 2] = arguments[i];//回调参数
			}
  			this.XmlHttp.onreadystatechange = this.StateChange;	
	  		this.XmlHttp.open(this.XmlMethod, url, this.XmlAsync);
			if(this.XmlMethod == "POST"){
				this.XmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			}
			this.XmlHttp.send(data);
			return true;
		}catch(e){
			this.XmlHttp = null;
			return false;
		}
	}
	//回调
	this.StateChange = function(){
		try{
  			if(_C.XmlHttp.readyState == 4) {
				if(_C.CallBackFunc)_C.CallBackFunc(_C.XmlHttp.responseText, true, _C.FuncArguments);
				_C.XmlHttp = null;
	  		}
		}catch(e){
			_C.XmlHttp = null;
		}	
	}
}