﻿var pWinMsg=null;

function NewMsg(){
    if (pWinMsg!=null){
        pWinMsg.show();
        return ;
    }
    
    jQuery.facebox("正在打开......");
    var url="./HTML/NewMsg.html";
    var options = {};
    
    var ajax = {
        url: url, type: 'GET', dataType: 'html', cache: false, 
        success: function(html) {
            html = jQuery(html);
            if (options.filter) html = jQuery(options.filter, html);
                   options.title='站内短信';
               pWinMsg=new Boxy(html, options);
            
            KE.init({
                id : 'NewMsg_Content',
                cssPath : './../Common/kindeditor-3.3.1/examples/index.css'
            });
            KE.create('NewMsg_Content');
            KE.util.setData('NewMsg_Content');
            jQuery.facebox.close();
        }
    };
    
    jQuery.each(['type', 'cache'], function() {
        if (this in options) {
            ajax[this] = options[this];
            delete options[this];
        }
    });
    
    jQuery.ajax(ajax);
}


function saveMsg(){
    
    if ($("#Name").val()==""){
        alert("请输入标题！");
        return ;
    }
    if ($("#ToUser").val()==""){
        alert("请输入收件人！");
        return ;
    }


    var strContent=KE.util.getData('NewMsg_Content');
    if (strContent==""){
        alert("请输入内容");
        return ;
    }
    
    $("#ButtonOK").attr("diable","diable");
    jQuery.facebox("正在提交......");
    
    $.post("SaveMsg.aspx", 
        {
            action: "post",
            Name: $("#Name").val(),
ToUser: $("#ToUser").val(),
            Content: strContent
        },
        function(data){
            jQuery.facebox(data+"<a href='javascript:Web_Refresh()'>刷新</a>");
            pWinMsg.hide();
        });
}
