

function Xhr(){
	this.method='POST';
	this.url=null;
	this.fun;
	this.query='';
	xmlhttp=null;
};

Xhr.prototype.send = function(){
	xmlhttp=null;
	var data = '';
	for (var a in this.query) {
		if (data.length > 0)
			data += "&";
		if (typeof this.query[a] != "object")
			data += encodeURIComponent(a) + "=" + encodeURIComponent(this.query[a]); 
		else {
			for (var i = 0; i < query[a].length; i++)
				data += encodeURIComponent(a) + "=" + encodeURIComponent(this.query[a][i]) + "&";
			data = data.slice(0, -1);
		}
	}
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp!=null){
		xmlhttp.onreadystatechange=xhr.onStateChange;
		xmlhttp.open(this.method.toUpperCase(),this.url+(this.method.toUpperCase()=='GET'?("?"+this.data):""),true);
		if(this.method.toUpperCase()=='POST')
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(this.method.toUpperCase()=='POST'?(this.data):null);
	}
	else{
		alert("Your browser does not support XMLHTTP.");
	}
}

Xhr.prototype.simpleSend = function(query,fun,url,method){
	if(!method)
		method='post';
	if(!url)
		url=window.location.href;
	xmlhttp=null;
	var data = '';
	for (var a in query) {
		if (data.length > 0)
			data += "&";
		if (typeof query[a] != "object")
			data += encodeURIComponent(a) + "=" + encodeURIComponent(query[a]); 
		else {
			for (var i = 0; i < query[a].length; i++)
				data += encodeURIComponent(a) + "=" + encodeURIComponent(query[a][i]) + "&";
			data = data.slice(0, -1);
		}
	}
	//try{xhrLoading();}catch(e){}
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp!=null){
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==(0||1)){
				try{xhrLoading();}catch(e){}
			}
			else if (xmlhttp.readyState==4 && xmlhttp.status==200 ){
				try{xhrLoadingDone();}catch(e){}
				try{fun(xmlhttp.responseText);}catch(e){}
			}
		}	
		xmlhttp.open(method.toUpperCase(),url+(method.toUpperCase()=='GET'?("?"+data):""),true);
		if(method.toUpperCase()=='POST')
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(method.toUpperCase()=='POST'?(data):null);
	}
	else{
		alert("Your browser does not support XMLHTTP.");
	}
}
Xhr.prototype.getUrl=function(){return this.url;};
Xhr.prototype.getMethod=function(){return this.method;};
Xhr.prototype.getFunction=function(){return this.fun;};
Xhr.prototype.setUrl=function(u){this.url=u;};
Xhr.prototype.setMethod=function(m){this.method=m;};
Xhr.prototype.setFunction=function(f){this.fun=f};
Xhr.prototype.getData=function(){return this.data;};
Xhr.prototype.setData=function(d){this.data=d;};
xhr = new Xhr();
