
Douban = new Object();
Douban.errdetail = ["", "未知错误", "文件过大", "信息不全", "域名错误", "分类错误", "用户错误", "权限不足", "没有文件", "保存文件错误", "不支持的文件格式", "超时", "文件格式有误", "", "添加文件出错", "已经达到容量上限", "不存在的相册", "删除失败", "错误的MP3文件", "有禁用的内容,请修改重试"];
var trace = function(b) {
    if (!/^http:\/\/(www|movie|music\.|book|douban\.fm)/.test(location.href) && window.console && window.console.log) {
        console.log(b)
    }
};
var report = function(b) {
    $.get("/j/report?e=" + b)
};
Douban.EventMonitor = function() {
    this.listeners = new Object()
};
Douban.EventMonitor.prototype.broadcast = function(c, f, d) {
    var b = this.listeners[f];
    if (b != null) {
        for (var e in b) {
            b[e](c, d)
        }
    }
};
Douban.EventMonitor.prototype.subscribe = function(c, d) {
    var b = this.listeners[c];
    if (b) {
        b.push(d)
    } else {
        this.listeners[c] = [d]
    }
};
Douban.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 Douban.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 f = fns[m[1]];
            if (!f) {  	
                f = eval("Douban.init_" + m[1]);
                fns[m[1]] = f
            }
            f && f(this)
        }
    })
}
function request_log_ad_displays() {
    $('div[id^="daslot"]').each(function(b) {
        var c = $(this).attr("id");
        params = c.split("-");
        $.get("/j/da/view?da=" + params[1] + "&dag=" + params[2] + "&dac=" + params[3] + "&p=" + params[4] + "&kws=" + params[5])
    })
}
$(function() {
    load_event_monitor(document)
});
Douban.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")
};

var voteuse_act = function(b, f, e, d) {
    var c = "/j/" + e + "/" + f + (b ? "/useful": "/useless");
    $.postJSON_withck(c, {},
    function(j) {
        if (j.result) {
            if (d) {
                var h = $("#ucount" + f + "u"),
                g = $("#ucount" + f + "l");
                if ((h.text() == j.usecount) && (g.text() == j.totalcount - j.usecount) && (j.result != "notself")) {
                    alert("你已经投过票了")
                }
                h.html(j.usecount);
                g.html(j.totalcount - j.usecount)
            } else {
                $("#voteuse_" + f).html('<span class="m gtleft">你的投票已经提交，谢谢。</span>');
                $("#userate_" + f).html('<p id="userate_%s" class="pl">' + j.usecount + "/" + j.totalcount + "的人觉得此评论有用:</p>")
            }
        }
        return false
    })
};
var vote_type = function(b) {//有用
    switch (b) {
    case "d":
        return "doulist";
    case "r":
        return "reviews";
    case "c":
        return "discussion"
    }
};
var voteuseful = function(e, c) {//有用
	if(!tcheck_p_login()){  	
	    if ($("#dialog").length) {
	        close_dialog();
	    }
		pop_win.loadcache("/j/login");
		return false;
	}
    var b = e.split("-");
    var d = vote_type(b[0]);
    return voteuse_act(true, b[1], d, c)
};
var voteuseless = function(e, c) {//有用
	if(!tcheck_p_login()){  	
		pop_win.loadcache("/j/login");
		return false;
	}
    var b = e.split("-");
    var d = vote_type(b[0]);
    return voteuse_act(false, b[1], d, c)
};

Douban.init_unfolder = function(b) {//有用
    $(b).click(function() {
        var e = b.id.split("-")[1];
        var c = b.rel.split("-")[1];
        var d = "/j/reviews/" + e + "/fullinfo";
        $.getJSON(d, function(f) {
            var g = document.createElement("div");
            g.innerHTML = f.html;
            $("#review_" + e + "_short").hide();
            $("#review_" + e + "_full").html("").append(g);
            $("#review_" + e + "_full").show();
            $("#af-" + e).hide();
            $("#au-" + e).show();
            load_event_monitor($("#review_" + e + "_full"))
        });
        return false
    }).hover_fold("unfolder")
};
Douban.init_folder = function(b) {//有用
    $(b).click(function() {
        var c = $(b).attr("id").split("-")[1];
        $("#review_" + c + "_full").hide();
        $("#review_" + c + "_short").show();
        $(b).hide();
        $("#af-" + c).show()
    }).hover_fold("folder")
};

Douban.init_unfolder_n = function(b) {//有用
    $(b).click(function() {
        var e = b.id.split("-")[1];
        var c = b.rel.split("-")[1];
        var d = "/j/reviews/" + e + "/fullinfo";
        $.getJSON(d, function(f) {
            var g = document.createElement("div");
            g.innerHTML = f.html;
            $("#review_n_" + e + "_short").hide();
            $("#review_n_" + e + "_full").html("").append(g);
            $("#review_n_" + e + "_full").show();
            $("#af_n-" + e).hide();
            $("#au_n-" + e).show();
            load_event_monitor($("#review_n_" + e + "_full"))
        });
        return false
    }).hover_fold("unfolder")
};
Douban.init_folder_n = function(b) {//有用
    $(b).click(function() {
        var c = $(b).attr("id").split("-")[1];
        $("#review_n_" + c + "_full").hide();
        $("#review_n_" + c + "_short").show();
        $(b).hide();
        $("#af_n-" + c).show()
    }).hover_fold("folder")
};

Douban.init_guidelink = function(b) {
    $(b).click(function() {
        window.open("/help/guide1", "", "width=640,height=400");
        return false
    })
};
Douban.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"
        })
    })
}

Douban.init_interest_form = function(g) {
	
    var c = $(g),   	
    f = {},
    d = {};
    if (c.data("bind") === "true") {
        return
    } else {
        c.data("bind", "true")
    }
    var b = function(j) {
        if (f[j]) {
            d[j] = true;
            $.each(f[j],
            function(l, k) {
                $(k).removeClass("gract").addClass("rdact")
            })
        }
    };
    var e = function(j) {
        if (f[j]) {
            delete d[j];
            $.each(f[j],
            function(l, k) {
                $(k).removeClass("rdact").addClass("gract")
            })
        }
    };
    
    if ($(g).data("comment")) {
        g.comment.focus()
    } else {
        if ($("#foldcollect").val() == "U") {
            g.tags.focus()
        }
    }
    $(g).submit(function() {
        var j = $(this).attr("action").split("/")[3];
        remote_submit_json(this,
        function(k) {
            var l = $("#dialog .shuo :input[type=checkbox]");
            if (k.ok == 'ok') {
                $("#saving").remove();
                $("#submits").show();
                $("#error").html(Douban.errdetail[k.r]);
                refine_dialog();
                close_dialog();
                return
            }
            $("#collect_form_" + j).html("");
            if (l.length && l[0].checked) {
                close_dialog();
                if (typeof DoubanShare !== "undefined") {
                    DoubanShare.share(k);
                    DoubanShare.onDialogClose(function() {
                        self.location.replace(self.location.href)
                    })
                }
                return
            }
            if ($(g).data("reload")) {
                if (/movie\/\d+\/comment/.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
    });
    $(g.cancel).click(function() {
        var j = $(g).attr("action").split("/")[3];
        $("#collect_form_" + j).html("")
    });
};
Douban.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()
};

Douban.init_review_full = function(e) {
    var c = $(e).attr("id").split("_");
    var d = c[1];
    var b = c[2];
    $(".link", e).click(function() {
        var f = "/j/reviews/" + d + "/" + b;
        $.getJSON(f,
        function(g) {
            $(e).html(g.html);
            load_event_monitor($(e))
        });
        return false
    })
};
Douban.init_show_login = function(b) {//有用
    $(b).click(function() {
        if(!tcheck_p_login()){  	
		    if ($("#dialog").length) {
		        close_dialog();
		    }
			pop_win.loadcache("/j/login");
			this.blur();
			return false;
		}
    })
};

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
}
Douban.init_hideme = function(b) {
    $(b).click(function() {
        $(this).parent().parent().parent().hide()
    })
};
Douban.init_more = function(b) {
    $(b).click(function() {
        lastObj = $(this).prev().find("input");
        ids = /(.*_)(\d+)$/.exec(lastObj.attr("id"));
        id = ids[1] + (parseInt(ids[2]) + 1);
        a = lastObj.clone();
        a.attr("value", "");
        $(this).before("<br/>").before(a);
        a.attr("id", id).attr("name", id).wrap("<span></span>")
    })
};
Douban.init_more2 = function(b) {
    $(b).click(function() {
        lastObj = $(this).prev().find("input");
        ids = /(.*_)(\d+)_(\d+)$/.exec(lastObj.attr("id"));
        last_id = parseInt(ids[3]);
        nid = last_id + 1;
        id = ids[1] + parseInt(ids[2]) + "_" + nid;
        a = lastObj.clone();
        a.attr("value", "");
        $(this).before('<br/><span class="pl idx">' + (nid + 1) + "</span>").before(a);
        a.attr("id", id).attr("name", id).removeClass("m").wrap("<span></span>");
        init_keyup();
        list_data[id] = "无"
    })
};
Douban.init_search_text = function(b) {
    if (!b.value || b.value == b.title) {
        $(b).addClass("greyinput");
        b.value = b.title
    }
    $(b).focus(function() {
        $(b).removeClass("greyinput");
        if (b.value == b.title) {
            b.value = ""
        }
    });
    $(b).blur(function() {
        if (!b.value) {
            $(b).addClass("greyinput");
            b.value = b.title
        }
    })
};
Douban.init_checkreg = function(b) {
    $(b).find(".butt").click(function() {
        var c = true;
        $(b).find("input").each(function() {
            if (this.type != "submit" && this.type != "button") {
                if (this.value == "") {
                    $(this).next().css("display", "inline");
                    c = false
                } else {
                    $(this).next().css("display", "none")
                }
            }
        });
        return c
    })
};
Douban.init_click_tip = function(c) {
    var b = $(c).parent().find(".blocktip");
    $(c).click(function() {
        b.show().blur_hide();
        m = b.width() + b.pos().x - $.viewport_size()[0] > 0 ? -b.width() : 0;
        b.css("margin-left", m)
    });
    $(".hideme", b).click(function() {
        b.hide()
    })
};
function clean_tip() {
    var b = $("#page_focus")[0];
    return b && b.value != b.title
}
Douban.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) + 140;
    $("#dialog,#overlay").css("top", c);
    set_overlay()
};
Douban.init_show_full = function(b) {
    $(b).click(function() {
        $(b).parents(".short").hide();
        $(b).parents(".short").next().show()
    })
};
Douban.init_show_full2 = function(b) {
    $(b).click(function() {
        $(b).parents(".short").hide();
        $(b).parents(".short").next().show();
        $(b).parents(".reading-note").nextAll(".col-rec-con").show();
        $(b).parents(".reading-note").next().children(".no-comments").show()
    })
};
Douban.init_show_short = function(b) {
    $(b).click(function() {
        $(b).parents(".all").hide();
        $(b).parents(".all").prev().show()
    })
};
Douban.init_show_short2 = function(b) {
    $(b).click(function() {
        $(b).parents(".all").hide();
        $(b).parents(".all").prev().show();
        $(b).parents(".reading-note").nextAll(".col-rec-con").hide();
        $(b).parents(".reading-note").next().children(".no-comments").hide()
    })
};
Douban.init_show_more = function(b) {
    $(b).click(function() {
        $(b).parent().prevAll(".more").show();
        $(b).parent().remove()
    })
};

Douban.init_new_review = function(b) {
    $(b).click(function() {
        if(!tcheck_p_login()){  	
		    if ($("#dialog").length) {
		        close_dialog();
		    }
			pop_win.loadcache("/j/login");
			this.blur();
			return false;
		}
		var e = $(this).attr("name").split("-"),g = e[0],c = e[1];
		location.href='/movie/'+c+'/new_review';
    })
};
Douban.init_collect_btn = function(b) {
    $(b).click(function() {	
	    if(!tcheck_p_login()){  	
		    if ($("#dialog").length) {
		        close_dialog();
		    }
			pop_win.loadcache("/j/login");
			this.blur();
			return false;
		}
        if ($("#hiddendialog").length) {
            show_dialog($("#hiddendialog").html());
            load_event_monitor($("#dialog"))
        } else {       
            var e = $(this).attr("name").split("-"),
            g = e[0],
            c = e[1],
            h = e[2],
            f = e[3],
            d = "/j/form/?" + (c ? "did=" + c: "") + "" + (h ? "&interest=" + h: "") + (f ? "&rating=" + f: "") + (g == "cbtn" ? "&cmt=1": (g == "rcbtn" ? "&cmt=2": ""))+"&time="+new Date().getTime();
            if(!c) return false;
            show_dialog(null);
            $.getJSON(d,
            function(j){
                if ($("#dialog").length) {
                    var n = $("<div></div>").html(j.html);
                    var l = {};
                 
                    if (g == "pbtn" || g == "cbtn") {
                        $("form", n).data("reload", 1)
                    }
                    $("#dialog").html(n);
                    $("#showtags").click(function() {
                        
                        $(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)
                }
            })
        }
        return false
    })
};
Douban.init_reviews_btn = function(b) {
    $(b).click(function() {	
	    if(!tcheck_p_login()){  	
		    if ($("#dialog").length) {
		        close_dialog();
		    }
			pop_win.loadcache("/j/login");
			this.blur();
			return false;
		}
        if ($("#hiddendialog").length) {
            show_dialog($("#hiddendialog").html());
            load_event_monitor($("#dialog"))
        } else {       
            var e = $(this).attr("name").split("-"),
            g = e[0],
            c = e[1],
            h = e[2],
            f = e[3],
            d = "/j/form/?" + (c ? "pid=" + c: "") + "" + (h ? "&did=" + h: "") + (f ? "&rating=" + f: "") + (g == "cbtn" ? "&cmt=1": (g == "rcbtn" ? "&cmt=2": ""))+"&time="+new Date().getTime();
            if(!c) return false;
            show_dialog(null);
            $.getJSON(d,
            function(j){
                if ($("#dialog").length) {
                    var n = $("<div></div>").html(j.html);
                    var l = {};
                 
                    if (g == "pbtn" || g == "cbtn") {
                        $("form", n).data("reload", 1)
                    }
                    $("#dialog").html(n);
                    $("#showtags").click(function() {
                        
                        $(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)
                }
            })
        }
        return false
    })
};
Douban.init_pic_comment_btn = function(b) {
    $(b).click(function() {	
	    if(!tcheck_p_login()){  	
		    if ($("#dialog").length) {
		        close_dialog();
		    }
			pop_win.loadcache("/j/login");
			this.blur();
			return false;
		}
        if ($("#hiddendialog").length) {
            show_dialog($("#hiddendialog").html());
            load_event_monitor($("#dialog"))
        } else {       
            var e = $(this).attr("name").split("-"),
            g = e[0],
            c = e[1],
            h = e[2],
            f = e[3],
            d = "/j/form/?" + (c ? "picid=" + c: "") + "" + (h ? "&did=" + h: "") + (f ? "&pictype=" + f: "") + (g == "pcbtn" ? "&cmt=3": (g == "rcbtn" ? "&cmt=2": ""))+"&time="+new Date().getTime();
            if(!c) return false;
            show_dialog(null);
            $.getJSON(d,
            function(j){
                if ($("#dialog").length) {
                    var n = $("<div></div>").html(j.html);
                    var l = {};
                 
                    if (g == "pbtn" || g == "cbtn") {
                        $("form", n).data("reload", 1)
                    }
                    $("#dialog").html(n);
                    $("#showtags").click(function() {
                        
                        $(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)
                }
            })
        }
        return false
    })
};
Douban.init_nine_collect_btn = function(b) {
    $(b).click(function() {
        var e = $(this).attr("name").split("-");
        var f = e[0],
        c = e[1],
        g = e[2];
        var d = "/j/subject/" + c + "/interest";
        $.getJSON(d, g && {
            interest: g
        },
        function(l) {
            var j = $("<div></div>").html(l.html);
            var h = l.tags;
            var k = h.join(" ");
            $("input[name=tags]", j).val((k.length > 1) ? k + " ": k);
            var n = {};
            $.each(h,
            function(p, o) {
                n[o.toLowerCase()] = true
            });
            populate_tag_btns("我的标签(点击添加):", $("#mytags", j), l.my_tags, n);
            populate_tag_btns("豆瓣成员常用的标签(点击添加):", $("#populartags", j), l.popular_tags, n);
            if (f == "pbtn") {
                $("form", j).data("reload", 1)
            }
            $("#collect_form_" + c).html("").append('<p class="ul"></p>').append(j);
            load_event_monitor($("#collect_form_" + c))
        });
        return false
    })
};


$.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
};
$.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", "/public/default/image/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)
            }
        })
    }
});
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 center(b) {
    return {
        left: (document.documentElement.offsetWidth - b.offsetWidth) / 2 + "px",
        top: (document.documentElement.clientHeight - b.offsetHeight) * 0.45 + "px"
    }
}
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
};
pop_win.loadcache = function(c, b) {
    pop_win('<div style="padding:20px 60px;">加载中, 请稍等...</div>');
    $.ajax({
        url: c,
        success: pop_win,
        ifModified: true,
        dataType: "html"
    });
    return false
};
function event_init_tab() {
    $("#tongcheng_tab").click(function() {
        if ($("#tongcheng_tab_block").is(":hidden")) {
            show_tongcheng_tab();
            $(document.body).click(function() {
                hide_tongcheng_tab();
                $(document.body).unbind("click", arguments.callee)
            })
        } else {
            hide_tongcheng_tab()
        }
        return false
    })
}
function show_tongcheng_tab() {
    $("#tongcheng_tab_block").show();
    $("#tongcheng_tab span").addClass("up")
}
function hide_tongcheng_tab() {
    $("#tongcheng_tab_block").hide();
    $("#tongcheng_tab span").removeClass("up")
}
__load_bk = $.fn.load;
$.fn.load_withck = function(b, c, d) {
    if ($.isFunction(c)) {
        d = c;
        c = {}
    }
    return __load_bk.call(this, b, $.extend(c, {
        ck: get_cookie("ck")
    }), d)
};
function exp_dialog(b) {
    var c = document.documentElement;
    return 0 - parseInt(b.offsetHeight / 2) + (TBWindowMargin = c && c.scrollTop || document.body.scrollTop) + "px"
}
function exp_overlay(b) {
    return 0 - parseInt(b.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + "px"
}
function exp_sort_h2_over() {
    this.style.backgroundColor = "#eeffee"
}
function exp_sort_h2_out() {
    this.style.backgroundColor = ""
}
function getslider(h, n, d, b, k, g) {
    var c = 5,
    e = 100,
    l = 5,
    j = 0,
    f = function(o) {
        if (c + o > e) {
            c = e;
            h[0].className = "dis"
        } else {
            if (c + o < 5) {
                c = 5;
                n[0].className = "dis"
            } else {
                c += o
            }
        }
        n[0].className = c == 5 ? "dis": "";
        h[0].className = c == e ? "dis": "";
        j = (5 - c) * 105;
        d.animate({
            marginLeft: j + "px"
        },
        {
            duration: 250 * Math.abs(o),
            easing: $.easing.easeOutCirc
        })
    };
    return function(o) {
        if (c + o > l && l < e) {
            $.postJSON_withck(b, {
                start: l,
                pp: k,
                cat_id: g
            },
            function(p) {
                if (p.err) {
                    e = p.total;
                    l += p.num;
                    o = p.num;
                    d.html(d.html() + p.more_html);
                    f(o)
                }
            })
        } else {
            f(o)
        }
    }
}
Douban.init_song_interest = function(c) {
    var b = $(c).attr("id").split("-")[1];
    $(c).click(function() {
        var d = "/j/song/" + b + "/interest";
        var e = $(c).hasClass("interest");
        $.post_withck(d, {
            action: (e ? "n": "y")
        },
        function(f) {
            $(c).toggleClass("interest");
            if (e) {
                $(c).children().attr({
                    src: "/pics/gray-heart.gif",
                    title: "我喜欢",
                    alt: "我喜欢"
                })
            } else {
                $(c).children().attr({
                    src: "/pics/red-heart.gif",
                    title: "取消'我喜欢'",
                    alt: "取消'我喜欢'"
                })
            }
        },
        "text");
        return false
    })
};
Douban.init_vote_comment = function(c) {
    if (window.location.hostname != "www.3gp.cn") {
        //return
    }
    var b = $(c).prev().prev(),
    d = $(c).prev().val();
    $(c).click(function() {
    	if(!tcheck_p_login()){  	
		    if ($("#dialog").length) {
		        close_dialog();
		    }
			pop_win.loadcache("/j/login");
			this.blur();
			return false;
		}
        $.postJSON_withck("/j/form/vote", {
            pid: d
        },
        function(e) {
            if (e.count) {
                b.text(e.count)
            } else {
                alert("这条短评你已经投过票了")
            }
        })
    })
};
Douban.init_rev_text = function(d) {
    if (window.location.hostname != "movie.douban.com") {
        return
    }
    var c = $(d).parents("form"),
    b = $("input[name=rev_submit]");
    b.click(function() {
        if ($(d).val().length < 50) {
            var e = /subject\/(\d*)/.exec(location.href)[1];
            $.getJSON("/j/comment/check", {
                sid: e
            },
            function(f) {
                if (f.has) {
                    if (confirm("少于50字的评论将被自动转为简短评论。并替换之前发表的简短评论内容。是否继续？")) {
                        c.submit()
                    }
                } else {
                    c.submit()
                }
            });
            return false
        }
        return true
    })
};
Douban.init_popup = function(b) {
    $(b).click(function() {
        var c = / (\d+)x(\d+)$/.exec(b.className);
        if (!window.open(b.href, "popup", "height=" + c[2] + ",width=" + c[1] + ",toolbar=no,menubar=no,scrollbars=no,location=no,status=no")) {
            location.href = b.href
        }
        return false
    })
};
Douban.init_show_request_join_form = function(b) {
    $(b).click(function() {
        group_id = window.location.href.split("/")[4];
        return pop_win.load("/j/group/" + group_id + "/request_join_form")
    })
};
Douban.init_show_comment_form = function(b) {
    $(b).click(function() {
        $(b).hide();
        $("#comment_form").show()
    })
};
function cinema_full() {
    $("#info_area").html("正在查询，请稍等...");
    $("#info_area").load_withck("/j/movie/cinemainfo", {
        id: movie_id,
        city: at_city,
        day: delta_days,
        view: view
    })
}
Douban.init_add2cart = function(b) {
    $(b).click(function() {
        $.post_withck("/cart", {
            add: b.name
        },
        function() {
            $(b).next(".pl").hide();
            $(b).hide().nextAll(".hidden").show().yellow_fade()
        })
    })
};
Douban.init_switch_tab = function(b) {
    $(b).click(function() {
        $(".a_switch_tab").removeClass("current");
        $(b).addClass("current");
        $("#tag-loader").attr("class", "loading").text("");
        $.getJSON("/j/recommended/switch", {
            tag: b.name
        },
        function(c) {
            $(".tag-fav-cloud").replaceWith(c.tags);
            load_event_monitor(".tag-fav-cloud");
            $(".rec-list").replaceWith(c.subjects);
            load_event_monitor(".rec-list")
        });
        return false
    })
};
Douban.init_switch_tab_movie = function(b) {
    $(b).click(function() {
        $(".a_switch_tab").removeClass("current");
        url = $("#hide_full_path").attr("name") + "/switch";
        $("#tag_all").removeClass("current");
        $(".tag-fav-cloud a").removeClass("current");
        $(b).addClass("current");
        $("#tag-loader").attr("class", "loading").text("");
        $.getJSON(url, {
            tag: b.name
        },
        function(c) {
            $(".rec-list").replaceWith(c.subjects);
            load_event_monitor(".rec-list");
            $("#tag-loader").attr("class", "not-loading")
        });
        return false
    })
};
Douban.init_get_more = function(b) {
    $(b).click(function() {
        page = parseInt($(b).attr("attr")) + 10;
        url = $("#hide_full_path").attr("name") + "/switch";
        start = parseInt($(b).attr("start")) + 10;
        $(".a_switch_tab").removeClass("current");
        $(b).addClass("current");
        tag = b.name.replace("[", "", "g").replace("]", "", "g").replace("'", "", "g");
        $("#tag-loader").attr("class", "loading").text("");
        $.getJSON(url, {
            tag: tag,
            perpage: page,
            start: start
        },
        function(c) {
            $(b).attr("attr", page);
            $(".rec-list").replaceWith(c.subjects);
            load_event_monitor(".rec-list");
            $("#tag-loader").attr("class", "not-loading")
        });
        return false
    })
};
Douban.init_nointerest_subject = function(b) {
    $(b).click(function() {
        tag = $(".tag-fav-cloud > .current").attr("name");
        $.post_withck("/j/recommended/nointerest_subject", {
            sid: b.name
        },
        function(c) {
            if (c == "Y") {
                $("#tag-loader").attr("class", "loading").text();
                $.getJSON("/j/recommended/switch", {
                    tag: tag
                },
                function(d) {
                    $(".tag-fav-cloud").replaceWith(d.tags);
                    load_event_monitor(".tag-fav-cloud");
                    $(".rec-list").replaceWith(d.subjects);
                    load_event_monitor(".rec-list")
                })
            }
        });
        return false
    })
};
Douban.init_nointerest_entry = function(b) {
    $(b).click(function() {
        var c = b.href.match(/nointerest=(\d+)/)[1];
        $.post_withck("/j/recommended/nointerest_subject", {
            sid: c
        },
        function(d) {
            if (d == "Y") {
                window.location.reload()
            }
        });
        return false
    })
};
Douban.init_nointerest_subject_tab = function(b) {
    $(b).click(function() {
        tag = $(".tag-fav-cloud > .current").attr("name");
        $.post_withck("/j/recommended/nointerest_subject", {
            sid: b.name,
            tag: $(b).attr("tag")
        },
        function(c) {
            if (c == "Y") {
                $("#tag-loader").attr("class", "loading").text();
                $.getJSON("/j/recommended/switch", {
                    tag: $(b).attr("tag")
                },
                function(d) {
                    $(".tag-fav-cloud").replaceWith(d.tags);
                    load_event_monitor(".tag-fav-cloud");
                    $(".rec-list").replaceWith(d.subjects);
                    load_event_monitor(".rec-list")
                })
            }
        });
        return false
    })
};
Douban.init_nointerest_subject_movie = function(b) {
    $(b).click(function() {
        url = $("#hide_full_path").attr("name") + "/nointerest_subject";
        self_item = $(this).parents(".item");
        var c = true;
        _self = this;
        if (c) {
            tag = $(".tag-fav-cloud > .current").attr("name");
            total = $(".a_get_more").attr("attr");
            $.post_withck(url, {
                sid: b.name
            },
            function(d) {
                if (d == "Y") {
                    self_item.fadeOut(function() {
                        $.getJSON($("#hide_full_path").attr("name") + "/switch", {
                            tag: tag,
                            perpage: total
                        },
                        function(e) {
                            $(".rec-list").replaceWith(e.subjects);
                            load_event_monitor(".rec-list");
                            $("#tag-loader").attr("class", "not-loading")
                        })
                    })
                }
            })
        }
        return false
    })
};
Douban.init_nointerest_subject_top = function(b) {
    $(b).click(function() {
        url = $("#hide_full_path").attr("name") + "/nointerest_subject_top";
        var c = true;
        _self = this;
        if (c) {
            $(_self).parents("li").fadeOut("slow",
            function() {
                $(this).remove()
            });
            last_num -= 1;
            cover_num -= 1;
            if (cover_num === 0) {
                $("#movie-rec").remove()
            }
            if (last_num === 5) {
                $(".btn-next > a").addClass("dis")
            }
            $(".detail-tip").remove();
            $.post_withck(url, {
                sid: b.name
            },
            function(d) {
                if (d === "Y") {}
            })
        }
        return false
    })
};
Douban.init_nointerest_doulist = function(b) {
    $(b).click(function() {
        $("#doulist-loader").attr("class", "loading");
        $.post_withck("/j/recommended/nointerest_doulist", {
            dl_del: b.name
        },
        function(c) {
            $(".simple-dashed-list").replaceWith(c);
            load_event_monitor(".simple-dashed-list");
            $("#doulist-loader").attr("class", "not-loading")
        });
        return false
    })
};
Douban.init_nointerest_doulist_movie = function(b) {
    $(b).click(function() {
        url = $("#hide_full_path").attr("name") + "/nointerest_doulist";
        $("#doulist-loader").attr("class", "loading");
        $.post_withck(url, {
            dl_del: b.name
        },
        function(c) {
            $(".simple-dashed-list").replaceWith(c);
            load_event_monitor(".simple-dashed-list");
            $("#doulist-loader").attr("class", "not-loading")
        });
        return false
    })
};
Douban.init_post_link = function(b) {
    $(b).click(function(h) {
        var d = $(this),
        c = d.attr("href"),
        o = d.attr("title") || d.text() + "?",
        g = d.attr("rel") == "direct",
        j = d.attr("target"),
        l = c.split("?")[0],
        n = {},
        k = c.split("?")[1] || [];
        if (typeof k === "string") {
            k = k.split("&")
        }
        h.preventDefault();
        if (d.hasClass("processing")) {
            return
        }
        if (g) {
            var p = [];
            k.push("ck=" + get_cookie("ck"));
            for (i = 0, f; i < k.length; i++) {
                f = k[i].split("=");
                p.push('<input type="hidden" name="' + f[0] + '" value="' + f[1] + '">')
            }
            $('<form action="' + l + '" method="POST" target="' + (j || "_self") + '" sytle="display:none">' + p.join("") + "</form>").appendTo("body").submit()
        } else {
            for (i = 0; i < k.length; i++) {
                var f = k[i].split("=");
                n[f[0]] = f[1]
            }
            if (confirm(o)) {
                d.addClass("processing");
                $.post_withck(l, n,
                function(q) {
                    d.removeClass("processing");
                    location.reload(true)
                })
            }
        }
    })
};
try {
    document.execCommand("BackgroundImageCache", false, true)
} catch(err) {}
Douban.init_donate = function() {
    var p = '<div class="blocktip dou-tip">{BODY}</div>',
    l = '<form action="" method="post"><div class="frm-item">你将向作者赠送<b>1</b>颗小豆</div><div class="frm-item"><label for="dou-inp-msg">顺带捎个话...</label><input id="dou-inp-msg" type="text" name="note"></div><div class="frm-submit"><span class="bn-flat"><input type="submit" value="送出"></span><a href="#" class="tip-bn-cancel">取消</a></div></form>',
    c = '<p>“感谢”将向作者赠送<b>1</b>颗小豆，你还没有小豆。<br><a href="http://www.douban.com/help/account#t4-q1">怎样获取小豆?</a></p><span class="bn-flat"><input type="button" class="tip-bn-cancel"  value="知道了"></span>',
    k = '<span class="donated-fail">{MSG}</span>',
    q = '<span class="donated-success">{MSG}</span>',
    d = "<p>处理中，请稍候...</p>",
    f = ".tip-bn-cancel",
    e = "processing",
    j = function(s, u) {
        s.replaceWith(k.replace("{MSG}", u));
        b()
    },
    h = function(s, w) {
        b();
        var v = $(p.replace("{BODY}", s)).appendTo("body"),
        z = w.offset(),
        u = [],
        y = $(window),
        x = y.scrollTop() + y.height();
        if ((x - z.top) < (v.height() + 20)) {
            u = [z.left, z.top - v.height() - w.height()]
        } else {
            u = [z.left, z.top + w.height()]
        }
        v.css({
            position: "absolute",
            left: u[0] + "px",
            top: u[1] + "px"
        });
        return v.show()
    },
    b = function() {
        $(".dou-tip").remove()
    },
    o = function(u, v) {
        var y = v.offset(),
        s = [],
        x = $(window),
        w = x.scrollTop() + x.height();
        if ((w - y.top) < (u.height() + 20)) {
            s = [y.left, y.top - u.height() - v.height()]
        } else {
            s = [y.left, y.top + v.height()]
        }
        u.css({
            left: s[0] + "px",
            top: s[1] + "px"
        })
    },
    n = function(u) {
        var s = function(v) {
            if (v.error) {
                this.elm.replaceWith(k.replace("{MSG}", v.error))
            } else {
                this.elm.replaceWith(q.replace("{MSG}", v.msg))
            }
            b()
        };
        u.preventDefault();
        this.args.is_first = 0;
        this.args.note = $.trim(u.target.elements.note.value);
        this.relateTip.html(d);
        o(this.relateTip, this.elm);
        $.dataPoster(this.url, this.args, $.proxy(s, this), "post", "json")
    },
    g = function(s) {
        s.preventDefault();
        b();
        if (this.elm) {
            this.elm.removeClass(e)
        }
    },
    r = function(s) {
        var x = this.elm,
        w, v, u;
        if (s.error) {
            j(x, s.error);
            return
        }
        if (s.balance) {
            u = h(l, x);
            this.relateTip = u;
            u.find("form").bind("submit", $.proxy(n, this));
            u.find(f).bind("click", $.proxy(g, this));
            u.find("input[type=text]").bind({
                focusin: function(y) {
                    $(this).prev().hide()
                },
                focusout: function(y) {
                    if (this.value === "") {
                        $(this).prev().show()
                    }
                }
            })
        } else {
            u = h(c, x);
            u.css("width", 260 + "px");
            this.relateTip = u;
            u.find(f).bind("click", $.proxy(g, this))
        }
        $(window).bind("resize",
        function() {
            o(u, x)
        })
    };
    $("body").delegate(".btn-donate", "click",
    function(z) {
        var B = $(z.currentTarget),
        s = B.attr("href").split("?"),
        w,
        u,
        x,
        y,
        v = {
            elm: B
        },
        A = {
            is_first: 1
        };
        z.preventDefault();
        if (B.hasClass(e)) {
            return
        }
        B.addClass(e);
        if (s[1]) {
            w = s[1].split("&");
            for (x = 0, y = w.length; x < y; x++) {
                u = w[x].split("=");
                A[u[0]] = u[1] || ""
            }
        }
        v.args = A;
        v.url = s[0];
        $.dataPoster(s[0], A, $.proxy(r, v), "post", "json")
    })
};

//0610添加开始
$(document).ready(function() {
	/*$("a.a_show_login").click(function(){
		if(!tcheck_p_login()){
			pop_win.load("/j/login");
			this.blur();
			return false;
		}else{
			//pop_win.load(this.href);//collect_btn
			$(this).removeClass('a_show_login');
			Douban.init_collect_btn(this);
			this.blur();
			return false;
		}
	});

	$("a.jjj").click(function(){
		pop_win.load(this.href);
		this.blur();
		return false;
	});*/
});
//验证码
function seccode() {
	var img = '/my.php?mod=accounts&ac=seccode&rand='+Math.random();
	document.writeln('<img id="img_seccode" src="'+img+'" align="absmiddle">');
}
//刷新验证码
function updateseccode() {
	var img = '/my.php?mod=accounts&ac=seccode&rand='+Math.random();
	if($('#img_seccode')) {
		$('#img_seccode').attr('src',img);
	}
}
function gp3_getCookie(a) {
    var b = a + "=";
    a = document.cookie.indexOf(b);
    if (a != -1) {
        a += b.length;
        b = document.cookie.indexOf(";", a);
        if (b == -1) b = document.cookie.length;
        return unescape(document.cookie.substring(a, b))
    } else return ""
}
function _getCookie(a) {
    return document.cookie.match(RegExp("(^" + a + "| " + a + ")=([^;]*)")) == null ? "": decodeURIComponent(RegExp.$2)
}
function gp3_setCookie(a, b, c) {
	var   c   =   (typeof(c)   ==   "undefined "?'':c);
	if(c != ''){
		c = new Date((new Date()).getTime() + c * 60000);
		expire = "; expires=" + c.toGMTString()+";path=/";
	}else{//默认生存期
		c = new Date((new Date()).getTime() + 60 * 60000);
		expire = "; expires=" + c.toGMTString()+";path=/";
	}
	document.cookie = a + "=" + encodeURIComponent(b) + "; path=/; domain=.3gp.cn; " +expire
}

function gp3_delCookie(a) {
    var b = new Date((new Date).getTime());
    document.cookie = a + "= ; path=/; domain=.3gp.cn; expires=" + b.toGMTString()
}
function tcheck_p_login(){
	var login = gp3_getCookie('3gploginuid');
	var login2 = _getCookie('3gploginnickname');
	if(login == '' || login2==''){	
		return false;
	}else{
		return true;
	}
}
function check_p_login(){
	var login = gp3_getCookie('3gploginuid');
	var login2 = _getCookie('3gploginnickname');
	if(login == '' || login2==''){	
		$("#p_login_d_l").html('<UL> <LI>邮箱： <INPUT id="username" maxLength="64" name="username"></LI> <LI>密码： <INPUT id="password" value="" maxLength="20" type="password" name="password"></LI> <LI> <INPUT onClick="to_p_login();" value="登录" type="button"> <A href="/accounts/register" target="_blank">注册会员</A></LI></UL>');
	}else{
		msg(login2,login);
	}
}
function msg(name,uid){	
	var ss = '<UL><LI><a target="_blank" href="/people/'+uid+'">'+name+'</a></LI>&nbsp;&nbsp;&nbsp;&nbsp;<LI><a href="javascript:p_logout();">退出</a></LI></UL>';
	$("#p_login_d_l").html(ss);
}
function p_logout(){
	gp3_delCookie('3gploginuid');
	gp3_delCookie('3gploginnickname');
	gp3_delCookie('3gpauth');
	gp3_delCookie('3gploginuser');
	var login = gp3_getCookie('3gploginuid');
	if(login == ''){
		$("#p_login_d_l").html('<UL> <LI>邮箱： <INPUT id="username" maxLength="64" name="username"></LI> <LI>密码： <INPUT id="password" value="" maxLength="20" type="password" name="password"></LI> <LI> <INPUT onClick="to_p_login();" value="登录" type="button"> <A href="/accounts/register" target="_blank">注册会员</A></LI></UL>');
	}
}
function to_p_login(){
	var username=$('#username').val();
	var password=$('#password').val();
	if(!isEmail(username)){
		alert('请输入正确的邮箱地址');
		$('#username').focus();
		return false;
	}
	if(password==''){
		alert('密码不能为空吧？！');
		$('#password').focus();
		return false;
	}
	$.getJSON("/my.php?mod=accounts&ac=loginajax&username="+encodeURIComponent(username)+"&password="+encodeURIComponent(password)+"&time="+new Date().getTime()+"&jsoncallback=?",function(data){
		if(data.login=='success'){
			gp3_setCookie('3gpauth',data.auth,60);
			gp3_setCookie('3gploginuser',data.loginuser,60);
			gp3_setCookie('3gploginuid',data.loginuid,60);
			gp3_setCookie('3gploginnickname',data.loginnickname,60);
			msg(data.loginnickname,data.loginuid);
		}else{
			if(data.login=='users_were_not_empty_please_re_login'){
				alert('邮箱不能为空，请重新登录。');
			}else if(data.login=='fail'){
				alert('登录失败');
			}else{
				alert('其他错误');
			}
		}
    });

}
function isEmail(v){  
	var a = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/ ;  
	if( !v.match(a) ){  
		return false;  
	}else{  
		return true;  
	}  
}

function show_login_do(){
	var username=$('#show_login_username').val();
	var password=$('#show_login_password').val();
	if(!isEmail(username)){
		alert('请输入正确的邮箱地址');
		$('#show_login_username').focus();
		return false;
	}
	if(password==''){
		alert('密码不能为空吧？！');
		$('#show_login_password').focus();
		return false;
	}
	$.getJSON("/my.php?mod=accounts&ac=loginajax&username="+encodeURIComponent(username)+"&password="+encodeURIComponent(password)+"&time="+new Date().getTime()+"&jsoncallback=?",function(data){
		if(data.login=='success'){
			data.auth && gp3_setCookie('3gpauth',data.auth,60);
			data.loginuser && gp3_setCookie('3gploginuser',data.loginuser,60);
			data.loginuid && gp3_setCookie('3gploginuid',data.loginuid,60);
			data.loginnickname && gp3_setCookie('3gploginnickname',data.loginnickname,60);
			msg(data.loginnickname,data.loginuid);
			show_login_msg('登陆成功');
			pop_win.close();
			//location.reload();
		}else{
			if(data.login=='users_were_not_empty_please_re_login'){
				show_login_msg('邮箱不能为空，请重新登录。');
			}else if(data.login=='fail'){
				show_login_msg('登录失败');
			}else{
				show_login_msg('其他错误');
			}
		}
    });

}
function show_login_msg(msg){	
	$("#show_login_msg").html(msg);
}
function submit_interest_form(){
        remote_submit_json('form',
        function(k) {
        	if(k.ok == 'ok'){
        		pop_win.close();
        	}else{
        		$("#error").html(k.ok);
        	}
        },
        false,$('#interest_form').attr("action"));
        //$("#submits").hide().after('<span class="m" id="saving">正在保存...</span>');
        refine_dialog();
        return false;

}
//load_event_monitor('interest_form');
//0610添加结束
