
function AjaxForm(idNieaktyw,idAktyw,idZwrot,parTemp,parZadanie,parMiasto,miasto,parIdKat,idKat)
{
	this.xHttp=null;
	this.tabPola=new Array();

	this.elNieaktyw=document.getElementById(idNieaktyw);
	this.elAktyw=document.getElementById(idAktyw);
	this.elZwrot=document.getElementById(idZwrot);
	this.parTemp=parTemp;
	this.parZadanie=parZadanie;
	this.parMiasto=parMiasto;
	this.miasto=miasto;
	this.parIdKat=parIdKat;
	this.idKat=idKat;

	try
	{
		// Firefox, Opera 8.0+, Safari
		this.xHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			this.xHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				this.xHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				//brak obslugi ajax
				return false;
			}
		}
	}


	this.dodajPole=function(id,idPola)
	{
		var ob=document.getElementById(id);
		if (!ob)
			return false;
		var obCel=ob.getElementsByTagName('SELECT');
		if (!obCel.length)
			obCel=ob.getElementsByTagName('INPUT');
		//else obCel=obCel[0];
		if (!obCel.length)
			return false;

		var czyZnal=false;
		for (i in obCel)
			if (obCel[i].name==idPola)
			{
				obCel=obCel[i];
				czyZnal=true;
				break;
			}
		if (!czyZnal)
			return false;

		this.tabPola.push(obCel);
		return true;
	}

	this.odbierzZadanie=function()
	{
		//alert(xHttp);
		//return;
		if (glAjaxOb.xHttp.readyState==4)
		{
			glAjaxOb.elZwrot.innerHTML=glAjaxOb.xHttp.responseText;
			ustawWidokPozycje(glAjaxOb.elNieaktyw,true);
			ustawWidokPozycje(glAjaxOb.elAktyw,false);
		}
	}

	this.wyslijZadanie=function()
	{
		ustawWidokPozycje(this.elNieaktyw,false);
		ustawWidokPozycje(this.elAktyw,true);
		var par=new String();
		par+='index.php?'+this.parZadanie+'=on&'+this.parTemp+'='+Math.random()+'&'+this.parMiasto+'='+this.miasto+'&'+this.parIdKat+'='+this.idKat;
		for (var i in this.tabPola)
		{
			var wart;
			//alert(i+': '+this.tabPola[i]);
			if (this.tabPola[i].nodeName.toUpperCase=='SELECT')
				wart=this.tabPola[i].options[this.tabPola[i].selectedIndex].value;
			else wart=this.tabPola[i].value;
			par+='&'+this.tabPola[i].name+'='+wart;
		}

		glAjaxOb=this;
		this.xHttp.onreadystatechange=this.odbierzZadanie;

		this.xHttp.open('GET',par,true);
		this.xHttp.send(null);

	}

}
