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 = ID;
	var x = 0;
	var y = 22;
	var oPos = objPos(getE('p'+hID));

	allHiddenMenu(hID);
	getE('ch'+hID).style.left = oPos.x;
	getE('ch'+hID).style.top = oPos.y+nPlusY; //getE('idForMenuPos').offsetTop + nPlusY;
	getE('ch'+hID).style.display = "inline";
}
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'){ 
		if (objElem.tagName != 'BASEFONT') {
			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);
}
//added by rodney and upgraded by Lemma
function objPos(objForPos){
	if(Br.IE || Br.OP){objForPos.style.position = "";}else{objForPos.style.position = "relative";}
	this.x=0;
	this.y=0;
	while (typeof objForPos == 'object' && objForPos.tagName != 'BODY'){
		if (objForPos.tagName != 'BASEFONT') {
			this.x += objForPos.offsetLeft;
			this.y += objForPos.offsetTop;
		}
		objForPos = objForPos.parentElement;
	}
	return this;
}
