var tab;

function menu_deroulant() {
	document.forms["adm_menu"].elements["sous_menu"].options.length = 0;
	tab = eval("menutab_"+document.forms["adm_menu"].elements["menu_pere"].options[document.forms["adm_menu"].elements["menu_pere"].options.selectedIndex].value);
	for(i=0; i<tab.length; i=i+2){
		var monOption = new Option(tab[i+1], tab[i]);
		document.forms["adm_menu"].elements["sous_menu"].options[document.forms["adm_menu"].elements["sous_menu"].options.length] = monOption;
	}
}

function menu_deroulant_mod(sel) {

	menu_niveau = sel.split("-");

	document.forms["adm_menu"].elements["sous_menu"].options.length = 0;

	if(menu_niveau.length == 1){
		tab = eval("menutab_racine");
	}else{
		tab = eval("menutab_"+menu_niveau[0]);
	}
	
	j=0;
	for(i=0; i<tab.length; i=i+2){
		if(!((menu_niveau[1] == j)&&(menu_niveau.length == 2))){
			var monOption = new Option(tab[i+1], tab[i]);
			document.forms["adm_menu"].elements["sous_menu"].options[document.forms["adm_menu"].elements["sous_menu"].options.length] = monOption;
		}
		j++;
	}
	
	menu_niveau[1];
	if(menu_niveau.length > 1){
		document.forms["adm_menu"].elements["menu_pere"].options.selectedIndex = menu_niveau[0];
	}
	if(menu_niveau.length > 2){
		document.forms["adm_menu"].elements["sous_menu"].options.selectedIndex = menu_niveau[1];
	}
}

function menu_deroulant_add(sel) {

	menu_niveau = sel.split("-");

	document.forms["adm_menu"].elements["sous_menu"].options.length = 0;

	if(menu_niveau.length == 1){
		tab = eval("menutab_racine");
	}else{
		tab = eval("menutab_"+menu_niveau[0]);
	}

	for(i=0; i<tab.length; i=i+2){
		var monOption = new Option(tab[i+1], tab[i]);
		document.forms["adm_menu"].elements["sous_menu"].options[document.forms["adm_menu"].elements["sous_menu"].options.length] = monOption;
	}
	
	menu_niveau[1];
	if(menu_niveau.length > 1){
		document.forms["adm_menu"].elements["menu_pere"].options.selectedIndex = menu_niveau[0];
	}
	if(menu_niveau.length > 2){
		document.forms["adm_menu"].elements["sous_menu"].options.selectedIndex = menu_niveau[1];
	}
}

var sto_open;
var sto_close;

/*gestion du menu */
function cache(){
	clearTimeout(sto_open);
	clearTimeout(sto_close);
	document.getElementById("ssmenu1_md").style.display='none';
	document.getElementById("ssmenu2_md").style.display='none';
	document.getElementById("ssmenu3_md").style.display='none';
	document.getElementById("ssmenu4_md").style.display='none';
	document.getElementById("ssmenu5_md").style.display='none';
	
	document.getElementById("ssmenu1_menu").style.color='#ffffff';
	document.getElementById("ssmenu2_menu").style.color='#ffffff';
	document.getElementById("ssmenu3_menu").style.color='#ffffff';
	document.getElementById("ssmenu4_menu").style.color='#ffffff';
	document.getElementById("ssmenu5_menu").style.color='#ffffff';
}

function deroulemenu_accueil(idMenu, deroul){
	document.getElementById(idMenu).style.display='block';
	height = document.getElementById(idMenu).offsetHeight;
	document.getElementById(idMenu).style.clip = 'rect(0px 250px '+deroul+'px 0px)';
	deroul = deroul+5;
	if(deroul-10 <= height){
		sto_open = setTimeout("deroulemenu_accueil('"+idMenu+"', "+deroul+")", 15);
	}
}
function cachederoulmenu_accueil(idMenu, deroul){
	document.getElementById(idMenu).style.clip = 'rect(0px 250px '+deroul+'px 0px)';
	deroul = deroul-5;
	if(deroul+10 >= 0){
		sto_open = setTimeout("cachederoulmenu_accueil('"+idMenu+"', "+deroul+")", 15);
	}else{
		cache();
	}
}
function cachemenu_accueil(idMenu){
	height = document.getElementById(idMenu+"_md").offsetHeight;
	sto_close = setTimeout("cachederoulmenu_accueil('"+idMenu+"_md', "+height+")", 800);
}
function affiche_menu2(idMenu){
	clearTimeout(sto_close);
	document.getElementById(idMenu+"_md").style.display='block';
}
function affiche_menu(idMenu){
	clearTimeout(sto_close);
	if((document.getElementById(idMenu+"_md").style.display=='')
	  ||(document.getElementById(idMenu+"_md").style.display=='none')){
		cache();
		deroulemenu_accueil(idMenu+"_md", 0);
	}
	document.getElementById(idMenu+'_menu').style.color = '#ffffff';
}

// Permet d'ouvrir une fenêtre PopUp
// twPopUp( url de destination, Nom de la fenètre , largeur, hauteur, Avec défilement ou nom );
// 0 aucune barre de défilement
// 1 avec barre de défilement
function twPopUp(_url,_nom,_larg,_haut,_defil) {
	var op_scroll = 1;
	var op_wid = _larg;
	var op_heigh = _haut;
	var op_tool = 0;
	var op_loc_box = 0
	var op_dir = 0;
	var op_stat = 0;
	var op_menu = 0;
	var op_resize = 1;
	var options = "toolbar="+ op_tool +",location="+ op_loc_box +",directories="
	+ op_dir +",status="+ op_stat +",menubar="+ op_menu +",scrollbars="
	+ op_scroll +",resizable=" + op_resize +",width=" + op_wid +",height="+ op_heigh;
	var wNom = window.open(_url, _nom, options);
if(_nom.focus){_nom.focus();
}
}

function PopupCentrer(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 MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}