$(function() {

	if ($("#rotatePlayGamesTabLeft > div").size() > 1) {
		
		$('#slideshowPlayGames').hover(
		//comment out the following and set style #playGamesRotateControls display: block to show 100%								
		//function() { $('#playGamesRotateControls').fadeIn(); },
		//function() { $('#playGamesRotateControls').fadeOut(); }
		);

		$('#prev img').hover(
			function() { $('#prev img').attr("src", "/Pages/Home/Images/RotatingContentControl/back_hov.png"); },
			function() { $('#prev img').attr("src", "/Pages/Home/Images/RotatingContentControl/back.png"); }
		);

		$('#playPause img').hover(
			function() { $('#playPause img').attr("src", "/Pages/Home/Images/RotatingContentControl/pause_hov.png"); },
			function() { $('#playPause img').attr("src", "/Pages/Home/Images/RotatingContentControl/pause.png"); }
		);

		$('#next img').hover(
			function() { $('#next img').attr("src", "/Pages/Home/Images/RotatingContentControl/forward_hov.png"); },
			function() { $('#next img').attr("src", "/Pages/Home/Images/RotatingContentControl/forward.png"); }
		);
		
		$('#rotatePlayGamesTabLeft').cycle({
			fx: 'fade',
			//timeout: 6000,
			//delay: -2000,
			//pause: 1
			speed: 400,
			timeout: 6000,
			next: '#next',
			prev: '#prev',
			after: onAfter
		});

		var btnPlay = true;
		$('#playPause').click(function() {
			if (btnPlay) {
				$('#rotatePlayGamesTabLeft').cycle('pause');
				$('#playPause img').attr("src", "/Pages/Home/Images/RotatingContentControl/play_hov.png");
				$('#playPause img').attr("alt", "Play");
				$('#playPause img').hover(
					function() { $('#playPause img').attr("src", "/Pages/Home/Images/RotatingContentControl/play_hov.png"); },
					function() { $('#playPause img').attr("src", "/Pages/Home/Images/RotatingContentControl/play.png"); }
				);
				
				btnPlay = false;
			}
			else {
				$('#rotatePlayGamesTabLeft').cycle('resume');
				$('#playPause img').attr("src", "/Pages/Home/Images/RotatingContentControl/pause_hov.png");
				$('#playPause img').attr("alt", "Pause");
				$('#playPause img').hover(
					function() { $('#playPause img').attr("src", "/Pages/Home/Images/RotatingContentControl/pause_hov.png"); },
					function() { $('#playPause img').attr("src", "/Pages/Home/Images/RotatingContentControl/pause.png"); }
				);
				btnPlay = true;
			}
			return false;
		});
	}
	else {
		// Hide the rotating nav control if only 1 slide
		$("#playGamesRotateControls").hide();
	}
});

//$("#playGamesRotateControls").animate({ opacity: 0.85 }, 1); //Set Opacity
function onAfter(curr, next, opts) {
	var index = opts.currSlide;
	$('#currentSlide').html(index + 1);
	$('#slideCountTotal').html(opts.slideCount);
}