function initMenu(){
	/* Version 1.0 */
	/* Marc */
	for(var t=0;t<window.Dmc_declars.length;t++){
		addMenu(window.Dmc_declars[t],t); 
	}
}
function addMenu(tableau,t){
	var DmcParent = document.createElement("DIV");
	document.body.appendChild(DmcParent);
	DmcParent.id=tableau[0][0];
	//DmcParent.className=tableau[0][3];
	DmcParent.className="ssmenu";
	DmcParent.Niveau=tableau[0][4];
	DmcParent.style.position = "absolute";
	//DmcParent.style.top = "0px";
	//DmcParent.style.left= "10px";
	DmcParent.style.zIndex= t+1000;
	//DmcParent.style.width = tableau[0][1][0]+"px";
	DmcParent.style.overflow="hidden"; 
	//DmcParent.style.backgroundColor=tableau[0][2][0];
	//DmcParent.backgroundColorOver=tableau[0][2][1];
	//DmcParent.style.borderWidth ="1px";
	//DmcParent.style.borderStyle = "solid";
	//DmcParent.style.visibility = "hidden";
	DmcParent.style.display = "none";
	//DmcParent.style.padding = "0";
	//DmcParent.hauteur=0;
	DmcParent.isSelect="";
	var ul = document.createElement("ul");
	DmcParent.appendChild(ul);
	for(var i=1;i<tableau.length;i++){
		var items=addItem(DmcParent.id,tableau[0][1][0],tableau[i],i)
		if(i==tableau.length-1) {
			items.className = "ssmenulast";
		}
		ul.appendChild(items)
		items.setStyle();
	}
	//DmcParent.style.height=(parseInt(DmcParent.hauteur)-1)+"px"
}
function addItem(nom,width,table,index){
	var DmcItem = document.createElement("li");
	DmcItem.id=nom+"_"+index;
	DmcItem.style.zIndex=index;
	//DmcItem.style.position = "absolute";
	DmcItem.Url=table[1];
	DmcItem.Target="_self";
	DmcItem.Nom_Fils=table[2];
	DmcItem.style.cursor=setCursor((table[1]!="")? true:false)
	DmcItem.innerHTML ="<a href=\"#\" class=\"lien_menu\" style=\"cursor:"+setCursor((table[1]!="")? true:false)+"\" onclick=\"return false\">"+table[0]+"</a>";
	DmcItem.setStyle=setStyleItem;
  return DmcItem;
}
function setImage(Menu){
		Menu.firstChild.style.backgroundImage = "url(http://192.168.69.12:8888/geniecube171/sorhea/images/f.gif)";
		Menu.firstChild.style.backgroundPosition = "right center";
		Menu.firstChild.style.backgroundRepeat = "no-repeat";
}
function setStyleItem(){
	//this.className=this.parentNode.className;
	//this.style.backgroundColor=this.parentNode.style.backgroundColor;
	//this.style.padding = "2px";
	/*if(this.style.zIndex==1){
		this.style.top="0px"
	}else{
		this.style.top=(parseInt(this.previousSibling.offsetHeight)+parseInt(this.previousSibling.style.top))+"px";
	}
	this.style.left=0;*/
	
	//this.style.visibility='inherit';
	//this.style.borderWidth="0px";
	//this.style.borderBottomWidth ="1px";
	//this.style.borderStyle = "solid";
	//this.style.width=(parseInt(this.parentNode.offsetWidth)-(parseInt(this.style.padding)*2))+"px";
	if(this.Nom_Fils!=""){
		setImage(this)
	}
	this.onmouseover=rollover;
 	this.onmouseout=rollout;
	this.filsVisible = function(){
	if(this.Nom_Fils!=""){
				var DmcCalque=Dmc_Layer.is_object(this.Nom_Fils);
				if(DmcCalque!=false){
						if(Dmc_Layer.DMC_net){
						}else if(Dmc_Layer.DMC_net6 || Dmc_Layer.DMC_ie){
							if(DmcCalque.style.visibility=="visible"){
									this.style.backgroundColor=this.parentNode.backgroundColorOver;
									return
								}else{
									this.style.backgroundColor=this.parentNode.style.backgroundColor;
								}
						}
				}
			}
			this.style.backgroundColor=this.parentNode.style.backgroundColor;
	}
	if(Dmc_Layer.DMC_net){
		this.captureEvents(Event.MOUSEUP);
		this.onmouseup =ouvrePage;
	}else if(Dmc_Layer.DMC_net6){
		this.onclick=ouvrePage;
	}else if(Dmc_Layer.DMC_ie){
		this.onmousedown = ouvrePage;
	}
		//this.parentNode.hauteur=this.parentNode.hauteur+parseInt(this.offsetHeight);
}
function rollover(){
	clearTimeout(MenuTimer);
	var ecran =getEcranX();
	if(typeof(EnsembleMenu[this.parentNode.parentNode.Niveau+1])!="undefined"){
		cacheniveau(this.parentNode.parentNode.Niveau);
	}
	//cacheniveau(this.parentNode.parentNode.Niveau);
	//if(this.parentNode.isSelect!=""){this.parentNode.isSelect.filsVisible();}
	this.style.backgroundColor=this.parentNode.backgroundColorOver;
	if(this.Nom_Fils!=""){
		this.parentNode.isSelect=this;
		//alert(this.Nom_Fils);
		EnsembleMenu[this.parentNode.parentNode.Niveau+1]=this.Nom_Fils;
		var DmcCalque=Dmc_Layer.is_object(this.Nom_Fils);
		if( DmcCalque!=false){
			var longueur=parseInt(this.parentNode.style.width);
			if(is_droit==true){
				if((parseInt(this.parentNode.style.width)*2)+parseInt(this.parentNode.style.left) < ecran ){
						var posx=parseInt(this.parentNode.style.width)+parseInt(this.parentNode.style.left);
						is_droit=true;
				}else{
						var posx=parseInt(this.parentNode.parentNode.style.left);//-parseInt(this.parentNode.style.width);
						//is_droit=false;
				}
			}else{
			 	var posx=parseInt(this.parentNode.style.left)-parseInt(this.parentNode.style.width);
			}
			var posy=parseInt(this.parentNode.style.top)+parseInt(this.style.top)
			
			DmcCalque.style.left=(getPosition(this).x+164)+"px";
			
			DmcCalque.style.top=getPosition(this).y+"px";
			DmcCalque.style.visibility="visible";
			DmcCalque.style.display="block";
		}
	}else{
		this.parentNode.isSelect="";
	}	
}
function rollout(){
	MenuTimer=setTimeout("cacheniveau(-1)",1000);
	if(this.Nom_Fils==""){this.style.backgroundColor=this.parentNode.style.backgroundColor;}
}
function setCursor(action){
	if(!action){
		return "default";
	}else{
		if(Dmc_Layer.DMC_ie){return "hand";}
		else if(Dmc_Layer.DMC_net6){return "pointer";}
		else{return "";}
	}
}
function ouvrePage(){
	if(this.Url!=""){
		if(Dmc_Layer.DMC_net6 && this.Url.indexOf('javascript:')!=-1){eval(this.Url);}
		else{open(this.Url,this.Target);}
	}
}
function cacheniveau(Niveau){
	//alert(Niveau+1 + "   " + EnsembleMenu.length);
	for(var j=Number(Niveau+1);j<EnsembleMenu.length;j++){
		//alert("là");
		if(EnsembleMenu[j]!="" && typeof(EnsembleMenu[j])!="undefined"){
			//alert(EnsembleMenu[j])
			var obj=Dmc_Layer.is_object(EnsembleMenu[j]);
			Dmc_Layer.f_cacher(obj);
			if(obj!=false){
				Dmc_Layer.set_posy(obj,-200);
				Dmc_Layer.set_posx(obj,-100);
			}
			EnsembleMenu[j]="";
		}
	}
}
function getEcranX(){
		if (window.innerWidth != null){
		return parseInt(window.innerWidth);}
		if (document.body.clientWidth != null){
		return parseInt(document.body.clientWidth);}
		return (0);
}
function getArbo(nom){
	var result=new Array();
	for(var rt=0;rt<window.Dmc_declars.length;rt++){
		if(window.Dmc_declars[rt][0][0]==nom){
			result=window.Dmc_declars[rt];
			break;
		}
	}
	return result;
}

function AoMenu_AddOnline(nom,objlien){
	clearTimeout(MenuTimer);
	cacheniveau(-1);
	if(nom!=""){
		var _layer = Dmc_Layer.is_object(nom);
		if(_layer!=false){
			EnsembleMenu[0]=nom;
			var position = getPosition(objlien);
			var posX = position.x + 163 + 1;
			var posY = position.y
			Dmc_Layer.set_posx(_layer, posX);
			Dmc_Layer.set_posy(_layer, posY);
			Dmc_Layer.f_visible(_layer);
		}
	}
}



function AoMenu_AddOnlinev(calque,objetlien,blocconteneur,blocparent){
	clearTimeout(MenuTimer);
	cacheniveau(-1);
	var _blocconteneur = Dmc_Layer.is_object(blocconteneur);
	var blocconteneurY =_blocconteneur.offsetTop;
	var _blocparent = Dmc_Layer.is_object(blocparent);
	var blocparentY =_blocparent.offsetTop;
	var ecran  = ((getEcranX()-939)/2);
	var posx=255;
	var posy=233; //350;
	if(getEcranX()<=939){
		ecran  = 0;
	}
	var _layer = Dmc_Layer.is_object(calque);
	if(_layer!=false){ 
		EnsembleMenu[0] = calque;
		var _parente = Dmc_Layer.is_object("blockmenuv1");
		_y= parseInt(blocparentY)+parseInt(blocconteneurY)+posy+objetlien.offsetTop;
		Dmc_Layer.set_posx(_layer,posx+ecran);
		Dmc_Layer.set_posy(_layer,_y);
		Dmc_Layer.f_visible(_layer);
	}
}

function deroulefil(nom){
	if(window.oldDeplie!=""){
		var _layer = Dmc_Layer.is_object(window.oldDeplie);
					_layer.style.display ="none";
	}
	var _layer = Dmc_Layer.is_object(nom);
	if(_layer!=false){
			if(_layer.style.display == "none"){
				_layer.style.display = "block";
				window.oldDeplie =nom;
			}else{
				_layer.style.display ="none";
				window.oldDeplie ="";
			}
	}
}

/*
** Retourne la position d'un élément
** en parcourant l'arbre des parents
** et en incrémentant de l'offset
*/
function getPosition(e) {
	var left = 0;
	var top  = 0;

	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}

	left += e.offsetLeft;
	top  += e.offsetTop;
	
	return {x:left, y:top};
}