

function Rollover(id, normalSrc, rolloverSrc) {
   this.id = id;
   this.normalSrc = normalSrc;
   this.rolloverSrc = rolloverSrc;
   if (Image) {
      var normal = new Image();
      normal.src = this.normalSrc;
      var rollover = new Image();
      rollover.src = this.rolloverSrc;
   }
   this.image = null;
   addEventDelegate(window, "onload", this);
}

Rollover.prototype.onload = function() {
   this.image = document.getElementById(this.id);
   if (this.image) {
      this.getContainingCell(this.image);
      if (this.imageContainer) {
         addEventDelegate(this.imageContainer, "onmouseover", this);
         addEventDelegate(this.imageContainer, "onmouseout", this);
      }
   }
}

Rollover.prototype.onmouseover = function() {
   this.image.src = this.rolloverSrc;
   //this.imageContainer.style.backgroundColor = "#4c4c4c";
   //this.imageContainer.style.backgroundColor = "#ee3338";
   this.imageContainer.style.backgroundColor = "#fe2f35";
}

Rollover.prototype.onmouseout = function() {
   this.image.src = this.normalSrc;
   this.imageContainer.style.backgroundColor = this.imageContainerBackground;
}

Rollover.prototype.getContainingCell = function(image) {
   var currentElement = image;
   while (currentElement && currentElement.tagName.toLowerCase() != "td") {
      currentElement = currentElement.parentNode;
   }
   if (currentElement) {
      this.imageContainer = currentElement;
      if (currentElement.currentStyle) {
         this.imageContainerBackground = this.imageContainer.currentStyle.backgroundColor;
      } else if (document.defaultView.getComputedStyle) {
         this.imageContainerBackground = document.defaultView.getComputedStyle(currentElement,null).backgroundColor;
      }
   }
}

