var areaIn = 0;		/* 0 si le souris n'est dans aucun bloc du menu, 1 si dans un bloc */
var areaBloc = -1;

var idTimeout1 = 0;
var idTimeout2 = 0;

var delaiEntree = 0.75;	/* delai en seconde avant de le changement du menu */
var delaiReinitBloc = 5;	/* delai en seconde avant de la reinitialisation du menu */

var blocTitreInit = -1;
var rubriqueInit = -1;

var couleurInactif = "#999999";
var couleurActif = "#000000";

var nBlocTitres = 5;
var nRubriques = new Array(7, 8, 4, 6, 3);

function deuxDigits (nombre)
{
	if (nombre <= 9) {
		str = "0" + nombre;
	}
	else {
		str = "" + nombre;
	}
	return str;
}

function affiche (blocTitreID)
{
	areaIn++;
	areaBloc = blocTitreID;
	clearTimeout(idTimeout1);
	idTimeout1 = setTimeout("verifieBloc("+blocTitreID+")", delaiEntree * 1000);
}

function verifieBloc (blocTitreID)
{
	if (areaIn > 0 && blocTitreID == areaBloc) {
		afficheBloc(blocTitreID)
	}
}

function afficheBloc (blocTitreID)
{
	for (i = 0; i < nBlocTitres; i++) {
		document.getElementById("blocImg" + i).style.display = "block";
		document.getElementById("blocTxt" + i).style.display = "none";
		document.getElementById("ligneTxt" + i).style.display = "none";
	}
	if (blocTitreID >= 0 && blocTitreID < nBlocTitres) {
		document.getElementById("blocImg" + blocTitreID).style.display = "none";
		document.getElementById("blocTxt" + blocTitreID).style.display = "block";
		document.getElementById("ligneTxt" + blocTitreID).style.display = "block";
	}
}

function entree ()
{
	areaIn++;
}

function sortie ()
{
	areaIn--;
	areaBloc = -1;
	clearTimeout(idTimeout2);
	idTimeout2 = setTimeout("reinitBloc()", delaiReinitBloc * 1000);
}

function initBloc (blocTitreID, rubriqueID)
{
	if (blocTitreID == -1 && rubriqueID == -1) {
		couleurInactif = "#000000";
	}

	for (i = 0; i < nBlocTitres; i++) {
		document.getElementById("flecheGauche" + i).style.display = "none";
		document.getElementById("flecheDroite" + i).style.display = "none";
		document.getElementById("flecheGauche" + i).style.color = couleurInactif;
		document.getElementById("blocTitre" + i).style.color = couleurInactif;
		document.getElementById("flecheDroite" + i).style.color = couleurInactif;
		document.getElementById("blocTxt" + i).style.color = couleurInactif;
		for (j = 0; j < nRubriques[i]; j++) {
			if (document.getElementById("rubrique" + deuxDigits(i) + deuxDigits(j)) != null) {
				document.getElementById("rubrique" + deuxDigits(i) + deuxDigits(j)).style.color = couleurInactif;
			}
		}
	}
	if (blocTitreID >= 0 && blocTitreID < nBlocTitres) {
		document.getElementById("flecheGauche" + blocTitreID).style.display = "inline";
		document.getElementById("flecheDroite" + blocTitreID).style.display = "inline";
		document.getElementById("flecheGauche" + blocTitreID).style.color = couleurActif;
		document.getElementById("blocTitre" + blocTitreID).style.color = couleurActif;
		document.getElementById("flecheDroite" + blocTitreID).style.color = couleurActif;
		document.getElementById("blocTxt" + blocTitreID).style.color = couleurActif;
		if (rubriqueID >= 0 && rubriqueID < nRubriques[blocTitreID]) {
			if (document.getElementById("rubrique" + deuxDigits(blocTitreID) + deuxDigits(rubriqueID)) != null) {
				document.getElementById("rubrique" + deuxDigits(blocTitreID) + deuxDigits(rubriqueID)).style.color = couleurActif;
			}
		}
	}
	blocTitreInit = blocTitreID;
	rubriqueInit = rubriqueID;
	reinitBloc();
}

function reinitBloc ()
{
	if (areaIn == 0) {
		afficheBloc(blocTitreInit);
	}
}