/* ----- ----- ----- Free software Foundation - Affero License ----- ----- -----
tete.js - head animation
    Copyright (C) 2008  Thibault Garcia (thibault.garcia@revaweb.com)

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

----- ----- ----- Free software Foundation - Affero License ----- ----- ----- */

var teteTimer;

function teteInit(file,max) {
	for(var i=0;i<max;i++) {
		var img = document.createElement('img');
		img.src="tetes/"+file+"-tetes-0"+(i+1)+".png";
		img.style.display='none';
		document.getElementsByTagName('body')[0].appendChild(img);
	}
	teteFct(file,max);
}

var teteNb=0;
function teteFct(file,max) {
	if(teteTimer) clearTimeout(teteTimer);

	var val=Math.floor((max-1)*Math.random())+1;
	if(val>=teteNb) val++;
	teteNb=val;
	document.getElementById("tete").style.backgroundImage="url(tetes/"+file+"-tetes-0"+val+".png)";

	//var temps=Math.floor(4000*Math.random());
	var temps=1500;
	teteTimer=setTimeout("teteFct('"+file+"',"+max+")",temps);
}