﻿$(document).ready(function () {
	// Rotating Banner
	var delay = 7500;
	var rotateArray = $('ul.rotate li');
	if ( rotateArray.length == 1 ) return false;
	else {
		var currentItem = 0;
		$(rotateArray[currentItem]).css('z-index', 2);
		var nextItem = 1;
		var timer = setInterval(showNext, delay);
	}
	function showNext() {
		$(rotateArray[currentItem]).css('z-index', 2);
		$(rotateArray[nextItem]).css({
			'z-index':1,
			'display':'block'
			});
		$(rotateArray[currentItem]).fadeOut(1500);
		currentItem = nextItem;
		if ( currentItem < rotateArray.length-1 ) nextItem++;
		else nextItem = 0;
	}
	$('#stop').click( function() {
		clearInterval(timer);
	});
	$('#play').click( function() {
		setInterval(showNext, delay);
	});
});
