﻿var ie6 = false;
$(function () {
    $("a[href^='#']").attr("href", "JavaScript:void(0)");
    // ie6
    if ($.browser.msie && parseInt($.browser.version) < 7) {
        ie6 = true;
        $.include("/JS/JQuery/PNGFix.js", function () {
            $(document).PNGFix("/Images/Blank.gif");
        });
    }
    //登录
    if ($("a.LogOnWin").length > 0) {
        if ($("link[href$='/CSS/LogOn.css']").length == 0) {
            $.include(["/CSS/LogOn.css"]);
        }
        if ($("#LogOnWin").length == 0) {
            $("<div>").attr("id", "LogOnWin").hide().appendTo("body").load("/LogOn.html?_=" + $.Ext.GetRandom(6), function () {
                $.include(["/JS/Login.js"]);
            });
        }
        $("a.LogOnWin").click(function () { $.cover(true, 1000); $("#LogOnWin").show().find(".LogOn").show(); });
    } else {
        if ($(".AccountLogin").length > 0 && $("script[src$='/JS/Login.js']").length == 0) {
            $.include(["/JS/Login.js"]);
        }
    }
    // 下拉菜单样式 
    $(".Drop").hover(function () {

    }, function () {
        $(this).find("ul").hide();
    }).children("span").click(function (event) {
        $(this).next().show().find("li").show().filter("[value=" + $(this).attr("value") + "]").hide();
    }).end().children("ul").children("li").hover(function () {
        $(this).addClass("Hover");
    }, function () {
        $(this).removeClass("Hover");
    }).click(function () {
        $(this).closest(".Drop").find("input:hidden").val($(this).attr("value")).end().find("span").attr("value", $(this).attr("value")).find("font").text($(this).text()).end().end().find("ul").hide();
    });

    // CarouFredSel
    if ($("div.iIVLayer").length > 0) {
        $.include("/JS/JQuery/CarouFredSel.js", function () {
            $("#IVPanel").carouFredSel({
                auto: true,
                prev: "#IV_Prev",
                next: "#IV_Next",
                items: 5,
                scroll: { items: 5, duration: 1000, pauseOnHover: true }
            });
            $("#IV_Prev,#IV_Next").click(function () {
                $(this).blur();
            });
        });
    }

    try {
        $("img").not(".FucusImg img").lazyload({ effect: "fadeIn" });
    } catch (e) { }

    // imgAutoSize
    if ($(".imgAutoSize").length > 0) {
        $.include("/JS/JQuery/imgAutoSize.js", function () {
            $(".imgAutoSize").imgAutoSize(2);
        });
    }
    // soChange
    if ($(".FucusImg").length > 0) {
        $.include("/JS/JQuery/soChange.js", function () {
            $(".FucusImg>div").soChange({
                thumbObj: ".FucusImg>.ThumChange>li>a"
            });
        });
    }
    // Comment
    if ($("div.Comment").length > 0) {
        $.include("/JS/Comment.js");
    }
    //收藏与设为首页
    $("#AddFav").click(function () {
        if (document.all) {
            window.external.AddFavorite(SiteURL, SiteName);
        }
        else if (window.sidebar) {
            window.sidebar.addPanel(SiteName, SiteURL, "");
        }
    });
    $("#SetHome").click(function () {
        if (document.all) {
            document.body.style.behavior = 'url(#default#homepage)';
            document.body.setHomePage(SiteURL);
        } else if (window.sidebar) {
            if (window.netscape) {
                try {
                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                } catch (e) {
                    $.alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为 true");
                }
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', SiteURL);
        }
    });

    $("table.List > tbody > tr:visible").unbind().live("mouseenter", function () {
        $(this).removeClass("Activ").toggleClass("Hover");
    }).live("mouseleave", function () {
        $(this).removeClass("Activ").toggleClass("Hover");
    }).live("mousedown", function () {
        $(this).addClass("Activ");
    });

    $("a.Button").Buttons();
});



