var totalLay = 4;
var menuid = 0;
var currSub = 0;
var timerId = 0;
var startLeft = 26;

var arrMenu = new Array();
arrMenu[0]='mnshielding'; 
arrMenu[1]='mnetcm'; 
arrMenu[2]='mnewap';
arrMenu[3]='mnce';

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.display = "none";
				othera = document.getElementById(arrMenu[i] + "-a");
				if (othera) {
          othera.style.backgroundColor = "";
          othera.style.color = "#ffffff";
				}
      }
		}
		else { // hide just the specified menu
		 	otherLay = document.getElementById(menuid);
			if (otherLay) otherLay.style.display = "none";
			othera = document.getElementById(menuid + "-a");
			if (othera)  { 
        othera.style.backgroundColor = "";
        othera.style.color = "#ffffff";
			}
		}
	}
	if (showflag != 0) { // show the appropriate menu
  	tempLay = document.getElementById(menuid);
  	tempLay.style.display = "block";
  	tempa = document.getElementById(menuid + "-a");
  	if (tempa) {
      tempa.style.backgroundColor = "";
      tempa.style.color = "#ffffff";
  	}
  }
}

