<%@ 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"%>
<%
    SzCompany szCompany = new SzCompany(); 
%>
<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">
  <style type="text/css">
	img{vertical-align:middle;} 

    t img { vertical-align:middle;}
    
    
    .btnImg {
      cursor: hand;
    }

    .btnImgOver {
      cursor: hand;
      background:url(<%=strSkin_SESSION%>/top/t_m_over.gif); 
    }
    .btnImgClick {
      cursor: hand;
      background:url(<%=strSkin_SESSION%>/top/t_m_on.gif);
    }    
</style>  

<script language="javascript">
  //保存上一个选中的menu_id
  var obj_prio = null;
  //当鼠标经过top里（桌面，重新登陆）等指定的几个图片时，改变图片
  function ChangeImage(obj, img) {
    obj.src = "<%=strSkin_SESSION%>/top/" + img;
  }
  //当鼠标经过top里的menu时，改变样式。
  function MenuMouse(obj, number) {
    if (obj.className == "btnImgOver") {
      obj.className="btnImg";
      //取消二级菜单的显示
      
    } else if (obj.className == "btnImg") {
      obj.className="btnImgOver";
      //增加二级菜单的显示
    }
  }  
  //点中一个一级模块：改变样式，并且改变左侧菜单
  function ChangeMenu(obj, number, hasUrl) {
    if (obj_prio != null) {
    	obj_prio.className = "btnImg";
    }
    obj.className="btnImgClick";
    obj_prio = obj;
    
    //刷新menu.jsp
    top.szMenuFrame.location.href="form_menu.jsp?MKBH_TOP=" + number + "&hasUrl=" + hasUrl;
    
  }

  //控制divTopMenu向左滑动
  function ScrollLeft() {
    var divTopMenu = document.getElementById("divTopMenu");
    divTopMenu.scrollLeft = divTopMenu.scrollLeft + 20;
    //divTopMenu.doScroll("scrollbarLeft");   	
  }
  
  
  //控制divTopMenu向左滑动
  function ScrollRight() {
    var divTopMenu = document.getElementById("divTopMenu");
    divTopMenu.scrollLeft = divTopMenu.scrollLeft - 20;
    //divTopMenu.doScroll("scrollbarRight");
  }  
  
  function OpenContact() {
    var vUrl = "../organize/contact.jsp";
    window.showModalDialog(vUrl,window,"status=no;dialogWidth=400px;dialogHeight=250px");   
  }
</script>
</HEAD>
<body  bgcolor="#F4FEFF">
<table border=0 width="100%"  cellspacing="0" cellpadding="0">
  <tr>
    <td background="<%=strSkin_SESSION%>/top/top1_01.gif" width="10" height="70" align="left"></td>
    <td background="<%=strSkin_SESSION%>/top/top1_02.gif" width="440" height="70"></td>
    <td background="<%=strSkin_SESSION%>/top/top1_03.gif" height="70">&nbsp;      
    </td>
    <td background="<%=strSkin_SESSION%>/top/top1_04.gif" width="400" height="70" valign="top" align="right">
      <div style="margin-top:10px;" >
      <a href="form_desktop.jsp" OnClick="javascript:Desktop();" target="szMainFrame" onfocus="javascript:blur();">
      <img src="<%=strSkin_SESSION%>/top/t_desktop.gif" width="82" height="26" id="t_desktop" border="0" 
           OnMouseOver="javascript:ChangeImage(this, 't_desktop2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_desktop.gif');">
      </a>
      <%
	  //取得及时信息所在的模块ID
	  SzModule szModule = new SzModule();
	  SzModuleInfo szModuleInfo = null;	
	  int iMKID = 0;		  
	  
	  szModuleInfo = (SzModuleInfo)szModule.getInfoByCond("MKLJDZ LIKE '%online/message/index_receive.jsp%'");
	  iMKID = 0;
	  if (szModuleInfo != null) {
	     iMKID = szModuleInfo.getMKID();
	  }            
      %>
      <a href="../online/index_tree.jsp?MKID_SESSION=<%=iMKID%>" target="szMainFrame" onfocus="javascript:blur();">
      <img src="<%=strSkin_SESSION%>/top/t_alert.gif" width="82" height="26" id="t_alert"  border="0"
           OnMouseOver="javascript:ChangeImage(this, 't_alert2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_alert.gif');" >
      </a>     
           
      <a href="#" OnClick="javascript:top.location.href='../relogin.jsp?DLID=<%=iDLID_SESSION%>';"  onfocus="javascript:blur();">
      <img src="<%=strSkin_SESSION%>/top/t_relogin.gif" width="82" height="26" id="t_relogin" border="0" 
           OnMouseOver="javascript:ChangeImage(this, 't_relogin2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_relogin.gif');">
      </a>           
      <br>

          
      <a href="http://www.soarwell.com" target="_blank" onfocus="javascript:blur();">
      <img src="<%=strSkin_SESSION%>/top/t_ask.gif" width="82" height="26" id="t_help"   border="0"
           OnMouseOver="javascript:ChangeImage(this, 't_ask2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_ask.gif');" ></a>                      

      <a href="#" OnClick="javascript:OpenContact();" onfocus="javascript:blur();">
      <img src="<%=strSkin_SESSION%>/top/t_contact.gif" width="82" height="26" id="t_relogin" border="0" 
           OnMouseOver="javascript:ChangeImage(this, 't_contact2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_contact.gif');" ></a> 
      </a>
                 
      <a href="../help/soarwell-form.htm" target="_blank">
      <img src="<%=strSkin_SESSION%>/top/t_help.gif" width="82" height="26" id="t_help"   border="0"
           OnMouseOver="javascript:ChangeImage(this, 't_help2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_help.gif');" ></a>
            
      </div>    
    </td> 
    <td background="<%=strSkin_SESSION%>/top/top1_05.gif" width="10" height="70" align="right">    
    </td>    
  </tr>
</table>  
<%
  //获得本人可用的第一级菜单

    //权限
    SzPopedom szPopedom = new SzPopedom();
    //读取数据，2008-01-18改成到treeMap里读取。
    //SzModule szModule = new SzModule();
    //SzModuleInfo szModuleInfo = new SzModuleInfo();
	Collection collTop = SzModule.getTopLevelModuleList(szCOMPANY_SESSION, isSuperManager_SESSION);
    Iterator iter = null;
    int iSize = collTop.size();
    iSize = 600 - iSize * 21;
    if (collTop != null) {
    	iter = collTop.iterator();
    }
    //Iterator iter = szModule.getArrayList().iterator();
    String sBH = "";
    String sBH_ROOT = "";
    String sBH_SJ = "";

    String sBH_DEFAULT = "";
	String sImage_DEFAULT = "t_default.gif";
	String sImage = "";
%>
<table border=0 width="100%"  cellspacing="0" cellpadding="0"  bgcolor="#F4FEFF">  
  <tr>
	<td background="<%=strSkin_SESSION%>/top/top_menu_01.gif" width="10" height="35"></td>
	<td colspan="3" background="<%=strSkin_SESSION%>/top/top_menu_bg.gif" height="35" align="right" valign="middle">
	  <div id="divTopMenu" nowrap style="position:absolute;width:90%;height:35px;left:35px;top:70px;padding:0px; margin:0px;overflow:auto;overflow:hidden;">
<%
    String sLink = "";
    String sTemp_BH = ""; //这里保存不可使用的上级模块。如果上级模块都不能使用，直接跳过。
    String sManage_BH = ""; //这里保存有栏目管理权限的模块编号。下级可以继承
    boolean isBarManager = false;
    String sCanSee_BH = "";
    boolean isCanSee = false;
    int i = 0;
    boolean hasChild = false;
    boolean hasUrl = false;
    while (iter != null && iter.hasNext()) {
        szModuleInfo = (SzModuleInfo)iter.next();
      	sBH = szModuleInfo.getMKBH();
      	//已经设置横向显示的,这里不再显示
      	if (szModuleInfo.getMKTZID() >0) {
      		continue;
      	}

      	//如果上级模块都不能使用，直接跳过。
        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;
        }
		if (sBH_DEFAULT.equals("")) {
			sBH_DEFAULT = sBH;
		}
        sBH_SJ = SzConvert.toZeroStr( SzLevelNumber.getParentNumber(sBH) );
        sLink = SzModule.getMenuLink(szModuleInfo.getMKLJDZ(), szModuleInfo.getMKID());
        sImage = szModuleInfo.getMKTP1();
        if (sImage.equals("")) {
        	sImage = sImage_DEFAULT;
        }
        if (!sLink.equals("")) {
        	hasUrl = true;
        } else {
        	hasUrl = false;
        }
        i ++;
        if (i >1) {
%>	
  <img src="<%=strSkin_SESSION%>/top/top_menu_line.gif" width="5" height="35">	
<%
        }
%>
  <span class="btnImg" id="<%=sBH%>"
        OnMouseOver="javascript:MenuMouse(this, '<%=szModuleInfo.getMKBH()%>');" 
        OnMouseOut="javascript:MenuMouse(this, '<%=szModuleInfo.getMKBH()%>');" 
        OnClick="javascript:ChangeMenu(this, '<%=szModuleInfo.getMKBH()%>', '<%=hasUrl%>');">	  
  
  <% if (!sLink.equals("")) { %><a href="<%=sLink%>" target="szMainFrame" onfocus="javascript:blur();"><% } %> 
  <img src="../images/share2/top/<%=sImage%>" width="20" height="35" border="0"><%=szModuleInfo.getMKMC()%>
  <% if (!sLink.equals("")) { %></a><% } %>
  </span>  
 
<%
    }     
%>   
      <!-- 增加滚动按纽 -->
      <img src="<%=strSkin_SESSION%>/top/t_bl.gif" width="17" height="19" border="0" class="btnImg" OnClick="javascript:ScrollLeft();" >
      <img src="<%=strSkin_SESSION%>/top/t_br.gif" width="17" height="19" border="0" class="btnImg" OnClick="javascript:ScrollRight();">
      
      </div> 
      	
	</td>  	  
	<td background="<%=strSkin_SESSION%>/top/top_menu_02.gif" width="10" height="35"></td>			
  </tr>  
</table>

<script language="javascript">
  function Desktop() {
	//document.location.href.target = "szMainFrame";
	//document.location.href = "desktop.jsp";
	//收起左侧菜单
	//top.szMenuFrame.ChangeMenuAuto("0");
  } 
  
  var oDefaultObj = document.getElementById("<%=sBH_DEFAULT%>");
  ChangeMenu(oDefaultObj, "<%=sBH_DEFAULT%>");
</script>
</body>
</HTML>
 



