<%@ Page Language="C#" MasterPageFile="~/home/main.Master" AutoEventWireup="true" CodeBehind="newMsg.aspx.cs" Inherits="ZYDN.Web.home.newMsg" Title="写信" %>
<%@ MasterType VirtualPath="~/home/main.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script language="javascript" type="text/javascript">
    var id=readPar(location.href,"id");
    if (id!=null&id!=""){
        var objAjax=new JAjax();
        var objResponse=new JHttpResponse();
	    objResponse.write("id",id);	
        var out=objAjax.getText("post","../webServer.aspx?type=readMsg",objResponse,null);
        //alert(out);
        out=out.split(c1);
        
      //  $("msgTitle").value="re:"+out[0];
        var EditContent="<div style='width:90%;border: 1px solid #800000; background-color: #FFFFCC'>"+ out[3].replace("script","")+"</div>"
        
    }
  
    </script>
<div class="rTop_1"> </div>

<div class="rTop_2">
 <div class="topOptionList" style="width:100%;">
            <div style="width: 5px; float: left;"></div>
            <div  class="optionCar_1"> <a href="listInMsg.aspx">收件箱</a></div> 
            <div class="optionCar_1"> <a href="listFromMsg.aspx">发件箱</a> </div>
            <div  class="optionCar"> <a href="newMsg.aspx">写信</a></div>
 </div>
 <div class="topOptionListBody">
        <table id="editJob" name="editJob" width="100%">
            <tr>
                <td valign="top">
                    <form id="form1" name="form1">
                        <table>
                            <tr>
                                <td >
                                    主 &nbsp; &nbsp;题:
                                    <input title="主题" isv="1" notnull="1" max="100" maxlength="100" id="msgTitle" name="msgTitle"
                                        type="text" style="width: 500px;" />
                                </td>
                            </tr>
                            <tr>
                                <td >
                                    收信人:
                                    <input title="收信人" isv="1" notnull="1" max="100" maxlength="100" id="toUser" name="toUser"
                                        type="text" style="width: 500px;" /><input type="button" value="选择" onclick="selectUser()" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div id="editTextDiv" style="height: 450px; width: 650px">
                                        <iframe src="" id="editTxt" name="editTxt" style="width: 100%; height: 100%" marginwidth="0"
                                            marginheight="0" align="top" scrolling="no" frameborder="0"></iframe>
                                    </div>
                                    <input title="内容" isv="1" usehtml="1" notnull="1" max="50000" maxlength="100" type="hidden"
                                        id="T_content" name="T_content" />
                                </td>
                            </tr>
                            <tr>
                                <td align="center" style="text-align: center;">
                                    <input onclick="ok()" type="button" value="提交" />
                                </td>
                            </tr>
                        </table>
                    </form>
                </td>
            </tr>
        </table>
   
</div>
       </div>
       <div class="rTop_3">
       </div>

    <script language="javascript" type="text/javascript">
    
    var toUserName=readPar(location.href,"user");

    if (toUserName!="" & toUserName!=null){
		
        $("toUser").value =toUserName.replace(" ","");
    }
    
    
        if (id!=null & id!=""){
         $("msgTitle").value="re:"+out[0];
         $("toUser").value=out[1];
        }
        $("editTxt").src="../system/editor/Editor.htm";
        
        function selectUser(){
            var username=openSelectUser("all","../system/");
            var obj=$("toUser");
            if (username==null){return;}
            obj.value=username;
        }
        
        function ok(){
            $("T_content").value=editTxt.GetContent();
            var v=new validate();
		    v.form=document.getElementById("form1");
		  
		    if (!v.start()){  //验证必填项
		        return ;
		    }
		    
		    var title=$("msgTitle").value;
		    var content=$("T_content").value;
		    var toUser=$("toUser").value
		    
		    var objAjax=new JAjax();
		    var objResponse=new JHttpResponse();
	    	objResponse.write("title",title);
	    	objResponse.write("content",content);
	    	objResponse.write("toUser",toUser);	
	    	var out=objAjax.getText("post","../webServer.aspx?type=saveMsg",objResponse,null);
	    	out=out.split(c1);
	    	if (out.length<1){
	    	     alert(erStr(out.toString()));
	    	     return;
	    	}
	    	
	    	if (out[0]==""){
	    	    alert("你发送给" +out[1]+"的站内短信,已成功发送")
	    	   location.href= "listFromMsg.aspx?menuindex=1";
	    	    return;
	    	}
	    	
	    	
	    	if (out[0]!="" & out[1]==""){
	    	
	    	
	    	        alert("用户" +out[0]+"未找到");
	    	        return;
	    	}
	    	if (out[0]!="" & out[1]!=""){
	    	    alert("用户" +out[0]+"未找到\n\n你给"+out[1]+"发送的站内短信,已成功发送");
	    	}

        
        }
        
   var tomsg=readPar(null,"user");
    if (tomsg!=null){
        $("toUser").value=tomsg
    }
    </script>

</asp:Content>
