var s = new Array();
s.push("ciao");
s.push("hi");
s.push("guten tag");
s.push("salut");
s.push("hello");
s.push("bonjour");
s.push("buona notte");
s.push("uh la la");
s.push("buenos dias");
s.push("yeeeeeeeeeeeeeeeeeah!");
s.push("is lunch time");
s.push("go to hell");
s.push("namaste");
s.push("yo");
s.push("salute");
s.push("viva");
s.push("that you look like Britney Spears");
s.push("hasta la victoria");
s.push("ooooooooooooooooooooh");
s.push("I love you");
s.push("I want to be your slave");
s.push("I love your smell");
s.push("that you like yellow");
s.push("that chicken is your favorite food");
s.push("that gold is your favourite color");
s.push("that you hate me");
s.push("that life is life");
s.push("that it's time for a new pair of shoes ");
s.push("that you liked your dinner");
s.push("ti amo");



/////////////////////////////////////////////////////////
var textNode = document.getElementById("tiroir-2");

var frameCount = 0;
var t = setInterval(step, 25);
var mode;
var currentPhrase = -1;
var currentStep;
swap();

/////////////////////////////////////////////////////////
function step(){
	if (mode == 0){ //grow
		var end = s[currentPhrase].length;
		var start = end - currentStep - 1;
		textNode.innerHTML = s[currentPhrase].slice(start,end);
		currentStep++;
		if(currentStep == s[currentPhrase].length) {
			mode++;
			currentStep = 0;
		}
	} else if (mode == 1) { //crappy delay...
		currentStep++;
		if (currentStep == 160) swap(); 
	}
}

/////////////////////////////////////////////////////////
function swap(){
	do {
		var r = Math.floor(Math.random() * s.length);
	} while(r == currentPhrase);
	currentPhrase = r;
	currentStep = 0;
	mode = 0;
	textNode.innerHTML = "";
}

