
 
//菜单相关图标的路径
var g_MenuSkins = "/Skins/Default/";
if(g_SystemSkins!="" && g_SystemSkins!=null){
	g_MenuSkins = g_SystemSkins;
}

window.MFT						= {};			//浮动菜单处理类
MFT.Const						= {};			//常量
MFT.Const.prefix				= 'menu';		//前缀

MFT.State						= {};			//状态
MFT.State.oldMenuContainer		= null;			//current object headle to use know from //当前对象的副本(只用做标志区别)
MFT.State.hideTimer				= null;			//timer
MFT.State.doHide				= null;			//It is flag to do all Hide of true or false 
MFT.State.ie4					= null;			//MS IE
MFT.State.ns4					= null;			//NC NS 
MFT.State.linkButton			= null;			//linkbutton of object
MFT.State.oldTopMenuId			= null;
MFT.State.expendList			= {};			//显示的列表

//----------------------------------
//-- 说明 : 浮动菜单初始化
//----------------------------------
MFT.menuInit = function(){
	MFT.State.ie4 = (document.all)?true:false;
	MFT.State.ns4 = (document.layers)?true:false;
	document.onmousemove = MFT.mouseMove;
	if (MFT.State.ns4) { document.captureEvents(Event.MOUSEMOVE); }
}

//----------------------------------
//-- 说明 : 最得对象在浏览者屏幕的位置
//----------------------------------
MFT.getPos = function(el,sProp) { 
	var o;
	if(typeof(el)=='string'){
		o = document.all.item(el,0);
	}
	else{
		o = el
	}
 	var iPos = 0
	while(o!=null){
		iPos+=o["offset" + sProp]
		o = o.offsetParent
	}
	return iPos
}

//----------------------------------
//-- 说明 : 显示顶层菜单
//----------------------------------
MFT.topMenu =  function(ID, obj){
	MFT.State.linkButton = obj;
	if(MFT.State.oldTopMenuId != ID)
	{
		MFT.hideAll();
		MFT.State.oldTopMenuId = ID;
 	}
	MFT.expandMenu(null, null, ID, MFT.getPos(obj,'Left'), MFT.getPos(obj,'Top') + obj.offsetHeight);
} 

//----------------------------------
//-- 说明 : 光标移上菜单
//----------------------------------
MFT.onMove =  function(){
	MFT.State.doHide = false;
} 

//----------------------------------
//-- 说明 : 取得子菜单的高度偏移量
//----------------------------------
MFT.subMenuPosY =  function(obj){
	return MFT.getPos(obj,'Top') + 2;
} 

//----------------------------------
//-- 说明 : 取得子菜单的宽度偏移量
//----------------------------------
MFT.subMenuPosX =  function(obj){
	return 0;
} 

//----------------------------------
//-- 说明 : 显示子菜单
//----------------------------------
MFT.expandMenu = function (menuParentAll,menuContainer,subContainer,menuLeft,menuTop) {
	MFT.State.doHide = false;
	//从父节点移到子节点,不需要隐藏其它的.
	if (menuContainer != MFT.State.oldMenuContainer && menuParentAll!=null) {
		if (MFT.State.ie4) {
			var oList = {};
			for(var menuId in MFT.State.expendList){
				if ( 
					menuParentAll.indexOf("|" +menuId + "|") == -1		//不等所有父节点
					&& menuId != menuContainer							//不等于当前节点
					&& menuId != subContainer							//不等于子节点
					) {													
 					document.all[menuId].style.visibility = "hidden"; 
				}
				else{
					oList[menuId] = true;//有用的记下来.
				}
			}
			MFT.State.expendList = oList;
 		}
		else if (MFT.State.ns4) {}
	}
	//子节点菜单存在
	if (subContainer) {
		//顶层菜单
		if (menuContainer == null) {
			MFT.positionObject(
				menuContainer, 
				subContainer, 
				menuLeft, 
				menuTop
			);
		}
		else {
 			if (MFT.State.ie4) {
				MFT.positionObject(									//设定位置
					menuContainer,									//当前菜单ID
					subContainer,									//子菜单ID
																	//菜单宽度
					document.all[menuContainer].offsetWidth			//当前菜单左偏移量
					+ document.all[menuContainer].style.pixelLeft	//当前菜单宽度
					- 10,											//减10px是使子菜单的位置与当前菜单的位置有10px的重合.
					menuTop											//菜单高度
				);
			}
			else {}
 		}
		MFT.showObject(subContainer);
		MFT.State.oldMenuContainer = subContainer;
	}
}
//----------------------------------
//-- 说明 : 设置菜单的显示位置
//----------------------------------
MFT.positionObject = function (menu, sub, subX, subY)
{
	try{
		var Xb = window.document.body.clientWidth - subX;
		var Yb = window.document.body.clientHeight - subY;
		var Xo = parseInt(document.all[sub].clientWidth);
		var Yo = parseInt(document.all[sub].clientHeight);
		var newTop = 0 
		var newLeft = 0
		//右下
		if((Xb >= Xo) && (Yb >= Yo)){
			newLeft = subX;
			newTop = subY;
		}
		//右上
		else if((Xb > Xo) && (Yb < Yo)){
			newLeft = subX;
			if(menu==null){
				newTop = subY - Yo - MFT.State.linkButton.offsetHeight ;
			}
			else{
				newTop = subY - Yo + 20;
			}
		}
		//左下
		else if((Xb < Xo) && (Yb > Yo)){
			if(menu==null)
				newLeft = subX  - Xo + MFT.State.linkButton.offsetWidth ;
			else
				newLeft = subX - 2*Xo + 20 ;
			newTop = subY;
		}
		//左上
		else{
			if(menu==null){
				newLeft = subX  - Xo + MFT.State.linkButton.offsetWidth ;
				newTop = subY - Yo - MFT.State.linkButton.offsetHeight ;
			}
			else{
				newLeft = subX - 2*Xo + 20;
				newTop = subY - Yo + 20;
			}
		}
		if (MFT.State.ie4) {
			var foo = document.all[sub].style;
			if(foo)
			{
				foo.left = newLeft;
				foo.top = newTop;
			}
		}
		else if (MFT.State.ns4) {
			var foo = document.layers[sub];
			if(foo)
			{
				foo.left = newLeft;
				foo.top = newTop;
			}
		}
	}
	catch(e){}
}

//----------------------------------
//-- 说明 : 显示菜单对象(DIV)
//----------------------------------
MFT.showObject = function(obj) {
	try{
		if (MFT.State.ie4) {
			if(document.all[obj])
			{
				MFT.State.expendList[obj] = true;
				if(document.all[obj].isChangeHtml!="yes")
				{
					//默认的div不用挡住DropDownList，而iframe可以，所以进行html切换
					document.all[obj].isChangeHtml = "yes"
					var tWidth = document.all[obj].clientWidth;
					var tHeight = document.all[obj].clientHeight;
					var vMnuCode = document.all[obj].innerHTML.trim();
					if(vMnuCode!=null)
					{
						document.all[obj].innerHTML = "<iframe id='oframe_" + obj + "' style='margin:0' frameborder=0 scrolling=no  width="+tWidth+" height="+tHeight+" ></iframe>";
						eval('window.oframe_' + obj + '.document.open();')
						var strHtml = '<link href="' + g_MenuSkins + 'Styles/topchannel.css" rel="stylesheet" type="text/css">  '
									+ '	<link href="' + g_MenuSkins + 'Styles/frametable.css" rel="stylesheet" type="text/css">  '
									+ '	<link href="' + g_MenuSkins + 'Styles/main.css" rel="stylesheet" type="text/css">  '
									+ '	<link href="' + g_MenuSkins + 'Styles/menu.css" rel="stylesheet" type="text/css">  '
									+ '	<link href="' + g_MenuSkins + 'Styles/maintable.css" rel="stylesheet" type="text/css"> ' 
									+ '	<link href="' + g_MenuSkins + 'Styles/toolbar.css" rel="stylesheet" type="text/css"> '
						eval('window.oframe_' + obj + '.document.write(strHtml);')
						eval('window.oframe_' + obj + '.document.write(vMnuCode);')
						eval('window.oframe_' + obj + '.document.close();')
						eval('window.oframe_' + obj + '.document.body.style.margin = 0 ;')
						eval('window.oframe_' + obj + '.document.body.style.backgroundColor = "red" ;')
					}
				}
				document.all[obj].style.visibility = "visible"; 
			}
		}
		else if (MFT.State.ns4) { document.layers[obj].visibility = "show";  }
	}
	catch(e)
	{}
}

//----------------------------------
//-- 说明 : 隐藏指定对象
//----------------------------------
MFT.hideObject = function(obj) {
	if (MFT.State.ie4) { document.all[obj].style.visibility = "hidden"; }
	else if (MFT.State.ns4) { document.layers[obj].visibility = "hide"; }
}


//----------------------------------
//-- 说明 : 隐藏所有菜单
//----------------------------------
MFT.hideAll = function() {
	MFT.State.oldTopMenuId	= null;
	if (MFT.State.ie4) {
		for(var menuId in MFT.State.expendList)
		{
 			if(document.all[menuId])
 			{
 				document.all[menuId].style.visibility = "hidden"; 
 			}
		}
		MFT.State.expendList = {};
	}
	else if (MFT.State.ns4) {
	}
}

//----------------------------------
//-- 说明 : 隐藏当前菜单
//----------------------------------
MFT.hideMe = function(hide) {
	if (hide) {
		if (MFT.State.doHide) {MFT.hideAll(); }
	}
	else {
		MFT.State.doHide = true;
		MFT.State.hideTimer = window.setTimeout("MFT.hideMe(true);", 500);
	}
}

//----------------------------------
//-- 说明 : 光标移动记入位置
//----------------------------------
MFT.mouseMove = function(e) {
	if (MFT.State.ie4) { mouseY = window.event.y; }
	if (MFT.State.ns4) { mouseY = e.pageY; }
}

//----------------------------------
//-- 说明 : 执行初始化
//----------------------------------
MFT.menuInit();


//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// System Menu //////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

//----------------------------------
//-- 说明:创建根函数
//----------------------------------
LeadingMIS.Menu										= {};							//菜单对象

LeadingMIS.Menu.PageControl							= {};							//相关的页面控件对象
LeadingMIS.Menu.PageControl.WorkFrameID				= "idFraWorkPane";				//主Frame
LeadingMIS.Menu.PageControl.WorkSubFrameID			= "idSubFraWorkPane";			//辅Frame
LeadingMIS.Menu.PageControl.MainBarTableID			= "MenuBarMainTable";			//菜单表格
LeadingMIS.Menu.PageControl.FrameTableID			= "FrameMainTable";				//框架表格
LeadingMIS.Menu.PageControl.FrameTopTableID			= "FrameTopTable";				//框架表格
LeadingMIS.Menu.PageControl.SysMenuXmlID			= "SysMenuXml";					//数据岛ID
LeadingMIS.Menu.PageControl.FloatMenuDivID			= "FloatMenuDiv";				//存放浮动层
LeadingMIS.Menu.PageControl.ShowBannerImgID			= "SysMenuShowBannerImg";		//是否显示Banner按钮图片ID
LeadingMIS.Menu.PageControl.ChangeFrameTypeImageID	= "HitChangeFrameTypeImage";	//框架模式下左侧是否显示按钮的图片ID
LeadingMIS.Menu.PageControl.ChangeFrameTypeTableID	= "FrameSysSubMenuList";		//框架模式下左侧表格ID
LeadingMIS.Menu.PageControl.ChangeFrameTypeTdID		= "SysSubMenuList";				//框架模式下左侧TDID

LeadingMIS.Menu.Type								= {};							//类型集合
LeadingMIS.Menu.Type.LinkType						= {								//菜单展现方式
															"Common"	: "普通模式", 
															"Frame"		: "框架模式", 
															"Float"		: "浮动模式", 
															"Auto"		: "自定义模式"
														};
LeadingMIS.Menu.Type.FrameShowType					= {								//IFrame展现方式
															"System"	: "系统方式", 
															"Web"		: "网站方式"
														};

LeadingMIS.Menu.Type.PageOpenType					= {								//菜单打开方式
															"Work"		: "工作页面", 
															"Change"	: "切换页面", 
															"NewOpen"	: "弹出页面"
														};
 
LeadingMIS.Menu.Const = {};
LeadingMIS.Menu.Const.MenuRootID					= "-";							//根ID
LeadingMIS.Menu.Const.SysMenuXml					= null;							//数据岛对象
LeadingMIS.Menu.Const.UrlPulsMenuID					= "SysMenuID";					//参数:菜单名称 eg .aspx?SysMenuID=SM000000001 每个链接后面自动跟一个
LeadingMIS.Menu.Const.AboutBlank					= "/SysFrames/UserControl/Frames/WebUI/DefaultPage.aspx";		
																					//Frame空白页面地址
LeadingMIS.Menu.Const.ShowBannerCookieName			= "SysMenuShowBannerCookie" + "_" + window.location.hostname  + "_"  + window.location.port;			
																					//是否显示Banner图片COOKIE名称;	
LeadingMIS.Menu.Const.GetNodeUrl					= "/SysFrames/UserControl/Frames/WebUI/GetMenuNodeXml.aspx";	
																					//取得子节点的文件
 
LeadingMIS.Menu.State = {};
LeadingMIS.Menu.State.FrameOffSetHeight				= 0;							//Frame高度偏移量初始为0
LeadingMIS.Menu.State.IntLevelOver					= 0;							//当前选中行
LeadingMIS.Menu.State.LevelOverID					= "";							//当前选中的菜单ID		
LeadingMIS.Menu.State.DrawFrameLinkType				= "";							//菜单类型		--|
LeadingMIS.Menu.State.DrawFrameLinkUrl				= "";							//菜单地址		  |-- 用于框架模式时,打开第一个子菜单的参数 
LeadingMIS.Menu.State.DrawFrameMenuID				= "";							//菜单ID		--|
LeadingMIS.Menu.State.FrameUrl						= "";							//Frame地址
LeadingMIS.Menu.State.FrameMenuID					= "";							//菜单ID	
LeadingMIS.Menu.State.FrameShowType					= "";							//Frame展现方式
LeadingMIS.Menu.State.FrameTopLevelTabCount			= 0;							//顶层有几个节点
LeadingMIS.Menu.State.FrameIsAdd					= false;						//Frame是否已经加入到页面
LeadingMIS.Menu.State.ShowBannerState				= "";							//状态

/* 记录整个菜单状态
	LeadingMIS.Menu.State.RowStates = {
											"RS0" : {"preMenuId" : "", "curMenuId" : "" }, 
											"RS1" : {"preMenuId" : "", "curMenuId" : "" }, 
											"RS2" : {"preMenuId" : "", "curMenuId" : "" }
										}
*/
LeadingMIS.Menu.State.RowStates						= {};							//记录行状态
LeadingMIS.Menu.State.Divlevel						= 10000;						//Div层数
 

var g_bSubFrameState = true;														//框架模式下子菜单是否显示

//----------------------------------
//-- 说明:通过Msxml2.XMLHTTP取得信息
//----------------------------------
LeadingMIS.Menu.fnGetXML = function(strURL, strSent){
	try{
		var xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");
		xmlHTTP.open("POST",strURL,false);
		xmlHTTP.send(strSent);
		var strHTML = xmlHTTP.responseText;
		xmlHTTP = null;
		return strHTML;
	}
	catch(e)
	{
		return "";
	}
}

//----------------------------------
//-- 说明:取得展现类型
//----------------------------------
LeadingMIS.Menu.getMenuLinkType = function(MenuID){
	if(LeadingMIS.Menu.Const.SysMenuXml)
	{
		var oNode = LeadingMIS.Menu.Const.SysMenuXml.selectSingleNode("//node[@Menu_ID='" + MenuID + "']")
		if(oNode!=null)
		{
			return oNode.getAttribute("Menu_LinkType").trim();
		}
	}
	return "";
}

//----------------------------------
//-- 说明:判断是否有子节点
//----------------------------------
LeadingMIS.Menu.getHasChildren = function(menuId)
{
	LeadingMIS.Menu.loadData(menuId);
	if(LeadingMIS.Menu.Const.SysMenuXml)
	{
		var oNode = LeadingMIS.Menu.Const.SysMenuXml.selectSingleNode("//node[@Menu_ID='" + menuId + "']");
		if(oNode!=null)
		{
			return oNode.hasChildNodes();
		}
	}
	return false;
}

//----------------------------------
//-- 说明:取得第一个子节点的菜单ID
//----------------------------------
LeadingMIS.Menu.getFirstChildMenuID = function(menuId){
	if(LeadingMIS.Menu.Const.SysMenuXml){
		var strCondition;
		if(menuId == LeadingMIS.Menu.Const.MenuRootID)
		{
			strCondition = "/root";
		}
		else
		{
			strCondition = "//node[@Menu_ID='" + menuId + "']";
		}
		var oNode = LeadingMIS.Menu.Const.SysMenuXml.selectSingleNode(strCondition);
		if(oNode)
		{
			var oFirstChild = oNode.firstChild;
			if(oFirstChild)
			{
				return oFirstChild.getAttribute("Menu_ID").trim();
			}
		}
	}
	return "";
}

//----------------------------------
//-- 说明:取得行状态
//----------------------------------
LeadingMIS.Menu.getRowState = function(nLevel)
{
	if(LeadingMIS.Menu.State.RowStates["RS" + nLevel] == null) LeadingMIS.Menu.State.RowStates["RS" + nLevel] = {};	
	return LeadingMIS.Menu.State.RowStates["RS" + nLevel];
}

//----------------------------------
//-- 说明:取得子菜单的选中ID
//----------------------------------
LeadingMIS.Menu.getChildMenuOver = function(parentMenuId){
	var nLevel = LeadingMIS.Menu.getLevelFromMenuId(parentMenuId);
	if(nLevel != null)
	{
		nLevel++;
		var oRowState = LeadingMIS.Menu.getRowState(nLevel);
		if(oRowState.curMenuId == null)
		{
			oRowState.curMenuId = LeadingMIS.Menu.getFirstChildMenuID(parentMenuId);
		}
		return oRowState.curMenuId;
	}
	return null;
}
 
//----------------------------------
//-- 说明:设置菜单选中
//----------------------------------
LeadingMIS.Menu.setMenuOver = function(menuId, nLevel){
	
	if(nLevel == null || nLevel == undefined)
	{
		nLevel = LeadingMIS.Menu.getLevelFromMenuId(menuId);
	}
	
	if(nLevel != null)
	{
		var oRowState = LeadingMIS.Menu.getRowState(nLevel);
		//每次点击都记录ID，同一个菜单项时，也记录
		if(oRowState.curMenuId != null)
		{
			if(oRowState.curMenuId)
			{
				oRowState.preMenuId = oRowState.curMenuId;
			}
			oRowState.curMenuId = menuId;
		}
		//改变所有子行的选中节点。
		while(true)
		{
			oRowState = LeadingMIS.Menu.getRowState(++nLevel);
			if(oRowState.curMenuId != null)
			{
				oRowState.curMenuId = null;
			}
			else
			{
				break;
			}
		}
	}
}

//----------------------------------
//-- 说明:通过菜单ID得到层次
//----------------------------------
LeadingMIS.Menu.getLevelFromMenuId = function(menuId){
	if(LeadingMIS.Menu.Const.SysMenuXml)
	{
		if(menuId == LeadingMIS.Menu.Const.MenuRootID) return -1;
		var strCondition = "//node[@Menu_ID='" + menuId + "']";
		var objNode = LeadingMIS.Menu.Const.SysMenuXml.selectSingleNode(strCondition);
		if(objNode == null) return null;
 		var nIntLevel = 0;
		while(objNode.parentNode.tagName != 'root')
		{
			nIntLevel++;
			objNode = objNode.parentNode;
		}
 		return nIntLevel;
 	}
}

//----------------------------------
//-- 说明:浮动菜单切换菜单项
//----------------------------------
LeadingMIS.Menu.setChangeOver = function(menuId)
{
	var nLevel = LeadingMIS.Menu.getLevelFromMenuId(menuId);
	//alert(nLevel)
	if(nLevel != null)
	{
		var oRowState = LeadingMIS.Menu.getRowState(nLevel);
	//	alert(oRowState.curMenuId +"-"+menuId)
		if(oRowState.curMenuId != menuId)
		{
			LeadingMIS.Menu.setMenuOver(menuId, nLevel);
			LeadingMIS.Menu.loadStyle();
		}
 	}
}

//----------------------------------
//-- 说明:指定的菜单ID取得位置
//----------------------------------
LeadingMIS.Menu.loadPositionNeedNode = function(strMenuIds)
{
	if(strMenuIds.trim()=="")return;
	var arrMenuId = strMenuIds.split(",");
	for(var i= 0 ;i<arrMenuId.length;i++){
		if(!LeadingMIS.Menu.getHasChildren(arrMenuId[i])){
			LeadingMIS.Menu.setMenuOver(arrMenuId[i])
			break;
		}
	}
}

//----------------------------------
//-- 说明:重新刷新
//----------------------------------
LeadingMIS.Menu.reload = function(bShowError)
{
	if(bShowError)
	{
		alert('闲置时间过长，请重新登录！[编号：002]');
	}
	top.document.location ='/';
}

//----------------------------------
//-- 说明:取得下节点的数据列表
//----------------------------------
LeadingMIS.Menu.loadData = function(menuId)
{
	if(LeadingMIS.Menu.Const.SysMenuXml==null) return;
	var strCondition;
	if(menuId == LeadingMIS.Menu.Const.MenuRootID)
	{
		strCondition = "/root";
	}
	else
	{
		strCondition = "//node[@Menu_ID='" + menuId + "']";
	}
	//取得Node节点
	var oNode = LeadingMIS.Menu.Const.SysMenuXml.selectSingleNode(strCondition);
	if(oNode){
		//是否已经加载过数据。
		if(oNode.getAttribute("isload") !="true"){
			var strSentXml  = "<root>";
				strSentXml += "	<row parentid='" + menuId + "' linktype='" + oNode.getAttribute("Menu_LinkType") + "'/>";
				strSentXml += "</root>";
			var strXml = LeadingMIS.Menu.fnGetXML(LeadingMIS.Menu.Const.GetNodeUrl, strSentXml);
			if(strXml=="false" || strXml == "" || strXml == null)
			{
  				if(typeof(top.window.clientLogin) == 'function' && top.window.clientLogin('aspx'))
				{
					LeadingMIS.Menu.loadData(menuID);
				}
				else
				{
					LeadingMIS.Menu.reload(true);
				}
 			}
			//将获得的数据加入对象文档
			var oXmlDoc = new ActiveXObject("Msxml2.DOMDocument");
			oXmlDoc.async = false;
			oXmlDoc.loadXML(strXml);
			var oDataNodes = oXmlDoc.selectNodes("/root/node");
			if(oDataNodes!=null && oDataNodes.length>0){
				for(var i=0; i<oDataNodes.length; i++){
					var oDataNode = oDataNodes.item(i);
					var oCloneNode = oDataNode.cloneNode(true);
					oNode.appendChild(oCloneNode);
				}
				
				//如果从根位置取得数据，希望能取得两层。
				if(menuId == LeadingMIS.Menu.Const.MenuRootID)
				{
					if(oDataNodes.item(0) && oDataNodes.item(0).getAttribute("Menu_ID") && oDataNodes.item(0).getAttribute("isload") !="true")
					{
						//第一个子节点;
						oDataNodes.item(0).setAttribute("isload", "true" );
						LeadingMIS.Menu.loadData(oDataNodes.item(0).getAttribute("Menu_ID"));
					}
				}
			}
			oNode.setAttribute("isload", "true" );
		}
	}
}

//----------------------------------
//-- 说明:总体加载数据及控制结构。
//----------------------------------
LeadingMIS.Menu.loadStyle = function(){
	LeadingMIS.Menu.State.FrameIsAdd = false;
 	LeadingMIS.Menu.State.FrameUrl = "";
	LeadingMIS.Menu.State.FrameShowType = LeadingMIS.Menu.Type.FrameShowType.System;
	LeadingMIS.Menu.showMenuBar();
	if(LeadingMIS.Menu.State.FrameIsAdd == false){
		var FrameTableID = document.all.item(LeadingMIS.Menu.PageControl.FrameTableID,0);
		if(FrameTableID){
			var strShowType = (LeadingMIS.Menu.Type.FrameShowType.Web == LeadingMIS.Menu.State.FrameShowType) ? 1 : 0;
			var strHtml = "<iframe id='" + LeadingMIS.Menu.PageControl.WorkFrameID + "' width='100%' height='100%' frameborder='0' scrolling='auto'></iframe>"
			FrameTableID.rows(0).cells(0).innerHTML = strHtml;
			var strUrl = LeadingMIS.Menu.State.FrameUrl;
			if(strUrl == "")
			{
				strUrl = LeadingMIS.Menu.Const.AboutBlank;
			}			
			LeadingMIS.Menu.initFrame(strShowType, strUrl, LeadingMIS.Menu.State.FrameMenuID);
		}
	}
}

//----------------------------------
//-- 说明:显示菜单行。
//----------------------------------
LeadingMIS.Menu.showMenuBar = function()
{
	//当前点击的行索引
	var nLevelOver =  parseInt(LeadingMIS.Menu.State.IntLevelOver);
 	var parentMenuID = LeadingMIS.Menu.Const.MenuRootID;
	var menuID = "";
	var i = 0;
	var oMenuBarTableManager = new MenuBarTableManager(LeadingMIS.Menu.PageControl.MainBarTableID);
	oMenuBarTableManager.deleteRow({"rowIndex" : nLevelOver});
	
	//循环列出菜单行。
	while(true){
		//判断行是否存在，不存在则画行。
		if(!oMenuBarTableManager.existRow({"rowIndex" : i}))
		{
			LeadingMIS.Menu.drawTab(parentMenuID);
		}
		else
		{
			//取得行状态
			var oRowState = LeadingMIS.Menu.getRowState(i);
			var oMenuTag = document.all.item("Tag_"+oRowState.curMenuId, 0);
			if(oMenuTag !=null && oMenuTag.cusLinkUrl!=null)
			{
				//取得可用的Url地址 
				LeadingMIS.Menu.State.FrameUrl = oMenuTag.cusLinkUrl;
				//alert(LeadingMIS.Menu.State.FrameUrl)
			}
			
			//循环到点击的当前行，则重设Tab显示高亮
			if(nLevelOver == i)
			{
				//这次点击的与上次点击的是一个菜单项时，不能变样式。
				if(LeadingMIS.Menu.State.LevelOverID != oRowState.preMenuId)
				{
					var dataInfo = {};
					dataInfo.rowIndex = i; 
					dataInfo.style = {};
					dataInfo.style = LeadingMIS.Menu.StyleManager(i);
					dataInfo.menuList = {};
					dataInfo.menuList[oRowState.curMenuId] = {"isOver" : true};
					dataInfo.menuList[oRowState.preMenuId] = {"isOver" : false};
					oMenuBarTableManager.updateRow(dataInfo);
				}
			}
		}
		menuID = LeadingMIS.Menu.getChildMenuOver(parentMenuID);
		if(menuID=="")break;
		if((i - nLevelOver) >=1 && i > 0){//判断是否超出两层。约出不能超出两层(包括当前层)
			if(LeadingMIS.Menu.getMenuLinkType(menuID)!=LeadingMIS.Menu.Type.LinkType.Frame)break;//框架模式
		}		
		if(LeadingMIS.Menu.getMenuLinkType(menuID)==LeadingMIS.Menu.Type.LinkType.Common){//普通模式
			parentMenuID = menuID;
			i++;
			continue;
		}
		else if(LeadingMIS.Menu.getMenuLinkType(menuID)==LeadingMIS.Menu.Type.LinkType.Frame){//框架模式
			LeadingMIS.Menu.drawFrames(menuID);
			break;
		}
		else{
			break;
		}
	}
}

//-------------------------------------------- 普通模式 ----------------------------------------------

//----------------------------------
//-- 说明:
//----------------------------------
LeadingMIS.Menu.drawTab = function(parentMenuId)
{
	if(LeadingMIS.Menu.Const.SysMenuXml == null) return ;
	var oNodeList				= null;
	var strCondition			= null;
	if(parentMenuId == LeadingMIS.Menu.Const.MenuRootID)
	{
		strCondition = "/root";
	}
	else
	{
		strCondition = "//node[@Menu_ID='" + parentMenuId + "']";
	}
	var oNode = LeadingMIS.Menu.Const.SysMenuXml.selectSingleNode(strCondition);
	if(oNode)
	{
		oNodeList = oNode.childNodes;
	}
	if(oNodeList && oNodeList.length > 0){
		if(parentMenuId == LeadingMIS.Menu.Const.MenuRootID) 
		{
			LeadingMIS.Menu.State.FrameTopLevelTabCount = oNodeList.length;
		}
		//取得当前级数据
		var nLevel			= LeadingMIS.Menu.getLevelFromMenuId(parentMenuId) + 1;
		var dataInfo		= {};
		dataInfo.cellList	= [];
		var oRowState = LeadingMIS.Menu.getRowState(nLevel);
 		for(var i=0 ; i<oNodeList.length ; i++){
			//------------当FrameUrl为空并且所有子节点没被选中时 设置第一个子节点为被选中----------------------------
			var oNode = oNodeList.item(i);
			if(i==0){
				var overMenuId = LeadingMIS.Menu.getChildMenuOver(parentMenuId);
				if(overMenuId == null)
				{
					LeadingMIS.Menu.setMenuOver(oNode.getAttribute("Menu_ID"), nLevel);
				}
			}
			//----------------------------------------
 			var strLinkstyle = " style='margin-left:5px;margin-right:5px;' "; 
 			var oLb = document.createElement("<a " + strLinkstyle + " />");	
			oLb.innerHTML = oNode.getAttribute("Menu_Name").trim();
			oLb.title = oNode.getAttribute("Menu_Title");
 			if(oNode.getAttribute("Menu_OpenType").trim()==LeadingMIS.Menu.Type.PageOpenType.Change){
				oLb.href="javascript:OpenWindow(2, '" + oNode.getAttribute("Menu_LinkURL") + "', '" + oNode.getAttribute("Menu_ID") + "'); ";
			}
			else if(oNode.getAttribute("Menu_OpenType").trim()==LeadingMIS.Menu.Type.PageOpenType.NewOpen){
				oLb.href="javascript:OpenWindow(3, '" + oNode.getAttribute("Menu_LinkURL") + "', '" + oNode.getAttribute("Menu_ID") + "'); ";
			}
			else{
				oLb.href="javascript:LeadingMIS.Menu.Button_Clicked('','" + oNode.getAttribute("Menu_ID") + "','" + nLevel + "');";
			}
 			
			var isOver = oRowState.curMenuId == oNode.getAttribute("Menu_ID");
			if(isOver) {
				if(LeadingMIS.Menu.State.FrameUrl == ""){
					LeadingMIS.Menu.State.FrameUrl = oNode.getAttribute("Menu_LinkURL");
					LeadingMIS.Menu.State.FrameMenuID = oNode.getAttribute("Menu_ID");
				}
  				
 				if(parseInt(LeadingMIS.Menu.State.IntLevelOver) == parseInt(nLevel)){
					LeadingMIS.Menu.State.FrameUrl = oNode.getAttribute("Menu_LinkURL");
					LeadingMIS.Menu.State.FrameMenuID = oNode.getAttribute("Menu_ID");
				}
				LeadingMIS.Menu.State.FrameShowType = oNode.getAttribute("Menu_FrameShowType");
			}
			
			//子菜单是浮动模式(只在客户端直接反映)
			if(oNode.getAttribute("Menu_LinkType") == LeadingMIS.Menu.Type.LinkType.Float){
				var floatMenuId = oNode.getAttribute("Menu_ID");
				if(LeadingMIS.Menu.getHasChildren(floatMenuId)){
					oLb.onMouseOver = "MFT.topMenu('menu_" + floatMenuId + "',this);";
					oLb.onMouseOut = "MFT.hideMe();";
					if(document.all.item("menu_" + floatMenuId) == null)
					{
						LeadingMIS.Menu.drawFloat(floatMenuId, isOver);
					}
				}
			}
 			var o = {};
			o.menuId = oNode.getAttribute("Menu_ID");
			o.html = oLb.outerHTML;
			o.isOver = isOver;
			o.linkUrl = oNode.getAttribute("Menu_LinkURL");
			dataInfo.cellList[dataInfo.cellList.length] = o;
		}
		dataInfo.style = {};
		dataInfo.rightCell = {};
		dataInfo.rightCell.width = 0;
		dataInfo.rightCell.html = "";
		dataInfo.style = LeadingMIS.Menu.StyleManager(nLevel);
		
		if((parentMenuId == LeadingMIS.Menu.Const.MenuRootID && LeadingMIS.Menu.State.FrameTopLevelTabCount > 1) 
		|| (LeadingMIS.Menu.State.FrameTopLevelTabCount == 1 && nLevel == 1)) 
		{
			dataInfo.rightCell.width = 30;
			var strHtml = ""
			strHtml = strHtml.concat("<img src='" + g_MenuSkins + "Images/top_navi_ctrl.gif' style='cursor : hand ;' id='" + LeadingMIS.Menu.PageControl.ShowBannerImgID + "'");
			strHtml = strHtml.concat("align='absmiddle' onclick='LeadingMIS.Menu.ShowBanner()' onMouseOut='MM_swapImgRestore()' onMouseOver=\"MM_swapImage(this.id ,'','" + g_MenuSkins + "images/top_navi_ctrl_over.gif',1)\"");
			strHtml = strHtml.concat("border='0'>");
			dataInfo.rightCell.html = strHtml;
 		}
		
		var oMenuBarTableManager = new MenuBarTableManager(LeadingMIS.Menu.PageControl.MainBarTableID);
		var oRow = oMenuBarTableManager.insertRow(dataInfo);
		
		if(parentMenuId == LeadingMIS.Menu.Const.MenuRootID) 
		{
			if(LeadingMIS.Menu.State.FrameTopLevelTabCount == 1)
			{
				oRow.style.display = "none";
			}
 		}
		
		/*
		dataInfo.rowIndex
		dataInfo.style.bgCss;
		dataInfo.style.left;
		dataInfo.style.middle;
		dataInfo.style.right;
		dataInfo.style.splitImg;
		dataInfo.rightCell.width;
		dataInfo.rightCell.html;
		dataInfo.cellList[0...n] = {html, menuId};
		*/	
 	}		
}

LeadingMIS.Menu.StyleManager = function(iLevel)
{
	var oMan = {};
	if(iLevel == 0)
	{
		oMan.bgCss			= "top_navibg";
		oMan.left			= "top_navibtn_left";
		oMan.middle			= "top_navibtn_bg";
		oMan.right			= "top_navibtn_right";
		oMan.txt			= "top_navibtn_txt";
		oMan.splitImg		= g_MenuSkins + "Images/top_navi_line.gif";
		oMan.leftOver		= "top_navibtn_over_left";
		oMan.middleOver		= "top_navibtn_over_bg";
		oMan.rightOver		= "top_navibtn_over_right";
		oMan.txtOver		= "top_navibtn_over_txt";
	}
	else
	{
		if(iLevel>3) iLevel = iLevel%4 + 1;
		oMan.bgCss			= "top_navi" + iLevel + "bg";
		oMan.left			= "top_navi" + iLevel + "btn_left";
		oMan.middle			= "top_navi" + iLevel + "btn_bg";
		oMan.right			= "top_navi" + iLevel + "btn_right";
		oMan.txt			= "top_navi" + iLevel + "btn_txt";
		oMan.splitImg		= g_MenuSkins + "Images/top_navi" + iLevel + "_line.gif";
		oMan.leftOver		= "top_navi" + iLevel + "btn_over_left";
		oMan.middleOver		= "top_navi" + iLevel + "btn_over_bg";
		oMan.rightOver		= "top_navi" + iLevel + "btn_over_right";
		oMan.txtOver		= "top_navi" + iLevel + "btn_over_txt";
	}
	return oMan;
}

//-------------------------------------------- 框架通模式 ----------------------------------------------
//----------------------------------
//-- 说明:
//----------------------------------
LeadingMIS.Menu.drawFrames = function(parentMenuId)
{
	LeadingMIS.Menu.State.FrameIsAdd = true;
	LeadingMIS.Menu.loadData(parentMenuId);
	var strSubHtml = LeadingMIS.Menu.framesMenuNode(parentMenuId)
	var strShowType = (LeadingMIS.Menu.State.FrameShowType==LeadingMIS.Menu.Type.FrameShowType.Web) ? 1 : 0;
	var strHtml="";
	strHtml = strHtml.concat("		<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0' ID='Table1'>");
	strHtml = strHtml.concat(" 		<tr>");
	strHtml = strHtml.concat(" 			<td width='6' valign='Top' align='center' Class='ToolBody'><table ID='" + LeadingMIS.Menu.PageControl.ChangeFrameTypeTableID + "' width='160' height='100%' border='0' cellpadding='0' cellspacing='0'>");
	strHtml = strHtml.concat(" 					<tr>");
	strHtml = strHtml.concat(" 						<td ID='" + LeadingMIS.Menu.PageControl.ChangeFrameTypeTdID + "' valign='Top' align='center' Class='ToolTab'>");
	strHtml = strHtml.concat(							strSubHtml);
	strHtml = strHtml.concat(" 						</td>");
	strHtml = strHtml.concat(" 						<td width='6' align='left' valign='middle' Class='ToolTabCtrlBg'><img src='" + g_MenuSkins + "images/tooltab_ctrl_left.gif' onclick='LeadingMIS.Menu.ChangeFrameTypeImage();' style='cursor : hand ;' ID='" + LeadingMIS.Menu.PageControl.ChangeFrameTypeImageID + "'></td>");
	strHtml = strHtml.concat(" 					</tr>");
	strHtml = strHtml.concat(" 				</table>");
	strHtml = strHtml.concat(" 			</td>");
	strHtml = strHtml.concat(" 			<td valign='Top' align='center'><iframe id='" + LeadingMIS.Menu.PageControl.WorkFrameID + "' width='100%' height='100%' frameborder='0' scrolling='" + ((strShowType==1) ? "no" : "auto") + "'></iframe></td>");
	strHtml = strHtml.concat(" 		</tr>");
	strHtml = strHtml.concat(" 	</table>");
	var FrameTableID = document.all.item(LeadingMIS.Menu.PageControl.FrameTableID,0);
	if(FrameTableID)
	{
		FrameTableID.rows(0).cells(0).innerHTML = strHtml;
		//--------------------
		//--说明:初始化工作区页面
		
		var strUrl = LeadingMIS.Menu.State.FrameUrl;
		//alert(strUrl)
		if(strUrl == "")
		{
			strUrl = LeadingMIS.Menu.Const.AboutBlank;
		}
		LeadingMIS.Menu.initFrame(strShowType, strUrl, LeadingMIS.Menu.State.FrameMenuID);
		
		if(LeadingMIS.Menu.State.DrawFrameMenuID!="")
		{ 
			//--说明:初始化子菜单区页面
			if(LeadingMIS.Menu.State.FrameUrl!="" && LeadingMIS.Menu.State.DrawFrameLinkType=="0")
			{
				LeadingMIS.Menu.clickMenuSub(LeadingMIS.Menu.State.DrawFrameLinkType, LeadingMIS.Menu.State.DrawFrameMenuID, '');
			}
			else
			{
				LeadingMIS.Menu.clickMenuSub(LeadingMIS.Menu.State.DrawFrameLinkType, LeadingMIS.Menu.State.DrawFrameMenuID, LeadingMIS.Menu.State.DrawFrameLinkUrl);
			}
		}
	}
}
//----------------------------------
//-- 说明:
//----------------------------------
LeadingMIS.Menu.framesMenuNode = function(parentMenuId)
{
	if(LeadingMIS.Menu.Const.SysMenuXml==null)return "";
	LeadingMIS.Menu.State.DrawFrameLinkType = "";
	LeadingMIS.Menu.State.DrawFrameLinkUrl = "";
	LeadingMIS.Menu.State.DrawFrameMenuID = "";
	g_SysMenuOldMenuID=null;
	var oTable = document.createElement("<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0'/>");
	var oNodeList = null;
	var oNode = LeadingMIS.Menu.Const.SysMenuXml.selectSingleNode("//node[@Menu_ID='" + parentMenuId + "']");
	if(oNode)
		oNodeList = oNode.childNodes;
	if(oNodeList!=null){
		for(var i=0 ; i<oNodeList.length ; i++){
			var oNode = oNodeList.item(i);
			var LinkType = (oNode.getAttribute("Menu_LinkType").trim()==LeadingMIS.Menu.Type.LinkType.Auto) ? "1" : "0" ;//是否自定义模式
			var oRow = oTable.insertRow();
			var oCell = oRow.insertCell();
			oCell.align = "center";
			oCell.className="ToolTabButton";
			oCell.style.cursor="hand";
			if(oNode.getAttribute("Menu_OpenType").trim()==LeadingMIS.Menu.Type.PageOpenType.Change)
			{
				oCell.onclick = "OpenWindow(2, '" + oNode.getAttribute("Menu_LinkURL") + "', '" + oNode.getAttribute("Menu_ID") + "');return false;";
			}
			else if(oNode.getAttribute("Menu_OpenType").trim()==LeadingMIS.Menu.Type.PageOpenType.NewOpen)
			{
				oCell.onclick = "OpenWindow(3, '" + oNode.getAttribute("Menu_LinkURL") + "', '" + oNode.getAttribute("Menu_ID") + "');return false;";
			}
			else
			{
				if(oNode.getAttribute("Menu_FrameShowType").trim()==LeadingMIS.Menu.Type.FrameShowType.Web)
				{
					oCell.onclick = "LeadingMIS.Menu.SetFramereadystate(1);LeadingMIS.Menu.clickMenuSub('" + LinkType + "','" + oNode.getAttribute("Menu_ID") + "','" + oNode.getAttribute("Menu_LinkURL") + "');";
				}
				else
				{
					oCell.onclick = "LeadingMIS.Menu.SetFramereadystate(0);LeadingMIS.Menu.clickMenuSub('" + LinkType + "','" + oNode.getAttribute("Menu_ID") + "','" + oNode.getAttribute("Menu_LinkURL") + "');";
				}
			}
			var strHtml = "";
			strHtml = strHtml.concat("<table width='96%' border='0' cellpadding='0' cellspacing='0'>");
			strHtml = strHtml.concat("	<tr>");
			strHtml = strHtml.concat("		<td align='left' Class='ToolTabButtonFont' title='" + oNode.getAttribute("Menu_Title") + "'><img src='" + oNode.getAttribute("Menu_Icon") + "' align='absmiddle' border='0'>" + oNode.getAttribute("Menu_Name") + "</td>");
			strHtml = strHtml.concat("	</tr>");
			strHtml = strHtml.concat("</table> ");
			oCell.innerHTML = strHtml;
			//-----------------------------------------------------
			var oRowNoDispaly = oTable.insertRow();
			oRowNoDispaly.height = "100%";
			oRowNoDispaly.className="Sys_MenuSub";
			oRowNoDispaly.style.display="none";	
			oRowNoDispaly.id="Menu_" + oNode.getAttribute("Menu_ID");
			var oCellDis = oRowNoDispaly.insertCell();
			oCellDis.id = "TD_Menu_" + oNode.getAttribute("Menu_ID");
			oCellDis.align = "center";
			//设置默认值
			if(i==0){
				if(oNode.getAttribute("Menu_LinkURL").length > 0 && LeadingMIS.Menu.State.FrameUrl == "" && LinkType=="0" ){
					LeadingMIS.Menu.State.FrameUrl = oNode.getAttribute("Menu_LinkURL");
					LeadingMIS.Menu.State.FrameMenuID = oNode.getAttribute("Menu_ID");
				}
				if(oNode.getAttribute("Menu_FrameShowType") == LeadingMIS.Menu.Type.FrameShowType.Web){
					LeadingMIS.Menu.State.FrameShowType = LeadingMIS.Menu.Type.FrameShowType.Web;
				}
				LeadingMIS.Menu.State.DrawFrameLinkType = LinkType;
				LeadingMIS.Menu.State.DrawFrameLinkUrl = oNode.getAttribute("Menu_LinkURL");
				LeadingMIS.Menu.State.DrawFrameMenuID = oNode.getAttribute("Menu_ID");
			}
		}
	}
	var strHtml = oTable.outerHTML ;
	return strHtml;
}


//----------------------------------------浮动模式-------------------------------------------------------------------------
//----------------------------------
//-- 说明:
//----------------------------------
LeadingMIS.Menu.drawFloat = function(parentMenuId , isOver)
{
	if(document.all.item(LeadingMIS.Menu.PageControl.FloatMenuDivID, 0)==null){
		var oDiv = document.createElement("<div id='" + LeadingMIS.Menu.PageControl.FloatMenuDivID + "' />");
		window.document.body.insertAdjacentElement("afterBegin",oDiv);
	}
	var oDiv = document.createElement("<div id='Top_menu_" + parentMenuId + "'/>");//
	document.all.item(LeadingMIS.Menu.PageControl.FloatMenuDivID, 0).insertAdjacentElement("afterBegin",oDiv);
	LeadingMIS.Menu.floatMenuNode(oDiv, parentMenuId, parentMenuId) ;
	//-------------------------------
	//说明:当节点被选中,URL又为空.就取得子节点中有效的URL
	//-------------------------------
	if(LeadingMIS.Menu.Const.SysMenuXml==null) return;
	if(isOver && LeadingMIS.Menu.State.FrameUrl==""){
		while(true){
			try{
				var oParentNode = LeadingMIS.Menu.Const.SysMenuXml.selectSingleNode("//node[@Menu_ID='" + parentMenuId + "']");
				if(oParentNode){
					var oNode = oParentNode.firstChild;
					if(oNode!=null){
						var strUrl = oNode.getAttribute("Menu_LinkURL");
						if(strUrl!=null && strUrl!="" && strUrl.trim() != "")
						{
							LeadingMIS.Menu.State.FrameUrl = strUrl;
							LeadingMIS.Menu.State.FrameMenuID = oNode.getAttribute("Menu_ID"); 
							break;
						}
						else
						{
							parentMenuId = oNode.getAttribute("Menu_ID");;
						}
					}
					else
					{
						break;
					}
				}
			}
			catch(e){break;}
		}
	}
 	return ;
}
//-------------------------------
//说明:浮动类型节点循环取得
//参数:oPanel [object](DIV) ,parentMenuId父节点ID
//-------------------------------
LeadingMIS.Menu.floatMenuNode = function(oPanel, parentMenuId, topParentMenuId)
{
	var oNodeList = LeadingMIS.Menu.Const.SysMenuXml.selectSingleNode("//node[@Menu_ID='" + parentMenuId + "']").childNodes;
	if(oNodeList!=null && oNodeList.length>0)
	{
		LeadingMIS.Menu.State.Divlevel++;
		var oDiv = document.createElement("<div id='menu_" + parentMenuId + "' class='menu' onMouseOut='parent.MFT.hideMe();'  style=' position: absolute;left: 0;top: 0;visibility: hidden;width: 100px;overflow: visible;Z-INDEX: " + LeadingMIS.Menu.State.Divlevel + ";' onmouseover=\"this.style.display='block';parent.MFT.onMove();\" >");
		var strHtml = ""
		for(var i=0 ; i<oNodeList.length ; i++)
		{
			var oNode = oNodeList.item(i);
			oNode.setAttribute("Menu_LinkType", LeadingMIS.Menu.Type.LinkType.Float);
			var bHasChildRen = LeadingMIS.Menu.getHasChildren(oNode.getAttribute("Menu_ID"));
			var strMouseOver = "";
			var strHasChildRenImg = "";
			if(bHasChildRen)
			{
				strHasChildRenImg = "<img src='" + g_MenuSkins + "images/row_more.gif' border='0' align='absmiddle'>";
				strMouseOver = " parent.MFT.expandMenu('" + oNode.getAttribute("Menu_AllParentID") + "','menu_" + parentMenuId + "', 'menu_" + oNode.getAttribute("Menu_ID") + "', parent.MFT.subMenuPosX(this) , parent.MFT.subMenuPosY(this) +  parent.MFT.getPos('menu_" + parentMenuId + "','Top')); ";
				LeadingMIS.Menu.floatMenuNode(oPanel, oNode.getAttribute("Menu_ID"), topParentMenuId); 
			}
			else
			{
				strMouseOver = " parent.MFT.expandMenu('" + oNode.getAttribute("Menu_AllParentID")  + "','menu_" + parentMenuId + "');";
			}
			//点击链接
			var strClick = "";
			if(oNode.getAttribute("Menu_OpenType").trim()==LeadingMIS.Menu.Type.PageOpenType.Change)
			{
				strClick ="onclick=\"parent.LeadingMIS.Menu.setChangeOver('" + topParentMenuId + "'); parent.OpenWindow(2, '" + oNode.getAttribute("Menu_LinkURL") + "', '" + oNode.getAttribute("Menu_ID") + "');return false;\"";
			}
			else if(oNode.getAttribute("Menu_OpenType").trim()==LeadingMIS.Menu.Type.PageOpenType.NewOpen)
			{
				strClick ="onclick=\" parent.OpenWindow(3, '" + oNode.getAttribute("Menu_LinkURL") + "', '" + oNode.getAttribute("Menu_ID") + "');return false;\"";
			}
			else
			{
				if(oNode.getAttribute("Menu_FrameShowType").trim()==LeadingMIS.Menu.Type.FrameShowType.Web)
				{
					strClick ="onclick=\"parent.LeadingMIS.Menu.setChangeOver('" + topParentMenuId + "'); parent.LeadingMIS.Menu.SetFramereadystate(1);parent.OpenWindow(1, '" + oNode.getAttribute("Menu_LinkURL") + "', '" + oNode.getAttribute("Menu_ID") + "');return false;\"";
				}
				else
				{
					strClick ="onclick=\"parent.LeadingMIS.Menu.setChangeOver('" + topParentMenuId + "'); parent.LeadingMIS.Menu.SetFramereadystate(0);parent.OpenWindow(1, '" + oNode.getAttribute("Menu_LinkURL") + "', '" + oNode.getAttribute("Menu_ID") + "');return false;\"";
				}
			}
			strHtml = strHtml.concat("<tr>");
			strHtml = strHtml.concat("	<td align='center' class='top_menu_out' onMouseover=\"" + strMouseOver +" this.className='top_menu_over';\" onMouseOut=\"this.className='top_menu_out'\">");
			strHtml = strHtml.concat("		<table width='90%'  border='0' cellspacing='0' cellpadding='0'  >");
			strHtml = strHtml.concat("			<tr>");
			strHtml = strHtml.concat("				<td align='left' valign='middle' " + strClick + "  ><span style='cursor : hand ;'>" + oNode.getAttribute("Menu_Name") + "</span></td>");
			strHtml = strHtml.concat("				<td align='center' valign='middle' width='10px'>" + strHasChildRenImg + "</td>");
			strHtml = strHtml.concat("			</tr>");
			strHtml = strHtml.concat("		</table>");
			strHtml = strHtml.concat("	</td>");
			strHtml = strHtml.concat("</tr>");
		}
 		strHtml = "<table width='180' border='0' cellpadding='0' cellspacing='2' class='top_menu' align='center'  >" + strHtml + "</table>";
 		oDiv.innerHTML = strHtml;
		oPanel.insertAdjacentElement("afterBegin",oDiv);
	}			 
}		


//----------------------------------
//-- 说明:
//----------------------------------
LeadingMIS.Menu.ReSizeFrameEvent = function(){
	var oFrame = document.all.item(LeadingMIS.Menu.PageControl.WorkFrameID,0);
	if(oFrame){
		if(LeadingMIS.Menu.State.FrameOffSetHeight==0){
			LeadingMIS.Menu.State.FrameOffSetHeight = oFrame.offsetHeight;
		}
		oFrame.style.pixelHeight = LeadingMIS.Menu.State.FrameOffSetHeight;
		if(oFrame.readyState=='complete'){
			try{
				var sHeightValue = oFrame.contentWindow.document.body.scrollHeight;
 				if(sHeightValue==0){		
					oFrame.style.height = "100%";
				}
				else{
					oFrame.style.pixelHeight = sHeightValue;
					oFrame.contentWindow.document.body.scroll = "no";
				}
 			}
			catch(e){}
		}
	}
}

//----------------------------------
//-- 说明:
//----------------------------------
LeadingMIS.Menu.FrameReSize = function ()
{
	try{
		var TopTable = document.all.item(LeadingMIS.Menu.PageControl.FrameTopTableID,0);
		var MenuTable = document.all.item(LeadingMIS.Menu.PageControl.MainBarTableID,0);
		var FrameTable = document.all.item(LeadingMIS.Menu.PageControl.FrameTableID,0);
		if(TopTable.style.dispaly=="none")
			FrameTable.style.height = window.document.body.clientHeight - MenuTable.offsetHeight - 2;
		else
			FrameTable.style.height = window.document.body.clientHeight - TopTable.offsetHeight - MenuTable.offsetHeight - 2;
	}
	catch(e){}
}
//----------------------------------
//-- 说明:
//----------------------------------
LeadingMIS.Menu.SetFramereadystate = function(nType){
	var obj = document.all.item(LeadingMIS.Menu.PageControl.WorkFrameID, 0);
	if(obj){
		obj.width="100%";
		obj.height="100%";
		if(nType==1){
			obj.onreadystatechange = LeadingMIS.Menu.ReSizeFrameEvent;
		}
		else if (nType==0){
			obj.onreadystatechange = null;
		}
	}
}
////////////////////////////////////////// --------- Menu.Init -------- //////////////////////////////////////////////////////////
//--------------------------LeadingMIS.Menu.clickMenuSub------------------------
//CurrentType : 点击类型  0:MainFrame | 1 : SubFrame(自定义)
//CurrentMenuID : 菜单ID
//FrameUrl : 右侧frameUrl | 左侧SubFrameUrl
var g_SysMenuOldMenuID=null;
LeadingMIS.Menu.clickMenuSub = function (CurrentType, CurrentMenuID, FrameUrl)
{
	try{
		//重复点击不操作(不是自定义模式)
		if (CurrentType=="0" && g_SysMenuOldMenuID == CurrentMenuID)return;
		//取消上次点击效果
		if(g_SysMenuOldMenuID!=null){
			document.all.item('Menu_' + g_SysMenuOldMenuID,0).style.display = 'none';
			document.all.item('TD_Menu_' + g_SysMenuOldMenuID,0).innerHTML = '';
		}
		//展开当前点击菜单显示区域
		document.all.item('Menu_' + CurrentMenuID,0).style.display = '';
		var CurrentUrl = "";
		if(CurrentType=="1"){
			try{
				if(CheckIsAspPage(FrameUrl)==true){
					FrameUrl="/Common/GoToAspPage/GoPage.aspx?GoPageUrl=" + escape(FrameUrl);
				}
			}
			catch(e)
			{}
			CurrentUrl = FrameUrl ;
		}
		else{
			if(FrameUrl.trim().length > 0 ){
				OpenWindow(1, FrameUrl);
			}
			CurrentUrl = '/SysFrames/UserControl/Frames/WebUI/MenuSubList.aspx?ParentID=' + CurrentMenuID;
		}
		//显示菜单项目页面
		var strHtml = "<iframe src='" + CurrentUrl + "' width='100%' height='100%' frameborder='0' scrolling='auto' id='" + LeadingMIS.Menu.PageControl.WorkSubFrameID + "'></iframe>";
		document.all.item('TD_Menu_' + CurrentMenuID,0).innerHTML = strHtml ; 
		//记住当前点击菜单ID
		g_SysMenuOldMenuID = CurrentMenuID;
	}
	catch(e)
	{
		//alert(e.Message)
	}
}
//----------------------------------
//-- 说明:打开页面
//-- 参数：
/*
	nType:	0:return Url,
			1:toFrame, 
			2:modfiy.top.location.href, 
			3:new windows, 
			4:modfiy.self.location.href
	strUrl: to use the frame for src
	strMenuID : to use the frame for src
*/
//----------------------------------
function OpenWindow(nType, strUrl, strMenuID){
	
	//return;
	if(strUrl==""){
		return;
	}
	else{
		if(strMenuID!=null)
		{
			if(strUrl.toLowerCase().indexOf(".asp")!=-1)
			{
				var tempMenuAtt =LeadingMIS.Menu.Const.UrlPulsMenuID + "=" + strMenuID;
				if(strUrl.indexOf("?")!=-1){
					var tempArr = strUrl.split('?');
					if(tempArr[1].trim().length>0){
						strUrl += "&" + tempMenuAtt;
					}
					else{
						strUrl += tempMenuAtt;
					}
				}
				else{
					strUrl += "?" + tempMenuAtt;
				}
			}
		}
	}
	var type = nType;
	try{	
		//判断是不是ASP文件
		if(CheckIsAspPage(strUrl)==true){
			strUrl="/Common/GoToAspPage/GoPage.aspx?GoPageUrl=" + escape(strUrl);
		}
	}
	catch(e)
	{}
	if(type==0){
		return strUrl;
	}
	else if(type==1){
		var obj = document.all.item(LeadingMIS.Menu.PageControl.WorkFrameID,0);
		if(obj){obj.src = strUrl;}
	}
	else if(type==2){
		top.document.location.href = strUrl;
	}
	else if(type==3){
		window.open(strUrl);
	}
	else if(type==4){
		document.location.href = strUrl;
	}
}
//----------------------------------
//-- 说明: it's need buttonimage to change page state  when showmodule of page is frametype 
//----------------------------------
LeadingMIS.Menu.ChangeFrameTypeImage = function()
{
	var obj = document.all.item(LeadingMIS.Menu.PageControl.ChangeFrameTypeImageID,0);
	if (obj=="[object]")
	{
		if( obj.nameProp == 'tooltab_ctrl_left.gif' ){
			obj.src =  g_MenuSkins + 'images/tooltab_ctrl_right.gif'; 
			document.all.item(LeadingMIS.Menu.PageControl.ChangeFrameTypeTdID,0).style.display='none';
			document.all.item(LeadingMIS.Menu.PageControl.ChangeFrameTypeTableID,0).style.width='6px';
			g_bSubFrameState = false;
		}
		else
		{
			obj.src =   g_MenuSkins + 'images/tooltab_ctrl_left.gif'; 
			document.all.item(LeadingMIS.Menu.PageControl.ChangeFrameTypeTdID,0).style.display='';
			document.all.item(LeadingMIS.Menu.PageControl.ChangeFrameTypeTableID,0).style.width='160px';
			g_bSubFrameState = true;
		}
		try{
			LeadingMIS.Menu.OnChangeSelfEvent();
		}
		catch(e){}
	}
}
//----------------------------------
//-- 说明:当点击图标时，子页面的响应事件.
//----------------------------------
LeadingMIS.Menu.OnChangeSelfEvent = function(){};
//----------------------------------
//-- 说明:
//----------------------------------
LeadingMIS.Menu.ShowBanner = function()
{
	var objEvent =  document.all.item(LeadingMIS.Menu.PageControl.ShowBannerImgID,0);
	var thisTB = document.all.item(LeadingMIS.Menu.PageControl.FrameTopTableID,0);
	if(thisTB){
		if(thisTB.style.display == 'none'){
			thisTB.style.display = '';
			try{
	 			var obj = {};
	 			obj.type = "set";
	 			obj.name = LeadingMIS.Menu.Const.ShowBannerCookieName;
	 			obj.value = LeadingMIS.Menu.State.ShowBannerState = "down";
	 			LeadingMIS.Cookie.Services(obj);
			}
			catch(e){}
		}
		else{
			thisTB.style.display='none';
			try{
	 			var obj = {};
	 			obj.type = "set";
	 			obj.name = LeadingMIS.Menu.Const.ShowBannerCookieName;
	 			obj.value = LeadingMIS.Menu.State.ShowBannerState = "up";
	 			LeadingMIS.Cookie.Services(obj);
			}
			catch(e){}
		}
		LeadingMIS.Menu.FrameReSize();
	}
}
//----------------------------------
//-- 说明:
//----------------------------------
LeadingMIS.Menu.initShowBanner = function()
{
	if(LeadingMIS.Menu.State.ShowBannerState == "")
	{
		var objEvent =  document.all.item(LeadingMIS.Menu.PageControl.ShowBannerImgID,0);
		var thisTB = document.all.item(LeadingMIS.Menu.PageControl.FrameTopTableID,0);
		if(thisTB){
			try{
	 			var obj = {};
	 			obj.type = "get";
	 			obj.name = LeadingMIS.Menu.Const.ShowBannerCookieName;
	 			obj = LeadingMIS.Cookie.Services(obj);
	 			if(obj && obj.value)
	 			{
	 				LeadingMIS.Menu.State.ShowBannerState = obj.value;
	 			}
	 			else
	 			{
	 				LeadingMIS.Menu.State.ShowBannerState = "down";
	 			}
 				if( LeadingMIS.Menu.State.ShowBannerState == "up" ){
					thisTB.style.display='none';
				}
				else{
					thisTB.style.display='';
				}
			}
			catch(e){}
		}
	}
}
//----------------------------------
//-- 说明:
//----------------------------------
LeadingMIS.Menu.initFrame = function(Type, Url, MenuID)
{
	LeadingMIS.Menu.FrameReSize();
	LeadingMIS.Menu.SetFramereadystate(Type);
	OpenWindow(1, Url, MenuID);
}


//----------------------------------
//-- 说明:
//----------------------------------
LeadingMIS.Menu.Button_Clicked = function(LevelOver, LevelOverID, nLevel, sMenuIDList)
{
	//debugger
	LeadingMIS.Menu.Const.SysMenuXml = document.all.item(LeadingMIS.Menu.PageControl.SysMenuXmlID, 0);//refresh
	if(sMenuIDList!=null)
	{
		LeadingMIS.Menu.loadPositionNeedNode(sMenuIDList)//	String = "level1MenuId,level2MmenuId,level3MenuId"
	}
	if(LevelOverID == "") LevelOverID = LeadingMIS.Menu.Const.MenuRootID;
	LeadingMIS.Menu.State.IntLevelOver = nLevel;
	LeadingMIS.Menu.State.LevelOverID = LevelOverID;
	LeadingMIS.Menu.loadData(LevelOverID);
	LeadingMIS.Menu.setMenuOver(LevelOverID);
	LeadingMIS.Menu.loadStyle();
	LeadingMIS.Menu.FrameReSize();
	LeadingMIS.Menu.initShowBanner();
}

//----------------------------------
//-- 说明:MenuBar管理类
//----------------------------------
var MenuBarTableManager = function(tableName)
{
	this.Table = document.all.item(tableName, 0);
}
/*
	dataInfo.rowIndex
*/
MenuBarTableManager.prototype.existRow = function(dataInfo)
{
	return dataInfo.rowIndex < this.Table.rows.length;
}
/*
dataInfo.rowIndex
dataInfo.isOver
dataInfo.menuId
dataInfo.style.left;
dataInfo.style.middle;
dataInfo.style.right;
dataInfo.style.splitImg;
*/
MenuBarTableManager.prototype.updateRow = function(dataInfo)
{
	var oRowBase = this.Table.rows(dataInfo.rowIndex);
	if(oRowBase)
	{
		var oRow = oRowBase.all.item("cellCollection", 0);
 		for(var i = 0; i<oRow.childNodes.length; i++)
 		{
 			var oCell = oRow.childNodes[i];
 			if(oCell.cusGroup != null && oCell.cusGroup != undefined && dataInfo.menuList[oCell.cusGroup])
 			{
 				switch(oCell.cusTag)
 				{
 					case "left" :
 						oCell.className = (dataInfo.menuList[oCell.cusGroup].isOver) ?  dataInfo.style.leftOver : dataInfo.style.left;
 						break;
 					case "middle" :
 						oCell.className = (dataInfo.menuList[oCell.cusGroup].isOver) ?  (dataInfo.style.middleOver + " " + dataInfo.style.txtOver) : (dataInfo.style.middle + " " + dataInfo.style.txt);
 						break;
 					case "right" :
 						oCell.className = (dataInfo.menuList[oCell.cusGroup].isOver) ?  dataInfo.style.rightOver : dataInfo.style.right;
 						break;
 					case "img" :
 						oCell.className = dataInfo.style.splitImg;
 						break;
 				}
 			}
 		}
 	}
}

/*
dataInfo.rowIndex
*/
MenuBarTableManager.prototype.deleteRow = function(dataInfo)
{
	while(this.Table.rows.length-1 > dataInfo.rowIndex)
		this.Table.deleteRow(this.Table.rows.length-1);
}

/*
dataInfo.rowIndex
dataInfo.style.bgCss;
dataInfo.style.left;
dataInfo.style.middle;
dataInfo.style.right;
dataInfo.style.txt;

dataInfo.style.leftOver;
dataInfo.style.middleOver;
dataInfo.style.rightOver;
dataInfo.style.txtOver;

dataInfo.style.splitImg;
dataInfo.rightCell.width;
dataInfo.rightCell.html;
dataInfo.cellList[0...n] = {html, menuId, isOver};
 
*/
MenuBarTableManager.prototype.insertRow = function(dataInfo)
{
	var oRow = null;
	if(dataInfo.rowIndex == undefined || dataInfo.rowIndex == null )
		oRow = this.Table.insertRow();
	else
		oRow = this.Table.insertRow(dataInfo.rowIndex);
		
	oRow.className = dataInfo.style.bgCss;
	var oCell = oRow.insertCell();
	oCell.innerHTML = "<DIV style='OVERFLOW: hidden; WIDTH: 100%; HEIGHT: 100%'><TABLE  height='100%' cellSpacing='0' cellPadding='0' border='0'><tr id='cellCollection'></tr></TABLE></DIV>"
	var menuCollection = oCell.all.item("cellCollection", 0);
 	oCell = oRow.insertCell();
	oCell.style.width = dataInfo.rightCell.width;
	oCell.innerHTML = dataInfo.rightCell.html;
	oCell.align = "center";
 	for(var i = 0; i<dataInfo.cellList.length; i++)
	{
		//left class
		var oSubCell = menuCollection.insertCell();
		oSubCell.className = (dataInfo.cellList[i].isOver) ? dataInfo.style.leftOver : dataInfo.style.left;
		oSubCell.cusTag = "left";
		oSubCell.cusGroup = dataInfo.cellList[i].menuId;
		//middle class
		oSubCell = menuCollection.insertCell();
 		oSubCell.nowrap = true;	
		oSubCell.className = (dataInfo.cellList[i].isOver) ? (dataInfo.style.middleOver + " " + dataInfo.style.txtOver) : (dataInfo.style.middle + " " + dataInfo.style.txt);
		oSubCell.innerHTML = dataInfo.cellList[i].html;
		oSubCell.cusTag = "middle";
		oSubCell.cusGroup = dataInfo.cellList[i].menuId;
		oSubCell.cusLinkUrl = dataInfo.cellList[i].linkUrl;
		oSubCell.id = "Tag_"+dataInfo.cellList[i].menuId;
		//reight class
		oSubCell = menuCollection.insertCell();
		oSubCell.className = (dataInfo.cellList[i].isOver) ? dataInfo.style.rightOver : dataInfo.style.right;
		oSubCell.cusTag = "right";
		oSubCell.cusGroup = dataInfo.cellList[i].menuId;
		//img 
		oSubCell = menuCollection.insertCell();
		oSubCell.innerHTML = "<img src='" + dataInfo.style.splitImg + "'>";
		oSubCell.cusTag = "img";
		oSubCell.cusGroup = dataInfo.cellList[i].menuId;
	}
 	return oRow;
}


