﻿function AddFavorite(sURL, sTitle) {
    try {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, '');
        }
        catch (e) {
            alert('Favorite fails, please use Ctrl + D to add.');
        }
    }
}

function SetHome(obj, vrl) {
    try {
        obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(vrl);
    }
    catch (e) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
            }
            catch (e) {
                alert('This operation is your browser to refuse! \ n in the browser address bar type \'about: config\' and press ENTER \ n then [signed.applets.codebase_principal_support] value is set to \'true\', by double clicking.');
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', vrl);
        }
    }
}

function SetHomepage(vrl) {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(vrl);
    }
    else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
            }
            catch (e) {
                alert('This operation has been your browser to refuse, if you want to enable this feature in the address bar type about: config, and then the value of the item signed.applets.codebase_principal_support is true.');
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', 'http://www.langligelang.com');
    }
}