function switchpage(targetpage)
{
	removepageparam("course", "");
	removepageparam("step", "");
	addpageparam("category", targetpage, "");
	pageform.submit();
}

function setsorting(tableid, columnid, sorting)
{
	addpageparam("tabsorttable", tableid, "");
	addpageparam("tabsortcolumn", columnid, "");
	addpageparam("tabsortorder", sorting, "");
	pageform.submit();
	//
}

function addpageparam(paramid, value, sform)
{
	removepageparam(paramid, sform);
	var oInput = document.createElement("INPUT");
	oInput.type = "hidden";
	oInput.name = paramid;
	oInput.id = paramid;
	oInput.value = value;
	if(sform=="")sform="pageform";
	document.getElementById(sform).appendChild(oInput);
}
function addmultipleparam(paramid, value, sform)
{
	var oInput = document.createElement("INPUT");
	oInput.type = "hidden";
	oInput.name = paramid;
	oInput.id = paramid;
	oInput.value = value;
	if(sform=="")sform="pageform";
	document.getElementById(sform).appendChild(oInput);
}
function removepageparam(paramid, sform)
{
	if(sform=="")sform="pageform";

/*
	var oInput;
	oInput = document.getElementById(paramid);
	if(oInput != null)
	{
		if(oInput.form.id == document.getElementById(sform).id);
			oInput.removeNode();
	}
*/

	var oInputColl = document.body.getElementsByTagName("INPUT");
	//alert(oInputColl.length);
	for(var a=oInputColl.length-1;a>=0;a--)
	{
		if(oInputColl[a].form != null)
		{
			//alert(oInputColl[a].form.id + ", " + oInputColl[a].name);
			if(oInputColl[a].form.id == sform && oInputColl[a].name == paramid) {
      	//oInputColl[a].removeNode();
        oInputColl[a].parentNode.removeChild(oInputColl[a]);
        // EDITED BY JAN BRAVERMAN 2012-01-31
      }
			
      
   	
		}
	}
}

function settablescrollarea(tabledivID, width, height) //width, height jsou nepovinne parametry. pokud se ma dopocitavat automaticky, zadava se -1
{
	if(document.getElementById(tabledivID) == null) return;
	if(width != -1)
		document.getElementById(tabledivID).style.width=width;
	/*
  else
		document.getElementById(tabledivID).style.width = document.getElementById(tabledivID).childNodes(0).offsetWidth+20;
  */
	if(height != -1)
		document.getElementById(tabledivID).style.height=height;	
	else
	{
		var minheight = 180;
		if(document.body.offsetHeight > minheight) 
			document.getElementById(tabledivID).style.height = document.body.offsetHeight - minheight;
	}
}

function closeme()
{
	if(!window.opener.closed); //&& window.opener.location.toString().search("/nssd/"));
	{
		if(!window.opener.location.toString().match(/edit_/g))
			window.opener.location.reload();
	}
	window.close();
}

