String.prototype.trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.contains = function(str){
    return this.indexOf(str) != -1;
}

String.prototype.startsWith = function(str){
    return this.indexOf(str) === 0;
}
/**
 * 加入收藏夹
 * @param url：加入收藏的链接地址
 */
function addHomePage(url)
{
    if (window.sidebar)
    {
        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",url);
    }
    else if(document.all)
    {
        document.body.style.behavior="url(#default#homepage)";
        document.body.setHomePage(url);
    }
    else
    {
        ;
    }
}
/**
 * 加入收藏夹
 * @param title 标题
 * @param url 网页地址
 * @returns {Boolean}
 */
function addBookMark(title,url) {
	if (window.sidebar) {
	  window.sidebar.addPanel(title, url,"");
	}
	else if(document.all) {
	   window.external.AddFavorite(url, title);
	}
	else if( window.opera && window.print )
	{
	    return true;
	}
}

