var IdTime, gnHiddenMenuCount, aHiddentableIDs;

function allHiddenMenu(objId){

	window.clearTimeout(IdTime);
	IdTime=null;
	for (var i=0; i<aHiddentableIDs.length; i++){
		id = aHiddentableIDs[i];
		if (id != objId) getE('ch'+id).style.display = "none";
	}
}
function chHiddenMenu(chID,pID){

	window.clearTimeout(IdTime);
	IdTime=null;
	for (i=1; i<=aHiddentableIDs.length; i++){
		id = aHiddentableIDs[i];
		if (getE('ch'+id) != null){
			if(id > pID && id != chID){getE("ch"+id).style.display = "none";}
		}
	}
}
function menuHideOnTime(){
	IdTime = window.setTimeout("allHiddenMenu(-1)",300);
}
function onMenuShowRoot(hID,ID,nPlusY){

 
 var objElem = getE('p' + hID);

	var x = 0;
	var y = 0;



	// suited obj for x-pos ... (no IMG etc.)
	while (typeof objElem == 'object' && objElem.tagName != 'TD') objElem = objElem.offsetParent;
	while (typeof objElem == 'object' && objElem.tagName != 'BODY') {
		y += objElem.offsetTop;
		x += objElem.offsetLeft;
		objElem = objElem.offsetParent;
	}
	allHiddenMenu(hID);
	objElem = document.getElementById('ch'+hID);
	if (objElem == null) return; // if loading
	objElem.style.display = "inline";
  objElem.style.left = x + 'px';
	objElem.style.top = getE('idForMenuPos').offsetTop + nPlusY+ 'px';
}


function onMenuShowRoot2(hID,ID,nPlusY){

  var objElem = ID;  
 
	var x = 0;
	var y = 0;
  alert ('MG')
	// suited obj for x-pos ... (no IMG etc.)
	while (typeof objElem == 'object' && objElem.tagName != 'TD') objElem = objElem.offsetParent;
	while (typeof objElem == 'object' && objElem.tagName != 'BODY') {
		y += objElem.offsetTop;
		x += objElem.offsetLeft;
		objElem = objElem.offsetParent;
	}
	allHiddenMenu(hID);
	objElem = document.getElementById('ch'+hID);
	if (objElem == null) return; // if loading
  objElem.style.left = x;
	objElem.style.top = getE('idForMenuPos').offsetTop + nPlusY;
}

function onChildren(chID,ID,pID){
	var objElem = ID;
	var x = 0;
	var y = 0;
	// nejdřív se vyšplhám na rozumný objekt ... (slezu z obrázku apod. které mohou být v menu)
	while (typeof objElem == 'object' && objElem.tagName != 'TD') objElem = objElem.offsetParent;
	// offsetLeft posunu o šířku, ale ne TD.width, ani o A.width ale o TR.width
	x += parseFloat(objElem.parentElement.offsetWidth);
	while (typeof objElem == 'object' && objElem.tagName != 'BODY'){ 
		x += objElem.offsetLeft;
		y += objElem.offsetTop;
		objElem = objElem.offsetParent;
	};
	chHiddenMenu(chID,pID);
	getE('ch'+chID).style.left = x;
	getE('ch'+chID).style.top = y;
	getE('ch'+chID).style.display = "inline";
}
function ClearTime(){
	window.clearTimeout(IdTime);
}

/* web menu */

var gsMenuSep = "";
var gnMenuLast = -1;

function MenuUrlGet(sURL, pkTblMenu) {
	return (sURL == "") ? "/InfoPage.asp?TP=MN&ID=" + pkTblMenu : sURL;
}
function MenuRootAdd(pkTblMenu,pkID,nChildren,sLinkName,sURL,sPlusPath) {
	document.write(
		gsMenuSep +
		"<td class='MenuRoot' nowrap='nowrap'" +
		((nChildren==0) ?
			""
			:
			" onmouseover='onMenuShowRoot(" + pkID + ", event.srcElement, 44);' onmouseout='menuHideOnTime();' id='p" + pkTblMenu + "'"
		) +
		"><a href='" + MenuUrlGet(sURL, pkTblMenu) + "'>" + sLinkName + "</a></td>"
	);
	gsMenuSep =
		"<td width='1' style='padding-bottom:6px' valign='bottom'>" +
			"<img src='/img/" + sPlusPath + "OddMenu.gif' border='0'  height='14' width='1' style='margin-left:5px;margin-right:5px;'>" +
		"</td>";
}
function MenuSubBegin(nParent) {
	document.write(
		"<table id='ch" + nParent + "' class='MenuSubTbl'  onmouseover='ClearTime();' onmouseout='menuHideOnTime();' cellpadding=0 cellspacing=0 style='display: none; position: absolute;'>"
	);
}
function MenuSubAdd(pkTblMenu,pkID,nParent,nChildren,sLinkName,sURL,sPlusPath) {
	document.write(
		"<tr><td nowrap='nowrap' " +
		((nChildren==0) ?
			" onmouseover='chHiddenMenu(" + pkID + "," + nParent + ");'"
			:
			" onmouseover='onChildren(" + pkID + ",event.srcElement," + nParent + ");'"
		) +
		">&nbsp;<a class='MenuSub' href='" + MenuUrlGet(sURL, pkTblMenu) + "' id='p" + pkTblMenu + "'>" + sLinkName + "</a>&nbsp;</td></tr>"
	);
}
function MenuSubEnd() {
	document.write(
		"<tr><td><img src='/img/empty.gif' width=1 height=1></td></tr></table>"
	);
}

