var IdTime, gnHiddenMenuCount, aHiddenTableIDs;
var lockMenu=new Array();


function lockMenuA(p) {
    for (var i = 0; i < lockMenu.length; i++) {
        if (i != p && getE('ch' + i) != null) {
            getE('ch' + i).style.display = 'none';
            lockMenu[i] = false;
        } 
    }
    lockMenu[p] = !lockMenu[p];
}

function isLocked(p) {
    return lockMenu[p];
}

function addlock(p) {
    lockMenu[p] = false;
}

function allHiddenMenu(objId){

	window.clearTimeout(IdTime);
	IdTime=null;
	for (var i=0; i<aHiddenTableIDs.length; i++){
		id = aHiddenTableIDs[i];
		if ((id != objId) && (!isLocked(id))) 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){
// alert(getE('p' + hID).offsetLeft);
	var objElem = ID;
	var x = 0;
	var y = 22;
	var oPos = objPos(getE('p'+hID));

	allHiddenMenu(hID);
	getE('ch' + hID).style.marginLeft = getE('p' + hID).offsetLeft+580;
	getE('ch'+hID).style.top = oPos.y+nPlusY+10; //getE('idForMenuPos').offsetTop + nPlusY;
	getE('ch'+hID).style.display = "inline";
	getE('ch'+hID).style.position = "absolute";
	getE('ch'+hID).style.zIndex = "10000";
}
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;
}

