﻿
$(function() {

    $(_doc).bind("contextmenu", function() { return false; })

    $(_doc).keydown(function(event) {

        if (event.which == 86 && $.browser.mozilla) {
           
            $("#hidtArev").select();
            setTimeout(function() {
                $("#hidtArev").blur();
                insertHTML($("#hidtArev").val());
                $("#hidtArev").val("");
            }, 50);
        }

        if (event.ctrlKey && event.which == 86 && $.browser.msie) {
            insertHTML(window.clipboardData.getData("Text"));
            $(_doc.body).blur();
            setTimeout(function() { $(_doc.body).focus(); }, 50);
        }

    })

    //Chrome下
    _doc.body.onpaste = function(event) {
        if ($.browser.safari) {
            insertHTML(event.clipboardData.getData("Text"));
            event.preventDefault();
        }
    }



    $("#btnsave").click(function() {

    if (getNowMinuCount("review_play")) {
        var alerthtml = "<div style='color:#666666;font-size:12px;margin-left:60px;margin-top:40px;'>您的评价过快，请休息下，再评价，谢谢。</div><div style='margin-top:40px;margin-left:140px;cursor:pointer;' onclick='javascript:closeWindow(\"tgrz\");'><img src='/images/cloese.jpg'/></div>";
        showWindow('', alerthtml, '温馨提示', '', '350', '150', 'tgrz');
        return false;
    }
    
    
        var repvalues = _doc.body.innerHTML;
        var regd = /<img src=.*?\>/g; //验证图片l
        var objimg = repvalues.match(regd);
        var count = repvalues.length;
        if (objimg != null)
            count = repvalues.length - objimg.toString().replace(/,/g, '').length + objimg.length;

        if (count < 5 || count > 200) {
            alert("内容应为5到150个字符!");
            return false;
        }

        if (dUserid != "-1") {//已登陆
            if (count < 5 || count > 200) {
                alert("内容应为5到150个字符!");
            }
            else {
                if ($("#noreply").length != 0)
                    $("#noreply").remove();
                $("#loading2").show();
                $("#loading2").html("提交中...");
                $("#dvload").show();
                if (replyuserid != -1)//是否回复某人
                    repvalues = "回复@" + replyuserName + ":" + repvalues;
                var postData = { uid: dUserid, ucontent: repvalues, rID: r_rid, title: unescape($("#hidtitle").val()), pid: $("#hidpid").val(), uName: unescape($("#hidName").val()), pName: unescape($("#hidpName").val()), receid: $("#hiduid").val(), Trepuserid: replyuserid }

                $.post("/WebServe/userHand.ashx?usertype=10&round=" + (new Date()).getSeconds(), postData, function(datas) {

                    if (datas != "0") {
                        var jsonObj = eval("(" + datas + ")");
                        $("#loading2").html("已提交");
                        $("#dvload").hide();
                        pathul();
                        var dataContent = repvalues;
                        var html = "<div><div style='float:left; margin-top:30px; margin-left:10px'><a href='/user/" + jsonObj.userM_id + "'><img src='" + jsonObj.uFaci + "' style=' border:solid 2px #CCCCCC; width:35px; height:35px;'/></a>";
                        html += "</div><div style=' float:left;margin-top:25px; margin-left:20px; color:#666 '>";
                        html += "<div style='width: 520px;color:#000506'><div style='font-weight: bold; font-size: 14px; width:300px'><a href='/user/" + jsonObj.userM_id + "'>" + dUserName + "：</a></div><div style=' margin-top:10px;line-height: 20px;width:480px'>" + dataContent + "</div></div>";
                        html += "<div style='padding-top:15px;clear: both;'>" + jsonObj.datetime + "</div></div><div class='Clear'></div><div style='border-bottom:dashed 1px #ccc; height:20px;width:650px; overflow:hidden;'></div><br /> </div>";

                        if ($("#replycontent>div").size() > 9) {
                            $("#replycontent>div:first").remove();
                        }
                        if ($("#replycontent>div:last").size() != 0) {
                            $("#replycontent>div:last").after(html);
                        } else {
                            $("#replycontent").append(html);
                        }
                        _doc.body.innerHTML = "";
                    }
                })
            }

        }
        else {
            showlog("reply");

        }
    })

})


function ReplyReplace(replyContent) {
    var re = replyContent.replace(eval("/</g"), '&lt;');
    return re;
}


