<%@ page import="java.util.*"%>
<%@ page import="java.util.Vector"%>
<%@include file="Common.jsp" %>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<meta http-equiv="refresh" content="5">
<body bgcolor="#FFF7DD">
<%
if(session.getAttribute("load")!=null){
int startAt=Integer.parseInt(session.getAttribute("load").toString());
Calendar ca = Calendar.getInstance();
int m=ca.get(Calendar.MINUTE);
getServletContext().setAttribute(session.getAttribute("username").toString(),Integer.toString(m));
Vector tempVector=(Vector)getServletContext().getAttribute("chatmsg");
if(tempVector!=null){
session.setAttribute("load",Integer.toString(tempVector.size()));
if(startAt>tempVector.size()){
	startAt=startAt-maxMessage+lessMessage-1;
	}
out.println("<script language=\"JavaScript\" type=\"text/JavaScript\">");
out.println("parent.mainFrame.document.body.style.backgroundColor='#FFF7DD';");
//String msgToClient=new String("");
for(int i=startAt;i<=tempVector.size()-1;i++){
//msgToClient=msgToClient+"<table style='word-break:break-all;'><tr><td>";
//msgToClient=msgToClient+tempVector.elementAt(i).toString();
//msgToClient=msgToClient+"</td></tr></table>";
out.println("parent.mainFrame.document.write(\"<table style='word-break:break-all;font-size: 16px'><tr><td>\");");
out.println("parent.mainFrame.document.write(\""+tempVector.elementAt(i).toString()+"\");");
out.println("parent.mainFrame.document.write(\"</td></tr></table>\");");
}
//out.println("parent.mainFrame.document.write(\""+msgToClient+"\");");
//out.println("parent.mainFrame.document.getElementById(\"m\").innerHTML=parent.mainFrame.document.getElementById(\"m\").innerHTML+"+"\""+msgToClient+"\");");
//out.println("parent.mainFrame.window.backgroundColor=\"#EDFFD9\";");
out.println("parent.mainFrame.window.scrollTo(0,parent.mainFrame.document.body.clientHeight + parent.mainFrame.document.body.scrollHeight);");
//out.println("parent.mainFrame.document.write(\"<link href='chat.css' rel='stylesheet' type='text/css'>\");");
out.println("</script>");
}
else{
	session.setAttribute("load","0");
}
}
%>
