var current_image = 1;
var slideshow_status = 'stopped';
var timeout = false;

function showGallery() {
	stopSlideShow();
	$('#slideshow').hide();
	$('#gallery').show();
	return false;
}
function showSlideShow(number_of_images) {
	$('#gallery').hide();
	$('#slideshow').show();
	startSlideShow(number_of_images);
	return false;
}
function startSlideShow(number_of_images) {
	stopSlideShow();
	slideshow_status = 'started';
	timeout = window.setInterval('slideShow('+number_of_images+')',3000);
}
function stopSlideShow() {
	slideshow_status = 'stopped';
	window.clearInterval(timeout);
}
function toggleSlideShow(number_of_images) {
	if (slideshow_status == 'stopped') {
		startSlideShow(number_of_images);
	}
	else if (slideshow_status == 'started') {
		stopSlideShow();
	}
	return false;
}
function slideShow(number_of_images) {
	$('#slideshow_'+current_image).fadeOut('slow');								
	if (current_image == number_of_images) {
		new_image = 1; 	
	}
	else {
		new_image = current_image + 1;	
	}
	$('#slideshow_'+new_image).fadeIn('slow');
	current_image = new_image;
}

