function enable (name)
{
	el = document.forms[0].elements[name];
	el.disabled = false;
}

function disable (name)
{
	el = document.forms[0].elements[name];
	el.disabled = true;
}

function getElem (el_id)
{
	if (document.getElementById && document.getElementById(el_id))
		return document.getElementById(el_id);
	else if (document.all && document.all(el_id))
		return document.all(el_id);
  else if (document.layers && document.layers[el_id])
  	return document.layers[el_id];

	return false;
}

function setVisible (el_id, vis)
{
	var div = getElem (el_id);

	if (!div)
		return false;

	if (!vis)
		vis = 'none';
	div.style.display = vis;
}

//----------------------------

function runScript (name, url, elem)
{
	if (!elem)
		form = document.forms[0];
	dscr = document.getElementById (name);
	if (dscr)
	{
		form.removeChild (dscr);
	}
	script = document.createElement('script');
	script.type = "text/javascript";
	script.src = url;
	script.id = name;

	form.appendChild (script);
}

function changeText (node, text)
{
	while (node.hasChildNodes())
		node.removeChild(node.firstChild);

	node.appendChild(document.createTextNode(text));
}

function popupWindow (url, name)
{
	win = window.open (url, name, 'menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=yes, status=no');
	win.focus ();
}

//-------------------------------

function changeCat (mod, id, sec_name, fname)
{
	if (!fname)	fname = mod;
	sec_list = document.forms[fname].elements[sec_name];
	sec_list.options.length = 0;
	sec_list.options[0] = new Option ("--proszę czekać--", -1);

	runScript ('tmp_section_script', 'index.php?m=script&s=section&mod='+mod+'&cid='+id+'&name='+sec_name+'&form='+fname);
}

