
var totalLay = 2; //this value must be the count of array arrMenu
var menuid = 0;
var currSub = 0;
var timerId = 0;

var arrMenu = new Array();
//arrMenu[0]='mnPool';
//arrMenu[1]='mnMember';


var arrMenuWidth = new Array();
for (i=0; i<(totalLay-1); i++) {
  j = i + 1;
  if (document.getElementById(arrMenu[j]) != undefined && document.getElementById(arrMenu[i]) != undefined)
    arrMenuWidth[arrMenu[i]] =  document.getElementById(arrMenu[j]).style.left - document.getElementById(arrMenu[i]).style.left;   
}

function menuHandler(menuid, showflag) {
  if (showflag != 0) { //show menu
    clearTimeout(timerId);
    showMenu(menuid, showflag)
  }
  else { //hide menu after a few sec
    timerId = setTimeout("showMenu('', 0)", 500);
  }
}

function showMenu(menuid, showflag) {
	if (!showflag) {
		if (menuid == '') { // hide all if menunum = 0
			for (i=0; i<totalLay; i++) {
		  	otherLay = document.getElementById(arrMenu[i]);
				if (otherLay) {
				    otherLay.style.visibility = "hidden";
				    
				}
	  	    
	  	    otherLay = document.getElementById('m'+arrMenu[i]);
				if (otherLay) {
				    /*otherLay.style.background = "";
				    otherLay.style.color = "";
				    otherLay.style.border="";*/
				}
	  	    }
		}
		else { // hide just the specified menu
		 	otherLay = document.getElementById(menuid);
			if (otherLay){
			    otherLay.style.visibility = "hidden";
			}
		}
	}
	if (showflag != 0) { // show the appropriate menu
  	tempLay = document.getElementById(menuid);
  	tempLay.style.visibility = "visible";
  	tempLay.style.left = findPos(document.getElementById('m'+menuid)) + 'px';
  	tempLay.style.top = (findPosTop(document.getElementById('m'+menuid)) + 22) + 'px';
  	/*document.getElementById('m'+menuid).style.background ="url(images/top_menu_bg1.gif)";
  	document.getElementById('m'+menuid).style.borderleft="1px solid black";
  	document.getElementById('m'+menuid).style.borderright="1px solid black";*/
	}
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	
	return curleft;
}

function findPosTop(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	
	return curtop;
}