//cookie处理
var Cookie = {
    get: function (n) {
        var dc = "; " + document.cookie + "; ";
        var coo = dc.indexOf("; " + n + "=");
        if (coo != -1) {
            var s = dc.substring(coo + n.length + 3, dc.length);
            return unescape(s.substring(0, s.indexOf("; ")));
        } else {
            return null;
        }
    },
    set: function (name, value, expires, path, domain, secure) {
        var expDays = expires * 24 * 60 * 60 * 1000;
        var expDate = new Date();
        expDate.setTime(expDate.getTime() + expDays);
        var expString = expires ? "; expires=" + expDate.toGMTString() : "";
        var pathString = "; path=" + (path || "/");
        var domain = domain ? "; domain=" + domain : "";
        document.cookie = name + "=" + escape(value) + expString + domain + pathString + (secure ? "; secure" : "");
    },
    del: function (n) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval = this.get(n);
        if (cval != null) document.cookie = n + "=" + cval + ";expires=" + exp.toGMTString();
    }
}

function addCookie() {
    if (document.all) { window.external.addFavorite('http://tool.zbole.com/', '伯乐网站长工具'); }
    else if (window.sidebar) { window.sidebar.addPanel('伯乐网站长工具', 'http://tool.zbole.com/', ""); }
}
function setHomepage() {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage('http://tool.zbole.com/')
    } else if (window.sidebar) {
        if (window.netscape) {
            try
   { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }
   catch (e) { window.sidebar.addPanel('伯乐网站长工具', 'http://tool.zbole.com/', ""); }
        } var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage', 'http://tool.zbole.com/');
    }
}

function linkrand() {
    return fRandomBy(4, 8);
}
function fRandomBy(under, over) {
    switch (arguments.length) {
        case 1: return parseInt(Math.random() * under + 1);
        case 2: return parseInt(Math.random() * (over - under + 1) + under);
        default: return 0;
    }
} 

function showQQ() {
    document.writeln("<a target=_blank href=\"http:\/\/wpa.qq.com\/msgrd?v=3&uin=2224701471&site=qq&menu=yes\">在线建议<\/a>|")
}

function tj() {
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-23619575-1']);
    _gaq.push(['_setDomainName', '.zbole.com']);
    _gaq.push(['_setAllowHash', 'false']);
    _gaq.push(['_trackPageview']);

    (function () {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.go'+'ogle-ana'+'lytic'+'s.com/g'+'a.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
}

String.format = function () {
    if (arguments.length == 0)
        return null;

    var str = arguments[0];
    for (var i = 1; i < arguments.length; i++) {
        var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
        str = str.replace(re, arguments[i]);
    }
    return str;
} 