var slideshowStopped = 1;
var currentImage = 0;
var currentSlideshow = 0;

var image0;
var image1;
var image2;

var fx0;
var fx1;
var fx2;
var t0, t00, t1, t10, t2, t20, t3;



function startSlideshow(i) {
	var image5 = $('slideshow'+i);
		var fx5 = new Fx.Styles(image5, {duration:700, wait:false});
	fx5.start({
		'opacity': 1
	});
	
	currentSlideshow = i;
	slideshowStopped = 0;
	//	display slideshow+i

	// fade in slideshow+i+0
	image0 = $('slideshow'+i+'.0');
	image1 = $('slideshow'+i+'.1');
	image2 = $('slideshow'+i+'.2');
	
	fx0 = new Fx.Styles(image0, {duration:3000, wait:false});
	fx1 = new Fx.Styles(image1, {duration:3000, wait:false});
	fx2 = new Fx.Styles(image2, {duration:3000, wait:false});
	fx0.set({'opacity':0});
	fx1.set({'opacity':0});
	fx2.set({'opacity':0});
	activeSlideShow();
	
	fx0.start({'opacity':1});
}

	

function activeSlideShow(){
	window.clearTimeout(t0);
	window.clearTimeout(t00);
	window.clearTimeout(t1);
	window.clearTimeout(t10);
	window.clearTimeout(t2);
	window.clearTimeout(t20);
	window.clearTimeout(t3);
	
	
	t00=setTimeout("fade(0,0)",3000);
	t1=setTimeout("fade(1,1)",2000);
	t10=setTimeout("fade(1,0)",6000);
	t2=setTimeout("fade(2,1)",5000);
	t20=setTimeout("fade(2,0)",8000);
	t0=setTimeout("fade(0,1)",7000);
	t3=setTimeout("activeSlideShow()",9500);
	
}

function fade(int, opacity) {
	var fx;
	if (int == 0)
		fx = fx0;
	if (int == 1)
		fx = fx1;
	if (int == 2)
		fx = fx2;
	currentImage = int;
	fx.start({'opacity':opacity});
	
}


function stopSlideshow(i) {
	
	slideshowStopped = 1;
	// set current image display=none
	// set slideshow+i display=none
	var image5 = $('slideshow'+i);
		var fx5 = new Fx.Styles(image5, {duration:3000, wait:false});
	fx5.start({'opacity':0});
		
	currentImage=0;
}

