// Affichage du menu
function menu_open()
{
	var btn = this.getElementsByTagName("a")[0];
	var ul = this.getElementsByTagName("ul");
	
	if (ul.length > 0)
	{
		var lvl = this.parentNode.style.zIndex;
		if (menu_last[lvl] != undefined) document.getElementById(menu_last[lvl]).style.display = "none";
		menu_last[lvl] = ul[0].id;
		clearTimeout(menu_timeout[ul[0].id]);
		ul[0].style.display = 'block';
		btn.className = "over parent";
	}
	else btn.className = "over";
}

// Fermeture du menu
function menu_close()
{
	var btn = this.getElementsByTagName("a")[0];
	var ul = this.getElementsByTagName("ul");
	
	if (ul.length > 0)
	{
		menu_timeout[ul[0].id] = setTimeout("document.getElementById('"+ul[0].id+"').style.display='none'", 500);
		btn.className = "out parent";
	}
	else btn.className = "out";
}

// Initialisation du menu
function menu_init(div)
{
	menu_timeout =  new Array();
	menu_last = new Array();
	var nav = /MSIE/;
	var ie = nav.test(navigator.appVersion);
	var li = document.getElementById(div).getElementsByTagName("li");
	var ul = document.getElementById(div).getElementsByTagName("ul");
	
	// Configuration des LI
	for (var i=0; i<li.length; i++)
	{
		// Evenements de la souris
		li[i].onmouseover = menu_open;
		li[i].onmouseout = menu_close;
		
		// Détection des sous-menus
		if (li[i].getElementsByTagName("ul").length > 0)
		{
			li[i].getElementsByTagName("a")[0].className = "out parent";
		}
		
		// Bug fix pour IE (Microsoft please learn to code)
		if (ie == true) li[i].style.display = "inline";
	}
	
	// Configuration des UL
	for (var i=0; i<ul.length; i++)
	{
		// Détecion du niveau d'arborescence
		var lvl = 1;
		var item = ul[i];
		while (item.parentNode.id != div)
		{
			item = item.parentNode.parentNode;
			lvl++;
		}

		// Paramètres de l'élement
		ul[i].style.zIndex = lvl;
		ul[i].id = "menu_"+div+"_"+i;
	}
}

function PopupAffiche(page,largeur,hauteur,options) {
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

function panier(etat)
{
	block = document.getElementById('confirmPanier');
	if(etat == 'on')
	{
		block.style.display = "block";
	}
	else
	{
		block.style.display = "none";
	}
	
	if(etat == 'off')
	{
		block.style.display = "none";
	}
}
	
function indexhautchange(id_page)
{
	/*$('indexpres').update("<img src=\"/images/load.gif\" alt=\"\" />");
	new Ajax.Request('ajax.php',
	{
		method: 'post', parameters: 'id='+id_page, onSuccess: function(ajax)
		{
			$('indexpres').update(ajax.responseText);
		}
	});*/
	var txt_id = 'ftxt'+id_page;
	var tabf = document.getElementsByClassName('ftxt');
	
	for(var i=0; i<tabf.length; i++)
	{
		tabf[i].style.display = 'none';
	}
	
	$(txt_id).style.display = 'block';
	
	new Ajax.Request('ajax.php',
	{
		method: 'post', parameters: 'selected='+id_page, onSuccess: function(ajax)
		{
			$('indexHautBarre').update(ajax.responseText);
		}
	});
}

function bloc_login()
{
	var com = document.getElementById('block_log');
	if(com.style.display == "block") com.style.display = "none";
	else com.style.display = "block";
}

function blockFormation(idBlock)
{
	var blocFormation = document.getElementsByClassName('blocFormation');
	
	$('pourQui').style.display = 'none';
	$('lesObjectifs').style.display = 'none';
	$('leProgramme').style.display = 'none';
	$('leConsultant').style.display = 'none';
	$('lesPlus').style.display = 'none';
	$('lesDates').style.display = 'none';
	
	/*for(var i=0; i<blockFormation.length; i++)
	{
		alert(blockFormation.length);
		blocFormation[i].style.display = 'none';
	}*/
	
	$(idBlock).style.display = 'block';
}

function afficheTitle(title)
{
	if(title == 'Envoyer à un ami') $('envoiAmi').style.display = 'block';
	else $('envoiAmi').style.display = 'none';
	
	$('titleImage').update(title);
}