﻿function showHotNews(index) {
    $(".hotNewsHeadMenu ul li").removeClass("current").eq(index).addClass("current");
    $(".hotNewsList").hide().eq(index).show();
}
function showHotVideo(index) {
    $(".hotVideoHeadMenu ul li").removeClass("current").eq(index).addClass("current");
    $(".hotVideoList").hide().eq(index).show();
}
function showHotKnowledges(index) {
    $(".hotKnowledgesHeadMenu ul li").removeClass("current").eq(index).addClass("current");
    $(".hotKnowledgesList").hide().eq(index).show();
}
function showLastestInterview(index) {
    $(".lastestInterviewHeadMenu ul li").removeClass("current").eq(index).addClass("current");
    $(".lastestInterviewUL").hide().eq(index).show();
}
function FlashShow() {
    this.hbIndex = 0;
    this.cindex = 0;
    this.player = null;
    this.max = 0;
    this.option = {};
    Default = {
        Delay: 6000,
        Container: null,
        Images: null,
        ShowButtons: false
    };
    this.Play = function () {
        var old = this.hbIndex;
        this.hbIndex++;
        if (this.hbIndex >= this.max) {
            this.hbIndex = 0;
        }
        this.cindex = this.hbIndex;
        if (this.option.ShowButtons)
            this.ChangeButtonStyle();
        this.option.Images.eq(this.hbIndex).fadeIn(600);
        this.option.Images.eq(old).fadeOut(600);
    }
    this.PlayIndex = function () {
        var old = this.hbIndex;
        this.hbIndex = this.cindex;
        if (this.hbIndex >= this.max) {
            this.hbIndex = 0;
        }
        if (this.option.ShowButtons)
            this.ChangeButtonStyle();
        this.option.Images.eq(this.hbIndex).fadeIn(600);
        this.option.Images.eq(old).fadeOut(600);
    }
    this.Init = function () {
        $.extend(this.option, Default, arguments[0]);
        if (this.option.Images) {
            this.max = this.option.Images.length;
            var THIS = this;
            if (this.option.ShowButtons) {
                var buttonStr = '<div class="flashButtons clear">';
                for (i = 0; i < this.max; i++) {
                    if (i == 0)
                        buttonStr += '<a href="javascript:void(0);" class="selected">&nbsp;</a>';
                    else
                        buttonStr += '<a href="javascript:void(0);">&nbsp;</a>';

                }
                buttonStr += "</div>";
                this.option.Container.append(buttonStr);
                this.option.Container.find(".flashButtons").children("a").hover(function () {
                    clearInterval(THIS.player);
                }, function () {
                    THIS.player = setInterval(function () { THIS.Play(); }, THIS.option.Delay);
                }).click(function () {
                    var i = THIS.option.Container.find(".flashButtons").children("a").index(this);
                    THIS.cindex = i;
                    THIS.PlayIndex();
                });
            }
            this.player = setInterval(function () { THIS.Play(); }, this.option.Delay);
        }
    }
    this.ChangeButtonStyle = function () {
        this.option.Container.find(".flashButtons").children("a").removeClass("selected").eq(this.cindex).addClass("selected");
    }
    this.Stop = function () {
        clearInterval(this.player);
    }
} 
function addFavorite() {
    if (document.all) {
        window.external.addFavorite("http://" + window.location.host, "星巢创业网");
    }
    else if (window.sidebar) {
        window.sidebar.addPanel("星巢创业网", "http://" + window.location.host, "");
    }
}
function setHomepage() {
    if (document.all) {
        document.body.style.behavior = "url(#default#homepage)";
        document.body.setHomePage("http://" + window.location.host);
    }
    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", "http://" + window.location.host);
    }
}
