if (document.all || navigator.userAgent.indexOf("Netscape6")){
	n=0;ie=1;fShow="visible";fHide="hidden";
}

if (document.layers){
	n=1;ie=0;fShow="show";fHide="hide";
}

window.onerror=new Function("return true")

function Menu(){
	this.bgColor="#9b82e0";
	if (ie) this.menuFont="bold xx-small Verdana";
	if (n) this.menuFont="bold x-small Verdana";
	this.addItem=addItem;
	this.addSubItem=addSubItem;
	this.showMenu=showMenu;
	this.mainPaneBorder=0;
	this.subMenuPaneBorder=0;
	this.subMenuPaneWidth=128;
	lastMenu=null;
	rX=0;
	rY=0;
	lY=0;
	lX=0;

	Hst="";
	Hst+="<!-- MENU PANE DECLARATION BEGINS -->\n";
	Hst+="\n";
	if (ie) Hst+="<div id='MainTable' valign=\"middle\">\n";
	if (ie) Hst+="<table width=\"100%\" bgcolor='"+this.bgColor+"' border='"+this.mainPaneBorder+"' cellpadding=\"4\" cellspacing=\"0\">\n";
	if (n) Hst+="<table width=\"100%\" bgcolor='"+this.bgColor+"' border='"+this.mainPaneBorder+"' cellpadding=\"0\" cellspacing=\"0\">\n";
	Hst+="<tr>";
	if (n) Hst+="<td><nobr>&nbsp;";
	Hst+="<!-- MAIN MENU STARTS -->\n";
	Hst+="<!-- MAIN_MENU -->\n";
	Hst+="<!-- MAIN MENU ENDS -->\n";
	if (n) Hst+="</nobr></td>";
	Hst+="</tr>\n";
	Hst+="</table>\n";
	Hst+="\n";
	Hst+="<!-- SUB MENU STARTS -->\n";
	Hst+="<!-- SUB_MENU -->\n";
	Hst+="<!-- SUB MENU ENDS -->\n";
	Hst+="\n";
	if (ie) Hst+= "</div>\n";
	Hst+="<!-- MENU PANE DECALARATION ENDS -->\n";
}

function addItem(idItem,text,hint,location,altLocation){
	var Lookup="<!-- ITEM "+idItem+" -->";

	if (Hst.indexOf(Lookup)!=-1){
		alert(idParent+" existe déjà");
		return;
	}

	var Mnu="";
	Mnu+="\n<!-- ITEM "+idItem+" -->\n";

	if (n){
		Mnu+="<ilayer name="+idItem+">";
		Mnu+="<nobr><a class=clsMenuItemNS onmouseover=\"displaySubMenu('"+idItem+"')\"";
		if (location!=null){
			Mnu+=" href='"+location+"' ";
		} else {
			Mnu+=" href='.' onclick=\"return false;\"";
		}
		Mnu+=">";
		Mnu+=text;
		Mnu+="</a></nobr>";
		Mnu+="</ilayer>";
	}

	if (ie){
		Mnu+="<td align=\"center\">\n";
		Mnu+="<div id='"+idItem+"' style='font: "+this.menuFont+";'>\n";
		Mnu+="<nobr><a ";
		Mnu+="class=clsMenuItemIE ";

		if (hint!=null){
			Mnu+="title='"+hint+"' ";
		}

		if (location!=null){
			Mnu+="href='"+location+"' ";
			Mnu+="onmouseover=\"hideAll()\" ";
		} else {
			if (altLocation!=null){
				Mnu+="href='"+altLocation+"' ";
			} else {
				Mnu+="href='.' ";
				Mnu+="onmouseover=\"displaySubMenu('"+idItem+"')\" ";
				Mnu+="onclick=\"return false;\" "
			}
		}

		Mnu+=">";
		Mnu+=text;
		Mnu+="</a></nobr>\n";
		Mnu+="</div>\n";
		Mnu+="</td>\n";
	}

	Mnu+="<!-- END OF ITEM "+idItem+" -->\n\n";
	Mnu+="<!-- MAIN_MENU -->\n";

	Hst=Hst.replace("<!-- MAIN_MENU -->\n",Mnu);
}

function addSubItem(idParent,text,hint,location){
	var Mnu="";
	Lookup="<!-- ITEM "+idParent+" -->";

	if (Hst.indexOf(Lookup) == -1){
		alert(idParent+" non trouvé");
		return;
	}

	Lookup="<!-- NEXT ITEM OF SUB MENU "+idParent+" -->";

	if (Hst.indexOf(Lookup) == -1){
		if (n){
			Mnu+="\n";
			Mnu+="<layer id='"+idParent+"submenu' visibility='hide' bgcolor='"+this.bgColor+"'>\n";
			Mnu+="<table border='"+this.subMenuPaneBorder+"' bgcolor='"+this.bgColor+"' width="+this.subMenuPaneWidth+" cellpadding=\"2\" cellspacing=\"2\">\n";
			Mnu+="<p><!-- NEXT ITEM OF SUB MENU "+idParent+" --></p>";
			Mnu+="</table>\n";
			Mnu+="</layer>\n";
			Mnu+="\n";
		}

		if (ie){
			Mnu+="\n";
			Mnu+="<div id='"+idParent+"submenu' style='position:absolute; visibility: hidden; width: "+this.subMenuPaneWidth+"; font: "+this.menuFont+";'>\n";
			Mnu+="<table border='"+this.subMenuPaneBorder+"' bgcolor='"+this.bgColor+"' width="+this.subMenuPaneWidth+" cellpadding=\"2\" cellspacing=\"2\">\n";
			Mnu+="<!-- NEXT ITEM OF SUB MENU "+idParent+" -->";
			Mnu+="</table>\n";
			Mnu+="</div>\n";
			Mnu+="\n";
		}

		Mnu+="<!-- SUB_MENU -->\n";
		Hst=Hst.replace("<!-- SUB_MENU -->\n",Mnu);
	}

	Lookup="<!-- NEXT ITEM OF SUB MENU "+idParent+" -->";
	if (n)  Mnu="<tr><td><a class='clsMenuItemNS' title='"+hint+"' href='"+location+"'>"+text+"</a><br></td></tr>\n";
	if (ie) Mnu="<tr><td><a class='clsMenuItemIE' title='"+hint+"' href='"+location+"'>"+text+"</a><br></td></tr>\n";
	Mnu+=Lookup;
	Hst=Hst.replace(Lookup,Mnu);
}

function showMenu(){
	document.writeln(Hst);
}

function displaySubMenu(idMainMenu){
	var menu;
	var submenu;

	if (n){
		submenu=document.layers[idMainMenu+"submenu"];
		if (lastMenu!=null && lastMenu!=submenu) hideAll();
		submenu.left=document.layers[idMainMenu].pageX;
		submenu.top=document.layers[idMainMenu].pageY+20;
		submenu.visibility=fShow;

		lX =document.layers[idMainMenu+"submenu"].left;
		rX=lX+document.layers[idMainMenu+"submenu"].clip.width;
		lY =document.layers[idMainMenu+"submenu"].top+document.layers[idMainMenu+"submenu"].clip.height;
		rY=lY;
	}
	else if (ie){
		menu=eval(idMainMenu);
		submenu=eval(idMainMenu+"submenu.style");
		submenu.left=menu.style.left+calculateSumOffset(menu,'offsetLeft');
		submenu.top=calculateSumOffset(menu,'offsetTop')+20;

		submenu.visibility=fShow;
		if (lastMenu!=null && lastMenu!=submenu) hideAll();

		lX=document.all[idMainMenu+"submenu"].style.posLeft;
		rX=lX+document.all[idMainMenu+"submenu"].offsetWidth;
		lY =document.all[idMainMenu+"submenu"].style.posTop+document.all[idMainMenu+"submenu"].offsetHeight;
		rY=lY;
	}

	lastMenu=submenu;
}

function hideAll(){
	if (lastMenu!=null){
		lastMenu.visibility=fHide;lastMenu.left=0;
	}
}

function calculateSumOffset(idItem,offsetName){
	var totalOffset=0;
	var item=eval('idItem');

	do{
		totalOffset+=eval('item.'+offsetName);
		item=eval('item.offsetParent');
	} while (item!=null);

	return totalOffset;
}

if (document.all){
	document.body.onclick=hideAll;
	document.body.onscroll=hideAll;
}

if (document.layers){
	document.onmousedown=hideAll;
	//window.captureEvents(Event.MOUSEMOVE);
}
