

function theRotator() {
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',3000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:last'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.prev().length) ? ((current.prev().hasClass('show')) ? $('div#rotator ul li:last') :current.prev()) : $('div#rotator ul li:last'));
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.addClass('show');

	//Hide the current image
	current.removeClass('show');
	
};

$(document).ready(function() {		
	//Load the slideshow
	theRotator();
	
});

