/*
This script copyright tyfen, 2008
www.tyfen.com

It needs three famous libraries to run:

prototype.js
scriptaculous.js
effects.js

The first one copyright Sam Stephenson, 2005
http://prototype.conio.net/

The last two copyright Thomas Fuchs, 2005
http://script.aculo.us/
*/


// Variables which initialize the loops (don't touch!):
var linesIncrement = 0, logosIncrement = 0, previousLogo = 0, firstTime = true;

// This function displays the lines of #adText one after the other
// and then displays the button linking to the logos' page.
function displayText() {
	linesIncrement++;
	if(!document.getElementById("line"+linesIncrement)) {
		clearInterval(lineByLine);
		displayLogos();
	}
	else
	{
		Effect.Appear(document.getElementById("line"+linesIncrement), {duration: 2.0});
	}
}

// In the end of function displayText(), the logos and the button linking to logos' page are displayed:
function displayLogos() {
	logosIncrement++;
	// Displays the button at the beginning of the first loop:
	if((logosIncrement == 1) && firstTime)
	{
		imageByImage = setInterval("displayLogos()", 2600);
		Effect.Appear(document.getElementById("buttonToLogos"), {duration: 1.5});
		document.getElementById("decoFrame").style.borderColor = "#dedede";
		firstTime = false;
	}
	if(logosIncrement > 1) {
		previousLogo = logosIncrement-1;
		Effect.Fade(document.getElementById("logo"+previousLogo), {duration: 1});
		document.getElementById("logo"+previousLogo).style.display = "none";
	}
	// When all the logos have been viewed, the meter is reset.
	if(!document.getElementById("logo"+logosIncrement)) logosIncrement = 1;
	// Where the logos are "finally" displayed:
	Effect.Appear(document.getElementById("logo"+logosIncrement), {duration: 1.5});
}

// After the XHTML page has been loaded, the displayText() function is launched:
window.onload = function() {
	initLightbox(); // TO PREVENT JS CONFLICTS BETWEEN THE ACTUAL SCRIPT AND lightbox.js
	lineByLine = setInterval("displayText()", 1);
}