//------------------------------------------------------------------------
// Class: Slideshow
//------------------------------------------------------------------------
Slideshow =
{

	//--------------------------------------------------------------------
	// Public Variables
	//--------------------------------------------------------------------
	current_index:    1,
	max_index:        4,
	update_speed:     5000,


	//--------------------------------------------------------------------
	// Public Member Functions
	//--------------------------------------------------------------------
	//--------------------------------------------------------------------
	// Function: update()
	// Update the text.
	//--------------------------------------------------------------------
	update: function()
	{
		
		// Get the new index.
		Slideshow.current_index++;
		
		if ( Slideshow.current_index > Slideshow.max_index )
			Slideshow.current_index = 1;
				
		// Get the two images for enlargement.
		var image1 = document.getElementById( "main_image1" ).getElementsByTagName( "img" )[0];
		var image2 = document.getElementById( "main_image2" ).getElementsByTagName( "img" )[0];
		
		// Set image1 to have image2's source because we're about
		// to switch the src on image2 and fade it in.
		image2.src = image1.src;
		
		// Make image1 invisible so that we can fade it in.
		LW_DOM_Library.setStyle( image1, "opacity", 0 );
		
		// Set the image2's src as the new image that the user wants to view.
		image1.src = image1.src.substring( 0, image1.src.length - 5 ) + Slideshow.current_index + ".jpg";
		
		// Create the fading animation for the new enlarged image.
		var anim = new LW_Animation( image1, 1500 );	
		anim.controller.opacity.to = 1;
		
		// Start the image fading animation.
		anim.start();
		
	}

}

// Set to initialize when the page loads.
LW_Events_Handler.addEvent( window, "onload", function(){ setInterval( Slideshow.update, Slideshow.update_speed ); } );
