// JavaScript Document
var maxSlides;
var slideNum;
var t;
var autoClass;
var autoArray;

//time between slides in miliseconds
var slideTimer = 4000;

//called from the 'next' button. This may also be called to initialize the slideshow WITHOUT auto advancing the slides
function nextSlide(slideshowClass, myArray){
	if (slideNum == myArray.length-1 ){slideNum=0;}
	else{slideNum=slideNum+1;}
	load_new(slideshowClass, myArray);
	clearTimeout(t);
}


//this is called to initialized the slideshow while auto advancing the slides
function startSlide(slideshowClass, myArray){
	if (slideNum == myArray.length-1 ){slideNum=0;}
	else{slideNum=slideNum+1;}
	load_new(slideshowClass, myArray);

	t=setTimeout("autoSlide()",slideTimer);
	autoClass=slideshowClass;
	autoArray=myArray;
}

//called repeatedly until clearTimeout(t) is called
function autoSlide(){
	if (slideNum == autoArray.length-1 ){slideNum=0;}
	else{slideNum=slideNum+1;}
	load_new(autoClass, autoArray);
	t=setTimeout("autoSlide()",slideTimer);
}

// called from 'prev' button
function prevSlide(slideshowClass, myArray){
	if (slideNum == 0 ){slideNum=myArray.length-1;}
	else{slideNum=slideNum-1;}
	load_new(slideshowClass, myArray);
	clearTimeout(t);
}



function load_new(slideshowClass, myArray){
	//not sure what objImage was used for here. Commenting that part out for now. dm 20110806
	//objImage = new Image();
	//objImage.src=myArray[slideNum];
	$(slideshowClass).css('background-image','url(' + myArray[slideNum] + ')');
}












