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("grüezi");
s.push("buenas dias");
s.push("こんにちは");
s.push("olà olà");
s.push("go to hell");
s.push("namaste");
s.push("yo");
s.push("prosit");
s.push("viva");
s.push("shaba-daba");
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 my cat”");
s.push("that you don’t want to hire me");
s.push("that blue is your favourite color");
s.push("that gold is your favourite color");
s.push("that vermillion is your favourite color");
s.push("that life is life");
s.push("that man has never been on moon");
s.push("that you liked your dinner");
s.push("that it’s time for a new haircut");



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

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 = "";
}

