// JavaScript Document

$(document).ready(function() {
	newsRotator();
	spotRotator()
});

function newsRotator() {
	//Set all images to hidden
	$('div#newsrotator ul li').hide();
	
	//Get the first image and display it (gets set to full opacity)
	$('div#newsrotator ul li:first').show();
		
	//Call the rotator function to run the slideshow, 10000 = change to next image after 10 seconds
	 setInterval('rotateNews()', 10000); 
	
}

function rotateNews() {	
	//Get the first image
	var current = ($('div#newsrotator ul li.shownews')?  $('div#newsrotator ul li.shownews') : $('div#newsrotator 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('shownews')) ? $('div#newsrotator ul li:first') :current.next()) : $('div#newsrotator ul li:first'));
	
	//Hide the current image
	current.hide();
	current.removeClass('shownews');
	
	//Show the next image, the show class has higher z-index
	next.show();
	next.addClass('shownews');

	//show/hide mac
	//$('div#spotlite ul li:first').toggle();
	
};

function spotRotator() {
	//Set all images to hidden
	$('div#spotlite ul li').hide();
	
	//Get the first image and display it (gets set to full opacity)
	$('div#spotlite ul li:first').show();
		
	//Call the rotator function to run the slideshow, 10000 = change to next image after 10 seconds
	 setInterval('showsopts()', 10000); 
	
}

function showsopts() {	
	//Get the first image
	var current = ($('div#spotlite ul li.shows')?  $('div#spotlite ul li.shows') : $('div#spotlite 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('shows')) ? $('div#spotlite ul li:first') :current.next()) : $('div#spotlite ul li:first'));
	
	//Hide the current image
	current.hide();
	current.removeClass('shows');
	
	//Show the next image, the show class has higher z-index
	next.show();
	next.addClass('shows');

	//show/hide mac
	//$('div#spotlite ul li:first').toggle();
	
};
