<%@ Page Language="C#" MasterPageFile="~/webUser/MasterPage.master" AutoEventWireup="true"
    Inherits="webUser_newMsg" Title="Untitled Page" Codebehind="newMsg.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Content1" 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="maxTitle">
        写站内短信
    </div>
    <div style="width: 100%; border: 1px solid #b5d1e4;">
        <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: 600px">
                                        <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>

    <script language="javascript" type="text/javascript">
        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");
            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]+"发送的站内短信,已成功发送");
	    	}

        
        }
    </script>

</asp:Content>
