//-----------------------------------------------------------------------------------------------	
//																						Preload all the image for quick loading in the slideshow       
       for(i=0; i<=image_array_length; i++) {
         preload_image_object.src = image_array[i];
		}
//-----------------------------------------------------------------------------------------------		
		function show_next_image(){			
			
			if((image_array_length - current_slideshow_position) == 1){
				current_slideshow_position = 0;
			}
			else{
				current_slideshow_position++;
			}			
	
			document.ss_image.src = image_array[current_slideshow_position];
			
			// update the caption
			// document.getElementById('desc').childNodes[0].nodeValue = caption_array[current_slideshow_position];
			document.getElementById('desc').innerHTML = caption_array[current_slideshow_position];
			if (!pauseSlideShow){
				init_slideshow();
			}
		}
//-----------------------------------------------------------------------------------------------		
		function init_slideshow(){				
					window.slideShowTimer = setTimeout('show_next_image()', time_delay);				
		}		
//-----------------------------------------------------------------------------------------------		
		function pause_play_slideshow(){
			if (window.slideShowTimer) {
				clearTimeout(window.slideShowTimer);
				window.slideShowTimer = null;
			}
			
			if (pauseSlideShow){
				pauseSlideShow = false;
				document.slideshow.play_pause.value = "Pause";
				init_slideshow();
			}
			else {
				pauseSlideShow = true;
				document.slideshow.play_pause.value = "Play";
			}			
		}
//-----------------------------------------------------------------------------------------------		
		function pause_slideshow(){		
			pauseSlideShow = true;
			document.slideshow.play_pause.value = "Play";		
		}


//-----------------------------------------------------------------------------------------------


function setPicAndCaption (whichpic, whichCaption) { 

//pause the slideshow
pause_slideshow();

//set the caption
document.getElementById('desc').innerHTML = caption_array[whichCaption];
 
 //set the image
document.ss_image.src = whichpic;
return false;
}
