image_counter = 0;

loader = 0;

slideshow_playing = 0;

function slideshow_play(){
	if(loaded == 1 && slideshow_playing == 1){
		loaded = 0;
		slideshow_next();
		setTimeout("slideshow_play()",5000);
	}
	else{
		slideshow_playing = 1;
		setTimeout("slideshow_play()",5000);
	}
}

function slideshow_next(){
	if(image_counter == (images.length-1)){
		image_counter = 0;
	}
	else{
		image_counter++;
	}
	new Effect.Opacity('slideshow_current',{ duration: 1.0, from: 1.0, to: 0.0 });
	new Effect.Opacity('caption',{ duration: 1.0, from: 1.0, to: 0.0 });	
	setTimeout("$(\'slideshow_current\').innerHTML=\"<img width=288 height=217 src=\" + images[image_counter] + \" onload=\'show_image()\'>\"",1200);
	setTimeout("$(\'caption\').innerHTML=captions[image_counter]",1200);	
}

function show_image(){
	new Effect.Opacity('slideshow_current',{ duration: 0.0, from: 1.0, to: 0.0 });
	new Effect.Opacity('caption',{ duration: 0.0, from: 1.0, to: 0.0 });	
	$('slideshow_current').show();	
	$('caption').show();		
	new Effect.Opacity('slideshow_current',{ duration: 1.0, from: 0.0, to: 1.0 });
	new Effect.Opacity('caption',{ duration: 1.0, from: 0.0, to: 1.0 });	
	loaded = 1;
}


