var Weed = { 
  hit: function() {
   var now = new Date();
   var host = "http://weed.rbse.com/";
   var key  = "A1a003"
   var uri = host + "stat/add_stat?key=" + key + "&";
   for (test in Weed.Tests) try { Weed.Tests[test].run(); } catch (e) { };
   uri += this.params.join('&');
    
    // Now actually send the stats.
   document.write('<img src="' +uri+ '" alt="" style="position:absolute; right:17761px;" onload="this.style.display=\'none\';" >');
  },

  params: [],
  result: function(k,v) {
   this.params.push(encodeURIComponent(k) + '=' + encodeURIComponent(v));
  }
}

if (!Array.prototype.push) {
  Array.prototype.push = function() {
    var startLength = this.length;
    for (var i = 0; i < arguments.length; i++)
      this[startLength + i] = arguments[i];
    return this.length;
  }
}

var Engine = {
  detect: function() {
    var UA = navigator.userAgent;
    this.isKHTML = /Konqueror|Safari|KHTML/.test(UA);
    this.isGecko = (/Gecko/.test(UA) && !this.isKHTML);
    this.isOpera = /Opera/.test(UA);
    this.isMSIE  = (/MSIE/.test(UA) && !this.isOpera);
  }
}
Engine.detect();

Weed.Tests = {}

Weed.Tests.Basics = {
  title: function() {
    return (document.title==null || document.title=="")? "No title" : document.title;
  },
  run: function() {
    Weed.result('referer', document.referrer);
    Weed.result('path_info', document.URL);
    Weed.result('page_title', this.title());  
  }
}
  
Weed.Tests.Resolution = {
  run: function() {
    Weed.result('resolution_x',screen.width);
    Weed.result('resolution_y',screen.height);
    Weed.result('color_depth',screen.colorDepth);
  }
}

Weed.Tests.SessionUser = {
  findCookie: function(name) {
    var cookies = document.cookie.split(';');
    for (var i=0; i<cookies.length; i++) {
      var c = cookies[i].split('=');
      if (c[0] == name) return(c[1]);
    }
    return '';
  },
  run: function() {
    Weed.result('user', this.findCookie('login'));
  }
}

Weed.Tests.Java = {
  run: function() {
    Weed.result('java', navigator.javaEnabled());
  }
}

Weed.Tests.Flash = {
  detect: function() {
    if(Engine.isMSIE) return this.detectIE();
    if(navigator.plugins && navigator.plugins.length) {
      var f = navigator.plugins["Shockwave Flash"];
      if (f && (d = f.description)) return d.charAt(d.indexOf('.')-1);
      if (navigator.plugins["Shockwave Flash 2.0"]) return 2;
    }
    if (navigator.mimeTypes && navigator.mimeTypes.length) {
       var f = navigator.mimeTypes['application/x-shockwave-flash'];
       if (f && f.enabledPlugin) return 2;
       return 1;  
    }
    return false;
  },
  detectIE: function() {
    for (var i=7; i>0; i--) {
      try{ var f = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i); return i; }
      catch(e) {}
    }
    return false;
  },
  run: function() {
    Weed.result('flash', this.detect());
  }
}

// more complex example
Weed.Tests.VisibleDimensions = {
  run: function() {
    var x; var y;
    if (self.innerHeight) { // all except Explorer
      x = self.innerWidth;
      y = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      x = document.documentElement.clientWidth;
      y = document.documentElement.clientHeight;
    }
    else if (document.body) { // other Explorers
      x = document.body.clientWidth;
      y = document.body.clientHeight;
    }
    Weed.result('viewport_x', x);
    Weed.result('viewport_y', y);
  }
}

Weed.hit();
