var activeSub=0;
var SubNum=0;

function reDo(){ menuInit(); }
    window.onresize = reDo;


    //Define global variables

	    var timerID = null;
		var timerOn = false;
		var timecount = 1000;
		var what = null;
		var newbrowser = true;
		var check = false;
		var flagShow = false;

    	function menuInit(){
    	  //alert ("Running Init");
          if (document.layers) {
                      //  alert ("Running Netscape 4");
                        layerRef="document.layers";
                        styleSwitch="";
                        visibleVar="show";
			screenSize = window.innerWidth;
			what ="ns4";


          }else if(document.all){
                      //  alert ("Running IE");
                        layerRef="document.all";
                        styleSwitch=".style";
                        visibleVar="visible";
			screenSize = document.body.clientWidth + 18;
			what ="ie";

		  }else if(document.getElementById){
                      //  alert ("Running Netscape 6");
                        layerRef="document.getElementByID";
                        styleSwitch=".style";
                        visibleVar="visible";
			what="moz";
		  
		  }else{
		  	//alert("Older than 4.0 browser.");
			what="none";
			newbrowser = false;
		  }
		  
		window.status='status bar text to go here';
		check = true;

  	 	}

	// Turns the layers on and off
        function showLayer(layerName){

			updateMenuPosition('living', 265);
			//updateMenuPosition('business', 548);
			//updateMenuPosition('reservation', 722);
			//updateMenuPosition('life', 842);

			if (flagShow==false)
			{
			
				if(check){
					if (what =="none"){
						return;
						}
					else if (what == "moz"){
						//document.getElementById(layerName).style.visibility="visible";
						fadeIn(layerName, 1000);
						}
					else{
					  //eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
					  fadeIn(layerName, 1000);
					  }
				}
				else {// alert ("Please wait for the page to finish loading.");
					return;
				}
				flagShow = true;
			}
		}

		function moveMenuPosition() {
			if (flagShow==false)
			{
				updateMenuPosition('living', -9999);
				//updateMenuPosition('business', -9999);
				//updateMenuPosition('reservation', -9999);
				//updateMenuPosition('life', -9999);
			}
		}

        function hideLayer(layerName){

        	if(check){
        		if (what =="none"){
        			return;
        			}
        		else if (what == "moz"){
					fadeOut(layerName, 1000);
        			//document.getElementById(layerName).style.visibility="hidden";
        			}
        		else{
					fadeOut(layerName, 1000);
                  //eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
				}
        
        	}
        	else {// alert ("Please wait for the page to finish loading.");
        		return;}

			flagShow = false;
			setTimeout('moveMenuPosition()', 1000);
        }


		function hideAll(){
				hideLayer('living');
				//hideLayer('business');
				//hideLayer('reservation');
				//hideLayer('life');
				}


		function startTime() {
	        if (timerOn == false) {
                timerID=setTimeout( "hideAll()" , timecount);
                timerOn = true;

	        }

		}

		function stopTime() {
	        if (timerOn) {
    	        clearTimeout(timerID);
                timerID = null;
                timerOn = false;
	        }
		}

		function updateMenuPosition(menuDivName, contentOffset) {
			contentWidth = 1000;

			if (document.layers) {
			}else if(document.all){ // IE
				windowWidth = document.body.offsetWidth;
				adjustpos = -11;
			}else if(document.getElementById){ // Netscape
				windowWidth = document.body.clientWidth;
				adjustpos = 1;
			}else{
			}

			if (windowWidth<=contentWidth)
			{
				startpos = contentWidth;
			}
			else {
				startpos = (windowWidth - contentWidth) / 2;
				startpos = parseInt(startpos) + parseInt(contentOffset) + adjustpos;
			}
			document.getElementById(menuDivName).style.left = startpos+"px";
		}

		function showMenu(menuDivName) {
/*			if (menuDivName=='living')
			{
				hideLayer('life');
			}
			if (menuDivName=='life')
			{
				hideLayer('living');
			}
*/
			showLayer(menuDivName); 
			stopTime();
		}