var XHR = function(obj)
{
	this.xmlhttp=null;
	this.method=(obj.method=='POST')?'POST':'GET';//Method: Post, Get
	this.url=obj.url;//URL
	this.data=(obj.data)?obj.data:null;//Data to send
	this.onload=(obj.onload)?obj.onload:null;//On load Function
	this.update=(obj.update)?obj.update:null;//Element ID, which should be updated
	this.response=(obj.response)?obj.response:null;//Response type: Text, XML
	var loader=this;
	if (window.XMLHttpRequest)
		this.xmlhttp=new XMLHttpRequest();
	else if (window.ActiveXObject)
		this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	if (this.xmlhttp!=null)
	{
	  var req=this.xmlhttp;
	  req.open(this.method,this.url,true);
	  req.onreadystatechange=function()
	  {
			if (req.readyState==4)
			{
			  if (req.status==200)
			  {
				  if(req.responseXML||req.responseText)
					resp=(loader.response=='XML')?req.responseXML:req.responseText;
				  if(loader.onload!=null&&typeof(resp)!='undefined')
				  	loader.onload.call(this,resp);
				  else if(loader.onload!=null&&typeof(resp)=='undefined')
					loader.onload.call(this);
				  if(typeof(resp)!='undefined')
					  if(loader.update!=null&&resp)
						document.getElementById(loader.update).innerHTML=resp;
			  }
			  else
				  return 0;
			     //alert("Problem retrieving data "+req.statusText);
			 }
	  }
	  if(this.method=='POST')
	  {
		  req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		  req.setRequestHeader("Content-length", this.data.length);
		  req.setRequestHeader("Connection", "close");
	  }
	  req.send(this.data);
	}
	else
	  alert("Your browser does not support XMLHTTP.");
}
