function showNoticeMsgForm(b, d, a){//(b:the userId of your pokeing, d:the username of your pokeing,a:'ta' or '她' or '他')
    a = a != undefined ? a : "ta";
    var c = '<div id="chuodialog">					<p class="conTinge">' + d + " \u4e0a\u7ebf\u540e\u4f1a\u77e5\u9053\u4f60\u6233\u4e86" + a + '\u4e00\u4e0b</p>					<div><button type="button" onclick="noticeMsg(' + b + ",'" + escape(d) + '\')" class="btn w3">\u6233\u4e0b\u53bb</button> <button type="button" onclick="ye_dialog.close();" class="btn w2">\u53d6\u6d88</button></div>					</div>';
    ye_dialog.openHtml(c, "\u6233 " + d + " \u4e00\u4e0b", 420, 100);
    $("#chuoCommon a").click(function(){
        $("#chuoCommon").hide()
    });
    $("#chuoArr").click(function(){
        if ($("#chuoCommon").css("display") == "none") {
            $("#chuoCommon").show()
        }
        else {
            $("#chuoCommon").hide()
        }
    })
}

function noticeMsg(a, d){//(a:uId, d:uname)
    var b = "../leku_message/addMessageData.jsp";
    var c = getCookie("qiao");
    $.ajaxSetup({
        cache: false
    });
    $.getJSON(b, {
        r_userId: a,
        type: "1",
        cookie_m: c
    }, function(e){
        if (e.result == "success") {
            ye_msg.open("\u4f60\u6233\u4e86 " + unescape(d) + " \u4e00\u4e0b\u3002", 1, 1)
        }
        else {
            if (e.result == "fail") {
                ye_msg.open("\u6233\u4e00\u4e0b\u5931\u8d25\uff0c\u8bf7\u91cd\u65b0\u64cd\u4f5c\uff01", 1, 2)
            }
            else {
                if (e.result == "noLogin") {
                    ye_msg.open("\u8bf7\u5148\u767b\u5f55\u540e\u518d\u64cd\u4f5c\u3002", 1, 2)
                }
                else {
                    ye_msg.open("\u6570\u636e\u4f20\u8f93\u5f02\u5e38\uff0c\u8bf7\u91cd\u65b0\u64cd\u4f5c\uff01", 1, 2)
                }
            }
        }
    });
    ye_dialog.close()
}

function showSendMsgForm(a, c){//(a:uid, c:uname)
    var b = '<div style="padding:10px; width:400px;">					<div style="height:20px; line-height:20px; text-align:right;" id="textnumber">\u8fd8\u53ef\u4ee5\u8f93\u5165140\u5b57</div>					<textarea  name="status" id="status" onPropertyChange="if(this.value.length>140){this.value=this.value.substr(0,140)}" style="width:400px; height:150px; border:1px solid #666;"></textarea>					<div style="padding:10px 0; text-align:center;"><button type="button" onclick="addMessage(' + a + ')" class="btn w2">\u786e\u5b9a</button> <button type="button" onclick="ye_dialog.close();" class="btn w2">\u53d6\u6d88</button></div>';
    ye_dialog.openHtml(b, "\u7ed9 " + c + " \u5199\u7ad9\u5185\u4fe1", 420, 260);
    $("#status").keydown(function(){
        $("#textnumber").text("\u8fd8\u53ef\u4ee5\u8f93\u5165" + (140 - $(this).val().length) + "\u5b57")
    })
}

function addMessage(d){//(d:receiveUid)
    var c = document.getElementById("status").value;
    var a = "/k/inbox/ajax/inbox_ajax.php";
    var b = getCookie("qiao");
    $.ajaxSetup({
        cache: false
    });
    $.getJSON(a, {
    	aid: 'sendMessage',
        updateTextarea: c,
        receiveUid: d,
        cookie_m: b
    }, function(e){
        if (e.result == "success") {
            ye_msg.open("\u7ad9\u5185\u4fe1\u53d1\u9001\u6210\u529f\uff01", 1, 1)
        }
        else {
            if (e.result == "fail") {
                ye_msg.open("\u7ad9\u5185\u4fe1\u53d1\u9001\u5931\u8d25\uff0c\u8bf7\u91cd\u65b0\u64cd\u4f5c\uff01", 1, 2)
            }
            else {
                if (e.result == "noLogin") {
                    ye_msg.open("\u8bf7\u5148\u767b\u5f55\uff01", 1, 2)
                }
                else {
                    ye_msg.open("\u6570\u636e\u4f20\u8f93\u5f02\u5e38\uff0c\u8bf7\u91cd\u65b0\u64cd\u4f5c\uff01", 1 ,2)
                }
            }
        }
    });
    ye_dialog.close()
}

function chk_newMsg(){	
    $.ajaxSetup({
        cache: false
    });
    $.getJSON("/k/ajax/getSysMsgData.php", function(a){													
        if (a.msgNum > 0) {
            $("#span_newmsg").html('<img src="http://site.tongxueimg.com/v4/k/images/msg.gif" alt="\u65b0\u6d88\u606f" align="absmiddle" /> <a href="/login.php?aid=lekuAllPeople&from=message">\u4f60\u6709' + a.msgNum + "\u6761\u65b0\u4fe1\u606f</a> ");
            documentTitleTwinkler.twinkle("\u65b0\u4fe1\u606f[" + a.msgNum + "]")
        }
        else {
            if (a.msgNum == 0) {
                $("#span_newmsg").html("Hi! " + leku.userName)
            }
            else {
                if (a.noticeNum > 0) {
                    $("#span_newmsg").html('<img src="http://site.tongxueimg.com/v4/k/images/msg.gif" alt="\u65b0\u6d88\u606f" align="absmiddle" /> <a href="/login.php?aid=lekuAllPeople&from=message&label=lekuAsk">\u4f60\u6709' + a.noticeNum + "\u6761\u65b0\u901a\u77e5</a> ");
                    documentTitleTwinkler.twinkle("\u65b0\u901a\u77e5[" + a.noticeNum + "]")
                }
                else {
                    return
                }
            }
        }
    })
}

var documentTitleTwinkler = {
    documentTitle: document.title,
    twinkleCount: 0,
    twinkleWords: "",
    setTimeoutHandler: null,
    runTimeout: function(){
        document.title = (this.twinkleCount % 2 == 0 ? "\u25cf" : "\u25cb") + this.twinkleWords;
        if (this.twinkleCount++ <= 10) {
            this.setTimeoutHandler = window.setTimeout("documentTitleTwinkler.runTimeout()", this.speed)
        }
        else {
            document.title = this.documentTitle;
            this.twinkleCount = 0
        }
    },
    twinkle: function(b, a){//(msg polling, b:title, a:timeout)
        this.speed = a ? a : 500;
        this.twinkleWords = b;
        if (this.setTimeoutHandler) {
            clearTimeout(this.setTimeoutHandler)
        }
        this.runTimeout()
    }
};
function showBlockMsgForm(b, a){//(b:uid,a:'她' or '他' or maybe the uname of he(she))
    a = a != undefined ? a : "\u4ed6";
    var c = '<div style="text-align:left;padding:0 20px;">					<p>\u6254\u8fdb\u9ed1\u540d\u5355\u4e4b\u540e...</p><ul class="conTinge"><li>\u5982\u679c\u4f60\u5df2\u7ecf\u5173\u6ce8' + a + '\uff0c\u4f1a\u81ea\u52a8\u89e3\u9664\u5173\u7cfb\uff1b</li>					<li>\u4ed6\u4e5f\u4e0d\u80fd\u518d\u5173\u6ce8\u4f60\u6216\u8005\u505a\u5176\u4ed6\u9a9a\u6270\u4f60\u7684\u4e8b\u4e86\u3002</li></ul>					<div style="text-align:center;padding-top:15px;"><button type="button" onclick="addBlock(' + b + ')" class="input_button">\u6254\u9ed1\uff01</button> <button type="button" onclick="ye_dialog.close();" class="cancel_button">\u53d6\u6d88</button></div>					</div>';
    ye_dialog.openHtml(c, "\u4f60\u771f\u7684\u8981\u628a" + a + "\u6254\u8fdb\u9ed1\u540d\u5355\u4e48\uff1f", 400, 150);
    $("#chuoCommon a").click(function(){
        $("#chuoCommon").hide()
    });
    $("#chuoArr").click(function(){
        if ($("#chuoCommon").css("display") == "none") {
            $("#chuoCommon").show()
        }
        else {
            $("#chuoCommon").hide()
        }
    })
}

function addBlock(b){//(b:uid)
    var a = "/ajax/status/addBlockData.php";
    $.ajaxSetup({
        cache: false
    });
    $.getJSON(a, {
        blockUserId: b
    }, function(c){
        if (c.result == "success") {
            ye_msg.open("\u6254\u9ed1\u6210\u529f\uff01", 1, 1);
            window.setTimeout("window.location.reload()", 1000)
        }
        else {
            if (c.result == "fail") {
                ye_msg.open("\u6254\u9ed1\u5931\u8d25!", 1, 2)
            }
            else {
                if (c.result == "noLogin") {
                    ye_msg.open("\u8bf7\u5148\u767b\u5f55\u540e\u518d\u64cd\u4f5c\u3002", 1, 2)
                }
                else {
                    ye_msg.open("\u6254\u9ed1\u5931\u8d25!", 1, 2)
                }
            }
        }
    });
    ye_dialog.close()
};
