﻿//<![CDATA[
var goto_top_type = -1;
var goto_top_itv = 0;

function goto_top_timer() {
    var y = goto_top_type == 1 ? document.documentElement.scrollTop : document.body.scrollTop;
    var moveby = 15;

    y -= Math.ceil(y * moveby / 100);
    if (y < 0) {
        y = 0;
    }

    if (goto_top_type == 1) {
        document.documentElement.scrollTop = y;
    }
    else {
        document.body.scrollTop = y;
    }

    if (y == 0) {
        clearInterval(goto_top_itv);
        goto_top_itv = 0;
    }
}

function goto_top() {
    if (goto_top_itv == 0) {
        if (document.documentElement && document.documentElement.scrollTop) {
            goto_top_type = 1;
        }
        else if (document.body && document.body.scrollTop) {
            goto_top_type = 2;
        }
        else {
            goto_top_type = 0;
        }

        if (goto_top_type > 0) {
            goto_top_itv = setInterval('goto_top_timer();', 50);
        }
    }
}
//]]>

function addFav() {
    try {
        window.external.AddFavorite('http://news.yourke.net/', '-旅游人 ');
    }
    catch (e) {
        try {
            window.sidebar.addPanel("旅游人", "http://news.yourke.net/", "");
        }
        catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}

function addHome() {
    //document.body.style.behavior = 'url(#default#homepage)';
    //document.body.setHomePage('http://www.yourke.com');
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage('http://news.yourke.net/');
    }
    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', 'www.yourke.net');
    }
}