
var pls_str = null;
var pls_opcja = null;

function cennik_szukaj(fr)
{
	if (fr.plsid.disabled == true || fr.plcid.disabled == true) return false;
	else return true;
}


function cennik_zsel2()
{
	if (typeof(pls_vals) != 'object' || typeof(pls_names) != 'object')
	{
		setTimeout(cennik_zsel2, 50);
	}
	else
	{
		//----------------------------------
		if (pls_opcja == 1)
		{
			var cel = document.plsrch.plsid;
			var zrodlo = document.plsrch.plcid;
		}
		else if (pls_opcja == 2)
		{
			var zrodlo = document.plsrch.plsid;
			var cel = document.plsrch.plcid;
		}

		var wwart = cel.options[cel.selectedIndex].value;
		var j = cel.options.length;
		for (var i = (j - 1); i >= 0; i--)
		{
			cel.remove(i);
		}

		var widx = -1;
		for (var i = 0; i < pls_vals.length; i++)
		{
			var opt = new Option(pls_names[i], pls_vals[i]);
			if (wwart == pls_vals[i] && widx == -1)
			{
				widx = i;
				opt.selected = true;
			}
			cel.options[i] = opt;
		}
		if (widx != -1) cel.selectedIndex = widx;

		cel.disabled = false;
		zrodlo.disabled = false;
		//----------------------------------
		document.body.removeChild(pls_str);
		pls_str = null;
		pls_vals = '';
		pls_names = '';
	}
}

function cennik_zsel(opcja)
{
	if (!(document.createElement && document.body.appendChild && document.body.removeChild)) return;

	if (pls_str == null)
	{
		pls_opcja = opcja;
		if (pls_opcja == 1)
		{
			var cel = document.plsrch.plsid;
			var zrodlo = document.plsrch.plcid;
		}
		else if (pls_opcja == 2)
		{
			var zrodlo = document.plsrch.plsid;
			var cel = document.plsrch.plcid;
		}

		cel.disabled = true;
		zrodlo.disabled = true;

		var czas = new Date();
		var adres = "js/cennik_dane.php/"+czas.getTime()+"?op="+pls_opcja+"&id="+zrodlo.options[zrodlo.selectedIndex].value;

		var js = document.createElement('script');
		js.type = "text/javascript";
		js.src = adres;
		document.body.appendChild(js);
		pls_str = js;

		setTimeout(cennik_zsel2, 50);
	}
}



