// ********* SlideShow object ***************************************

function SlideShow( uniqueId )
{
	this.uniqueId = uniqueId;

	this.init = function()
	{ 
		this.currentIndex = 1;
		this.picturebox = document.getElementById( this.uniqueId );
		if ( this.captioncontrolid )
			this.captioncontrol = document.getElementById( this.captioncontrolid );
		
		// Preload the pictures.
		this.pictureCount = this.picturepaths.length;
		this.preLoad = new Array();
		for ( i = 1; i < this.pictureCount; i++ )
		{
			this.preLoad[i] = new Image();
			this.preLoad[i].src = this.picturepaths[i];
		}
	}
		
	// --------- Command functions ------------------------------------

	// Function called with setInterval() in the startup script.
	// See string GetStartupScript() in the control code.
	this.nextpicture = function()
	{
		// Advance the index.			
		this.currentIndex = this.currentIndex + 1;
		if ( this.currentIndex >= this.pictureCount )
			this.currentIndex = 1;

		this.picturebox.style.filter = "blendTrans( duration=this.crossfade )";
		this.picturebox.filters.blendTrans.Apply();
		this.picturebox.src = this.preLoad[this.currentIndex].src;
		
		if ( this.captioncontrol )
			captioncontrol.innerHTML = captions[this.currentIndex];
				
		this.picturebox.filters.blendTrans.Play();
	}
}
