/*SLIDESHOW*/

var amount = 10;
var next = Math.max(1,Math.round(Math.random()*amount));

function crossfade()
{
	new Ajax.Request('slideshow.php', {
		method: 'get', 
		parameters: {id: next}, 
		onComplete: function(request) {
			$('canvas').insert(request.responseText);
			$('image'+next).hide();
			before = (next > 1 ? next-1 : amount);
			new Effect.Appear('image'+next, {afterFinish: function() { $('canvas').firstDescendant().remove(); } });
			next = (next < amount ? next+1 : 1);
		}
	}); 
}

var slideshow = window.setInterval("crossfade()", 5000);

function toggleSlideshow(){
	if (slideshow) slideshow = window.clearInterval(slideshow);
	else {
		crossfade();
		slideshow = window.setInterval("crossfade()", 5000);	
	}
}
