﻿//加入收藏
$(function(){
    setMenu(0);
})

function setMenu(currentNumber)
{
    $(".menulist").each(function(i){
        if(i==currentNumber){
            $("#menu" + i).addClass("menu_current");
            menuCurrent = i;
        }
        
        $(this).hover(
            function(){
                $("#menu" + menuCurrent).removeClass("menu_current");
                $(this).addClass("menu_current");
                $(this).find("ul").fadeIn(200);
            },
            function(){
                $(this).removeClass("menu_current");
                $("#menu" + menuCurrent).addClass("menu_current");
                $(this).find("ul").fadeOut(200);
            }                
        )
    })
}

function addFavorite(sURL, sTitle)
{
   try
   {
       window.external.addFavorite(sURL, sTitle);
   }
   catch (e)
   {
       try
       {
           window.sidebar.addPanel(sTitle, sURL, "");
       }
       catch (e)
       {
           alert("加入收藏失败，请使用Ctrl+D进行添加");
       }
   }
}

//设为首页
function setHomepage(sUrl)
{
    if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
        document.body.setHomePage(sUrl);
    }
    else if (window.sidebar)
    {
        if(window.netscape)
        {
            try
            {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch(e)
            {
                alert("this action was aviod by your browser，if you want to enable，please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
            }
         }
         var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
         prefs.setCharPref('browser.startup.homepage',sUrl);
     }
}
