<%@ page contentType="text/html; charset=gb2312" %>
<%@ include file="../Common.jsp" %>
<jsp:useBean id="db" scope="page" class="chatweb.conn" />
<html>
<head>
<title>
write
</title>
<link href="../chat.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body bgcolor="#FFF7DD">
<%!
String writeto=null;
String title=null;
%>
<%
if(request.getMethod().toUpperCase().equals("POST")){
    String toUser=request.getParameter("receiver");
    String fromUser=session.getAttribute("username").toString();
    String ti=request.getParameter("ttitle");
    ti=new String(ti.replaceAll("<","&lt;"));
    ti=new String(ti.replaceAll(">","&gt;"));
    String content=request.getParameter("content");
    content=new String(content.replaceAll("<","&lt;"));
    content=new String(content.replaceAll(">","&gt;"));
    if(db.addMsg(fromUser,toUser,content,ti)){%>
		<script language="JavaScript" type="text/JavaScript">
		window.alert("信息发送成功");
		location.href="message.jsp";
		</script>
		<%}
	else{%>
	<script language="JavaScript" type="text/JavaScript">
	window.alert("发送失败，请检查接收方");
	</script>
	<%}
}
if(request.getMethod().toUpperCase().equals("GET")){
    writeto=getStr(request.getParameter("writeto"));
    title="Re: "+getStr(request.getParameter("title"));
}
if(writeto==null){
writeto=new String("");
title=new String("");
}
%>
<div align="center">
  <form name="form1" method="post" action="">
    <table width="80%" border="0" cellspacing="1" class="mytable">
      <tr bgcolor="#FFF7DD">
        <td nowrap>
          <div align="left">主题：</div></td>
        <td width="90%">
          <input name="ttitle" type="text" id="title" value="<%=title%>">
        </td>
      </tr>
      <tr bgcolor="#FFF7DD">
        <td nowrap>
          <div align="left">接收人：</div></td>
        <td>
          <input name="receiver" type="text" id="receiver" value="<%=writeto%>"></td>
      </tr>
      <tr bgcolor="#FFF7DD">
        <td nowrap>
          <div align="left">内容：</div></td>
        <td>
          <textarea name="content" cols="50" rows="6" id="content"></textarea></td>
      </tr>
      <tr bgcolor="#FFF7DD">
        <td colspan="2" nowrap>
          <div align="center">
            <input type="submit" name="Submit" value="提交">
            <input type="reset" name="Submit3" value="重置">
            <input name="Submit2" type="button" onClick="MM_goToURL('parent','message.jsp');return document.MM_returnValue" value="取消">
          </div></td>
      </tr>
    </table>
  </form>
</div>
</body>
</html>
