// fade.js
// Duration images is shown
var duration = 3000;
var timeout = 4000;
// variables
var currentS = 0;
var nextS = 0;
var working = false;
// next image
function nextSlide(){
	working = true;
	var slides = $$('div.container');
	//started
	if (currentS < 1) currentS = 1;
	//next slide, start over
	if (currentS < slides.length) { nextS = currentS+1; }
	else{ nextS = 1;}
		// transition		
		$('slide'+currentS).setStyle({left:'0px', top:'0px', display:'inline', zIndex:'2'});
		$('slide'+nextS).setStyle({left:'0px', top:'0px', display:'inline', zIndex:'1'});
		new Effect.Appear('slide'+nextS);
		new Effect.Fade('slide'+currentS, {	afterFinish: function(){ working = false;} });
	currentS = nextS;
	clearTimeout(duration);
	duration = setTimeout('nextSlide()',timeout);
}

// Start
function play() {
	if (!$('slide1').visible()) Effect.Appear('slide1');
	duration = setTimeout('nextSlide()',timeout);
}