<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="java.util.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.online.*" %>
<%@ page import="net.sz600.system.*" %>
<%@ 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">
</head>

<body>
<script language="javascript">
	/*
	var n = 100;
	var i = 0;
	if(self.moveBy) {
	  	self.resizeTo (350, 300);
		self.moveTo (screen.availWidth-355,screen.availHeight);
		for(i = n; i > 0; i--) {
			self.moveBy(0,-3);
		}
	}
	*/
	self.resizeTo (350, 300);
	//self.moveTo (screen.availWidth-355,screen.availHeight - 300);
	
	//接收全部信息
	function ReceiveAll() {
		//定位
		formUpdate.OPERATOR.value = "receiveAll";
		formUpdate.action = "control.jsp";
		formUpdate.submit();
	}
	
	//查看信息
    function ReceiveMessageWin(vJSID) {
    	var vUrl = "../message/receive.jsp?OPERATOR=receive&KEY=" + vJSID;
	  	childWin = window.open(vUrl,"","status=yes,height=500,width=600,top=100,left=100");
	  	//关闭自己
	  	//window.close();    
    }
    
    //暂停或者启动通知，重新登陆就启动通知！
    function PauseAlert(vOper) {
		//定位
		formUpdate.OPERATOR.value = vOper;
		formUpdate.action = "control.jsp";
		formUpdate.submit();
    }
    
    function MoreMessage() {
        //document.location.href.target = "szMainFrame";
        //document.location.href = "index_receive.jsp";  
        window.opener.top.frames["szMainFrame"].location.href  = "index_receive.jsp?MKID_SESSION=378";  
        //window.close();    
    }       
</script>

<%
  OlMessageControl messageControl = new OlMessageControl(); 
  int iCount = OlUserSession.getInstance().refresh(iDLID_SESSION);
  ArrayList list = (ArrayList)OlMessageControl.mapUserMessage.get(new Integer(iDLID_SESSION));
  Map mapMessage = OlMessageControl.mapMessage;
  String sTitle = "";
  String sTitle2= "";
%>
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <tr class="trClassTitle">
    <td align="left" colspan="2">
      你有<b>[<%=iCount%>]</b>条未接收的信息&nbsp;     
    </td>
  </tr>
<%
  int i =0;
  String strJSID = "";
  if (list != null) {
  	Iterator iter = list.iterator();
	Integer intJSID = null;
	StringBuffer sb = new StringBuffer("");
	
	while (iter.hasNext()) {
		intJSID = (Integer)iter.next();
		sb.append(",");
		sb.append(intJSID);		
		//获取对应的信息
		sTitle =(String)mapMessage.get(intJSID);
		//sTitle2 = SzConvert.trunc(sTitle, 18) + "..";
		sTitle2 = sTitle;
		i ++;
		if (i == 9) {
			break;
		}
%>
  <tr>
    <td width="20"><%=i%></td>
    <td align="left" title="<%=sTitle %>" width="95%"><a href="#" OnClick="javascript:ReceiveMessageWin(<%=intJSID%>);"><%=sTitle2%></a></td>
  </tr>
<%		
	}//while
	strJSID = sb.toString();
	sb = null;
	
	out.println(SzPageHelp.outIndexTableTr(i, 9, 2));		
  }//if
%>  
  <tr class="trClassTitle">
    <td align="right" colspan="2">
    &nbsp;
    </td>
  </tr>
</table>
<form name="formUpdate" method="post" ENCTYPE="multipart/form-data">
  <input type="hidden" name="OPERATOR" value="">
  <input type="hidden" name="JSID" value="<%=strJSID %>">  
</form>
<script language="javascript">
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	var checkresult=null; 

	function CheckMessage() { 
		xmlhttp.open("POST", "messageAlertAction.jsp", false);
		xmlhttp.send(null); 
		xmlhttp.abort();
		var response = xmlhttp.responseText;
		var vJSID = "0";
		var vIndex = response.indexOf("SzMessageJSID");		
		if (vIndex >=0) {
			var vIndex1 = response.indexOf("SzEnd");
		    vJSID = response.substring(vIndex + 13, vIndex1);
			//比较一下
			var vJSID_OLD = formUpdate.JSID.value;
			if (vJSID_OLD == vJSID) {
			} else {
				document.location.reload();
			}
		} else {

		}
	} 
	
	window.setInterval('CheckMessage()',5000);
</script>
</body>