<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.TreeMap" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ page import="net.sz600.system.SzLevelNumber" %>
<%@ page import="net.sz600.organize.SzModule" %>
<%@ page import="net.sz600.organize.SzModuleInfo" %>
<%@ page import="net.sz600.organize.SzPopedom" %>
<%@ include file="/sessionInfo.jsp"%>


<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
<SCRIPT src="../share/js/ftiens4_tree_menu.js"></SCRIPT>
<style type=text/css>
body{ 
SCROLLBAR-FACE-COLOR: white;
SCROLLBAR-HIGHLIGHT-COLOR: white; 
SCROLLBAR-SHADOW-COLOR: white;
SCROLLBAR-3DLIGHT-COLOR: white;
SCROLLBAR-ARROW-COLOR: #0C0C0C; 
SCROLLBAR-TRACK-COLOR: white; 
SCROLLBAR-DARKSHADOW-COLOR: white  
}

.menuOn1 {
    background-image:  url(<%=strSkin_SESSION%>/menu/menu_bt2.gif);
}
.menuOut1 {
    background-image:  url(<%=strSkin_SESSION%>/menu/menu_bt.gif);
}
	.menu_text {
		line-height: 140px;
	}
</style>
</head>


<body bgcolor="#F4FEFF">
<%
    //这里是传递进来的一级模块，下面列出二级模块。
    String sMKBH_TOP = SzConvert.toZeroStr(request.getParameter("MKBH_TOP"));   
    String hasUrl = SzConvert.toZeroStr(request.getParameter("hasUrl"));
    
	String sLink = "";
	String sLink_Default = "";
	String sBH_DEFAULT = "";
	String sTemp_BH = ""; //这里保存不可使用的上级模块。如果上级模块都不能使用，直接跳过。
	String sManage_BH = ""; //这里保存有栏目管理权限的模块编号。下级可以继承
	boolean isBarManager = false;
	String sCanSee_BH = "";
	boolean isCanSee = false;
	int i = 0;
	int iSize = 0;
	boolean hasChild = false;
	
    //权限
    SzPopedom szPopedom = new SzPopedom();
    //读取数据，2008-01-18改成到treeMap里读取。
    SzModule szModule = new SzModule();
    SzModuleInfo szModuleInfo = null;
    String sBH = sMKBH_TOP;
    String sBH_ROOT = "";
    String sBH_SJ = "";
    
    Iterator iterChild = null;	
    
    //取得传过来的一级
    int iMKID_TOP = szModule.getModuleId(sMKBH_TOP);
    szModuleInfo = (SzModuleInfo)szModule.getModuleInfoByMap(iMKID_TOP);
    if (szModuleInfo == null) {
    	szModuleInfo = new SzModuleInfo(); 
    }
%>
<table width="100%" bgcolor="#F4FEFF" >
  <tr>
    <td align="right">
  <table border="0" cellpadding="0" cellspacing="0" align="center" id="tableMenu1" >
    <tr>
      <td background="<%=strSkin_SESSION%>/menu/menu01_01.gif" width="8" height="8" colspan="2"></td>
      <td background="<%=strSkin_SESSION%>/menu/menu01_02.gif" width="160" height="8" colspan="3"></td>
      <td background="<%=strSkin_SESSION%>/menu/menu01_03.gif" width="8" height="8" colspan="2"></td>
      <td></td>
    </tr>
    <tr>
      <td background="<%=strSkin_SESSION%>/menu/menu02_a1.gif" width="2" height="23"></td>
      <td background="<%=strSkin_SESSION%>/menu/menu02_a2.gif" width="6" height="23"></td>
      <td background="<%=strSkin_SESSION%>/menu/menu02_02.gif" width="160" height="23" valign="top" colspan="3">&nbsp;
        <img src="<%=strSkin_SESSION%>/menu/menu_b01.gif"> <%=szModuleInfo.getMKMC()%>
      </td>
      <td background="<%=strSkin_SESSION%>/menu/menu02_a3.gif" width="6" height="23"></td>
      <td background="<%=strSkin_SESSION%>/menu/menu02_a4.gif" width="2" height="23"></td>
      <td></td>
    </tr>   
    <tr>
      <td background="<%=strSkin_SESSION%>/menu/menu03_01.gif" width="2" height="23"></td>
      <td height="500" valign="top"  colspan="5">
        <div id='div' style="position:relative;width:100%;overflow:auto;padding:0px; margin:0px;">
        <table border="0" cellpadding="0" cellspacing="0" valign="top">
          <tr><td height="10px"></td></tr>        
  <%      
      sBH_ROOT = sBH;
      sTemp_BH = "";
      sManage_BH = "";
      sCanSee_BH = "";
      iterChild =  SzModule.getChildModuleList(sMKBH_TOP, szCOMPANY_SESSION, isSuperManager_SESSION).iterator();
     
      while (iterChild != null && iterChild.hasNext()) {
    	  szModuleInfo = (SzModuleInfo)iterChild.next();
          sBH = szModuleInfo.getMKBH();
          //已经设置横向显示的,这里不再显示
          if (szModuleInfo.getMKTZID() >0 && szModuleInfo.getMKTZID() != szModuleInfo.getMKID()) {
        	continue;
          }		  
		  
		  isCanSee = false;
		  
          //如果上级模块都不能使用，直接跳过。
          if (!sTemp_BH.equals("") && sBH.indexOf(sTemp_BH) == 0) {
                continue;
          }

         //根据编号判断是否是管理员，上级模块是管理员，则可管理所有下级模块
         if (!sManage_BH.equals("") && sBH.indexOf(sManage_BH) == 0) {
                isBarManager = true;
         } else {
                isBarManager = szPopedom.isModuleManager(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());
                if (isBarManager) {
                    sManage_BH = sBH;
                } else {
                    sManage_BH = "";
                }
         }

         //如果上级模块分派了可见权限，则下级可以继承，不需要再判断权限
         if (!sCanSee_BH.equals("") && sBH.indexOf(sCanSee_BH) == 0) {
                isCanSee = true;
         } else {
                if (szModuleInfo.getMKQX() == 3) {
                  //系统管理员可见，判断是否系统管理员，该模块有没有设置成可见的权限。
                  isCanSee = isSystemManager_SESSION ||
                             szPopedom.isModuleCanSee(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());
                  if (isCanSee) {
                      sCanSee_BH = sBH;
                  }

                } else if (szModuleInfo.getMKQX() == 2) {
                  //模块管理员可见，判断是否模块管理员，该模块有没有设置成可见的权限。
                  isCanSee = isBarManager ||
                             szPopedom.isModuleCanSee(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());
                  if (isCanSee) {
                      sCanSee_BH = sBH;
                  }

                } else {
                  //普通模块，判断是否设置可见的权限
                  isCanSee = szPopedom.isModuleCanSee(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());
                  //这个的目的是保存已经授权的上级模块编号，不是作为本级显示的依据
                  if (isCanSee) {
                      sCanSee_BH = sBH;
                  }
                  isCanSee = true; //这个应该永远是tree
                }
          }

          if (!isCanSee) {
               //该模块不能使用，该模块直接跳过。
               sTemp_BH = sBH;  //记录不能使用的上级模块
               sCanSee_BH = "";
               continue;
          }
          sTemp_BH = "";    	  
    	  
    	  sBH = szModuleInfo.getMKBH();
    	  sBH_SJ = SzConvert.toZeroStr( SzLevelNumber.getParentNumber(sBH) );
    	  sLink = SzModule.getMenuLink(szModuleInfo.getMKLJDZ(), szModuleInfo.getMKID());
    	  if (sLink_Default.equals("")) {
    		  sLink_Default = sLink;
    	  }
  		  if (sBH_DEFAULT.equals("")) {
			  sBH_DEFAULT = sBH;
		  }    	  
    	  
    	  //是否有下级,
    	  hasChild = SzModule.hasChildModule(sBH);
    	  i ++;
    	  if (hasChild) {
    	  %>
          <tr><td class="menu_text" height="25" colspan="3">
          <% if (!sLink.equals("")) { %>
             <a href="<%=sLink%>" target="szMainFrame" onfocus="javascript:blur();" id="<%=sBH%>" >
             &nbsp;&nbsp;&nbsp;<img src="<%=strSkin_SESSION%>/menu/menu_b01.gif" border="0">&nbsp;&nbsp;<%=szModuleInfo.getMKMC()%>
             </a>          
          <% } else {%>
             &nbsp;&nbsp;&nbsp;<img src="<%=strSkin_SESSION%>/menu/menu_b02.gif" border="0">&nbsp;&nbsp;<%=szModuleInfo.getMKMC()%>                 
          <% } %>
          </td></tr>
  		  <%
    	  } else {
          %>
          <tr><td class="menu_text" height="25" colspan="3">
          <% if (!sLink.equals("")) { %>
             <a href="<%=sLink%>" target="szMainFrame" onfocus="javascript:blur();" id="<%=sBH%>" >
             &nbsp;&nbsp;&nbsp;<img src="<%=strSkin_SESSION%>/menu/menu_b01.gif" border="0">&nbsp;&nbsp;<%=szModuleInfo.getMKMC()%>
             </a>          
          <% } else {%>
             &nbsp;&nbsp;&nbsp;<img src="<%=strSkin_SESSION%>/menu/menu_b02.gif" border="0">&nbsp;&nbsp;<%=szModuleInfo.getMKMC()%>                 
          <% } %>
          </td></tr>          
          <%    		  
    	  }
    	  %>
          <tr>
            <td background="<%=strSkin_SESSION%>/menu/menu_line02.gif" width="46" height="1"></td>
            <td background="<%=strSkin_SESSION%>/menu/menu_line03.gif" width="50%" height="1"></td>
            <td background="<%=strSkin_SESSION%>/menu/menu_line04.gif" width="46" height="1"></td>          
          </tr>
    	  <%
      }
  %>   
        </table> 
        </div>
      </td>
      <td background="<%=strSkin_SESSION%>/menu/menu03_02.gif" width="2" height="23"></td>
      <td width="11" align="left"> <!-- 左右缩进 -->      
        <img src="<%=strSkin_SESSION%>/menu/menu_b04.gif" width="11" height="259" onClick="javascript:ChangeMenuWidth();">
      </td>
    </tr>
    <tr>
      <td background="<%=strSkin_SESSION%>/menu/menu04_01.gif" width="8" height="8" colspan="2"></td>
      <td background="<%=strSkin_SESSION%>/menu/menu04_02.gif" width="160" height="8"" height="8"  colspan="3"></td>
      <td background="<%=strSkin_SESSION%>/menu/menu04_03.gif" width="8" height="8" colspan="2"></td>
      <td></td>
    </tr>                       
  </table> 
  <table border="0" cellpadding="0" cellspacing="0" align="center" width="11" id="tableMenu2" style="display:none;">
    <tr>
      <td width="11" height="540" align="left" valign="middle">       
        <img src="<%=strSkin_SESSION%>/menu/menu_b03.gif" width="11" height="259" onClick="javascript:ChangeMenuWidth();">
      </td>
    </tr>   
  </table>  
    </td>
    
  </tr>
</table>  
<input type="hidden" id="count" value="<%=i%>">
<input type="hidden" id="MKID_TOP" value="<%=iMKID_TOP%>">
<input type="hidden" id="hasUrl" value="<%=hasUrl%>">
<input type="hidden" id="BH_DEFAULT" value="<%=sBH_DEFAULT%>">
<input type="hidden" id="Link_Default" value="<%=sLink_Default%>">

<script language="javascript">

    function ChangeMenuWidth() {
		var o1 = document.getElementById("tableMenu1");
		var o2 = document.getElementById("tableMenu2");

	    if (window.top.pframe.cols == "200,*") {
			window.top.pframe.cols="20,*";
			o1.style.display = "none";
			o2.style.display = "";
	    } else {
			window.top.pframe.cols="200,*";
			o1.style.display = "";
			o2.style.display = "none";			
	    }	
    }
    
    function ChangeMenuAuto(vType) {
		var o1 = document.getElementById("tableMenu1");
		var o2 = document.getElementById("tableMenu2");
		if (vType == "0") { //隐藏
			window.top.pframe.cols="20,*";
			o1.style.display = "none";
			o2.style.display = "";		
		} else {
			window.top.pframe.cols="200,*";
			o1.style.display = "";
			o2.style.display = "none";					
		}
    }    
    
  //重新计算div的大小
  var vHeight = document.body.clientHeight;  
  var divHeight = vHeight - 51;  
  div.style.height = divHeight;
  
  //如果没有二级，自动隐藏  
  var vCount = document.getElementById("count").value;
  var vMKID_TOP = document.getElementById("MKID_TOP").value;
  if (vCount == "0") {
	  ChangeMenuAuto("0");
  } else {
	  ChangeMenuAuto("1");
  }
  
  //如果一级没有url，那这里就显示第一个url
  var hasUrl = document.getElementById("hasUrl").value;
  var oBH_DEFAULT = document.getElementById("BH_DEFAULT");
  var Link_Default = document.getElementById("Link_Default").value;
  if (hasUrl == "" || hasUrl == "0" || hasUrl == "false") {
    if (Link_Default == "" || vMKID_TOP == "0") {
	  Link_Default = "form_desktop.jsp";
    }
    top.szMainFrame.document.location.href = Link_Default;    
  }
</script>    
</body>