jQuery(document).ready(function (af) {
    var ao = af("#smilies"),
        ad = af(".smiliecion");
    ad.click(function () {
        var a = af(this);
        if (!a.hasClass("selected")) {
            a.addClass("selected");
            ao.slideDown()
        } else {
            ad.removeClass("selected");
            ao.slideUp()
        }
    });
    af(document).click(function (a) {
        if (ad.hasClass("selected") && a.target) {
            ad.removeClass("selected");
            ao.slideUp()
        }
    });
    af("#smilies, .smiliecion").click(function (a) {
        if (ad.hasClass("selected")) {
            a.stopPropagation()
        }
    });
    var C = function (e) {
        var a;
        e = " " + e + " ";
        if (document.getElementById("comment") && document.getElementById("comment").type == "textarea") {
            a = document.getElementById("comment")
        } else {
            return false
        } if (document.selection) {
            a.focus();
            sel = document.selection.createRange();
            sel.text = e;
            a.focus()
        } else {
            if (a.selectionStart || a.selectionStart == "0") {
                var c = a.selectionStart;
                var d = a.selectionEnd;
                var b = d;
                a.value = a.value.substring(0, c) + e + a.value.substring(d, a.value.length);
                b += e.length;
                a.focus();
                a.selectionStart = b;
                a.selectionEnd = b
            } else {
                a.value += e;
                a.focus()
            }
        } if (ad.hasClass("selected")) {
            ad.removeClass("selected");
            ao.slideUp()
        }
    };
    af("#smilies a").click(function (a) {
        a.preventDefault();
        C(af(this).attr("data-smile"))
    });
	    af("#smiliemain-txt a").click(function (a) {
        a.preventDefault();
        C(af(this).attr("data-smile"))
    });
});

jQuery(document).ready(function (a) {
    if (0 < a("#comment_form").length) {
        var s = a("#comment_form"),
            k = mufeng.ajaxurl,
            t = k + "wp-admin/images/no.png",
            u = '<div id="loading"><img src="' + (k + "wp-admin/images/loading.gif") + '" style="vertical-align:-2px;" alt=""/> \u6b63\u5728\u63d0\u4ea4, \u8bf7\u7a0d\u5019...</div>',
            v = '"><img src="' + (k + "wp-admin/images/yes.png") + '" style="vertical-align:-2px;" alt=""/> \u63d0\u4ea4\u6210\u529f',
            i, d = 0,
            m = [],
            n = a("#cancel-comment-reply-link"),
            w = n.text(),
            f = a("#submit");
        f.attr("disabled", !1);
        $body = window.opera ? "CSS1Compat" == document.compatMode ? a("html") : a("body") : a("html,body");
        a("#author_error").append(u + '<div id="error">#</div>');
        a("#loading, #error").hide();
        a(".commentlist").length || a(".comments-container").before('<ol class="commentlist"></ol>');
        s.submit(function () {
            a("#loading").slideDown();
            f.attr("disabled", !0).fadeTo("slow", 0.5);
            i && a("#comment").$ter('<input type="text" name="edit_id" id="edit_id" value="' + i + '" style="display:none;" />');
            a.ajax({
                url: k,
                data: a(this).serialize() + "&action=mfthemes_ajax_comment",
                type: a(this).attr("method"),
                error: function (b) {
                    a("#loading").slideUp();
                    a("#error").slideDown().html('<img src="' + t + '" style="vertical-align:-2px;" alt=""/> ' + b.responseText);
                    setTimeout(function () {
                        f.attr("disabled", !1).fadeTo("slow", 1);
                        a("#error").slideUp()
                    }, 3E3)
                },
                success: function (b) {
                    a("#loading").hide();
                    m.push(a("#comment").val());
                    a("textarea").each(function () {
                        this.value = ""
                    });
                    var c = addComment,
                        g = c.I("cancel-comment-reply-link"),
                        e = c.I("wp-temp-form-div"),
                        h = c.I(c.respondId);
                    c.I("comment_post_ID");
                    var o = c.I("comment_parent").value;
                    new_htm = '" id="new_comm_' + d + '"></';
                    new_htm = "0" == o ? "<div " + new_htm + "div>" : '\n<ul class="children' + new_htm + "ul>";
                    ok_htm = '\n<span id="success_' + d + v;
                    ok_htm += "</span><span></span>\n";
                    "0" == o ? a(".commentlist").append(new_htm) : a("#respond").before(new_htm);
                    a("#new_comm_" + d).hide().append(b);
                    a("#new_comm_" + d + " li").append(ok_htm);
                    a("#new_comm_" + d).fadeIn(4E3);
                    a("#comments-number").text(parseInt(a("#comments-number").text()) + 1);
                    $body.animate({
                        scrollTop: a("#new_comm_" + d).offset().top - 200
                    }, 900);
                    p();
                    d++;
                    i = "";
                    a("*").remove("#edit_id");
                    g.style.display = "none";
                    g.onclick = null;
                    c.I("comment_parent").value = "0";
                    e && h && (e.parentNode.insertBefore(h, e), e.parentNode.removeChild(e))
                }
            });
            return !1
        });
        addComment = {
            moveForm: function (b, c, g, e, h) {
                var b = this.I(b),
                    d = this.I(g),
                    f = this.I("cancel-comment-reply-link"),
                    k = this.I("comment_parent"),
                    j = this.I("comment_post_ID");
                i && q();
                0 < m.length && h ? (this.I("comment").value = m[h], i = this.I("new_comm_" + h).innerHTML.match(/(comment-)(\d+)/)[2], $new_sucs = a("#success_" + h), $new_sucs.hide(), $new_comm = a("#new_comm_" + h), $new_comm.hide(), n.text("\u53d6\u6d88\u7f16\u8f91")) : n.text(w);
                this.respondId = g;
                e = e || !1;
                this.I("wp-temp-form-div") || (g = document.createElement("div"), g.id = "wp-temp-form-div", g.style.display = "none", d.parentNode.insertBefore(g, d));
                !b ? (temp = this.I("wp-temp-form-div"), this.I("comment_parent").value = "0", temp.parentNode.insertBefore(d, temp), temp.parentNode.removeChild(temp)) : b.parentNode.insertBefore(d, b.nextSibling);
                $body.animate({
                    scrollTop: a("#respond").offset().top - 180
                }, 400);
                j && e && (j.value = e);
                k.value = c;
                f.style.display = "";
                f.onclick = function () {
                    i && q();
                    var a = addComment,
                        b = a.I("wp-temp-form-div"),
                        c = a.I(a.respondId);
                    a.I("comment_parent").value = "0";
                    if (b && c) {
                        b.parentNode.insertBefore(c, b);
                        b.parentNode.removeChild(b)
                    }
                    this.style.display = "none";
                    this.onclick = null;
                    return false
                };
                try {
                    this.I("comment").focus()
                } catch (l) {}
                return !1
            },
            I: function (a) {
                return document.getElementById(a)
            }
        };
        var q = function () {
            $new_comm.show();
            $new_sucs.show();
            a("textarea").each(function () {
                this.value = ""
            });
            i = ""
        }, j = 10,
            x = f.val(),
            p = function () {
                0 < j ? (f.val(j), j--, setTimeout(p, 1E3)) : (f.val(x).attr("disabled", !1).fadeTo("slow", 0.5), j = 10)
            }
    }
    var l = a(".comments-container"),
        y = mufeng.postid,
        r = mufeng.ajaxurl,
        z = '<div style="padding-bottom:20px;"><img src="' + r + 'wp-content/themes/Arbitrary/images/loading.gif" style="vertical-align:-2px;">  \u6b63\u5728\u52a0\u8f7d\u4e2d, \u8bf7\u7a0d\u5019...</div>';
    l.on("click", ".comment-topnav a.page-numbers", function (b) {
        b.preventDefault();
        var b = a(this).attr("href"),
            c = 1;
        /comment-page-/i.test(b) ? c = b.split(/comment-page-/i)[1].split(/(\/|#|&).*$/)[0] : /cpage=/i.test(b) && (c = b.split(/cpage=/)[1].split(/(\/|#|&).*$/)[0]);
        a.ajax({
            url: r + "?action=mfthemes_ajax_pagenavi&post=" + y + "&page=" + c,
            beforeSend: function () {
                l.html(z)
            },
            error: function (a) {
                alert(a.responseText)
            },
            success: function (b) {
                l.html(b);
                a("body, html").animate({
                    scrollTop: l.offset().top - 50
                }, 1E3)
            }
        })
    });
});