// Rollover Object version 1.0
// written by: Jon M. Toribio

function Rollover(tgt, on_img) {
   arg = Rollover.arguments;
   if (arg.length < 2) {
      alert("new Rollover: wrong number of parameters passed. Expecting at least 2.");
      return null;
   }

   // Properties
   this.active = true;

   imgObj = eval("document."+tgt);
   if (imgObj && imgObj.length) { 
      this.tgt = "document."+tgt+"[0]"; 
   }
   else { 
      this.tgt = "document."+tgt; 
   }
   
   // if a Layer ID has been specified change this.tgt
   if (arg[4]) {
      if (document.layers) {
         this.tgt = "document.layers['" + arg[4] + "'].document.images['"+tgt+"']";
      } 
      if (document.all) {
         this.tgt = "document."+tgt; 
      }
   }

   if (document.images) {
      this.on_image = new Image();
      this.on_image.src = on_img;
      if (arg[2]) {
         this.off_image = new Image();
         this.off_image.src = arg[2];
      }
      if (arg[3]) {
         this.down_image = new Image();
         this.down_image.src = arg[3];
      }
   }
   return this;
}

// ===========================================================================
// Methods
// ===========================================================================

function Rollover_on() {
   if (document.images && this.on_image && this.active) {
      theObj = eval(this.tgt);
      if (theObj) { theObj.src = this.on_image.src; }
   }
}

function Rollover_off() {
   if (document.images && this.off_image && this.active) {
      theObj = eval(this.tgt);
      if (theObj) { theObj.src = this.off_image.src; }
   }
}

function Rollover_down() {
   if (document.images && this.down_image && this.active) {
      theObj = eval(this.tgt);
      if (theObj) { theObj.src = this.down_image.src; }
   }
}

function Rollover_activate() { this.active = true; }
function Rollover_deactivate() { this.active = false; }

// For Navigator 3 compatibility we have to call
// the constructor before we can work with the prototype.
new Rollover("noidion","");

// Assigning the methods to the prototype
Rollover.prototype.on         = Rollover_on;
Rollover.prototype.off        = Rollover_off;
Rollover.prototype.down       = Rollover_down;
Rollover.prototype.activate   = Rollover_activate;
Rollover.prototype.deactivate = Rollover_deactivate;

