// Thumby
// Verkleinert Bilder ab bestimmten Groessen
// (c) 2010 by Dicope
// Mail: dicope [aht] plan-of-attack [puhnkt] net
// ==UserScript==
// @name          Thumby
// @namespace     http://greasemonkey.ppopn.net
// @description   Verkleinert Bilder ab bestimmten Groessen
// @description   Verkleinert Bilder ab bestimmten Groessen
// @include       http://82.149.226.131/bb/thread.php*
// @include       http://forum.counter-strike.de/bb/thread.php*
// @include       http://forum.cstrike.de/bb/thread.php*
// @include       http://forum.mods.de/bb/thread.php*
// ==/UserScript==

/////////////// [ KONFIGURATION ] ///////////////

var maxw = 300;	// Maximale Breite eines Bildes
var maxh = 200;	// Maximale Hoehe eines Bildes
var thbw = 150;	// Breite des Thumbnails
var thbh = 100;	// Hoehe des Thumbnails

/////////////////////////////////////////////////

var checkzoom = function() {
  if(this.scrollWidth - this.naturalWidth != 0) {
    this.style.maxHeight = this.naturalHeight;
    this.style.maxWidth = this.naturalWidth;
    this.style.cursor = "-moz-zoom-out;"
    this.style.MozOpacity = 1;
  } else {
    this.style.maxHeight = thbh + "px";
    this.style.maxWidth = thbw + "px";
    this.style.cursor = "-moz-zoom-in;"
    this.style.MozOpacity = 0.5;
  }
}

var checksize = function(e) {
  if((this.scrollWidth > maxw || this.scrollHeight > maxh) && this.src.indexOf("/bb/img/logo1a.gif") == -1) {
    this.style.maxWidth = thbw + "px";
    this.style.maxHeight = thbh + "px";
    this.style.cursor = "-moz-zoom-in;"
    this.style.MozOpacity = 0.5;
    this.addEventListener("click", checkzoom, true);
    this.addEventListener("mouseover", function(e) { if(this.scrollWidth - this.naturalWidth != 0) { e.target.style.MozOpacity = 1; } }, true);
    this.addEventListener("mouseout", function(e) { if(this.scrollWidth - this.naturalWidth != 0) { e.target.style.MozOpacity = 0.5; } }, true);
  }
}

var i = 0;
var imgs = document.getElementsByTagName("img");
while (i < imgs.length) {
  imgs[i].addEventListener("load", checksize, true);
  i++;
}