﻿



(function () {
    var b = window.white_site_list || /http:\/\/movie\.Zhangxiu\.com\/sogou_search|http:\/\/audit\.Zhangxiu\.com|web2\.qq\.com/;
    if (self !== top && document.referrer.search(b) === -1) {
        top.location = self.location
    }
})();
Zhangxiu = new Object();
Zhangxiu.errdetail = ["", "未知错误", "文件过大", "信息不全", "域名错误", "分类错误", "用户错误", "权限不足", "没有文件", "保存文件错误", "不支持的文件格式", "超时", "文件格式有误", "", "添加文件出错", "已经达到容量上限", "不存在的相册", "删除失败", "错误的MP3文件", "有禁用的内容,请修改重试"];
var trace = function (b) {
    if (!/^http:\/\/(www|movie|music\.|book|Zhangxiu\.fm)/.test(location.href) && window.console && window.console.log) {
        console.log(b)
    }
};
var report = function (b) {
    $.get("/j/report?e=" + b)
};
Zhangxiu.EventMonitor = function () {
    this.listeners = new Object()
};
Zhangxiu.EventMonitor.prototype.broadcast = function (c, f, d) {
    var b = this.listeners[f];
    if (b != null) {
        for (var e in b) {
            b[e](c, d)
        }
    }
};
Zhangxiu.EventMonitor.prototype.subscribe = function (c, d) {
    var b = this.listeners[c];
    if (b) {
        b.push(d)
    } else {
        this.listeners[c] = [d]
    }
};
Zhangxiu.EventMonitor.prototype.unsubscribe = function (c, d) {
    var b = this.listener[c];
    if (b != null) {
        b = b.filter(function (g, f, e) {
            return g != d
        })
    }
};
var event_monitor = new Zhangxiu.EventMonitor();
function load_event_monitor(root) {
    var re = /a_(\w+)/;
    var fns = {};
    $(".j", root).each(function (i) {
        var m = re.exec(this.className);
        if (m) {
            var actionName = m[1],
            f = fns[actionName];
            if (!f) {
                f = eval("Zhangxiu.init_" + actionName);
                fns[actionName] = f
            }
            f && f(this)
        }
    })
}
Zhangxiu.prettify_form = function (b) {
    $("input:submit", b).each(function (d) {
        var c = $('<a href="#" class="butt"></a>').text($(this).val());
        c.click(function () {
            if (clean_tip()) {
                b.submit()
            }
            return false
        });
        $(this).hide().after(c)
    })
};
var get_form_fields = function (b) {
    var c = {};
    $(":input", b).each(function (e) {
        var d = this.name;
        if (this.type == "radio") {
            if (this.checked) {
                c[d] = this.value
            }
        } else {
            if (this.type == "checkbox") {
                if (this.checked) {
                    c[d] = this.value
                }
            } else {
                if (this.type == "submit") {
                    if (/selected/.test(this.className)) {
                        c[d] = this.value
                    }
                } else {
                    if (d) {
                        c[d] = this.value
                    }
                }
            }
        }
        if (/notnull/.test(this.className) && this.value == "") {
            $(this).prev().addClass("errnotnull");
            c.err = "notnull"
        }
    });
    return c
};
var remote_submit_json = function (f, e, c, g) {
    var d = get_form_fields(f);
    if (d.err != undefined) {
        return
    }
    $(":submit,:input", f).attr("disabled", c == false ? 0 : 1);
    var b = g || f.action;
    $.post_withck(b, d,
    function (h) {
        e(h)
    },
    "json")
};

Zhangxiu.init_closelink = function (b) {
    $('<a href="#">关闭</a>').appendTo($(b)).click(function () {
        window.close();
        return false
    })
};
function ext_links() {
    es = $(".entry-summary");
    es.each(function (c) {
        var b = $(es[c]).find("a");
        b.each(function (d) {
            b[d].target = "_blank"
        })
    })
}
Zhangxiu.init_confirm_link = function (f) {
    if (/recc/.test(f.name)) {
        var d = f.name.split("-");
        var e = $(f).attr("href").split("/");
        var b = e[0] != "http:" ? e[2] : e[4];
        var c = "/j/rec_comment";
        $(f).click(function () {
            var g = confirm("真的要删除?");
            if (g) {
                $.getJSON(c, {
                    rid: d[1],
                    del_comment: d[2]
                },
                function () {
                    $(f).parent().parent().parent().remove()
                })
            }
            return false
        })
    } else {
        if (/sayc/.test(f.name)) {
            var d = f.name.split("-");
            var e = $(f).attr("href").split("/");
            var b = e[0] != "http:" ? e[2] : e[4];
            var c = "/j/saying_comment";
            $(f).click(function () {
                var g = confirm("真的要删除?");
                if (g) {
                    $.getJSON(c, {
                        sid: d[1],
                        del_comment: d[2]
                    },
                    function () {
                        $(f).parent().parent().parent().remove()
                    })
                }
                return false
            })
        } else {
            $(f).click(function () {
                var g = f.title || $(f).text();
                return confirm("真的要" + g + "?")
            })
        }
    }
};
var populate_tag_btns = function (g, h, b, e) {
    if (b.length) {
        var c = $("<dl><dt>" + g + "</dt></dl>"),
        f = $("<dd></dd>");
        $.each(b,
        function (k, d) {
            var j = $('<span class="tagbtn"></span>').addClass(e[d.toLowerCase()] ? "rdact" : "gract").text(d);
            f.append(j).append(" &nbsp; ")
        });
        c.append(f);
        h.append(c)
    }
};

Zhangxiu.init_interest_form = function (b) {
    var k = $(b),
    d = {},
    e = {},
    h = $("#inp-share", b),
    n = true;
    if (k.data("bind") === "true") {
        return
    } else {
        k.data("bind", "true")
    }
    var j = function (o) {
        if (d[o]) {
            e[o] = true;
            $.each(d[o],
            function (q, p) {
                $(p).removeClass("gract").addClass("rdact")
            })
        }
    };
    var g = function (o) {
        if (d[o]) {
            delete e[o];
            $.each(d[o],
            function (q, p) {
                $(p).removeClass("rdact").addClass("gract")
            })
        }
    };
    var c = function () {
        var o = $.trim(b.tags.value.toLowerCase()).split(" "),
        p = {};
        $.each(o,
        function (r, q) {
            if (q != "") {
                j(q);
                p[q] = true
            }
        });
        for (t in e) {
            if (!p[t]) {
                g(t)
            }
        }
    };
    var l = function () {
        var o = $("#inp-private"),
        p = $("#inp-share"),
        q = $(".share-label");
        if (o.attr("checked") == true) {
            p.attr("checked", false);
            p.attr("disabled", "disabled");
            q.addClass("greyinput")
        } else {
            p.removeAttr("disabled");
            q.removeClass("greyinput");
            p.attr("checked", n)
        }
    };
    var f = function () {
        if (n == true) {
            n = false
        } else {
            n = true
        }
    };
    c();
    if ($(b).data("comment")) {
        b.comment.focus()
    } else {
        if ($("#foldcollect").val() == "U") {
            b.tags.focus()
        }
    }
    $(b).submit(function () {
        var o = $(this).attr("action").split("/")[3];
        remote_submit_json(this,
        function (r) { },
        false);
        $("#submits").hide().after('<span class="m" id="saving">正在保存...</span>');
        refine_dialog();
        return false
    });
    if (h) {
        $("#inp-private").click(l);
        $("#inp-share").click(f)
    }
    $(b.cancel).click(function () {
        var o = $(b).attr("action").split("/")[3];
        $("#collect_form_" + o).html("")
    });
    $(".tagbtn", b).each(function (p) {
        var o = $(this).text().toLowerCase();
        if (d[o]) {
            d[o].push(this)
        } else {
            d[o] = [this]
        }
    }).click(function () {
        var o = $(this).text();
        var q = $.trim(b.tags.value).split(" "),
        u = false,
        p = o.toLowerCase(),
        r;
        q = $.grep(q,
        function (w, v) {
            if (w.toLowerCase() == p) {
                g(p);
                u = true;
                return false
            } else {
                return true
            }
        });
        if (!u) {
            q.push(o);
            j(p)
        }
        var s = q.join(" ");
        b.tags.value = (s.length > 1) ? s + " " : s;
        b.tags.focus()
    });
    $(b.tags).keyup(c)
};
Zhangxiu.init_interest_form = function (b) {
    var k = $(b),
    d = {},
    e = {},
    h = $("#inp-share", b),
    n = true;
    if (k.data("bind") === "true") {
        return
    } else {
        k.data("bind", "true")
    }
    var j = function (o) {
        if (d[o]) {
            e[o] = true;
            $.each(d[o],
            function (q, p) {
                $(p).removeClass("gract").addClass("rdact")
            })
        }
    };
    var g = function (o) {
        if (d[o]) {
            delete e[o];
            $.each(d[o],
            function (q, p) {
                $(p).removeClass("rdact").addClass("gract")
            })
        }
    };
    var c = function () {
        var o = $.trim(b.tags.value.toLowerCase()).split(" "),
        p = {};
        $.each(o,
        function (r, q) {
            if (q != "") {
                j(q);
                p[q] = true
            }
        });
        for (t in e) {
            if (!p[t]) {
                g(t)
            }
        }
    };
    var l = function () {
        var o = $("#inp-private"),
        p = $("#inp-share"),
        q = $(".share-label");
        if (o.attr("checked") == true) {
            p.attr("checked", false);
            p.attr("disabled", "disabled");
            q.addClass("greyinput")
        } else {
            p.removeAttr("disabled");
            q.removeClass("greyinput");
            p.attr("checked", n)
        }
    };
    var f = function () {
        if (n == true) {
            n = false
        } else {
            n = true
        }
    };
    c();
    if ($(b).data("comment")) {
        b.comment.focus()
    } else {
        if ($("#foldcollect").val() == "U") {
            b.tags.focus()
        }
    }
    $(b).submit(function () {
        var o = $(this).attr("action").split("/")[3];
        remote_submit_json(this,
        function (r) {

            if ($(b).data("reload")) {
                if (/subject\/\d+\/comments/.test(location.href)) {
                    location.href = location.href.split("?sort")[0] + "?sort=time"
                } else {
                    if (/people\/[^\/]+\/(edittag|all|do|wish|collect)/.test(location.href)) {
                        location.href = location.href
                    } else {
                        location.href = location.href.split("?")[0]
                    }
                }
            } else {
                close_dialog()
            }
        },
        false);
        $("#submits").hide().after('<span class="m" id="saving">正在保存...</span>');
        refine_dialog();
        return false
    });
    if (h) {
        $("#inp-private").click(l);
        $("#inp-share").click(f)
    }
    $(b.cancel).click(function () {
        var o = $(b).attr("action").split("/")[3];
        $("#collect_form_" + o).html("")
    });
    $(".tagbtn", b).each(function (p) {
        var o = $(this).text().toLowerCase();
        if (d[o]) {
            d[o].push(this)
        } else {
            d[o] = [this]
        }
    }).click(function () {
        var o = $(this).text();
        var q = $.trim(b.tags.value).split(" "),
        u = false,
        p = o.toLowerCase(),
        r;
        q = $.grep(q,
        function (w, v) {
            if (w.toLowerCase() == p) {
                g(p);
                u = true;
                return false
            } else {
                return true
            }
        });
        if (!u) {
            q.push(o);
            j(p)
        }
        var s = q.join(" ");
        b.tags.value = (s.length > 1) ? s + " " : s;
        b.tags.focus()
    });
    $(b.tags).keyup(c)
};
Zhangxiu.init_stars = function (e) {
    var b = {
        1: "很差",
        2: "较差",
        3: "还行",
        4: "推荐",
        5: "力荐"
    },
    g = $("#n_rating", e),
    c = $("#stars img", e),
    d = function (f) {
        var h = g.val() || 0;
        c.each(function (l) {
            var k = this.src.replace(/\w*\.gif$/, ((l < f) ? "sth" : ((l < h) ? "st" : "nst")) + ".gif");
            this.src = k
        });
        if (f) {
            $("#rateword", e).text(b[f])
        } else {
            $("#rateword", e).text(h ? b[h] : "")
        }
    };
    c.hover(function () {
        d(this.id.charAt(4))
    },
    function () {
        d(0)
    });
    if (g.attr("name")) {
        c.click(function () {
            var f = this.id.charAt(4);
            g.val(f);
            d(f)
        })
    }
    d()
};
Zhangxiu.init_show_login = function (b) {
    $(b).click(function () {
        return pop_win.load("/ajax/loginform/")
    })
};
Zhangxiu.init_show_signup_table = function (b) {
    $(b).click(function () {
        event_id = window.location.href.split("/")[4];
        return pop_win.load("/j/event/" + event_id + "/signup")
    })
};
var set_cookie = function (f, e) {
    e = e || 30;
    var c = new Date();
    c.setTime(c.getTime() + (e * 24 * 60 * 60 * 1000));
    var b = "; expires=" + c.toGMTString();
    for (var d in f) {
        document.cookie = d + "=" + f[d] + b + "; path=/"
    }
};
function get_cookie(d) {
    var f = d + "=";
    var b = document.cookie.split(";");
    for (var e = 0; e < b.length; e++) {
        var g = b[e];
        while (g.charAt(0) == " ") {
            g = g.substring(1, g.length)
        }
        if (g.indexOf(f) == 0) {
            return g.substring(f.length, g.length).replace(/\"/g, "")
        }
    }
    return null
}
function clean_tip() {
    var b = $("#page_focus")[0];
    return b && b.value != b.title
}
Zhangxiu.init_submit_link = function (b) {
    $(b).click(function () {
        $(b).parent().submit()
    })
};
var nowmenu = null;
var hidemenu = function (b) {
    b.find(".down").css("display", "inline");
    b.find(".up").hide();
    b.next().hide();
    nowmenu = null;
    $("body").unbind("mousedown")
};
var openmenu = function (b) {
    if (nowmenu != null) {
        hidemenu(nowmenu)
    }
    b.find(".up").css("display", "inline");
    b.find(".down").hide();
    b.next().show();
    nowmenu = b;
    $("body").mousedown(function () {
        if (b.parent().attr("rel") != "on") {
            hidemenu(b)
        }
    })
};
$(function () {
    $("a", "#dsearch").each(function () {
        $(this).click(function () {
            if (!clean_tip()) {
                return true
            }
            urls = $(this).attr("href").split("?cat=");
            $("#ssform").attr("action", urls[0]);
            if (urls[1] != undefined) {
                $('<input type="hidden" name="cat" value="' + urls[1] + '" />').appendTo($("#ssform"))
            }
            $("#ssform").submit();
            return false
        })
    });
    $(".arrow").click(function () {
        if ($(this).find(".up").is(":hidden")) {
            openmenu($(this))
        } else {
            hidemenu($(this))
        }
        this.blur()
    });
    $(".arrow").parent().hover(function () {
        $(this).attr("rel", "on")
    },
    function () {
        $(this).attr("rel", "off")
    });
    if ($.suggest) {
        $("#page_focus").suggest("/j/subject_suggest", {
            onSelect: function () {
                $(this).parents("form").append('<span><input name="add" value="1" type="hidden"/></span>').submit()
            }
        })
    }
    var b = get_cookie("report");
    if (b) {
        set_cookie({
            report: ""
        },
        0);
        $.get("/stat.html?" + b)
    }
    $(":submit").each(function () {
        if ($(this).val() == "加上去") {
            $(this).click(function () {
                var c = this;
                setTimeout(function () {
                    c.disabled = 1
                },
                0)
            })
        }
    });
    if ($.browser.msie && $.browser.version == "6.0") {
        $("form.miniform > :submit").hover(function () {
            $(this).addClass("hover")
        },
        function () {
            $(this).removeClass("hover")
        })
    }
});
var show_dialog = function (c, b) {
    if ($("#dialog").length) {
        return
    }
    $("body").prepend('<div id="overlay"></div><div id="dialog" style="width:' + (b || 550) + 'px;"></div>');
    if (c != null) {
        $("#dialog").html(c)
    } else {
        $("#dialog").html("<div class='loadpop'>正在载入，请稍候...</div>")
    }
    set_overlay()
};
var set_overlay = function () {
    var d = ($.browser.msie ? -2 : 16),
    c = $("#dialog")[0],
    b = c.offsetWidth,
    e = (document.body.offsetWidth - b) / 2;
    $("#overlay").css({
        height: c.offsetHeight + d,
        width: b + 16,
        left: e + 5 + "px"
        
    });
    c.style.left = e + "px"
};
var close_dialog = function () {
    $("#overlay").unbind("click");
    $("#dialog,#overlay,.bgi").remove();
    if (typeof document.body.style.maxHeight == "undefined") {
        $("body", "html").css({
            height: "auto",
            width: "auto"
        });
        $("html").css("overflow", "")
    }
    document.onkeydown = "";
    return false
};
var refine_dialog = function () {
    if (!$("#dialog").length) {
        return
    }
    var b = navigator.userAgent.toLowerCase();
    var c = 0.5 * ($.viewport_size()[1] - $("#dialog")[0].offsetHeight);
////    $("#dialog,#overlay").css("top", c);
    $("#dialog,#overlay").css("_top", c);
    set_overlay()
};
$.viewport_size = function () {
    var b = [0, 0];
    if (typeof window.innerWidth != "undefined") {
        b = [window.innerWidth, window.innerHeight]
    } else {
        if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth != 0) {
            b = [document.documentElement.clientWidth, document.documentElement.clientHeight]
        } else {
            b = [document.body.clientWidth, document.body.clientHeight]
        }
    }
    return b
};
Zhangxiu.init_collect_btn = function (b) {
    $(b).click(function () {
        if ($("#hiddendialog").length) {
            show_dialog($("#hiddendialog").html());
            load_event_monitor($("#dialog"))
        } else {
            show_dialog(null);
            var e = $(this).attr("name").split("-"),
            g = e[0],
            c = e[1],
            h = e[2],
            f = e[3],
            d = "/ajax/show/" + c + "/favorite/?cmd=get&" + (h ? "interest=" + h : "") + (f ? "&rating=" + f : "") + (g == "cbtn" ? "&cmt=1" : "");
            $.getJSON(d,
            function (j) {
                if ($("#dialog").length) {
                    var n = $("<div></div>").html(j.html);
                    var v = j.tags;
                    var q = v.join(" ");
                    $("input[name=tags]", n).val((q.length > 1) ? q + " " : q);
                    var l = {};
                    $.each(v,
                    function (w, r) {
                        l[r.toLowerCase()] = true
                    });
                    populate_tag_btns("我的标签:", $("#mytags", n), j.my_tags, l);
                    populate_tag_btns("常用标签:", $("#populartags", n), j.popular_tags, l);
                    if (g == "pbtn" || g == "cbtn") {
                        $("form", n).data("reload", 1)
                    }
                    $("#dialog").html(n);
                    $("#showtags").click(function () {
                        if ($("#advtags").is(":hidden")) {
                            $(this).html("缩起 ▲");
                            $("#advtags").show();
                            $("#foldcollect").val("U")
                        } else {
                            $(this).html($(this).attr("rel"));
                            $("#advtags").hide();
                            $("#foldcollect").val("F")
                        }
                        $(this).blur();
                        refine_dialog()
                    });
                    var k = $("input[name=interest]"),
                    s = $(".rate_stars"),
                    p = function () {
                        if (k[0].checked) {
                            s.hide()
                        } else {
                            s.show()
                        }
                        refine_dialog()
                    };
                    k.click(p);
                    p();
                    if ($("#left_n").length) {
                        var o = $("#left_n").text();
                        llen = (o.match(/\d+/i) == o) ? o : 140;
                        $("#comment").display_limit(llen, $("#left_n"))
                    }
                    if (g == "cbtn") {
                        var u = $("h2", "#dialog");
                        u.text(u.text().replace("修改", "写短评"));
                        if (!k[0].checked && k[1]) {
                            k[1].checked = true
                        }
                        $("form", "#dialog").data("comment", 1)
                    }
                    load_event_monitor(n);
                    $.fn.movieDisplayLimit = function (w, z, r) {
                        function x(B, C, A) {
                            C.text(A - Math.ceil(B.val().replace(/[^\x00-\xff]/g, "**").length / 2))
                        }
                        function y(C) {
                            var D = C.val().match(/[^\x00-\xff]/ig),
                            A = !D ? 0 : D.length,
                            B = C.val().length - A;
                            w.attr("maxlength", 140 + Math.ceil(B / 2))
                        }
                        x(w, z, r);
                        $(this).keyup(function () {
                            x($(this), z, r);
                            y($(this));
                            return false
                        })
                    };
                    if ($("div#dialog form.movie-sns").length) {
                        $("textarea#comment").unbind().movieDisplayLimit($("textarea#comment"), $("span#left_n"), 140)
                    }
                }
            })
        }
        return false
    })
};
$.ajax_withck = function (b) {
    if (b.type == "POST") {
        b.data = $.extend(b.data || {},
        {
            ck: get_cookie("ck")
        })
    }
    return $.ajax(b)
};
$.postJSON_withck = function (b, c, d) {
    $.post_withck(b, c, d, "json")
};
$.post_withck = function (b, d, e, c) {
    if ($.isFunction(d)) {
        c = e;
        e = d;
        d = {}
    }
    return $.ajax({
        type: "POST",
        url: b,
        data: $.extend(d, {
            ck: get_cookie("ck")
        }),
        success: e,
        dataType: c || "text"
    })
};
(function () {
    var b = {};
    $.tmpl = function (e, d) {
        var c = b[e] = b[e] || new Function("obj", "var p=[];with(obj){p.push('" + e.replace(/[\r\t\n]/g, " ").replace(/'(?=[^%]*%})/g, "\t").split("'").join("\\'").split("\t").join("'").replace(/{%=(.+?)%}/g, "',$1,'").split("{%").join("');").split("%}").join("p.push('") + "');}return p.join('');");
        return c(d)
    }
})();
String.prototype.escapeHTML = function () {
    return this.replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;")
};
jQuery.fn.extend({
    pos: function () {
        var c = this[0];
        if (c.offsetParent) {
            for (var d = 0, b = 0; c.offsetParent; c = c.offsetParent) {
                d += c.offsetLeft;
                b += c.offsetTop
            }
            return {
                x: d,
                y: b
            }
        } else {
            return {
                x: c.x,
                y: c.y
            }
        }
    },
    chop: function (g, b) {
        var d = [],
        c = [];
        for (var e = 0, f = this.length; e < f; e++) {
            if (!b != !g(this[e], e)) {
                d.push(this[e])
            } else {
                c.push(this[e])
            }
        }
        return [d, c]
    },
    sum: function (c, e) {
        var b = this.length,
        d = zero = e ? "" : 0;
        while (b) {
            d += this[--b][c] + (b && e || zero)
        }
        return d
    },
    set_len_limit: function (c) {
        var d = this.find(":submit:first");
        var e = d.attr("value");
        var b = function () {
            if (this.value && this.value.length > c) {
                d.attr("disabled", 1).attr("value", "字数不能超过" + c + "字")
            } else {
                d.attr("disabled", 0).attr("value", e)
            }
        };
        $("textarea", this).focus(b).blur(b).keydown(b).keyup(b)
    },
    display_limit: function (b, g) {
        var c = this,
        e, d = function (h) {
            var f = c.val();
            if (f == e) {
                return
            }
            if (f.length >= b) {
                c.val(f.substring(0, b))
            }
            g.text(b - c.val().length);
            e = c.val()
        };
        this.keyup(d);
        d()
    },
    set_caret: function () {
        if (!$.browser.msie) {
            return
        }
        var b = function () {
            this.p = document.selection.createRange().duplicate()
        };
        this.click(b).select(b).keyup(b)
    },
    insert_caret: function (c) {
        var k = this[0];
        if (document.all && k.createTextRange && k.p) {
            var j = k.p;
            j.text = j.text.charAt(j.text.length - 1) == "" ? c + "" : c
        } else {
            if (k.setSelectionRange) {
                var f = k.selectionStart;
                var h = k.selectionEnd;
                var g = k.value.substring(0, f);
                var d = k.value.substring(h);
                k.value = g + c + d;
                k.focus();
                var b = c.length;
                k.setSelectionRange(f + b, f + b);
                k.blur()
            } else {
                k.value += c
            }
        }
    },
    get_sel: function () {
        var b = this[0];
        return document.all && b.createTextRange && b.p ? b.p.text : b.setSelectionRange ? b.value.substring(b.selectionStart, b.selectionEnd) : ""
    },
    blur_hide: function () {
        var c = this,
        b = function () {
            return false
        };
        c.mousedown(b);
        $(document.body).mousedown(function () {
            c.hide().unbind("mousedown", b);
            $(document.body).unbind("mousedown", arguments.callee)
        });
        return this
    },
    yellow_fade: function () {
        var b = 0,
        d = 1,
        c = this;
        function e() {
            c.css({
                backgroundColor: "rgb(100%,100%," + b + "%)"
            });
            b += d;
            d += 0.5;
            if (b <= 100) {
                setTimeout(e, 35)
            } else {
                c.css({
                    backgroundColor: ""
                })
            }
        }
        e();
        return this
    },
    hover_fold: function (d) {
        var b = {
            folder: [1, 3],
            unfolder: [0, 2]
        },
        c = function (e, f) {
            return function () {
                $("img", e).attr("src", "/pics/arrow" + f + ".gif")
            }
        };
        return this.hover(c(this, b[d][0]), c(this, b[d][1]))
    },
    multiselect: function (d) {
        var g = function () {
            return true
        },
        f = d.onselect || g,
        e = d.onremove || g,
        c = d.onchange || g,
        h = d.selclass || "sel",
        b = d.values || [];
        return this.click(function () {
            var k = /id(\d*)/.exec(this.className)[1],
            j = $.inArray(k, b);
            if (j != -1) {
                if (!e(this)) {
                    return
                }
                b.splice(j, 1);
                $(this).removeClass(h)
            } else {
                if (!f(this)) {
                    return
                }
                b.push(k);
                $(this).addClass(h)
            }
            c(b);
            return false
        })
    },
    initDataInput: function () {
        var b = $(this);
        if (!b.val() || b.val() === b.attr("title")) {
            b.addClass("color-lightgray");
            b.val(b.attr("title"))
        }
        b.focus(function () {
            b.removeClass("color-lightgray");
            if (b.val() === b.attr("title")) {
                b.val("")
            }
        }).blur(function () {
            if (!b.val()) {
                b.addClass("color-lightgray");
                b.val(b.attr("title"))
            }
        })
    },
    setItemList: function (p) {
        var c = {},
        g = "",
        n = '<img class="gray-loader" src="/pics/spinner.gif" />',
        e = "/pics/spinner.gif",
        j = ".input-create",
        l = {
            keyup: function (q) {
                var o = q.target.value.replace(/ /g, "");
                if (q.keyCode === 13) {
                    p.create.callback(c, g, o, p.limit)
                }
            }
        },
        d = document.body,
        k = new Image(),
        f = {
            create: {
                title: "新分组",
                tips: "创建新分组"
            }
        },
        p = $.extend(f, p),
        b = '<span class="create-new">' + p.create.title + "</span>",
        h = '<input class="input-create" type="text" value="" title="' + p.create.tips + '" maxlength="' + p.create.maxLen + '" />';
        k.src = e;
        $(this).click(function (o) {
            o.stopPropagation();
            c = this;
            sglist.hide();
            g = $.isFunction(p.target) ? p.target(c) : p.target;
            sgarrow.removeClass(CSS_ARROW_SELECT);
            $(c).addClass(CSS_ARROW_SELECT);
            $(CSS_SET_GROUP_LIST, this).show();
            $(j).focus();
            if ($.browser.msie && $.browser.version !== "8.0") {
                sgarrow.css("z-index", "");
                $(this).css("z-index", 10)
            }
        });
        $(CSS_SET_GROUP_LIST).delegate("li:not('.last')", "click",
        function (w) {
            w.preventDefault();
            var v = w.target,
            q = this,
            u = v.type === "checkbox" ? true : false,
            o = $(this).children("input"),
            s = $(this).children("input").val(),
            r = (u && o.attr("checked") || !u && !o.attr("checked")) ? "addtotag" : "removefromtag";
            if (!$(CSS_LOADER, this).length) {
                o.hide().after(n)
            }
            p.callback(q, r, u, g, s)
        });
        $(d).click(function (o) {
            $(CSS_SET_GROUP_LIST, this).hide();
            $(c).removeClass(CSS_ARROW_SELECT);
            if (newGroupNum && newGroupNum < p.limit) {
                $(j).replaceWith(b)
            }
        });
        $(CSS_SET_GROUP_LIST).delegate(".create-new", "click",
        function () {
            $(this).replaceWith(h);
            $(j).focus()
        });
        $(CSS_SET_GROUP_LIST).delegate(j, "keyup",
        function (o) {
            if ($.isFunction(l[o.type])) {
                l[o.type].call(this, o)
            }
        })
    }
});
Zhangxiu.init_vote_article = function (c) {
    var b = $(c).next(),
    d = $(c).prev().val();
    e = $(c).prev().prev().val();
    $(c).click(function () {
        $.postJSON_withck("/ajax/vote/article/", {
            id: d, pkid: e
        },
        function (e) {
            if (e.count) {
                b.text(e.count)
            } else {
                alert("这篇文章你已经投过票了")
            }
        })
    })
};
Zhangxiu.init_vote_favorite = function (c) {
    var b = $(c).next(),
    d = $(c).prev().val();
    e = $(c).prev().prev().val();
    $(c).click(function () {
        $.postJSON_withck("/ajax/vote/favorite/", {
            id: d, pkid: e
        },
        function (e) {
            if (e.count) {
                b.text(e.count)
            } else {
                alert("这条短评你已经投过票了")
            }
        })
    })
};
$(function () {
    load_event_monitor(document)
});

/*---------------------------------------------------------------------------------------*/
(function () {
    var b =
	{
	};
    $.tmpl = function (e, d) {
        var c = b[e] = b[e] || new Function("obj", "var p=[];with(obj) {p.push('" + e.replace(/[\r\t\n]/g, " ").replace(/'(?=[^%]*%})/g, "\t").split("'").join("\\'").split("\t").join("'").replace(/{%=(.+?)%}/g, "',$1,'").split("{%").join("');").split("%}").join("p.push('") + "');}return p.join('');"); return c(d)
    } 
})(); String.prototype.escapeHTML =
        function () { return this.replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;") }; jQuery.fn.extend({ pos:
        function () {
            var c = this[0]; if (c.offsetParent) { for (var d = 0, b = 0; c.offsetParent; c = c.offsetParent) { d += c.offsetLeft; b += c.offsetTop } return { x: d, y: b} } else {
                return { x: c.x, y: c.y}
            } 
        }, chop: function (g, b) { var d = [], c = []; for (var e = 0, f = this.length; e < f; e++) { if (!b != !g(this[e], e)) { d.push(this[e]) } else { c.push(this[e]) } } return [d, c] }, sum:
        function (c, e) { var b = this.length, d = zero = e ? "" : 0; while (b) { d += this[--b][c] + (b && e || zero) } return d }, set_len_limit:
        function (c) {
            var d = this.find(":submit:first"); var e = d.attr("value"); var b =
        function () { if (this.value && this.value.length > c) { d.attr("disabled", 1).attr("value", "字数不能超过" + c + "字") } else { d.attr("disabled", 0).attr("value", e) } }; $("textarea", this).focus(b).blur(b).keydown(b).keyup(b)
        }, display_limit:
        function (b, g) {
            var c = this, e, d =
        function (h) { var f = c.val(); if (f == e) { return } if (f.length >= b) { c.val(f.substring(0, b)) } g.text(b - c.val().length); e = c.val() }; this.keyup(d); d()
        }, set_caret:
        function () {
            if (!$.browser.msie) { return } var b =
        function () { this.p = document.selection.createRange().duplicate() }; this.click(b).select(b).keyup(b)
        }, insert_caret:
        function (c) { var k = this[0]; if (document.all && k.createTextRange && k.p) { var j = k.p; j.text = j.text.charAt(j.text.length - 1) == "" ? c + "" : c } else { if (k.setSelectionRange) { var f = k.selectionStart; var h = k.selectionEnd; var g = k.value.substring(0, f); var d = k.value.substring(h); k.value = g + c + d; k.focus(); var b = c.length; k.setSelectionRange(f + b, f + b); k.blur() } else { k.value += c } } }, get_sel:
        function () { var b = this[0]; return document.all && b.createTextRange && b.p ? b.p.text : b.setSelectionRange ? b.value.substring(b.selectionStart, b.selectionEnd) : "" }, blur_hide:
        function () {
            var c = this, b =
        function () { return false }; c.mousedown(b); $(document.body).mousedown(
        function () { c.hide().unbind("mousedown", b); $(document.body).unbind("mousedown", arguments.callee) }); return this
        }, yellow_fade:
        function () {
            var b = 0, d = 1, c = this;
            function e() { c.css({ backgroundColor: "rgb(100%,100%," + b + "%)" }); b += d; d += 0.5; if (b <= 100) { setTimeout(e, 35) } else { c.css({ backgroundColor: "" }) } } e(); return this
        }, hover_fold: function (d) {
            var b = { folder: [1, 3], unfolder: [0, 2] }, c =
        function (e, f) { return function () { $("img", e).attr("src", "/pics/arrow" + f + ".gif") } }; return this.hover(c(this, b[d][0]), c(this, b[d][1]))
        }, multiselect:
        function (d) {
            var g =
        function () { return true }, f = d.onselect || g, e = d.onremove || g, c = d.onchange || g, h = d.selclass || "sel", b = d.values || []; return this.click(
        function () { var k = /id(\d*)/.exec(this.className)[1], j = $.inArray(k, b); if (j != -1) { if (!e(this)) { return } b.splice(j, 1); $(this).removeClass(h) } else { if (!f(this)) { return } b.push(k); $(this).addClass(h) } c(b); return false })
        }, initDataInput:
        function () {
            var b = $(this); if (!b.val() || b.val() === b.attr("title")) { b.addClass("color-lightgray"); b.val(b.attr("title")) } b.focus(
        function () { b.removeClass("color-lightgray"); if (b.val() === b.attr("title")) { b.val("") } }).blur(
        function () { if (!b.val()) { b.addClass("color-lightgray"); b.val(b.attr("title")) } })
        }, setItemList:
        function (p) {
            var c = {}, g = "", n = '<imgclass="gray-loader"src="/pics/spinner.gif"/>', e = "/pics/spinner.gif", j = ".input-create", l = { keyup:
        function (q) { var o = q.target.value.replace(/ /g, ""); if (q.keyCode === 13) { p.create.callback(c, g, o, p.limit) } } 
            }, d = document.body, k = new Image(), f = { create: { title: "新分组", tips: "创建新分组"} }, p = $.extend(f, p), b = '<spanclass="create-new">' + p.create.title + "</span>", h = '<inputclass="input-create"type="text"value=""title="' + p.create.tips + '"maxlength="' + p.create.maxLen + '"/>'; k.src = e; $(this).click(
        function (o) { o.stopPropagation(); c = this; sglist.hide(); g = $.isFunction(p.target) ? p.target(c) : p.target; sgarrow.removeClass(CSS_ARROW_SELECT); $(c).addClass(CSS_ARROW_SELECT); $(CSS_SET_GROUP_LIST, this).show(); $(j).focus(); if ($.browser.msie && $.browser.version !== "8.0") { sgarrow.css("z-index", ""); $(this).css("z-index", 10) } }); $(CSS_SET_GROUP_LIST).delegate("li:not('.last')", "click",
        function (w) { w.preventDefault(); var v = w.target, q = this, u = v.type === "checkbox" ? true : false, o = $(this).children("input"), s = $(this).children("input").val(), r = (u && o.attr("checked") || !u && !o.attr("checked")) ? "addtotag" : "removefromtag"; if (!$(CSS_LOADER, this).length) { o.hide().after(n) } p.callback(q, r, u, g, s) }); $(d).click(
        function (o) { $(CSS_SET_GROUP_LIST, this).hide(); $(c).removeClass(CSS_ARROW_SELECT); if (newGroupNum && newGroupNum < p.limit) { $(j).replaceWith(b) } }); $(CSS_SET_GROUP_LIST).delegate(".create-new", "click",
        function () { $(this).replaceWith(h); $(j).focus() }); $(CSS_SET_GROUP_LIST).delegate(j, "keyup",
        function (o) { if ($.isFunction(l[o.type])) { l[o.type].call(this, o) } })
        } 
        }); var check_form =
        function (b) {
            var c = true; $(":input", b).each(
        function () { if ((/notnull/.test(this.className) && this.value == "") || (/most/.test(this.className) && this.value && this.value.length > /most(\d*)/.exec(this.className)[1])) { $(this).next().show(); c = false } else { if (/attn/.test($(this).next().attr("className"))) { $(this).next().hide() } } }); return c
        }; var paras = function (d) { var e = {}; if (d.indexOf("?") == -1) { return {} } var f = d.split("?")[1].split("&"); for (var c = 0; c < f.length; c++) { if (f[c].indexOf("=") != -1) { var b = f[c].split("="); e[b[0] + ""] = b[1] + "" } } return e }; function delete_reply_notify(b) { if (!delete_reply_notify.id) { delete_reply_notify.id = b; show_dialog($("#confirm_delete").html(), 280); $("#overlay").css("z-index", 100); $("#dialog .submit").eq(0).focus() } return false } function close_delete(b) { if (b) { var c = delete_reply_notify.id; $.get("/j/accounts/remove_notify?id=" + c); $("#reply_notify_" + c).fadeOut() } delete_reply_notify.id = null; close_dialog() }
function moreurl(b, e) { var d = ["ref=" + encodeURIComponent(location.pathname)]; for (var c in e) { d.push(c + "=" + e[c]) } set_cookie({ report: d.join("&") }) } function tip_win(b) { $(b).next(".blocktip").show().blur_hide() } tip_win.hide =
        function (b) { $(b).parents(".blocktip").hide() }; function js_parser(htm) {
            var tag = "script>", begin = "<" + tag, end = "</" + tag, pos = pos_pre = 0, result = script = ""; while ((pos = htm.indexOf(begin, pos)) + 1) { result += htm.substring(pos_pre, pos); pos += 8; pos_pre = htm.indexOf(end, pos); if (pos_pre < 0) { break } script += htm.substring(pos, pos_pre) + ";"; pos_pre += 9 } result += htm.substring(pos_pre, htm.length); return { htm: result, js:
        function () { eval(script) } 
            }
        }





function pop_win(f, e) { if (!window.__pop_win) { var h = document.createElement("div"); h.className = "pop_win_bg"; document.body.appendChild(h); var k = document.createElement("div"); k.className = "pop_win"; document.body.appendChild(k); __pop_win = { bg: h, body: k, body_j: $(k), bg_j: $(h)} } var c = __pop_win.body, d = __pop_win.body_j, j = js_parser(f); if (e !== true) { j.htm = '<a onclick="pop_win.close()"href="javascript:;"class="pop_win_close">X</a>' + j.htm } c.innerHTML = j.htm; var g = { left: (document.documentElement.offsetWidth - c.offsetWidth) / 2 + "px", top: (document.documentElement.clientHeight - c.offsetHeight) * 0.45 + "px" }; if (document.documentElement.clientHeight < c.offsetHeight) { g.top = "0"; g.height = document.documentElement.clientHeight - 40 + "px"; g.overflow = "auto" } d.css({ display: "block" }).css(g).css({ visibility: "visible", zIndex: 9999 }); j.js(); pop_win.fit(); if (!window.XMLHttpRequest) { __pop_win.bg.style.top = "" } } pop_win.fit = function () { if (window.__pop_win) { var c = __pop_win.body; __pop_win.bg_j.css({ height: c.offsetHeight + 16 + "px", width: c.offsetWidth + 16 + "px", left: c.offsetLeft - 8 + "px", top: c.offsetTop - 8 + "px", zIndex: 8888 }).show() } }; pop_win.close = function () { $(__pop_win.bg).remove(); $(__pop_win.body).remove(); window.__pop_win = null }; pop_win.load = function (c, b) { pop_win('<div style="padding:20px 60px;">加载中,请稍等...</div>'); $.ajax({ url: c, success: pop_win, cache: b || false, dataType: "html" }); return false };





/*解决ie6下png图片不透明问题*/
function correctPNG() {
    for (var i = 0; i < document.images.length; i++) {
        var img = document.images[i]
        var imgName = img.src.toUpperCase()
        if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
            img.outerHTML = strNewHTML
            i = i - 1
        };
    };

};

if (navigator.userAgent.indexOf("MSIE") > -1) {

    window.attachEvent("onload", correctPNG);

};





$(function () {

    //$(".search_text").attr("disabled", "disabled");
    var select = $(".br");
    var values = $(".searchtext").val();
  
    /************************************/
    $(".search_text").focus(function () {
        $(this).removeClass("text_blur");
        $(this).addClass("text_focus");

        if ($(this).val() == values) {
            $(this).val("");
        }
    });
    $(".search_text").blur(function () {
        if ($(this).val() == values || $(this).val() == "") {
            $(this).val(values);
            $(this).removeClass("text_focus");
            $(this).addClass("text_blur");
        }
    });
    /************************************/
    $(".box_right").click(function () {

        $("#searchType").attr("value", $("#cate").attr("value"));
        $("#searchForm").submit();
    });


    select.children("span").click(function () {
        select.children("ul").height(0);
        select.children("ul").css("display", "block");
        select.children("ul").animate({ "height": "115" }, 100);
    });

    select.children("ul").hover(
                function () {
                    return false;
                },
                function () {
                    $(this).css("display", "none");
                });

    select.find("li").click(function () {
        select.children("span").text($(this).text());
        select.children("span").attr("value", $(this).text());
        select.children("ul").trigger("mouseout");
    });



    var select1 = $(".phone");
    select1.click(function () {
        select1.children("ul").height(0);
        select1.children("ul").css("display", "block");
        select1.children("ul").animate({ "height": "115" }, 100);
    });

    select1.children("ul").hover(
                function () {
                    return true;
                },
                function () {
                    $(this).css("display", "none");
                });

    select1.find("li").click(function () {
        select1.children("span").text($(this).text());
        select1.children("span").attr("value", $(this).attr("value"));
        select1.children("ul").trigger("mouseout");
        set_cookie({ "system": $(this).attr("system") }, 0);
        //alert(get_cookie("system"));
        location.href = location.href;
    });

});






var currentindex = -1;
var size = 0;
var currentTxt;
function getSuggestion(w) {
    var url = $("#word").attr("url");
    var t = setTimeout(function () {
        $.getJSON(url, { w: w }, showData);
    }, 500);
}
function showData(data) {
    var suggestions = $("#suggestions").html("");
    var input = $("#word");
    if ($(data).length > 0) {
        $(data).each(function (i, it) {
            suggestions.append('<li >' + it + '</li>');
        })
        suggestions.show();
        suggestions.children("li").click(function () {
            input.val($(this).text());
            suggestions.hide();
        });
        size = $("#suggestions li").size();
        document.onclick = function (e) {
            var e = e ? e : window.event;
            var tar = e.srcElement || e.target;
            if (tar.id != "suggestions") {
                suggestions.hide();
            }
        }
    }
    else {
        suggestions.hide();
    }
}

function movethis(up) {

    currentindex = currentindex + (up ? -1 : 1);
    if (currentindex == size) {
        currentindex = 0;
    }
    else if (currentindex < 0) {
        currentindex = size - 1;
    }
    $("#suggestions li").removeClass("suggec");
    $($("#suggestions li")[currentindex]).addClass("suggec");
    var textvalue = $($("#suggestions li")[currentindex]).text();
    $("#word").val(textvalue);
}
$(function () {
    var input = $("#word");
    var suggestions = $("#suggestions").html("").hide();
    input.keyup(function (e) {
        if (e.keyCode != 40 && e.keyCode != 38) {
            var word = $.trim(input.val());
            if (word) {
                getSuggestion(word);
            }

            else {
                suggestions.hide();
            }
        }

    });

    input.keyup(function (evn) {
        if (evn.keyCode == 38) {
            movethis(true);
        }
        else if (evn.keyCode == 40) {
            movethis(false);
        }
        else if (evn.keyCode == 13) {
            $("#suggestions").hide();
            $(".br").trigger("click");
        }
    })
    $("#suggestions").mouseover(function () { //鼠标滑过  
        select = $("#suggestions");
        select.children("li").mouseover(
                function () {
                    $(this).addClass("suggec");
                },
                function () {
                    $(this).removeClass("suggec");
                });
    }).mouseout(function () { //鼠标滑出  
        $("#suggestions li").removeClass("suggec");
    });
    suggestions.width(input.outerWidth() + 3);
})


function exp_dialog(g) { var h = document.documentElement; return 0 - parseInt(g.offsetHeight / 2) + (TBWindowMargin = h && h.scrollTop || document.body.scrollTop) + "px" }
function exp_overlay(g) { return 0 - parseInt(g.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + "px" };

$(document).ready(function () {
    $(".myproduct").focus(function () {
        $(this).val("");
    }).blur(function () {

        if ($(this).val() != "机型搜索") {
            $(this).val($(this).attr("value"));
        }
        if ($(this).val() == "") {

            $(this).val("机型搜索");
        }
    }).css("color", "#ccc");
})
