function ImgRotator (objId,speed)
{
	this.objId = objId; // VARIABLE SHOULD BE NAMED THIS AS WELL
	this.obj = getObj(objId);
	this.speed = speed;
	this.ImgSrc = new Object();
	this.ImgAlt = new Object();
	this.curIndex =  0;
	this.count = 0;
	this.started = false;
	this.preloaded = false;
	if (this.obj) { this.addImage(this.obj.src,this.obj.alt);	this.curIndex++; }
}

var IR = ImgRotator.prototype;

IR.addImage = function(source,alt) { this.ImgSrc[this.count] = source; this.ImgAlt[this.count++] = alt; }
IR.preloadImages = function() { for(i=0;i < this.count;i++) { var img= new Image(); img.src = this.ImgSrc[i]; } this.preloaded = true; }
IR.beginSlideShow = function() { if (!this.obj || this.count <=1) return; if(!this.preloaded) this.preloadImages(); this.obj.onload = function() { this.started = true; setTimeout("eval("+this.id+").showImage()",eval(this.id).speed); }; /*this.showImage();*/ }
IR.showImage = function () { 
	if (this.obj.parentNode){
		this.obj.parentNode.style.backgroundImage = 'url('+this.obj.src+')';
	}
	this.obj.title = this.ImgAlt[this.curIndex];
	this.obj.alt = this.ImgAlt[this.curIndex];
	this.obj.src = this.ImgSrc[this.curIndex];
	this.curIndex++; this.curIndex %= this.count;
	
	fadeIn(this.objId,0);
	if (!this.preloaded) { // fetch the next image when preloading has
		imgy = new Image();
		imgy.src = this.ImgSrc[this.curIndex];
	}
}