﻿$(function () {
    var mouserover_tid = [];
    var mouseout_tid = [];
    $("#navihover li").each(function (index) {
        $(this).hover(
        //鼠标进入
            function () {
                var _self = this;
                //停止卷起事件
                clearTimeout(mouseout_tid[index]);
                mouserover_tid[index] = setTimeout(function () {
                    var posi = $(_self).position();
                    $(_self).find('ul:eq(0)').slideDown(200).offset({
                        top: 124,
                        left: posi.left
                    });
                }, 200);


            },
        //鼠标离开
            function () {
                var _self = this;
                clearTimeout(mouserover_tid[index]);
                //当鼠标离开超过0.2秒,卷起菜单，并记录到线程ID中
                mouseout_tid[index] = setTimeout(function () {
                    $(_self).find("ul:eq(0)").slideUp(300);
                }, 100);
            }
        );
    });

    $.extend({
        show: function () {
            $("#AutoDisplay ul").each(function () {
                $(this).toggle(1000);
            });
        }
    });

    setInterval("$.show()", 4000)
});

/**
$(function () {
    $("#navihover li .a").hover(
                function () {
                    $("#navihover li a").removeClass("cur");
                    $(this).addClass("cur");
                    $("#navihover li .sub_navi").css("display", "none");
                    $(this).parent().find(".sub_navi").css("display", "");
                    var posi = $(this).position();
                    var submenu = $(this).parent().find(".sub_navi");
                    submenu.offset({
                        top: 124,
                        left: posi.left
                    });

                },
                function () {
                    var submenu = $(this).parent().find(".sub_navi").css("display", "");
                    submenu.slideUp("slow");
                }
            );


    $.extend({
        show: function () {
            $("#AutoDisplay ul").each(function () {
                $(this).toggle(1000);
            });
        }
    });

    setInterval("$.show()", 4000)
});
**/

function Search() {
    var keyword = $("#txt_search");
    if (keyword == null || keyword.val().length == 0) {
        alert("请输入关键字.");
        keyword.focus();
        return false;
    }

    window.location.href = 'search.aspx?key=' + escape(keyword.val());
}

function SetHome(obj) {
    var vrl = "http://www.jovian.com.cn";
    try {
        obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(vrl);
    }
    catch (e) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', vrl);
        }
    }
}
