<%@ page contentType="text/html;charset=UTF-8"%>
<%@ 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" %>
<%@ page import="net.sz600.online.*" %>
<%@ include file="/sessionInfo.jsp"%>
<%
	String sPicture = OlUserSession.getInstance().alertCountInfo(iDLID_SESSION);
  	SzCompany szCompany = new SzCompany(); 
	StringBuffer sb = new StringBuffer("");
	sb.append("<font size='2' color='#F02C56'><b>");
	sb.append("<span id='divAlert'>");
	sb.append(sPicture);
	sb.append("</span>");
	sb.append("&nbsp;&nbsp;欢迎您:");
	if (!sBMMC_SESSION.equals("")) {
	  sb.append("&nbsp;[部门]");
	  sb.append(sBMMC_SESSION);
	  sb.append("");
	}
	sb.append("&nbsp;[姓名]");
	sb.append(sDLXM_SESSION);
	sb.append("</b></font>");	

	String sInfo = sb.toString();
	sb = null;
	
	String top02 = szCompany.getTopPicture3(strSkin_SESSION, szCOMPANY_SESSION);
	if (net.sz600.check.SzHasp.getInstance().hasDog()) {
	  top02 = "../images/customer/top1_02.gif";
        } 
	//System.out.println(strSkin_SESSION);
	%>
<HTML>
  <HEAD>
  <TITLE></TITLE>
  <META http-equiv=Content-Type content="text/html; charset=UTF-8">
  <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%>/top2/" + 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="menu.jsp?MKBH_TOP=" + number + "&hasUrl=" + hasUrl;
  }

  //控制divTopMenu向左滑动
  function ScrollLeft() {
    var divTopMenu = document.getElementById("divTopMenu");
    divTopMenu.scrollLeft = divTopMenu.scrollLeft - 500;
    //divTopMenu.doScroll("scrollbarLeft");   	
  }
  
  
  //控制divTopMenu向左滑动
  function ScrollRight() {
    var divTopMenu = document.getElementById("divTopMenu");
    divTopMenu.scrollLeft = divTopMenu.scrollLeft + 500;
    //divTopMenu.doScroll("scrollbarRight");
  }  

  function OpenGuide() {
    var sw = screen.width;
    var w = 700;
    var l = sw - w - 100; 
    var vUrl = "../help/guide/guide_index.jsp";
    window.open(vUrl, "", "status=not,resizable=yes,height=500,width=" + w + ",top=100,left=" + l); 
  }
  
  function Desktop() {
		//document.location.href.target = "szMainFrame";
		//document.location.href = "desktop.jsp";
		//收起左侧菜单
		top.szMenuFrame.ChangeMenuAutoDesktop("0");
  }  
     
	//查看信息
  function ReceiveMessageWin(vJSID) {
    	var vUrl = "../online/message/receive.jsp?refresh=true&OPERATOR=receive&KEY=" + vJSID;
	  	childWin = window.open(vUrl,"","status=yes,height=500,width=600,top=100,left=100");  
  }
    
  function OpenOnline() {
    var sw = screen.width;
    var w = 340;
    var h = screen.height - 200;
    var l = sw - w - 100; 
    var vUrl = "../online/index_tree.jsp?type=1";
    var szOnlineWin = window.open(vUrl, "szOnlineWin", "status=not,scroll=yes,scrollbars=yes,resizable=yes,height=" + h + ",width=" + w + ",top=100,left=" + l);   
  }  
  
		var time = <%=new java.util.Date().getTime()%>;
		//window.status = time;
		var date = new Date();
		date.setTime(time);
		//TIME.innerHTML = date.toLocaleString();
		function showTime(){
			time += 1000;
			date.setTime(time);
			TIME.innerHTML = date.toLocaleString();
		}

  function version() {
  	var url = "version.jsp"
  	window.showModalDialog(url,window,"status=no;dialogLeft=200;dialogTop=200;dialogWidth=401px;dialogHeight=320px");
  }
  
  function ChangeTopMenu(vType) {
  	document.location.href = "top.jsp?type=" + vType;
  }

  function OpenGuide2() {
    var sw = screen.width;
    var w = 750;
    var l = sw - w - 100; 
    var vUrl = "http://www.soarwell.com/FAQ/index.shtml";
    window.open(vUrl, "", "status=not,resizable=yes,scrollbars=yes,height=500,width=" + w + ",top=100,left=" + l); 
  }
		

</SCRIPT>
</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="<%=top02%>" width="440" height="70" OnClick="javascript:version();" style="cursor:hand;">
    </td>
    <td background="<%=strSkin_SESSION%>/top/top1_03.gif" height="70" align="center">&nbsp;
   	</td>    

    <td background="<%=strSkin_SESSION%>/top/top1_04b.gif" width="550" height="70" valign="top" align="right">
      <div style="margin-top:10px;" >
      <%=sInfo%>     
      </div>      	
      <div style="margin-top:5px;" >

      <a href="desktop.jsp" OnClick="javascript:Desktop();" target="szMainFrame" onfocus="javascript:blur();">
      <img src="<%=strSkin_SESSION%>/top2/t_desktop.png" width="60" height="26" id="t_desktop" border="0" 
           OnMouseOver="javascript:ChangeImage(this, 't_desktop2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_desktop.png');">
      </a>

      <a href="#" OnClick="javascript:OpenGuide2();" onfocus="javascript:blur();">
      <img src="<%=strSkin_SESSION%>/top2/t_help.png" width="60" height="26" id="t_help" border="0"
           OnMouseOver="javascript:ChangeImage(this, 't_help2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_help.png');" >
      </a>

                
	  	<a href="#" OnClick="javascript:OpenOnline();" onfocus="javascript:blur();">
      <img src="<%=strSkin_SESSION%>/top2/t_user.gif" width="60" height="26" id="t_alert"  border="0"
           OnMouseOver="javascript:ChangeImage(this, 't_user2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_user.gif');" >
      </a>
  	  
      <a href="#" OnClick="javascript:top.location.href='../relogin.jsp?DLID=<%=iDLID_SESSION%>';"  onfocus="javascript:blur();">
      <img src="<%=strSkin_SESSION%>/top2/t_relogin.png" width="60" height="26" id="t_relogin" border="0" 
           OnMouseOver="javascript:ChangeImage(this, 't_relogin2.gif');" 
           OnMouseOut="javascript:ChangeImage(this, 't_relogin.png');">
      </a>
      </div>                   
    
    </td> 
    <td background="<%=strSkin_SESSION%>/top/top1_05.gif" width="10" height="70" align="right">
    </td>    
  </tr>
</table>  
<%
  //获得本人可用的第一级菜单

    String sType = SzConvert.toZeroStr(request.getParameter("type")); //分公司信息
    String strType = sType;
    if (strType.equals("0")) {
    	strType = "-4";	
    }

    //权限
    SzPopedom szPopedom = new SzPopedom();
    //读取数据，2008-01-18改成到treeMap里读取。
    SzModule szModule = new SzModule();
    SzModuleInfo szModuleInfo = new SzModuleInfo();
		Collection collTop = SzModule.getTopLevelModuleList(szCOMPANY_SESSION, isSuperManager_SESSION, szDLID_SESSION, strType);
    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_DEFAULT = "blank.gif";
	String sImage = "";
%>
<table border=0 width="100%"  cellspacing="0" cellpadding="0"  bgcolor="#F4FEFF">  
  <input type="hidden" id="type" name="type" value="<%=sType%>">
  <tr>
	<td width="10">
	   <img src="<%=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:100%;height:35px;left:-55px;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 && szModuleInfo.getMKTZID() != szModuleInfo.getMKID()) {
      		continue;
      	}
      	//2013-12-13增加超级管理员的判断
		if (isSuperManager_SESSION) {
			isBarManager = true;
			isCanSee = true; //这个应该永远是tree 
		} else {
        	//根据编号判断是否是管理员，上级模块是管理员，则可管理所有下级模块
        	isBarManager = szPopedom.isModuleManager(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());    
            if (szModuleInfo.getMKQX() == 3) {
              //系统管理员可见，判断是否系统管理员，该模块有没有设置成可见的权限。
              isCanSee = isSystemManager_SESSION ||
                       szPopedom.isModuleCanSee(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());
            } else if (szModuleInfo.getMKQX() == 2) {
              //模块管理员可见，判断是否模块管理员，该模块有没有设置成可见的权限。
              isCanSee = isBarManager ||
                       szPopedom.isModuleCanSee(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());
            } else if (szModuleInfo.getMKQX() == 1) {
            	//2013-12-19增加
              //指定人员可见：判断是否模块管理员，该模块有没有设置成可见的权限。
                isCanSee = isBarManager ||
                         szPopedom.isModuleCanSee(szModuleInfo.getMKID(), szLoginInfo_SESSION.getDLID());              
            } else {
            	isCanSee = true; //这个应该永远是tree
          	}
		}


        if (!isCanSee) {
           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;
        }
      	//是否有下级,2014-06增加
      	hasChild = SzModule.hasChildModule(sBH, szModuleInfo.getMKTZID());
      	if (!hasChild && !hasUrl) {
      		//没有连接,没有下级的跳过
      		continue;
      	}        
        i ++;
        if (i >1) {
%>	
  <img src="<%=strSkin_SESSION%>/top/top_menu_line.gif" width="5" height="35">	
<%
        }
%>
  <!--2012-02-27:将连接移到span外面，确保解决“选中状态已切换，但是连接不对，严重问题”-->
  <% if (!sLink.equals("")) { %><a href="<%=sLink%>" target="szMainFrame" onfocus="javascript:blur();"><% } %> 
  <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 (!sImage.equals("blank.gif")) { 
  	  	out.print("<img src='../images/share2/top/" + sImage + "' width='20' height='35' border='0'>");
  	  	out.println(szModuleInfo.getMKMC());
  	} else {  		
  		out.print("<img src='../images/share2/top/" + sImage + "' width='1' height='35' border='0'>");
  		out.println(szModuleInfo.getMKMC());
  	}
  	%>  
  </span>  
  <% if (!sLink.equals("")) { %></a><% } %> 
<%
    }     
%>   
      
      </div> 
      <!-- 增加滚动按纽 -->
      <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();">   	
	</td>  	  
	<td width="10">
	  <img src="<%=strSkin_SESSION%>/top/top_menu_02.gif" width="10" height="35">
	</td>			
  </tr>  
</table>
<script language="javascript">
	//2011-11-04修改
	var xmlhttp = null; 
	var checkresult=null; 
	if   (window.XMLHttpRequest)   {   //   Mozilla,   Safari,...   
       		xmlhttp =new XMLHttpRequest();               
        }  else if(window.ActiveXObject)   {   //   IE    
		xmlhttp =new ActiveXObject("Microsoft.XMLHTTP");    
        }   

	function CheckMessage() { 
		xmlhttp.open("POST", "../online/message/refresh_action.jsp", false); 
		//xmlhttp.onreadystatechange = updatePage; 
		xmlhttp.send(null); 

		var response = xmlhttp.responseText;
		var vCount = "0";
		var vFirst = "0";
		var vIndex = response.indexOf("SzMessageYes");		
		if (vIndex >=0) {
			var vIndex1 = response.indexOf("SzFirstJSID");
			var vIndex2 = response.indexOf("SzEnd");
		    vCount = response.substring(vIndex + 12, vIndex1);
		    vFirst = response.substring(vIndex1 + 11, vIndex2);
		    divAlert.innerHTML 
		    	   =  ""
    	           + "<a href='#' OnClick='javascript:ReceiveMessageWin(" + vFirst + ")'>"
    	           + "<img border='0' src='../images/share/online_m.gif'>"
    	           + "</a>"	
                   + "<a href='../online/message/index_receive.jsp?MKID_SESSION=842' target='szMainFrame' OnClick='javascript:blur();'>"   	   
		   + "<font size='2' color='#F02C56'>未收信息[<b>" + vCount + "</b>]</font>"
    	           + "</a>";    
		} else {
		    divAlert.innerHTML = "<img border='0' src='../images/share/online_i.gif'><a href='../online/message/index_receive.jsp?MKID_SESSION=842' target='szMainFrame' OnClick='javascript:blur();'><font size='2' color='#F02C56'>未收信息[0]</font></a>";
		}
		xmlhttp.abort();
	} 
	CheckMessage();
	window.setInterval('CheckMessage()',5000);

</script>
<script language="javascript">
	//2011-06-27启用

  var vType = document.getElementById("type").value;
  if (vType != "0") {
  	var oDefaultObj = document.getElementById("<%=sBH_DEFAULT%>");
  	ChangeMenu(oDefaultObj, "<%=sBH_DEFAULT%>");
  }
  
  //TIME.innerHTML = date.toLocaleString();
  //var showObj = setInterval('showTime()',1000);  	
</script>







</body>
</HTML>
 



