stat = {
    refresh : function(data){
        var _div = document.getElementById("statistic");
        _div.innerHTML = "";
        var b = stat.getCookie("page_size_before");
        var a = stat.getCookie("page_size_after");  
        if (a && b && a != '0') {
          _div.innerHTML +=
            "[GZip: " +
            "<span>"+a+"</span>/" +
            "<span>"+b+"</span> " +
            "<span>("+(100-Math.round(a/b*100))+"%)</span>" +
            "]";
        } else {
          _div.innerHTML +="[GZip off]";
        }
        var t = stat.getCookie("page_gentime");
        if (t) {
          _div.innerHTML += "[Time: " + parseInt(t*1000)/1000 + " s]" 
        }
        var sql_t = stat.getCookie("page_sqltime");
        if (sql_t) {
          _div.innerHTML += "[SQLTime: " + parseInt(sql_t*1000)/1000 + " s ("+(Math.round(sql_t/t*100))+"%)]"
        }
        var sql_c = stat.getCookie("page_sqlcount");
        if (sql_c) {
          _div.innerHTML += "[SQLCount: " + sql_c +" ]"
        }
        var cache_c = stat.getCookie("page_cache");
        if (cache_c) {
          _div.innerHTML += "[Cache: " + cache_c +" ]"
        }
    },
    getCookie: function (name) {
      var p = name + "=";
      var si = document.cookie.indexOf(p);
      if (si == -1) return null;
      var ei = document.cookie.indexOf(";", si + p.length);
      if (ei == -1) ei = document.cookie.length;
      return unescape(document.cookie.substring(si + p.length, ei));
    },
    
        d : function(o, e, a){

      if (o.addEventListener) return o.addEventListener(e, a, false);

      else if (o.attachEvent) return o.attachEvent("on" + e, a);

      else return false;

    }
}


stat.d(window.addEventListener || window.attachEvent ? window : document.addEventListener ? document : null, "load", stat.refresh);
