﻿/***************************************************************************************

	Source: http://www.alohatechsupport.net/webdesignmaui/maui-web-site-design/easy_jquery_auto_image_rotator.html

***************************************************************************************/

function startRotator()
{
	//Set the opacity of all images to 0
	$('div#Rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#Rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 7000 = change to next image after 7 seconds
	setInterval('rotate()', 7000);
}

function rotate()
{	
	//Get the first image
	var current = ($('div#Rotator ul li.Show')?  $('div#Rotator ul li.Show') : $('div#Rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('Show')) ? $('div#Rotator ul li:first') :current.next()) : $('div#Rotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('Show')
	.animate({opacity: 1.0}, 1500);

	//Hide the current image
	current.animate({opacity: 0.0}, 1500)
	.removeClass('Show');
};

