﻿/*  ----------------------------------------------------------------------------------------------------------------------
        SET STARTUP PAGE ON BROWSER - WORKS FOR IE AND FIREFOX - 2009-11-24
        
        Ref: http://forums.asp.net/t/1279376.aspx
        
        DESCRIPTION:
        ------------
        You cannot set the home page on Firefox if the browser's bool value, signed.applets.codebase_principal_support 
        in about:config is set to false. The only thing we can do is remind the user to change this setting to true. If 
        the user does this, than the next time this is called, the request will be carried out.
        
    ---------------------------------------------------------------------------------------------------------------------- */
function setHomepage() {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage('http://www.free.se');

    }
    else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("This action was avoided by your browser. If you want to enable this please enter about:config in your address line, and change the value of signed.applets.codebase_principal_support to true. You do this by right-clickning signed.applets.codebase_principal_support and then click switch.");
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', 'http://www.free.se');
    }
}
