function init_menu(selected_section){
	
	var main_menu_items = $$('.sousmenu');
	//console.log(main_menu_items.length);
	
	main_menu_items.each(function(item){
			
			//console.log(item.id);		
			data = item.id.split('_');	
			//console.log('categorie_id = ' + data[1]);		
			
			if($('sub_' + data[1]))
			{
				submenu = $('sub_' + data[1]);
				
				var height_fx = new Fx.Style($('sub_' + data[1]),'height')
				var nb = $('sub_' + data[1]).getChildren().length
				
				//var Pos = $('supermenu_' + data[1]).getPosition();
				//$('submenuw_' + data[1]).style.left = Pos.x - 2 + 'px';
				
				//console.log('nb = ' + nb);		

			

				//--deb
				item.addEvent('mouseenter',function(e){
					//$$('input').setStyles({visibility: 'hidden' });
					item.addClass('active');


					e = new Event(e)
					
					// calculate the submenu new item
					height_fx.stop()
					height_fx.start(nb*29)
					//console.log('sdsd'+submenu.id);
					submenu.getChildren().each(function(submenu_item){
						//console.log('pwet');
						submenu_item.addEvent('mouseover',function(e){
							// change color
							//submenu_item.addClass('active');
							// end of submenu_item.addEvent('mouseover')
						})
						submenu_item.addEvent('mouseout',function(e){
							// change color
							//submenu_item.removeClass('active');
							// end of submenu_item.addEvent('mouseout')
						})
					})

					e.stop()
					// end of item.addEvent('mouseenter')
				})
				//--deb

				
				//--deb
				item.addEvent('mouseleave',function(e){
					item.removeClass('active');

					
					e = new Event(e)
					height_fx.stop()
					height_fx.start(0)
					// change color
					e.stop()

					//$$('input').setStyles({visibility: 'visible' });
					
					// end of item.addEvent('mouseleave')
				})
				//--deb


			} //ifsubmenu


			
		


	// end of each
	})
	
// end of function
}

var fondDiv = false;
var dataDiv = false;
// Ajout a la newsletter
function addNewsletter(idForm) {
	
	if(!fondDiv){
		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		document.body.appendChild(fondDiv);
	}
	fondDiv.innerHTML = '';
	//alert(getHeight());

	$(fondDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '100%',
	   height: getScrollHeight(),
	   position: 'absolute',
	   opacity: '0.5',
	   overflow: 'hidden',
	   top: '0px',
	   left: '0px',
	   zIndex: '1500',
	   visibility: 'hidden'
	});

	if(!dataDiv){
		dataDiv = document.createElement('div');
		dataDiv.style.position = 'absolute';
		document.body.appendChild(dataDiv);
	}

	$(dataDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '300px',
	   height: '300px',
	   position: 'absolute',
	   border: '1px solid #000',
	   top: '50%',
	   left: '50%',	   
	   marginLeft: '-150px',	   
	   marginTop: (getScrollTop()-150) + 'px',	   	   	   
	   zIndex: '1600',
	   visibility: 'hidden'
	});	

	new Ajax(
		'/js/ajax/newsletter.php',
		{
			update: dataDiv,
			data:$(idForm).toQueryString(),
			onSuccess: function(req) {

					$$(fondDiv).setStyles({visibility: 'visible' });
					$$('select').setStyles({visibility: 'hidden' });
					$$(dataDiv).setStyles({visibility: 'visible' });
	
			},
			evalScripts: true
		}
	).request();		
	
	
	
}

function removeDiv()
{
	if(fondDiv){
		$(fondDiv).remove();
		fondDiv = false;
	}	
	if(dataDiv){
		$(dataDiv).remove();
		dataDiv = false;
	}
	$$('select').setStyles({visibility: 'visible' });		
}

/*
function popup_formation(coords,formation) {
	

	if(formation>0) {
		
		curpopup = coords;
		
		var arr = coords.split(',');
		document.getElementById('filiere_roll').style.width=(parseInt(arr[2])-parseInt(arr[0]))+'px';
		document.getElementById('filiere_roll').style.height=(parseInt(arr[3])-parseInt(arr[1]))+'px';
		document.getElementById('filiere_roll').style.top=parseInt(arr[1])+'px';
		document.getElementById('filiere_roll').style.left=parseInt(arr[0])+'px';
		document.getElementById('filiere_roll').style.display='block';
		
		document.getElementById('filiere_roll').onclick=function(event) {

			
			
		  if( window.event)
		    event = window.event;
			
			var x = event.clientX;
			var y = event.clientY;
			
			$("filiere_masque").innerHTML = '';

			$("filiere_masque").setStyles({
			   width: parseFloat(arr[2])-parseFloat(arr[0]),
			   height: parseFloat(arr[3])-parseFloat(arr[1]),
			   position: 'absolute',
			   overflow: 'hidden',
			   top: '0px',
			   left: '0px',
			   zIndex: '1500',
			   visibility: 'hidden',
			   top: parseInt(arr[1])+'px',
			   left: parseInt(arr[0])+'px',
			   cursor:'pointer'
			   
			});

			new Ajax(
				'/js/ajax/formation.php',
				{
					update: document.getElementById('bibi1'),
					data:'formation_id='+formation,
					onSuccess: function(req) {
							
							var infos = req.split('|');
							
							$("filiere_masque").setStyles({visibility: 'visible' });
							$("filiere_popup").setStyles({visibility: 'visible' });

							$$('select').setStyles({visibility: 'hidden' });
							
							document.getElementById('filiere_popup').style.display='block';
							document.getElementById('filiere_popup').style.left=x+'px';
							document.getElementById('filiere_popup').style.top=y+getScrollTop()+'px';							
							document.getElementById('filiere_popup').style.cursor='pointer';			
							
							document.getElementById('filiere_popup').onclick=function(event) {
								location.href=infos[0];
							}
							
							document.getElementById('bibi_titre').innerHTML = infos[1];
							document.getElementById('bibi_desc').innerHTML = infos[2];
							document.getElementById('bibi_link').href= infos[0];
							
					},
					evalScripts: true
				}
			).request();
			
			
		}
		document.getElementById('filiere_masque').onclick=function(event) {
		  if( window.event)
		    event = window.event;
			
			var x = event.clientX;
			var y = event.clientY;
						
			document.getElementById('filiere_popup').style.left=x+'px';
			document.getElementById('filiere_popup').style.top=y+getScrollTop()+'px';			
		}
		
		document.getElementById('filiere_roll').onmouseout=function() {
				hide_formation();
		}
	}
}

*/


function popup_formation(coords,formation) {
	

	if(formation>0) {
		
		curpopup = coords;
		
		var arr = coords.split(',');
		document.getElementById('filiere_roll').style.width=(parseInt(arr[2])-parseInt(arr[0]))+'px';
		document.getElementById('filiere_roll').style.height=(parseInt(arr[3])-parseInt(arr[1]))+'px';
		document.getElementById('filiere_roll').style.top=parseInt(arr[1])+'px';
		document.getElementById('filiere_roll').style.left=parseInt(arr[0])+'px';
		document.getElementById('filiere_roll').style.display='block';
		
		document.getElementById('filiere_roll').onclick=function(event) {


			


			new Ajax(
				'/js/ajax/formation.php',
				{
					update: document.getElementById('bibi1'),
					data:'formation_id='+formation,
					onSuccess: function(req) {
							
							var infos = req.split('|');
							

							

								location.href=infos[0];
							

							
					},
					evalScripts: true
				}
			).request();
			
			
		}

		
		document.getElementById('filiere_roll').onmouseout=function() {
				hide_formation();
		}
	}
}


function hide_formation() {
	document.getElementById('filiere_roll').style.display='none';
}



function hide_popup() {


	//	$("filiere_masque").setStyles({visibility: 'hidden' });
	//	$("filiere_popup").setStyles({visibility: 'hidden' });

}





var fondDiv = false;
var dataDiv = false;

function ViewPopup()
{
	if(!fondDiv){
		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		document.body.appendChild(fondDiv);
	}
	fondDiv.innerHTML = '';
	//alert(getHeight());

	$(fondDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '100%',
	   height: getScrollHeight(),
	   position: 'absolute',
	   opacity: '0.5',
	   overflow: 'hidden',
	   top: '0px',
	   left: '0px',
	   zIndex: '1500',
	   visibility: 'hidden'
	});

	if(!dataDiv){
		dataDiv = document.createElement('div');
		dataDiv.style.position = 'absolute';
		document.body.appendChild(dataDiv);
	}

	$(dataDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '300px',
	   height: '300px',
	   position: 'absolute',
	   border: '1px solid #000',
	   top: '50%',
	   left: '50%',	   
	   marginLeft: '-150px',	   
	   marginTop: (getScrollTop()-150) + 'px',	   	   	   
	   zIndex: '1600',
	   visibility: 'hidden'
	});	
	new Ajax(
		'/popup.php',
		{
			method: 'get',
			update: dataDiv,
			//data:$(idForm).toQueryString(),
			onSuccess: function(req) {
				$$(fondDiv).setStyles({visibility: 'visible' });
				$$('select').setStyles({visibility: 'hidden' });
				$$(dataDiv).setStyles({visibility: 'visible' });

				
			},
			evalScripts: true
		}
	).request();
	
}

function onglet_out(menu_id) {
	// On réinitialise tous les menus
	var main_menu_items = $$(".grandmenu");

	main_menu_items.each(function(item){
		var old_id = item.id;		
		
		$(old_id).style.backgroundColor="transparent";
		$(old_id).style.backgroundImage="url(/styles/images/onglet/onglet.png)";
		$(old_id).style.backgroundRepeat="no-repeat";
		$(old_id).style.backgroundPosition="bottom left";
		$(old_id).style.color="#fff";
		
		data = item.id.split('_');
		$("supermenu_a_"+data[1]).style.color="#fff";
		$("supermenu_a_"+data[1]).style.textDecoration="none";
	})	
}


function onglet_hover(menu_id) {
	
	// On réinitialise tous les menus
	var main_menu_items = $$(".grandmenu");

	main_menu_items.each(function(item){
		var old_id = item.id;		
		
		$(old_id).style.backgroundColor="transparent";
		$(old_id).style.backgroundImage="url(/styles/images/onglet/onglet.png)";
		$(old_id).style.backgroundRepeat="no-repeat";
		$(old_id).style.backgroundPosition="bottom left";
		$(old_id).style.color="#fff";
		
		data = item.id.split('_');
		$("supermenu_a_"+data[1]).style.color="#fff";
		$("supermenu_a_"+data[1]).style.textDecoration="none";
	})
	

	// On active que celui qui nous interesse	
	if($("supermenu_"+menu_id)) {
		$("supermenu_"+menu_id).style.backgroundColor="transparent";
		$("supermenu_"+menu_id).style.backgroundImage="url(/styles/images/onglet/rollover.png)";
		$("supermenu_"+menu_id).style.backgroundRepeat="no-repeat";
		$("supermenu_"+menu_id).style.backgroundPosition="bottom left";		
		
		$("supermenu_a_"+menu_id).style.color="#fff";
		$("supermenu_a_"+menu_id).style.textDecoration="underline";
	}
	
	
}


function nowindex(obj, pos) {
	if(pos==1) {
		
		obj.style.backgroundColor="transparent";
		obj.style.backgroundImage="url(/styles/images/onglet/indexr.png)";
		obj.style.backgroundRepeat="no-repeat";
		obj.style.backgroundPosition="bottom left";		
		$('aindex').style.color="#fff";		
		
	}else if(pos==2){
		obj.style.backgroundColor="transparent";
		obj.style.backgroundImage="url(/styles/images/onglet/indexa.png)";
		obj.style.backgroundRepeat="no-repeat";
		obj.style.backgroundPosition="bottom left";		
		$('aindex').style.color="#fff";				
	}
	
}