// JavaScript Document

var i = 0; var wait = 5000;
var ttvSlideshow = 0;

function slideShow() {
Effect.Fade(slides[i], { duration:.5, from:1.0, to:0.0 }); 
i++;
 if (i == slides.length) {
	 i = 0; 
 	updatebuttons(i, slides.length-1);
 } else {
	 updatebuttons(i,i-1);
 }
Effect.Appear(slides[i], { duration:.5, from:0.0, to:1.0 });
 } 
 
function goToSlide(slideNum) {
	//alert(i);
	//alert(slideNum);
	if(i == slideNum) return;
	Effect.Fade(slides[i], { duration:.5, from:1.0, to:0.0 }); 
	Effect.Appear(slides[slideNum], { duration:.5, from:0.0, to:1.0 });
	
	updatebuttons(slideNum, i);

	i = slideNum;
}

function slideClicked(slideNum) {
	clearInterval ( ttvSlideshow );
	goToSlide(slideNum);
}

function updatebuttons(newbutton, oldbutton) {
	//alert(newbutton);
	//alert(oldbutton);
	//Effect.Fade(buttons[newbutton] + '-off', { duration:.2, from:1.0, to:0.0 }); 
	Effect.Appear(buttons[newbutton] + '-on', { duration:.5, from:0.0, to:1.0 });
	
	Effect.Fade(buttons[oldbutton] + '-on', { duration:.5, from:1.0, to:0.0 }); 
	//Effect.Appear(buttons[oldbutton] + '-off', { duration:.2, from:0.0, to:1.0 });
	
}

// the onload event handler that starts the fading. 
function start_slideshow() { 
	ttvSlideshow = setInterval('slideShow()',wait); 
}
