var tdWidth = new Number();

var timeoutID;





function clearTimeoutHideSubMenuTimeOut(){

	try{

		if(timeoutID) clearTimeout(timeoutID);

	}catch(e){

		alert("clearTimeoutHideSubMenuTimeOut.err = " + e.message);

	}

}



function hideSubMenuTimeOut(){

	try{

		clearTimeoutHideSubMenuTimeOut();

		timeoutID=window.setTimeout("hideSubMenu();",1000);

	}catch(e){

		alert("hideSubMenuTimeOut.err = " + e.message);	

	}

}



function hideSubMenu(){

	document.getElementById("submenuArea").innerHTML = "";

	clearTimeoutHideSubMenuTimeOut();

}



function displaySubMenus(menuId){

	try{

		//alert("displaySubMenus:hideSubMenuTimeOut = " + hideSubMenuTimeOut);

		clearTimeoutHideSubMenuTimeOut();

		var str = new String();

		var numOfSubMenus = menus[menuId].length-1;

		var i;

		var leftMargin = (menuId-1)*tdWidth;

		

		str =	"<table cellpadding='0' cellspacing='0'";

		str +=		" onmouseover='clearTimeoutHideSubMenuTimeOut();' onmouseout='hideSubMenuTimeOut();'";

		str +=		" style='padding:3px;margin-left:" + leftMargin + "px;width:"+ tdWidth;

		str +=		"px;background-color:#eeeeee;border:solid #999999 1px'>";

		str +=		"<tr><td>";

		

		for(i=1; i<=numOfSubMenus; i++){

			str +=	"<a href='" + menusURL[menuId][i] + "' class='link1'>" + menus[menuId][i] + "</a><br />";

		}

		

		str +=		"</td></tr>";

		str +=	"</table>";

		

		document.getElementById("submenuArea").innerHTML = str;

		

	}catch(e){

		alert("displaySubMenus.err: " + e.message);	

	}

}



function changeLocation(newUrl){

	try{

		var fileName = new String(window.location.href);	

		var domainPath = fileName.substr(0,(fileName.lastIndexOf("/")+1));//"http://www. ... .com/";

		

		window.location.href = domainPath + newUrl;

	}catch(e){

		alert("changeLocation.err: "+e.message);	

	}

}



function getMenu(selected){

	try{

		var str = new String("");

		var i;

		var exactMenuWidth = estimateMenuWidth;	//declared in const.js

		var pageUrl = new String();

		tdWidth = estimateMenuWidth / level1MenuItems;

		exactMenuWidth = tdWidth * level1MenuItems;

		

		str += "<div align='right' style='padding-right:30px;padding-bottom:25px;font-size:9px;'><a href='index.htm'>Home</a></div>";

		

		str += "<table cellpadding='0' cellspacing='0' border='0' style='width:"+ exactMenuWidth +"px' class='menuTable'>";

		str +=	"<tr>";

		

		for(i=1; i<=level1MenuItems; i++){

			str += "<td id='menuId"+i+"' style='width:"+ tdWidth +"px;text-align:center;cursor:pointer;";

			if(i == selected){	// selected menu

				str += "color:#e9b136;";	//' >" + menus[i][0] + "</td>";

			}	//else{

			if(menusURL[i][0] == ""){	// this menu has subMenus: onmouseover(displaySubMenu());

				str +=		"' onmouseover='displaySubMenus(" + i + ")' ";

				str +=		" onmouseout='hideSubMenuTimeOut()'>" + menus[i][0] + "</td>";

			}else{	// this menu doesn't have submenus: onclick(...)

				pageUrl = menusURL[i][0];

				str +=		"' onclick='changeLocation(\"" + pageUrl + "\")'>" + menus[i][0]+ "</td>";

			}	

			//}

		}

		

		str +=		"</tr>";

		str +=	"</table>";

		

		return str;

	}catch(e){

		alert("getMenu.Err: "+e.message);

	}

}
