<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ page import="net.sz600.system.SzOut" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.organize.*" %>
<%@ page import="net.sz600.system.SzLog" %>
<%@ page import="net.sz600.online.*" %>
<%@ include file="/sessionInfo.jsp"%>
<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">
<SCRIPT src="../share/js/ftiens4_online.js"></SCRIPT>
</head>
<body>
<%
	//获取提交的参数
	String sType = SzConvert.toZeroStr(request.getParameter("type"));
	if (sType.equals("0")) {
%>
<%@ include file="/online/title.jsp"%>
<%		
	} else {
%>
<%@ include file="/online/title2.jsp"%>
<%		
	} 
%>

<%
	Map userMap = OlUserSession.getInstance().getOnLineUser();
	int iOnlineCount = userMap.size();
	int iAllCount = SzUserHelp.getLoginStaticMap().size();
	Iterator iterUser = userMap.keySet().iterator();
	String sName = "";
	String sDLID = "";
    String sPicture = OlUserSession.getInstance().alertCountInfo(iDLID_SESSION);

%>
<table width=100% border="0" cellpadding=0 cellspacing=0 align="left">
  <tr>
    <td align="center" width="33"></td>
    <td width="751" colspan="2" align="left" height="25">
      <div id='divAlert'><%=sPicture %>&nbsp;总人数[<%=iAllCount%>],在线人数[<%=iOnlineCount %>]</div> 
    </td>
  </tr>
  <tr>
    <td align="center" width="33"></td>
    <td width="751" colspan="2" align="left">    
      <!--名字，连接，定位的页面，图片---->
      <SCRIPT>
        USETEXTLINKS = 1
        level_0 = gFld("", "","","images/skin1/menu/asset.gif")    
<%
   int i =0;
   int iDLID = 0;
   int iCompany = 0;
   sPicture = "" + OlMessageControl.IMAGE_PATH + "/online_i2.gif";    
   while (iterUser.hasNext()) {
     sDLID = (String)iterUser.next();	
     //判断是否同一公司
     iDLID = SzConvert.toInt(sDLID);
     iCompany = SzUserHelp.getCompanyID(iDLID);
     //System.out.println(szCOMPANY_SESSION + " == " + iCompany);
     if (!szCOMPANY_SESSION.equals("" + iCompany)) {
    	 continue;
     }
     //获得该用户的详细信息
     sName = SzUserHelp.getLoginName(iDLID);
     //输出本用户姓名
     i ++;
%>
		level_<%=i%> = insFld(level_0, gFld("<%=sName%>", "<%=sDLID%>","_win","<%=sPicture%>"))
<%     
   }

%>
      </SCRIPT>
<SCRIPT>
    initializeDocument();
    
    function SendMessageWin(vJSDLID) {
		var vUrl = "message/send.jsp?OPERATOR=send&JSDLID=" + vJSDLID;
    	window.open(vUrl,"","status=yes,height=500,width=600,top=100,left=100");    
  	}    
	//查看信息
    function ReceiveMessageWin(vJSID) {
    	var vUrl = "message/receive.jsp?refresh=true&OPERATOR=receive&KEY=" + vJSID;
	  	childWin = window.open(vUrl,"","status=yes,height=500,width=600,top=100,left=100");  
    }    	
</SCRIPT>
    </td>
  </tr>
</table>
<script language="javascript">
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	var checkresult=null; 
	var vOnlineCount_OLD = "<%=iOnlineCount %>";
	
	function CheckMessage() { 
		xmlhttp.open("POST", "message/refresh_action.jsp", false); 
		//xmlhttp.onreadystatechange = updatePage; 
		xmlhttp.send(null); 

		var response = xmlhttp.responseText;
		var vCount = "0";
		var vFirst = "0";
		var vOnlineCount = "0";
		var vAllCount = "0";
		var v1 = response.indexOf("SzOnlineCountBegin");
		var v2 = response.indexOf("SzOnlineCountEnd");
		
		if (v1 >=0 && v2>v1) {
			vOnlineCount = response.substring(v1 + 18, v2);
			if (vOnlineCount != vOnlineCount_OLD) {
				document.location.reload();
			}				
		}
		
		var v3 = response.indexOf("SzAllCountBegin");
		var v4 = response.indexOf("SzAllCountEnd");
		if (v3 >=0 && v4>v3) {
			vAllCount = response.substring(v3 + 15, v4);
		}

		
		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 class='img2' border='0' src='../images/share/online_m.gif'>"
    	           + "</a>"		    	   
				   + "未收信息[<b>" + vCount + "</b>]";

		} else {
		    divAlert.innerHTML = "<img class='img2' border='0' src='../images/share/online_i.gif'>未收信息[0]";
		}
		divAlert.innerHTML += " 总人数[" + vAllCount + "],在线人数[" + vOnlineCount + "]";
		xmlhttp.abort();
	} 
	
	window.setInterval('CheckMessage()',5000);
</script>

</body>
</HTML> 
