// JavaScript Document

function previousPhoto()
{
	var current_photo = document.getElementById("current_photo");
	var current_caption = document.getElementById("current_caption");
 	if (current_index > 0)
		current_index--;
	else
		current_index=n_photos-1;
	current_photo.src=jPhotos[current_index].src;
	current_caption.innerHTML=jPhotoCaptions[current_index];
}

function viewPhoto(index)
{
	var current_photo = document.getElementById("current_photo");
	var current_caption = document.getElementById("current_caption");
	current_index=index;
	current_photo.src=jPhotos[current_index].src;
	current_caption.innerHTML=jPhotoCaptions[current_index];
	
}

function nextPhoto()
{
	var current_photo = document.getElementById("current_photo");
	var current_caption = document.getElementById("current_caption");
 	if (current_index < n_photos-1)
		current_index++;
	else
		current_index=0;
	current_photo.src=jPhotos[current_index].src;
	current_caption.innerHTML=jPhotoCaptions[current_index];
}

var go_on = new Image();
go_on.src = "/images/gallery-slideshow-go_on.gif";
var go_off = new Image();
go_off.src = "/images/gallery-slideshow-go_off.gif";
var stop_on = new Image();
stop_on.src = "/images/gallery-slideshow-stop_on.gif";
var stop_off = new Image();
stop_off.src = "/images/gallery-slideshow-stop_off.gif";

var slideshow=null;
function toggleSlideshow()
{
	var slideshow_image = document.getElementById("slideshow_image");
	if (!slideshow)
	{
		slideshow = setInterval('nextPhoto()', 4000);
		slideshow_image.src = stop_on.src;
	}
	else
	{
		clearInterval(slideshow)
		slideshow=null;
		slideshow_image.src = go_on.src;
	}	
}

