
//Simple Jquery slideshow written by Brandon More

//automatically counts the number of img elements in the #slideshow container
//automatically stacks images with z-index
//no need for specific image ids

$(document).ready(function(){

var int = 7000; //controls amount of time between slides
var dur = 3000; //controls smoothness of transitions

var fade_state = 1;
var current_slide = '';
var next_slide = '';
var slides = $("#slideshow a");
var slide_num = $("#slideshow a").length;

//function for slide animation
function slide() {

	if (fade_state < slide_num) {
	current_slide = $(slides[fade_state-1]);
	next_slide = $(slides[fade_state]);
	$(current_slide).fadeOut(dur);
	$(next_slide).fadeIn(dur);
		
	fade_state++;
	
	} 
		
	else {
	current_slide = $(slides[fade_state-1]);
	next_slide = $(slides[0]);
	$(current_slide).fadeOut(dur);
	$(next_slide).fadeIn(dur);
	
	fade_state = 1;
		
	} 
  
}//end slide function

//function for stacking slides with z-index
function stack(){
	var i = 0;
	for(i=0; i<=slide_num; i=i+1){
		$(slides[i]).css("zIndex", slide_num-i);
		if(i==slide_num){
			window.setInterval(function(){slide()},int);//calls slide function
		}
	}
};//end stacking

if(slide_num > 1){
	stack();
}
//controls slide timer	
//window.setInterval(function(){slide()},int);

});	


