var _this;

function imageRotator(viewport, cycleOffset)
{
   _this = this;
   this.imageStack = new Array;
   this.offset = cycleOffset;

   var exists = document.getElementById(viewport);
   if(!eval(exists))
   {
      alert('Element ID does not exist.');
   }
   else
   {
      this.viewport = viewport;
   }
}

imageRotator.prototype.getRandom = function()
{
   var random = Math.floor(Math.random() * this.imageStack.length);

   return this.imageStack[random];
}

imageRotator.prototype.setViewport = function()
{
   document.getElementById(_this.viewport).src = _this.getRandom();
}

imageRotator.prototype.start = function()
{
   this.setViewport();
   setInterval(function() { _this.setViewport() }, _this.offset);
}

imageRotator.prototype.add = function(imageName)
{
   this.imageStack.push(imageName);
}
