function Rotator(width, height, interval) {
  this.id = Rotator.instances.length;
  Rotator.instances[this.id] = this;	
	
	this._images = [];
	this._width = width;
	this._height = height;
	this.interval = (!interval) ? 5000 : interval * 1000;
	
	this.add = function (src) {
		// preload images as they are added
		var img = new Image();
		img.src = src;
		this._images.push(img);
	}
	
	this.rotate = function() {
		this._current = (this._current == undefined) ? 0 : this._current + 1;
		if (this._current == this._images.length) {
			this._current = 0;			
		}
		var rot = document.getElementById('rotator_image_container');
		rot.src = this._images[this._current].src;
	}
	
	this.draw = function() {
		var style  = 'width:' + this._width + ';';
		    style += 'height:' + this._height + ';';
		    style += 'overflow:hidden;';
		
		document.write('<div style="' + style + '">');
    document.write('<img id="rotator_image_container" src="' + this._images[0].src + '" />');
		document.write('</div>');
		
		window.setInterval('Rotator.instances[' + this.id + '].rotate()', this.interval);
	}
}