<!-- ***javascript pour menu*** -->

window.onload=montre;
_global.menustate=0;
_global.menu_show_noshow='none';

function reinit_var() {
	menustate=0
	menu_show_noshow="none";
	//montre(sousmenu);
}


function montre(id) {
		// this function gets executed every time the page gets refreshed and 
		// upon clicking on a menu
	var d = document.getElementById(id);
	// dont know how to test for true/ false in switch so I set up a fake variable to test instead
	if (d) {
		test_id=id;
	}else 
	{
		test_id=99;
	}
	
	switch (test_id)
	{
	 case 99:  // on clicking , just loading
		menustate=0 ;
		menu_show_noshow="none";
		break;
	 case menustate: // same menu as last time so need to flipflop
	 	if (menu_show_noshow=='none') {menu_show_noshow='block';}
		else {menu_show_noshow='none'}
	 	break;
	 default:  // all other cases, should be just another menu so need to show the block
		menustate=id ;
		menu_show_noshow='block';
	}
	
	// the loop gets executed for all smenus
	for (var c = 1; c<=10; c++) {
		if (document.getElementById('smenu'+c)) {
			document.getElementById('smenu'+c).style.display='none';
		}
	}
	// display only the sous-menu that is passed as argument
	if (d) 	{
		d.style.display=menu_show_noshow;
		menustate=id;
	}else {
		menustate=0}
}


