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

var arrMenu = new Array();
arrMenu[0]='mnAbout'; 
arrMenu[1]='mnRental'; 
arrMenu[2]='mnShowcase'; 
arrMenu[3]='mnLeasing'; 

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);
    document.getElementById(menuid).className = "";
  }
}

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 = "#333333";
			//	}
      }
		}
		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 = "#333333";
		//	}
		}
	}
	if (showflag != 0) { // show the appropriate menu
  	tempLay = document.getElementById(menuid);
  	tempLay.style.display = "block";
  	tempa = document.getElementById(menuid + "-a");
  	if(tempa) {
  	  for (i=0; i<totalLay; i++) {
  	    document.getElementById(arrMenu[i]).className = "";
  	  }
  	  document.getElementById(menuid).className = "topmenu2";
  	}
  	
  	//if (tempa) {
    //  tempa.style.backgroundColor = "#F26521";
    //  tempa.style.color = "#ffffff";
  //	}
  }
}


function repositionMenu()	{
	var browser = navigator.appName;
	var ch = 0;
	var newpos = 0;

	if (browser == "Microsoft Internet Explorer")  {
  	ch = document.body.clientWidth;
  	var offset = 0;
	}
	else {
  	ch = window.innerWidth;
  	var offset = -8;
	}

	if (ch <= 831)
  	var leftspace = 0;
	else
  	var leftspace = Math.ceil((ch - 831) / 2);
  
	var x = 0;
  for (i=0; i<arrMenu.length; i++) {
		x = parseInt(document.getElementById(arrMenu[i]).style['left']);
    document.getElementById(arrMenu[i]).style['marginLeft'] = leftspace + offset + "px";
  }
}