function changeMod (mod, at)
{
	switch (mod)
	{
		case 'art':
			setVisible ('art_table', 'block');
			setVisible ('ann_table', 'none');
			setVisible ('dir_table', 'none');
			if (!at)
			{
				cat_list = document.forms['search'].elements['art_cid'];
				cat_list.options.length = 0;
				cat_list.options[0] = new Option ('--proszę czekać--', -1);
				runScript ('tmp_acat_script', 'index.php?m=script&s=category&mod=article&name=art_cid&first=--wszystkie--&form=search');
				changeArtCat (0, 'art_sid[]');
			}
		break;

		case 'ann':
			setVisible ('art_table', 'none');
			setVisible ('ann_table', 'block');
			setVisible ('dir_table', 'none');
			if (!at)
			{
				cat_list = document.forms['search'].elements['ann_cid'];
				cat_list.options.length = 0;
				cat_list.options[0] = new Option ('--proszę czekać--', -1);
				runScript ('tmp_acat_script', 'index.php?m=script&s=category&mod=announ&name=ann_cid&first=--wszystkie--&form=search');
				changeAnnCat (0, 'ann_sid[]');
			}

		break;

		case 'dir':
			setVisible ('art_table', 'none');
			setVisible ('ann_table', 'none');
			setVisible ('dir_table', 'block');

			if (!at)
			{
				pro_list = document.forms['search'].elements['dir_pid'];
				pro_list.options.length = 0;
				pro_list.options[0] = new Option ('--proszę czekać--', -1);
				runScript ('tmp_dpro_script', 'index.php?m=script&s=province&mod=directory&name=dir_pid&first=--wszystkie--&form=search');
				changeDirPro (0, 'dir_cid[]');
			}
		break;

		default:
			setVisible ('art_table', 'none');
			setVisible ('ann_table', 'none');
			setVisible ('dir_table', 'none');
	}
}

function changeAnnCat (cid, sel)
{
	sec_list = document.forms['search'].elements[sel];
	sec_list.options.length = 0;
	if (parseInt(cid) < 1)
	{
		sec_list.options[0] = new Option ("--wszystkie--", 0);
		setVisible ('ann_cat_row', 'none');
	}
	else
	{
		setVisible ('ann_cat_row', 'table-row');
		sec_list.options[0] = new Option ("--proszę czekać--", -1);

		runScript ('tmp_asec_script', 'index.php?m=script&s=section&mod=announ&cid='+cid+'&name='+sel+'&first=--wszystkie--&form=search');
	}
}

function changeDirPro (pid, sel)
{
	res_list = document.forms['search'].elements[sel];
	res_list.options.length = 0;
	if (parseInt(pid) < 1)
	{
		res_list.options[0] = new Option ("--wszystkie--", 0);
		setVisible ('dir_cat_row', 'none');
	}
	else
	{
		setVisible ('dir_cat_row', 'table-row');
		res_list.options[0] = new Option ("--proszę czekać--", -1);

		runScript ('tmp_cat_script', 'index.php?m=script&s=category&mod=directory&name='+sel+'&first=--wszystkie--&form=search');
	}
}

