// JavaScript Document

var tab_menu = new Array('identite', 'competence', 'reference', 'actualite');
var heightMin = 12;
var tab_heightMax = new Array();
tab_heightMax["identite"] = 99;
tab_heightMax["competence"] = 99;
tab_heightMax["reference"] = 133;
tab_heightMax["actualite"] = 82;
//var heightMoy = heightMax - heightMin;
var t;

function resizePlus(nom, heightMin, heightMax, heightMoy) {
	var anim = document.getElementById ("retract");
	var etat = anim.clientHeight;
	anim.style.height = heightMin + "px";
	heightMin += (etat/10);
	
	if (heightMin > heightMoy) {
		var nom_menu = "menu_" + nom;
		var menu = document.getElementById(nom_menu);
		menu.style.display = 'block';
	}
	
	if (heightMin < heightMax) {
		string = "resizePlus('" + nom +"', " + heightMin + ", " + heightMax + ", " + heightMoy + ")";
		t = setTimeout (string, 30);
	} else anim.style.height = heightMax + "px";
}

function resizeMoins(nom, heightMin, heightMax, heightMoy) {
	var anim = document.getElementById ("retract");
	var etat = anim.clientHeight;
	anim.style.height = heightMax + "px";
	heightMax -= (etat/10);
	
	if (heightMax < heightMoy) {
		var nom_menu = "menu_" + nom;
		var menu = document.getElementById(nom_menu);
		menu.style.display = 'none';
	}
	
	if (heightMax > heightMin) {
		string = "resizeMoins('" + nom +"', " + heightMin + ", " + heightMax + ", " + heightMoy + ")";
		t = setTimeout (string, 30);
	} else anim.style.height = heightMin + "px";
}

function statusNav(nom) {
	var nom_nav_on = "nav_" + nom + "_on";
	var nom_nav_off = "nav_" + nom + "_off";
	var nav_on = document.getElementById(nom_nav_on);
	var nav_off = document.getElementById(nom_nav_off);
	nav_on.style.display = (nav_on.style.display == 'none') ? 'block' : 'none';
	nav_off.style.display = (nav_off.style.display == 'block') ? 'none' : 'block';
}

function menuOn(nom) {
	var flag = 0;

	for (i=0; i < tab_menu.length; i++) {
		var nom_menu = "menu_" + tab_menu[i];
		var menu = document.getElementById(nom_menu);
		if (tab_menu[i] != nom && menu.style.display == 'block') {
			menu.style.display = 'none';
			statusNav(tab_menu[i]);
			flag = 1;
		}
	}
	
	statusNav(nom);
	
	if (flag) {
		var anim = document.getElementById ("retract");
		anim.style.height = tab_heightMax[nom] + "px";
		var nom_menu = "menu_" + nom;
		var menu = document.getElementById(nom_menu);
		menu.style.display = 'block';
	} else resizePlus(nom, heightMin, tab_heightMax[nom], tab_heightMax[nom] - heightMin);
}

function menuOff(nom) {
	resizeMoins(nom, heightMin, tab_heightMax[nom], tab_heightMax[nom] - heightMin);
	statusNav(nom);
}

function initMenu(nom) {
	for (i=0; i < tab_menu.length; i++) {
		var nom_nav_on = "nav_" + tab_menu[i] + "_on";
		var nom_nav_off = "nav_" +  tab_menu[i] + "_off";
		var nom_menu = "menu_" + tab_menu[i];
		var nav_on = document.getElementById(nom_nav_on);
		var nav_off = document.getElementById(nom_nav_off);
		var menu = document.getElementById(nom_menu);
		if (tab_menu[i] == nom) {
			nav_on.style.display = 'block';
			nav_off.style.display = 'none';
			menu.style.display = 'block';
		} else {
			nav_on.style.display = 'none';
			nav_off.style.display = 'block';
			menu.style.display = 'none';
		}
	}
}

function initNav(nom) {
	document.getElementById("nav_" + nom + "_on").style.display = 'block';
	document.getElementById("nav_" + nom + "_off").style.display = 'none';
}
