/*
	Custom jquery, drupal site development and theme 
	by Wheelercreek Studio, Inc. 
	http://www.wheelercreek.com 	
	
	This slideshow uses clickable numbered buttons, and a fade transition.
*/	
var i = 0; //this holds slide position for the auto-slideshow
$(function() {
		var i = 0;
		$('#slideshow img').css({position:'absolute',left:0,top:0}); 
		$('#slideshow_nav li').click(function() {
			num = $(this).text(); //on newer jquery - use .index()
			dofade(num); 
			clearInterval(anim); 
		}); 
		var anim = setInterval('slide()', 12000);
});

function slide(){
	//find out how many slides there are:
	count = $('#slideshow img').size();
	i++;
	if (i >= count) {
		i = 0;
	}
	dofade(i);
}
		
/* this is a function to fade all the others except the one passed in */
function dofade(num){
	/* this works on newer versions of jquery
	 $('#slideshow img').not('#slideshow img:eq('+num+')').fadeOut();
	 $('#slideshow_nav li').not('#slideshow_nav li:eq('+num+')').removeClass('active');
	 Assume no more than 20 slides
	 */
	for(x=0; x<20; x++) {
		if (x != num) {
			$('#slideshow img:eq('+x+')').fadeOut();
			$('#slidetext_wrap .slidetext:eq('+x+')').fadeOut();
			$('#slideshow_nav li:eq('+x+')').removeClass('active');
		}
	}
	$('#slideshow img:eq('+num+')').fadeIn('slow');
	$('#slidetext_wrap .slidetext:eq('+num+')').fadeIn('slow');
	$('#slideshow_nav li:eq('+num+')').addClass('active');
}
