// NB - global array to store rotator objects - can't get at them from setTimeout otherwise ...
arrRotatorObjects = new Array();

function imageRotator(imgName) {

  this.imgName = imgName;
  this.images = new Array();
  this.currImg = -1;
  this.delay = 2500;

  arrRotatorObjects.push(this);
  this.objIndex = arrRotatorObjects.length - 1;

  this.addImage = function(imgSrc) {
    this.images.push(imgSrc);
  }
  
  this.runRotator = function() {
    if(!document.images) return; // Don't bother if the browser doesn't support it.
    this.currImg++;
    if(this.currImg >= this.images.length) this.currImg = 0;
    document.images[this.imgName].src = this.images[this.currImg];
    if(this.images.length > 1) {
      setTimeout("arrRotatorObjects["+this.objIndex+"].runRotator();", this.delay);
    }
  }
  
}