/*
	$Id: SlideShow.js,v 1.2 2005/04/21 11:25:34 macio Exp $
*/

var current_photo_id = 0;
var last_photo_id = ss.length;
var timeout_id = 1;
var interval = 5;

// buffer to store images
var buffer = new Array(ss.length);

function ChangePhoto()
{
	if (current_photo_id == last_photo_id)
	{
		current_photo_id = 0;
	}

	UpdatePhoto();	

	current_photo_id++;

	timeout_id = window.setTimeout("ChangePhoto()", interval * 1000);
}

function Play()
{
	if (0 < timeout_id)
	{
		Stop();
	}
	
	document.getElementById("button_play").style.display = "none";
	document.getElementById("button_pause").style.display = "inline";
	ChangePhoto();
}

function Stop()
{
	if (0 < timeout_id || -1 == timeout_id)
	{
		window.clearTimeout(timeout_id);
		timeout_id = 0;
		current_photo_id = 0;
		
		document.getElementById("button_pause").style.display = "none";
		document.getElementById("button_play").style.display = "inline";
		UpdatePhoto();
	}
}

function Pause()
{
	if (0 != timeout_id)
	{
		window.clearTimeout(timeout_id);
		timeout_id = -1;
	
		document.getElementById("button_pause").style.display = "none";
		document.getElementById("button_play").style.display = "inline";
	}
}

function UpdatePhoto()
{
	document.fotka.src = buffer[current_photo_id].src;
	document.fotka.alt = buffer[current_photo_id].alt;
	document.fotka.title = buffer[current_photo_id].title;
	document.getElementById("title").innerHTML = buffer[current_photo_id].title;
}

function IncInterval()
{
	if (10 > interval)
	{
		++interval;
	}
	else
	{
		interval = 10;
	}
	
	document.getElementById("interval").innerHTML = interval;
}

function DecInterval()
{
	if (1 < interval)
	{
		--interval;
	}
	else
	{
		interval = 1;
	}
	
	document.getElementById("interval").innerHTML = interval;
}

function PrepareImages()
{
	for (var i = 0; i < ss.length; i++)
	{
		buffer[i] = new Image();
		buffer[i].src = ss[i][0];
		buffer[i].alt = ss[i][1];
		buffer[i].title = ss[i][1];
	}
}

// loads images to the buffer to increase speed
PrepareImages();

Stop();

document.getElementById("interval").innerHTML = interval;
document.getElementById("button_pause").style.display = "none";

