function SetMenu(MenuName)
{
	var Menu = document.getElementById(MenuName);
	if(Menu)
	{
		if(Menu.style.display == "none")
			Menu.style.display = "";
		else
			Menu.style.display = "none";
	}
}

//宣告計時器函式執行代號
var TimerID = null;
function ShowMenu(sender, menuId)
{
	var iMENU = document.getElementById(menuId);
	if(sender)
	{
		var x = 0;
		var y = 0;
		var offsetPointer = sender; // cElement;
		while (offsetPointer) {
			x += offsetPointer.offsetLeft;
			y += offsetPointer.offsetTop;
			offsetPointer = offsetPointer.offsetParent;
		}
		// correct for MacIE body margin factors
		if(navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") {
			x += document.body.leftMargin;
			y += document.body.topMargin;
		}
		
		iMENU.style.left = x + 185 + "px";
		iMENU.style.top  = y + "px";
		iMENU.style.display = "";
	}
}

//給中文主站與英文站用的
function ShowMenu2(sender, menuId)
{
	
	var divSubMenu2 = document.getElementsByTagName("div");
	for(var i=0; i< divSubMenu2.length; i++)
	{
	    if(divSubMenu2[i].className == "SubMenu trans-Opa")
	    {
	        HideMenu(divSubMenu2[i].id);
	    }
	}
	
	if(document.getElementById(menuId) && sender)
	{
	    var iMENU = document.getElementById(menuId);
	    if(sender)
	    {
		    var x = 0;
		    var y = 0;
		    var offsetPointer = sender; // cElement;
		    while (offsetPointer!=null && offsetPointer!=document.body) {
			    x += offsetPointer.offsetLeft;
			    y += offsetPointer.offsetTop;
			    offsetPointer = offsetPointer.offsetParent;
		    }
		    // correct for MacIE body margin factors
		    if(navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") {
			    x += document.body.leftMargin;
			    y += document.body.topMargin;
		    }
    		
		    
		    //IE or FireFox
		    var bIE = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 4);
            var bFF = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4);
		    
		    //加上來源物件本身的寬度 sender.offsetWidth
		    if(bFF)
		    {
		        iMENU.style.left = x + 175 +"px";
		        iMENU.style.top  = y -10 + "px";
		        iMENU.style.display = "";
                //iMENU.focus();
            }
            else
            {
		        iMENU.style.left = x + 175 + "px";
		        iMENU.style.top  = y + "px";
		        iMENU.style.display = "";
                //iMENU.focus();
            }
	    }
	}
}

function HideMenu(menuId)
{
	if(document.getElementById(menuId))
	    document.getElementById(menuId).style.display = "none";
}

function EnterMenu(objFocus)
{
	if(TimerID != null)
	{
	    window.clearTimeout(TimerID);
	    TimerID = null;
	}
	objFocus.focus();
}

function LeaveMenu(sender, menuId)
{
	TimerID = window.setTimeout("HideMenu('"+menuId+"')", 200);
}

