function wallerSlider(){	
	/*$('#hero-extras').load('/slide-show/featured-products #featured-content', function() {
	  
	});*/

	var imageIndex = 0;
	//check for first time
	var firstTime = true;
	//used to see if the slideshow should play automatically
	var auto = true;
	//total number of slides
	var totalSlides = $("#hero .hero-image").length;
	//empty timer
	var timer = null;
	//fade in speed
	var fadeSpeed = 500;
	//transition speed
	var transSpeed = 500;
	//hide the extra content
	$("#hero-extras").hide();
	
	//add links to controls
	var prevLink = $("#hero-control-prev");
	var nextLink = $("#hero-control-next");
	
	//total number of divs
	var heroContent = $("#hero-descriptions div");	
	for (var i=0; i<heroContent.length; i++) {
		//hide the divs
		$(heroContent).hide();
		//if the div id is equal to hero-image remove it and add it to the hero-images div
		if ($(heroContent[i]).attr("class") == "hero-image"){
			$(heroContent[i]).remove().appendTo("#hero-images");
		};
	};
	
	//hero descriptions
	var heroDescriptions = $("#hero-descriptions .hero-description");
	//hero images
	var heroImages = $("#hero-images .hero-image");
	
	//previous link
	$(prevLink).click(function(){
		auto = false;
		prevSlide();
		return false;
	});
	
	//next link
	$(nextLink).click(function(){
		auto = false;
		nextSlide();
		return false;
	});
	
	slideshow("next");
	
	function slideshow(){
		//console.log("slideshow called");
		clearInterval(timer);
		var detailsHeight = $(heroDescriptions[imageIndex]).height()	
		
		if(firstTime == true){
			$("#hero-descriptions").animate({
				height: detailsHeight
			  }, {
				duration: transSpeed, 
				complete: function() {
				  $('#hero-extras').fadeOut(fadeSpeed);
				  $(heroDescriptions[imageIndex]).fadeIn(fadeSpeed).attr("id","description-show");
					if($(heroDescriptions[imageIndex]).attr("alt") != ""){
						$('#hero-extras').load($(heroDescriptions[imageIndex]).attr("alt"), function() {
							$(this).fadeIn(fadeSpeed);
						});
					}
				}
			  });
			
			firstTime = false;
		}else{
			for (var i=0; i<totalSlides; i++) {
				if($(heroDescriptions[i]).attr("id") == "description-show"){				
					$('#hero-extras').fadeOut(fadeSpeed);
					$(heroDescriptions[i]).fadeOut(fadeSpeed, function(){
						$("#hero-descriptions").animate({
							height: detailsHeight
						}, {
							duration: transSpeed, 
							complete: function() {
							  $(heroDescriptions[imageIndex]).fadeIn(fadeSpeed).attr("id","description-show");
								if($(heroDescriptions[imageIndex]).attr("alt") != ""){
									$('#hero-extras').load($(heroDescriptions[imageIndex]).attr("alt"), function() {
										$(this).fadeIn(fadeSpeed);
									});
								}
							}
						});
					}).attr("id","");
				}//end if
			};//end for
		}
		
		
		//hide the currently showing image slide
		for (var i=0; i<totalSlides; i++) {
			if($(heroImages[i]).attr("id") == "image-show"){
				$(heroImages[i]).fadeOut(1000).attr("id","");
			};
		};
		//show the next image slide
		$(heroImages[imageIndex]).fadeIn(1000).attr("id","image-show");
		
		
		//reset the timer if auto is set to true
		if(auto == true){
			//console.log("timer called");
			timer = setTimeout(nextSlide, 8000);
		};
	}
	function nextSlide(){
		//add 1 to the imageIndex
		imageIndex = imageIndex + 1;
		
		//make sure the imageIndex is not higher than the number of slides, if it is make it zero
		if(imageIndex >= totalSlides){
			imageIndex = 0;
		};

		//play the slideshow
		slideshow("next");
	}
	function prevSlide(){
		//subtract 1 to the imageIndex
		imageIndex = imageIndex - 1;

		//make sure the imageIndex is not lower than zero, if it is make it the number of the last slide
		if(imageIndex < 0){
			imageIndex = totalSlides - 1;
		};

		//play the slideshow
		slideshow("prev");
	}
	
}
$(document).ready(function(){
	wallerSlider();
});

