// Rewritten 2007
////////////////////////////////////////////////////////////////////////////////

var openBtn = "js/btn_open.gif";
var solidBtn = "js/btn_solid.gif";
var intervalID;
var total;
var current;
var delay= 5000;

Event.observe(window, 'load', function() { // window.onload
	slideArray = new Array();
	btnArray = new Array();
	total = 5;
	for (i = 1; i < total+1; i++) {
		slideArray[i] = "slide" + (i);
		btnArray[i] = "slideBtn" + (i);
	
		$(btnArray[i]).src = openBtn;
		$(btnArray[i]).style.cursor = "pointer";
	}
	current = 1;
	$(btnArray[current]).src = solidBtn;
	intervalID = setInterval("showSlide(0)", delay);
});


function showSlide(next) {

	if (next == 0)	{
		next = current + 1;
	}
	if (next == total+1)	{
		next = 1;
	} else { // triggled by button
		next = next;
	}

	new Effect.Fade(slideArray[current], { duration: 0.3});
	//new Effect.BlindUp(slideArray[current], { duration: 0.5});

	setTimeout(function() {
		$(btnArray[current]).src = openBtn
		$(btnArray[current]).style.cursor = "pointer"
		//$(tagArray[current]).className = ""

		$(btnArray[next]).src = solidBtn
		$(btnArray[next]).style.cursor = "default"
		//$(tagArray[next]).className = "this"

		new Effect.Appear(slideArray[next], { duration: 0.3})
		//new Effect.BlindDown(slideArray[next], { duration: 0.5})
		current = next
	}, 500);

	clearInterval(intervalID);
	intervalID = setInterval("showSlide(0)", delay);
}