// JavaScript Document

var ROOT_PATH = '';


/**
 * Modifie l'heure affichée en graphique. La fonction est rappelée automatiquement à chaque seconde.
 */
MM_preloadImages(ROOT_PATH + '/commun/heures/heure_p1_0.gif',ROOT_PATH + '/commun/heures/heure_p1_1.gif',ROOT_PATH + '/commun/heures/heure_p1_2.gif',ROOT_PATH + '/commun/heures/heure_p1_3.gif',ROOT_PATH + '/commun/heures/heure_p1_4.gif',ROOT_PATH + '/commun/heures/heure_p1_5.gif',ROOT_PATH + '/commun/heures/heure_p1_6.gif',ROOT_PATH + '/commun/heures/heure_p1_7.gif',ROOT_PATH + '/commun/heures/heure_p1_8.gif',ROOT_PATH + '/commun/heures/heure_p1_9.gif',ROOT_PATH + '/commun/heures/heure_p2_0.gif',ROOT_PATH + '/commun/heures/heure_p2_1.gif',ROOT_PATH + '/commun/heures/heure_p2_2.gif',ROOT_PATH + '/commun/heures/heure_p2_3.gif',ROOT_PATH + '/commun/heures/heure_p2_4.gif',ROOT_PATH + '/commun/heures/heure_p2_5.gif',ROOT_PATH + '/commun/heures/heure_p2_6.gif',ROOT_PATH + '/commun/heures/heure_p2_7.gif',ROOT_PATH + '/commun/heures/heure_p2_8.gif',ROOT_PATH + '/commun/heures/heure_p2_9.gif',ROOT_PATH + '/commun/heures/heure_p3_0.gif',ROOT_PATH + '/commun/heures/heure_p3_1.gif',ROOT_PATH + '/commun/heures/heure_p3_2.gif',ROOT_PATH + '/commun/heures/heure_p3_3.gif',ROOT_PATH + '/commun/heures/heure_p3_4.gif',ROOT_PATH + '/commun/heures/heure_p3_5.gif',ROOT_PATH + '/commun/heures/heure_p3_6.gif',ROOT_PATH + '/commun/heures/heure_p3_7.gif',ROOT_PATH + '/commun/heures/heure_p3_8.gif',ROOT_PATH + '/commun/heures/heure_p3_9.gif',ROOT_PATH + '/commun/heures/heure_p4-5_0.gif',ROOT_PATH + '/commun/heures/heure_p4-5_1.gif',ROOT_PATH + '/commun/heures/heure_p4-5_2.gif',ROOT_PATH + '/commun/heures/heure_p4-5_3.gif',ROOT_PATH + '/commun/heures/heure_p4-5_4.gif',ROOT_PATH + '/commun/heures/heure_p4-5_5.gif',ROOT_PATH + '/commun/heures/heure_p4-5_6.gif',ROOT_PATH + '/commun/heures/heure_p4-5_7.gif',ROOT_PATH + '/commun/heures/heure_p4-5_8.gif',ROOT_PATH + '/commun/heures/heure_p4-5_9.gif',ROOT_PATH + '/commun/heures/heure_p6_0.gif',ROOT_PATH + '/commun/heures/heure_p6_1.gif',ROOT_PATH + '/commun/heures/heure_p6_2.gif',ROOT_PATH + '/commun/heures/heure_p6_3.gif',ROOT_PATH + '/commun/heures/heure_p6_4.gif',ROOT_PATH + '/commun/heures/heure_p6_5.gif',ROOT_PATH + '/commun/heures/heure_p6_6.gif',ROOT_PATH + '/commun/heures/heure_p6_7.gif',ROOT_PATH + '/commun/heures/heure_p6_8.gif',ROOT_PATH + '/commun/heures/heure_p6_9.gif');

function changeHeure() {
	my_date = new Date();
	mes_heures = my_date.getHours();
	heure_dizaines = Math.floor(mes_heures/10);
	heure_unites = mes_heures - (heure_dizaines*10);

	mes_minutes = my_date.getMinutes();
	minute_dizaines = Math.floor(mes_minutes/10);
	minute_unites = mes_minutes - (minute_dizaines*10);

	mes_secondes = my_date.getSeconds();
	seconde_dizaines = Math.floor(mes_secondes/10);
	seconde_unites = mes_secondes - (seconde_dizaines*10);
	
	document.getElementById('sec_unites').src = ROOT_PATH + '/commun/heure/heure_p1_' + seconde_unites + '.gif';
	document.getElementById('sec_dizaines').src = ROOT_PATH + '/commun/heure/heure_p2_' + seconde_dizaines + '.gif';
	document.getElementById('min_unites').src = ROOT_PATH + '/commun/heure/heure_p3_' + minute_unites + '.gif';
	document.getElementById('min_dizaines').src = ROOT_PATH + '/commun/heure/heure_p4-5_' + minute_dizaines + '.gif';
	document.getElementById('hre_unites').src = ROOT_PATH + '/commun/heure/heure_p4-5_' + heure_unites + '.gif';
	document.getElementById('hre_dizaines').src = ROOT_PATH + '/commun/heure/heure_p6_' + heure_dizaines + '.gif';
}
window.setInterval('changeHeure()',1000);

// Choisis une des 4 lettres au hasard et la flippe (ou déflippe si déjà flippée).
MM_preloadImages(ROOT_PATH + '/commun/top/flip1_on.gif', ROOT_PATH + '/commun/top/flip2_on.gif', ROOT_PATH + '/commun/top/flip3_on.gif', ROOT_PATH + '/commun/top/flip4_on.gif');

function flipLettres() {
	choix_lettre = Math.floor(Math.random( ) * 4) + 1;
	nom_source = eval('document.flip' + choix_lettre + '.src');
	nom_source = nom_source.substring(0,nom_source.length-4);
	if (nom_source.substring(nom_source.length-4) == '_off') {
		nom_source = nom_source.substring(0, nom_source.length - 4) + '_on.gif';
	} else {
		nom_source = nom_source.substring(0, nom_source.length - 3) + '_off.gif';
	}
	eval('document.flip' + choix_lettre + '.src = "' + nom_source + '";');
}
window.setInterval('flipLettres()', Math.floor(Math.random() * 5000) + 2000);
