function GetOffsetTop(vMenuObj)
	{
		var vY = 0;
		var objParent = null;
		with(vMenuObj)
		{
			vY = offsetTop;
			objParent = offsetParent;
			while(objParent.tagName.toUpperCase()!= "BODY")
			{
				vY += objParent.offsetTop;
				objParent = objParent.offsetParent;
			}
			// vY+=offsetHeight-1
		}
		return vY;
	}	
	
    // Occur when the menu exit the menu item
	function OnMouseOutMenu(obj, event)
	{
		var vIsContinue = true;
		if (typeof(obj) != 'undefined' && obj != null)
		{
			// Get the menu bar's leftX, rightX, topY
			var vLeftX = -1;	
			var vRightX = -1;
			var vTopY = -1;
			with(obj)
			{
				vLeftX = offsetLeft + 1;
				vTopY = offsetTop + 1;
				objParent=offsetParent;
				while(objParent.tagName.toUpperCase()!= "BODY")
				{
					vLeftX+=objParent.offsetLeft;
					vTopY+=objParent.offsetTop;
					objParent = objParent.offsetParent;
				}
				vRightX = vLeftX + offsetWidth;
			}

			vIsContinue = false;
			if (event.clientY - 2 < vTopY)
			{
				vIsContinue = true;
			} else 
			if (event.clientX - 2 < vLeftX)
			{
				vIsContinue = true;
			} else 
			if (event.clientX + 2 > vRightX)
			{
				vIsContinue = true;
			}
		}
		if (vIsContinue) SetMenuStatus(false);
	}
	
	function OnMouseOverMenu()
	{
		SetMenuStatus(true);
	}

	// Hide the sub menu
	function SetMenuStatus(vIsShow)
	{
		var vDisplay = 'none';
		if (vIsShow) vDisplay = 'block';
		var vItemObj = document.getElementById('DivPanelID');
		vItemObj.style.display = vDisplay;

		var vIfmObj = document.getElementById('IFramePanelID');	
		if (vIfmObj != null) vIfmObj.style.display = vDisplay;
	}

	function MenuItemClick(vMenuBarIndex, vLink)
	{
		try {
			var vMenuBarObj = document.getElementById('MenuBar_' + vMenuBarIndex)
			if (vMenuBarObj != null)
			{
				//vMenuBarObj.style.backgroundColor = vSelectBackGroundColor;
				//vMenuBarObj.style.color = vSelectForeColor;
				SetMenuBarCSSStatus(vMenuBarObj, true);

				//alert("vOldSelectMenuBar =" + vOldSelectMenuBar);
				if (vOldSelectMenuBar != vMenuBarObj && vOldSelectMenuBar != null)
				{
					//vOldSelectMenuBar.style.backgroundColor='';
					//vOldSelectMenuBar.style.color='';				

					SetMenuBarCSSStatus(vOldSelectMenuBar, false);

					SelectMenuBarStatus(vOldSelectIndex, false);
				}

				SelectMenuBarStatus(vMenuBarIndex, true);			

				vOldSelectIndex = vMenuBarIndex;
				vOldSelectMenuBar = vMenuBarObj;
			}
			SetMenuStatus(false);
			
			if (vLink == 'LinkSubMenu')
			{
				ExecMenuFirstLink(vMenuBarIndex);
			} else {
				ExecMenuItem(vLink);
			}
		} catch (err) {
			alert("MenuItemClick =" + err.message);
		}
	}
	
	function MenuItemImgClick(vMenuBarIndex, vLink)
	{
		try {
			var vMenuBarObj = document.getElementById('MenuBar_' + vMenuBarIndex)
			if (vMenuBarObj != null)
			{
				//vMenuBarObj.style.backgroundColor = vSelectBackGroundColor;
				//vMenuBarObj.style.color = vSelectForeColor;
				SetMenuBarCSSStatus(vMenuBarObj, true);

				//alert("vOldSelectMenuBar =" + vOldSelectMenuBar);
				if (vOldSelectMenuBar != vMenuBarObj && vOldSelectMenuBar != null)
				{
					//vOldSelectMenuBar.style.backgroundColor='';
					//vOldSelectMenuBar.style.color='';				

					SetMenuBarCSSStatus(vOldSelectMenuBar, false);

					SelectMenuBarStatus(vOldSelectIndex, false);
				}

				SelectMenuBarStatus(vMenuBarIndex, true);			

				vOldSelectIndex = vMenuBarIndex;
				vOldSelectMenuBar = vMenuBarObj;
			}
			
		    SetMenuStatus(false);
		    OpenLink(vLink);
			
		} catch (err) {
			alert("MenuItemClick2 =" + err.message);
		}
	}

	// Occur when click the menu bar item
	function ExecMenuFirstLink(vMenuBarIndex)
	{
		var vObj = document.getElementById("Menu_Item_" + vMenuBarIndex + "_1");
		if (vObj != null) 
		{
			var vLink = vObj.getAttribute("URL")
			ExecMenuItem(vLink);
		}
	}

	function SelectMenuBarStatus(vIndex, vIsSelect)
	{
		var vObj = document.getElementById('MenuBar_Item_' + vIndex)
		if (vObj != null) SetMenuBarCSSStatus(vObj, vIsSelect);

		vObj = document.getElementById('MenuBar_Img_' + vIndex)
		if (vObj != null)
		{
			if (vIsSelect)		
			{
				vObj.src = vSelectMenuBarImage;
			} else {
				vObj.src = vUnSelectMenuBarImage;
			}
		}
	}

	// Set the menu status
	function SetMenuBarCSSStatus(vObj, vIsSelect)
	{
		if (vIsSelect)
		{
			vObj.className = "SelectMenuBarCSS";
		} else {
			vObj.className = "MenuBarCSS";
		}
	}

	// Set the menu status
	function SetMenuItemCSSStatus(vObj, vIsSelect)
	{
		if (vIsSelect)
		{
			vObj.className = "SelectMenuCSS";
		} else {
			vObj.className = "MenuCSS";
		}
	}	

	// Occur when mouse over on the menu item
	function OnMouseOver(vObj) 
	{
		SetMenuItemCSSStatus(vObj, true);
	}

	// Occur when mouse out on the menu item
	function OnMouseOut(vObj) 
	{
		SetMenuItemCSSStatus(vObj, false);
	}

	// Exec the menu bar by special index
	function SelectMenuItem(vMenuBarIndex)
	{
		try 
		{	
			var vMenuBarID = "MenuBar_" + vMenuBarIndex;
			var vObj = document.getElementById(vMenuBarID);
			if (vObj != null)
			{
	            vOldSelectMenuBar = vObj;
	            vOldSelectIndex = vMenuBarIndex;			
				SetMenuBarCSSStatus(vObj, true);
			}
			
			vMenuBarID = "MenuBar_Item_" + vMenuBarIndex;
			vObj = document.getElementById(vMenuBarID);
			if (vObj != null)
			{
				SetMenuBarCSSStatus(vObj, true);
			}
		} catch (err) {
			alert("SelectMenuItem =" + err.message);
		}
	}

	// Build menu bar item start
	function BuildMenuBarStart()
	{
		var vHTML = "";
		vHTML += "<table  class='MenuBarBackgroundCSS' width='100%' border='0' cellpadding='0' cellspacing='0'>";
		vHTML += "	<tr><td  align=\"left\">";

		vHTML += "<table class='MenuBarBackgroundCSS' onselectstart='javascript:return false;' border='0' cellpadding='0' cellspacing='0'>";
		vHTML += "	<tr>";
		if(menuIndex == 1)
		    vHTML += "	<td style ='width:120px;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
		    
		vHTML += "	<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
		
		menuIndex++;
		return vHTML;
	}

	// Build menu bar item end
	function BuildMenuBarEnd()
	{
		var vHTML = "";
		vHTML += "	</tr>";
		vHTML += "</table>";
		vHTML += "	</td></tr>";
		vHTML += "</table>";
		return vHTML;
	}

	// Build menu bar item
	function BuildMenuBar(vIndex, vWidth, vIsIncludeSubItem, vMenuText, vLink)
	{	
		var vHTML = "";
		if (vIsIncludeSubItem)
		{
			vLink = "LinkSubMenu";
			vHTML += "<td class=\"MenuBarCSS\"  id=\"MenuBar_" + vIndex + "\" align=\"center\" onclick=\"ShowMenuItem(this, '" + vIndex + "')\" onmouseout=\"OnMouseOutMenu(this, event)\"  style=\"width:" + vWidth + "px;\">";
		} else {
			vHTML += "<td class=\"MenuBarCSS\"  id=\"MenuBar_" + vIndex + "\" align=\"center\" onclick=\"MenuItemClick('" + vIndex + "','" + vLink + "')\" onmouseout=\"OnMouseOutMenu(this, event)\" style=\"width:" + vWidth + "px;\">";
		}
		vHTML += "	<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
		vHTML += "		<tr>";
		vHTML += "			<td id='MenuBar_Item_" + vIndex + "' style='height:22px;' class=\"MenuBarCSS\" align ='Center'>";
		vHTML += "				" + vMenuText;
		vHTML += "			</td>";
	
		
		if (vIsIncludeSubItem)
		{
			vHTML += "			<td>&nbsp;</td>";
			vHTML += "			<td>";
			vHTML += "				<img id='MenuBar_Img_" + vIndex + "' border=\"0\" src=\"" + vUnSelectMenuBarImage + "\" width=\"8\" height=\"8\">";
			vHTML += "			</td>";
		}
		
		vHTML += "		</tr>";
		vHTML += "	</table>";
		vHTML += "</td>";
		if(vIndex < menuMaxIndex){ 
	        vHTML += "			<td>";
		    vHTML += "              <img src = '" + dotImg +"' border = 0>";
		    vHTML += "			</td>";
		    }
		return vHTML;
	}

	// Build the menu item start
	function BuildMenuItemStart(vIndex, vWidth, vHeight)
	{
		var vHTML = "";
		vHTML += "<div id='div" + vIndex + "' style=\"display:none;height:" + vHeight + "px; width:" + vWidth + "px;\">";
		vHTML += "	<table width=\"100%\" onselectstart='javascript:return false;' onmouseover=\"OnMouseOverMenu(this)\" onmouseout=\"OnMouseOutMenu(null,event)\"  cellpadding=\"1\" cellspacing=\"1\" class=\"MenuBorderCSS\">";
		return vHTML;
	}

	// Build the menu item end
	function BuildMenuItemEnd()
	{
		var vHTML = "";
		vHTML += "	</table>";
		vHTML += "</div>";
		return vHTML;
	}

	// Build the menu item
	function BuildMenuItem(vIndex, vIsFrstItem, vItemText, vLink)
	{
		var vHTML = "";
		if (vIsFrstItem)
		{
			vHTML += "<tr style=\"height:20px;\">";
			vHTML += "	<td id='Menu_Item_" + vIndex + "_1' class=\"MenuCSS\" URL=\"" + vLink + "\" style=\"cursor:pointer;\" onmouseover=\"OnMouseOver(this)\" onmouseout=\"OnMouseOut(this)\" onclick=\"MenuItemClick('" +  vIndex + "','" + vLink + "')\" align ='left' >&nbsp;&nbsp;&nbsp;" + vItemText + "</td>";
			vHTML += "</tr>";
		} else {
			vHTML += "<tr style=\"height:20px;\">";
			vHTML += "	<td class=\"MenuCSS\" style=\"cursor:pointer;\" onmouseover=\"OnMouseOver(this)\" onmouseout=\"OnMouseOut(this)\" onclick=\"MenuItemClick('" +  vIndex + "','" + vLink + "')\" align ='left' >&nbsp;&nbsp;&nbsp;" + vItemText + "</td>";
			vHTML += "</tr>";
		}
		return vHTML;
	}
	
	// Build the menu item
	function BuildImgMenuItem(vIndex, vIsFrstItem, vItemImgPath, vLink)
	{
		var vHTML = "";
		var imgPath = "<img src = '"+ vItemImgPath +"' border = 0 />";
		if (vIsFrstItem)
		{
		    
			vHTML += "<tr style=\"height:20px;\">";
			vHTML += "	<td id='Menu_Item_" + vIndex + "_1' class=\"MenuCSS\" URL=\"" + vLink + "\" style=\"cursor:pointer;\" onmouseover=\"OnMouseOver(this)\" onmouseout=\"OnMouseOut(this)\" onclick=\"MenuItemImgClick('" +  vIndex + "','" + vLink + "')\" align ='center' >" + imgPath + "</td>";
			vHTML += "</tr>";
		} else {
			vHTML += "<tr style=\"height:20px;\">";
			vHTML += "	<td class=\"MenuCSS\" style=\"cursor:pointer;\" onmouseover=\"OnMouseOver(this)\" onmouseout=\"OnMouseOut(this)\" onclick=\"MenuItemImgClick('" +  vIndex + "','" + vLink + "')\" align ='center' >" + imgPath + "</td>";
			vHTML += "</tr>";
		}
		return vHTML;
	}