	/*
		KO-SLIDER.JS
		@author(s) Randall Haney, the people at queness.com
		@since 11-17-2009
		
		
		
		Modified code found at this tutorial to make this slider.
		I tried to remove redundant code and made it more specific
		to my needs.
		
		http://www.queness.com/post/152/simple-jquery-image-slide-show-with-semi-transparent-caption
	*/
	var slideshow = {
		
		settings: {
			useTitles: true
		},
		
		init: function(useTitles){
				//set the use of titles to the value passed in.
				this.settings.useTitles = useTitles;
				//Set the opacity of all images to 0  
				$('#slideshow img').css({opacity: 0.0});
				//Show the slideshow container
				$("#slideshow").slideDown("slow");
				//start the slideshow
				slideshow.slideSwitch();
		},
		
		slideSwitch: function(){
			//make the first image opaque and add the active class
			$('#slideshow img:first').css({opacity: 1.0}); 					
			$('#slideshow img:first').addClass("active");
			if(this.settings.useTitles){
				//set caption overlay to the width of the image
				$('#slideshow .caption').css({width: $('#slideshow img').css('width')});	
			
				//Animate in caption
			  	$('#slideshow .caption').animate({opacity: 0.7},100 ).animate({height: '50px'},500 );				
			}
			//Call the handleImg function to run the slideshow, 6000 = change to next image after 6 seconds  
		  	setInterval('slideshow.handleImg()',6000);
		},
		
		
		handleImg:function() {  

		    //if no IMGs have the show class, grab the first image  
		    var current = $('#slideshow img.active')?  $('#slideshow img.active') : $('#slideshow img:first');  
			
			var	next = $('#slideshow img:first');
			
			if(current.next().length){
				if(!current.next().hasClass("caption")){
					next = current.next();
				}
			}
			

			//console.log("current: " + current.attr("src"));
			//console.log("next: " + next.attr("src"));
			
			//Hide the current image  
		     current.animate({opacity: 0.0}, 1000).removeClass('active');
			 if(this.settings.useTitles)$('#slideshow .caption').css({opacity: 0.0, height: '1px'});

		     //Set the fade in effect for the next image, show class has higher z-index  
		     next.css({opacity: 0.0}).animate({opacity: 1.0}, 1000).addClass('active');  

			if(this.settings.useTitles){
				
				$('#slideshow .caption').css({width: $('#slideshow img').css('width')});
			 	
				//Get next image caption  
			     var caption = next.attr('alt');
				 $('#slideshow div.content').html(caption);

			    //Animate in caption
			  	$('#slideshow .caption').animate({opacity: 0.7},100 ).animate({height: '50px'},500 );
			}
			
			
		}

	}
