function Ajax()
{
	this.version = '2.0';
}

Ajax.prototype = {	
	post:function(url,func,oParam,oHeader)
	{
		this.url = url;
		this.onload = func;
		this.oParam = oParam?oParam:Object();
		this.oHeader = oHeader?oHeader:Object();
		this.method = "POST";
		
		this.oHeader.Content_Type = "application/x-www-form-urlencoded";
		this.loadXMLDoc(); 
	},
	
	get:function(url,func,oParam,oHeader)
	{	
		this.url = url;
		this.onload = func;
		this.oParam = oParam;
		this.oHeader = oHeader;
		this.method = "GET";
		
		this.loadXMLDoc();	
	},
	
	loadXMLDoc:function(){			
		if (window.XMLHttpRequest) this.req = new XMLHttpRequest();		    
		else if (window.ActiveXObject) this.req = new ActiveXObject("Microsoft.XMLHTTP");
		if (this.req)
		{
			try
			{				
				var loader = this;
				loader.req.onreadystatechange = function()
				{
					loader.onReadyState.call(loader);	
				}				
				
				loader.req.open(loader.method,loader.url,true);
				
				for (sv in this.oHeader)
				{					
					loader.req.setRequestHeader( sv.replace("_","-"),this.oHeader[sv] ); 
				}				
				
				if (loader.method == "POST")
				{
					var str = "";
					
					for (sv in this.oParam)
					{						
						str += (str == "")?(sv+"="+this.oParam[sv]):("&"+sv +"="+this.oParam[sv]); 
					}
										
					loader.req.send(str);									
				}
				else loader.req.send(null);				
			}
			catch(error)
			{
				this.defaultError.call(this);	
			}        
		}
	},	
	
	onReadyState:function()
	{
		if (this.req.readyState == 4)
		{
			if (this.req.status == 200 || this.req.status == 0) this.onload.call(this);
			else this.defaultError.call(this);
		}
	},
	
	defaultError:function()
	{
		
		alert("Error fetching data!"+"\n\nresdyState:"+this.req.readyState+"\nstatus:"+this.req.status+"\nheaders:"+this.req.getAllResponseHeaders());	
	}	
}
