//Array.shuffle( deep ) - Randomly interchange elements
Array.prototype.shuffle = function( b ) {
 var i = this.length, j, t;
 while( i ) {
  j = Math.floor( ( i-- ) * Math.random() );
  t = b && typeof this[i].shuffle!=='undefined' ? this[i].shuffle() : this[i];
  this[i] = this[j];
  this[j] = t;
 }
 return this;
};

function teasers(numImages,targetImg)
{
	//image cache = document.rotImgCache
	var self = this;

	this.targetImg = targetImg;

	this.numImages = 5;
	if( numImages )
	{
		this.numImages = numImages;
	}

	this.ptr = 1;
	this.timer = '';
	this.delay = 3000;

	this.load = function(start)
	{
		//shuffle the image cache 
		document.rotImgCache.shuffle();

		if(start)
		{
			//alert(self.delay);
			this.timer = setTimeout('oTeasers.loop()',self.delay);
		}
	}

	this.loop = function()
	{
		if( self.ptr > (self.numImages -1) )
		{
			self.ptr = 0;
		}

		//alert(document.rotImgCache[self.ptr].src);
		$(self.targetImg).src = document.rotImgCache[self.ptr].src;

		self.ptr++;
		this.timer = setTimeout('oTeasers.loop()',self.delay);
	}
}