function AjaxObj()
{
	this.Req=null;
	if(typeof XMLHttpRequest!="undefined") {
		this.Req=new XMLHttpRequest();
	}
	else if(typeof ActiveXObject!="undefined") {
		try {
			this.Req=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			try {
				this.Req=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e) {}
		}
	}

	this.IsReady=function() {
		return this.Req!=null;
	};

	this.SendSync=function(url) {
		if(!this.Req) return false;
		this.Req.open('GET',url,false);
		this.Req.send(null);
		if(this.Req.status!=200) return false;
		return this.DecodeResponse(this.Req.responseText);
	};

	this.SendAsync=function(url,callback) {
		if(!this.Req) return false;
		var R=this.Req;
		this.Req.open('GET',url,true);
		this.Req.onreadystatechange=function() {
			if(R.readyState==4) {
				callback(R.status,this.DecodeResponse(R.responseText));
			}
		}
		this.Req.send('');
	};

	this.PostSync=function(url,param) {
		if(!this.Req) return false;
		this.Req.open('POST',url,false);
		this.Req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		this.Req.send(param===null?'':(typeof(param)=='string'?param:this.GetForm(param)));
		if(this.Req.status!=200) return false;
		return this.DecodeResponse(this.Req.responseText);
	};

	this.Abort=function() {
		if(!this.Req) return;
		this.Req.abort;
	};

	this.DecodeResponse=function(data) {
		if(navigator.appVersion.indexOf('KHTML')>=0) {
			// Safari
			var e=escape(data);
			if(e.indexOf("%u")<0 && e.indexOf("%")>=0) {
				return decodeURIComponent(e);
			}
		}
		return data;
	};

	this.GetForm=function(frm) {
		var v='',i,n=frm.elements.length;
		for(i=0;i<n;i++) {
			var e=frm.elements[i];
			if(e.name=='') continue;
			if((e.type=='radio'||e.type=='checkbox')&&!e.checked) continue;
			v+='&'+e.name+'='+encodeURIComponent(e.value);
		}
		return v.substring(1);
	};
}

function IsSupportAjax()
{
	return (new AjaxObj).IsReady();
}


