function theRotator() {
	//Set the opacity of all images to 0
	$('div.rotator_banner ul li').css({opacity: 0.0});
	$('div.rotator_promos ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.rotator_banner ul li:first').css({opacity: 1.0});
	$('div.rotator_promos ul li:first').css({opacity: 1.0});
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	
	setInterval('rotate()',10000);
}

function rotate() {	
	//Get the first image
	var current_banner = ($('div.rotator_banner ul li.show')?  $('div.rotator_banner ul li.show') : $('div.rotator_banner ul li:first'));
	var current_promos = ($('div.rotator_promos ul li.show')?  $('div.rotator_promos ul li.show') : $('div.rotator_promos ul li:first'));
	
    if ( current_banner.length == 0 ) current_banner = $('div.rotator_banner ul li:first');
	if ( current_promos.length == 0 ) current_promos = $('div.rotator_promos ul li:first');
	
	//Get next image, when it reaches the end, rotate it back to the first image
	var next_banner = ((current_banner.next().length) ? ((current_banner.next().hasClass('show')) ? $('div.rotator_banner ul li:first') :current_banner.next()) : $('div.rotator_banner ul li:first'));
	var next_promos = ((current_promos.next().length) ? ((current_promos.next().hasClass('show')) ? $('div.rotator_promos ul li:first') :current_promos.next()) : $('div.rotator_promos ul li:first'));
	//Un-comment the 3 lines below to get the images in random order
	
	var sibs = current_banner.siblings();
    var rndNum = Math.floor(Math.random() * sibs.length );
    var next = $( sibs[ rndNum ] );
			

	//Set the fade in effect for the next image, the show class has higher z-index
	next_banner.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	next_promos.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	
	//Hide the current_banner image
	current_banner.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	current_promos.animate({opacity: 0.0}, 1000)
	.removeClass('show');	
};



$(document).ready(function() {		
	//Load the slideshow
	theRotator();
	$('div.rotator_banner').fadeIn(1000);
    $('div.rotator_banner ul li').fadeIn(1000); // tweek for IE
	$('div.rotator_promos').fadeIn(1000);
    $('div.rotator_promos ul li').fadeIn(1000); // tweek for IE
});
