var arrayIndex = 0;

var imageArray = new Array();
var captionArray = new Array();
var textArray = new Array();

function FadeIn(containerElement, imageElement, captionElement, textElement, speed, timeout)
{
	imageElement = $(imageElement);
	captionElement = $(captionElement);
	textElement = $(textElement);
		
	if (arrayIndex >= imageArray.length)
		arrayIndex = 0;
		
	imageElement.src = imageArray[arrayIndex].src;
	captionElement.innerHTML = captionArray[arrayIndex];
	textElement.innerHTML = textArray[arrayIndex];
	
	arrayIndex++;
		
	new Effect.Appear(containerElement, {duration:speed});
	
	setTimeout('FadeOut(\'' + containerElement + '\', \'' + 
		imageElement.id + '\', \'' + captionElement.id + '\', \'' + textElement.id + '\', ' +
		speed + ', ' + timeout + ')', timeout);
}

function FadeOut(containerElement, imageElement, captionElement, textElement, speed, timeout)
{
	imageElement = $(imageElement);
	captionElement = $(captionElement);
	textElement = $(textElement);
	
	new Effect.Fade(containerElement, {duration:speed});
	
	setTimeout('FadeIn(\'' + containerElement + '\', \'' + 
		imageElement.id + '\', \'' + captionElement.id + '\', \'' + textElement.id + '\', ' +
		speed + ', ' + timeout + ')', timeout);
}
