// JavaScript Document


//Editable Variables.

//in milliseconds
var slideshow2_animateSpeed = 1000;
var slideshow2_animateDelay = 5000;



//Everything below here is part of the functionality.
//Proceed with Caution
var slideshow2_totalImages = 0;
var slideshow2_thisImage = 1;
//var navString = '';

$(document).ready(function(){
	
	//for each link, we add a class of 'slideshow2Image', and an ID of
	//slideshow2Image1, slideshow2Image2, slideshow2Image3, etc.
	//we later use these dynamic values to show / hide the images.
	$('#slideshow2 img').each(function(count){
		var slideshow2_imageNo = count + 1;
		$(this).attr('id', 'slideshow2Image'+slideshow2_imageNo);
		$(this).addClass('slideshow2Image');
		slideshow2_totalImages++;
	});
	
	//we append a new DIV, slideshowNavigation
	//$('#slideshow2').append('<div id="slideshowNavigation"></div>');
	
	//we create a navigation string based on the number of totalImages
	//for(var i=1; i <= totalImages; i++)
	//{
	//	navString += '<a id="slideshowNav'+i+'" class="slideshowNav">&nbsp;</a>';
	//}
	
	//we add the navString to our newly created 'slideshowNavigation' DIV
	//and add a click event to each slideshowNav
	//$('#slideshow2Navigation').html(navString);
	//$('.slideshowNav').click(jumpToSlide);
	
	//fade in the first image
	//and add the 'active' class to the first link.
	$('#slideshow2Image'+slideshow2_thisImage).fadeIn(slideshow2_animateSpeed);
	//$('#slideshow2Nav1').addClass('active');
	slideshow2_thisImage++;
	
	//everyTime will take a function and repeat it infinitely.
	$(document).everyTime(slideshow2_animateDelay, function(){										
		slideshow2_fadeOutImage();
	});
		
	function slideshow2_fadeOutImage()
	{
		$('#slideshow2').fadeOut(slideshow2_animateSpeed, slideshow2_fadeInNextImage);
	}
	
	function slideshow2_fadeInNextImage()
	{
		//remove the 'active' class from every button
		//re-add the 'active' class to the current button (based on thisImage)
		//$('.slideshowNav').removeClass('active');
		//$('#slideshow2Nav'+thisImage).addClass('active');
		
		//hide every image
		//show the current button (based on thisImage)
		$('.slideshow2Image').hide();
		$('#slideshow2Image'+slideshow2_thisImage).show();
		
		//fade the slideshow back in
		$('#slideshow2').fadeIn(slideshow2_animateSpeed);
		
		//increase the value of thisImage. if it's greater than the total
		//number of images, reset it to 1.
		slideshow2_thisImage++;
		if(slideshow2_thisImage > slideshow2_totalImages) slideshow2_thisImage = 1;
		//alert(thisID);
	}
	
	//function jumpToSlide(event)
	//{
		//we grab the number in the ID by
		//stripping off 'slideshowNav'
		//var thisID = $(this).attr('id');
		//thisID = thisID.substr(15,thisID.length);
		
		//reset the global imageID and reset the cycle
		//thisImage = thisID;
		//slideshow2_fadeOutImage();
	//}
	
});



