if(document.all) ActiveXObject.prototype.tag=0;
else XMLHttpRequest.prototype.tag=0;

function ajax(adres)
{
	this.x=0;
	this.adres=adres;
	this.block=false;

	var vers=new Array(
			"Microsoft.XMLHTTP",
			"MSXML2.XMLHTTP.6.0",
			"MSXML2.XMLHTTP.5.0",
			"MSXML2.XMLHTTP.4.0",
			"MSXML2.XMLHTTP.3.0",
			"MSXML2.XMLHTTP");
	
	try
	{
		this.x=new XMLHttpRequest();
	}
	catch(e) 
	{
		for(var i=0;i<vers.length && !this.x;i++)
		{
			try
			{
				this.x=new ActiveXObject(vers[i]);
			}
			catch(e){}
		}
	}
	
	
	this.wyslijGET = function()
	{
		if(!this.block)
		{
			this.x.open("GET",adres,true);
			this.x.send(null);
			this.block=true;
		}
	}
	
	this.wyslijPOST=function(zmienne)
	{
		if(!this.block)
		{
			this.x.open("POST",adres,true);
			this.x.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			this.x.send(zmienne);
			this.block=true;
		}
	}
	
	this.gotowe=function()
	{
		this.block=false;
	}
		
	this.x.tag=this;
	
	this.x.onreadystatechange=function ()
	{
		if(this.readyState==1)
			this.tag.ladowanie();
		else if(this.readyState==4)
		{
			this.tag.zakonczono();
			this.tag.gotowe();
		}
	}
		
	this.ladowanie=function() {}
	this.zakonczone=function() {}
		
}
