/**
 * Created for navigation effects. This depends on the jquery library.
 * @author Torgie
 */

var slideshowTimer;
var totalSlides = 9;

// Wait until the page is ready
$(document).ready(function(){

	// Enable the navigation hover effect
	$(".navItem").hover(
		function(){
			$(this).css({"background-color": "#401409"});
		},
		function(){
			$(this).css({"background-color": "#2A0B05"});
	});

	// Kick off the slideshow
	$("#slide2").css({display: "block", opacity: 0});
	slideshowTimer = setInterval("slideshowAdvance()", 4000);
});

var currentSlide = 1;
function slideshowAdvance() {

	// Figure out which slide is being turned on or off
	var offSlide = 1, onSlide = 2;
	if(currentSlide % 2 == 0)
		offSlide = 2, onSlide = 1;

	// Figure out what the next slide will be
	currentSlide++;
	var nextSlide = currentSlide % 9;

	// Swap the images
	$("#slide" + offSlide).animate({
		opacity: 0
	}, 1000, function(){
		$("#slide" + offSlide).attr("src", "/images/slideshow/slide" + nextSlide + ".jpg");
	});
	$("#slide" + onSlide).animate({
		opacity: 1
	}, 1000);

}//end function slideshowAdvance

