                                                                       /* HORIZONTAL  MENU  */


/* true = vertical menu on the left.
   false = horizontal menu on the top. */
var vertical = false;

/* VERY IMPORTANT !
	Put here the number of menus. The script is not able to count it by itself.
 */
var nbmenu = 5;



/* Center the menu (true/false).
	Centre horizontaly ou verticaly depending on the mode. */
var center_menu = false;

/*
      We must define the width of the menus.
      To have diferent menus'width:
        var width_menu = new Array( width_menu1, width_menu2, width_menu3...)
	Take care of puting as many values as there are menus!
	In the vertical mode, put a fixed width for all menus (no array).
*/

var width_menu = new Array( 70,95,110,85,75);



/*  In the vertical mode we need to know the height of each menu
    var height_menu  = new Array(height_menu1, height_menu2, height_menu3...)
    Same recommendations as before!
*/

var height_menu = 35;

var width_ssmenu = new Array( 70,95,110,95,95);

/*  default width value for menus */
var width_auto_ssmenu = true;

/* space between menus */
var space_between_menus = 5;

/* position of the menu compared to the top of the page (O=top of the page) */

var top_menu = 2;

/* In the horizontal mode:
	position of the ssmenus compared to the top of the page. */

var top_ssmenu = top_menu + 32;

/* Left position of the menu, in px. (pixels) */
var left_menu= 198;

/* In the vertical mode:
position of the ssmenus compared to the left side of the page. */
var left_ssmenu = left_menu+2;

/* Delay before the ssmenu closure when the mouse quit it */

var delay = 650; // en milliseconde

/* In the horizontal version:
Because the menu can overide the page text, it is possible to make the page it is possible to reduce
 a little the page (the margin top is increased) to give some air to the page*/
var top_margin = top_menu + 10;

/* In the vertical version:
the left margin is increased */
var left_margin = width_menu + 10;


/* Put true if you want the menu to be always visible.
Put false and the menu will disappear when scrolling down
*/
var follow_scroll=true;

/* Pour IE uniquement, les balises <select> passent toujours au-dessus du menu, donc
	par défaut on cache les listes déroulantes quand le menu est ouvert, puis on les fait
	réapparaître à la fermeture du menu. Pour empêcher ça, mettre à false. */
var hide_selection=false;


var timeout; //don't touch it is the declaration of the variable
var agt = navigator.userAgent.toLowerCase();
var isMac = (agt.indexOf('mac') != -1);
var isOpera = (agt.indexOf("opera") != -1);
var IEver = parseInt(agt.substring(agt.indexOf('msie ') + 5));
var isIE = ((agt.indexOf('msie')!=-1 && !isOpera && (agt.indexOf('webtv')==-1)) && !isMac);
var isIE5win = (isIE && IEver == 5);
var isIE5mac = ((agt.indexOf("msie") != -1) && isMac);
var blnOk=true;
//to replace the"px" for the calculations...
var reg = new RegExp("px", "g");

// onScroll for Internet Explorer, the position:fixed do the job for the other browsers that respect the CSS norms.
window.onscroll = function()
{
	if (blnOk && follow_scroll && (isIE || isIE5mac))
	{
		if (isIE5mac) document.getElementById("horizontalmenucontainer").style.visibility="hidden";
		var cumul=0;
		for(i=1;i<=nbmenu;i++)
		{
			if (!vertical) {
				document.getElementById("menu"+i).style.top = document.body.scrollTop + top_menu + "px";
				if (document.getElementById("ssmenu"+i))//undefined
					document.getElementById("ssmenu"+i).style.top = document.body.scrollTop + top_ssmenu + "px";
			} else {
				document.getElementById("menu"+i).style.top = document.body.scrollTop
							+(((i-1)*space_between_menus)+cumul+1+top_menu)+"px";
				if (document.getElementById("ssmenu"+i))//undefined
					document.getElementById("ssmenu"+i).style.top = document.body.scrollTop
							+(((i-1)*space_between_menus)+cumul+1+top_menu)+"px";
				cumul += isFinite(height_menu)?height_menu:height_menu[i-1];
			}
		}
		if (isIE5mac) document.getElementById("horizontalmenucontainer").style.visibility="visible";
	}
}

function preLoading()
{
	if (document.getElementById("horizontalmenucontainer"))
	{
		document.getElementById("horizontalmenucontainer").style.visibility="hidden";
		//IE5 mac as a bug : when the text is in a float element, it does not appear.
		/*if (isIE5mac)
		{
			document.getElementById("conteneurmenu").style="";
		}*/
	}
}

function Loading() {
	if (!blnOk) {
		if(document.body.style.backgroundColor!="") { blnOk=false; }
		if(document.body.style.color!="") { blnOk=false; }
		if(document.body.style.marginTop!="") { blnOk=false; }
		if(document.getElementById) {
			with(document.getElementById("horizontalmenucontainer").style) {
				if(position!="" || top!="" || left!=""
						|| width!="" || height!="" || zIndex!=""
						|| margin!="" || visibility!="") {
					blnOk=false;
				}
			}
		}
		else{
			blnOk=false;
		}
	}

	if(blnOk)
	{
		document.getElementById("horizontalmenucontainer").style.visibility="hidden";

		trimespaces();

		with(document.body.style) {
			if (!vertical) marginTop=top_margin+"px";
			else		   marginLeft=left_margin+"px";
		}

		positionning();
		HideMenus();
	}

	//we avoided the flickering and now we reveals the menu ;-)
	document.getElementById("horizontalmenucontainer").style.visibility='';
}
window.onresize = Loading;

/*
 Place correctly the menu's elements during the loading, the schrolling and the window resizing
 */
function positionning() {
	var width_window = (isIE?document.body.clientWidth:window.innerWidth);
	var height_window = (isIE?document.body.clientHeight:window.innerHeight);
	if (center_menu) {
		if (!vertical) {
			var total_width = space_between_menus * (nbmenu-1);
			if (isFinite(width_menu))
				total_width += width_menu * nbmenu;
			else {
				for (i = 1; i <= nbmenu; i++)
					total_width += width_menu[i-1];
			}
			left_menu = (width_window - total_width)/2;
		} else {
			var total_height = space_between_menus * (nbmenu-1);
			if (isFinite(height_menu))
				total_height += height_menu * nbmenu;
			else {
				for (i = 1; i <= nbmenu; i++)
					total_height += height_menu[i-1];
			}
			top_menu = (height_window - total_height)/2;
		}
	}
	
	//Menus
	var cumul = 0;
	for(i=1;i<=nbmenu;i++) {
		with(document.getElementById("menu"+i).style) {
			if (!vertical) {
				top=top_menu+"px";
                        	left=(((i-1)*space_between_menus)+cumul+1+left_menu)+"px";
			} else {
			        top=(((i-1)*space_between_menus)+cumul+1+top_menu)+"px";
				left=left_menu+"px";
			}
			if (!follow_scroll || isIE || isIE5mac)
				position="absolute";
			else position="fixed";

			margin="0";
			zIndex="2";
			if (vertical || isFinite(width_menu))
				width=width_menu+"px";
			else
				width=width_menu[i-1]+"px";
			if ((!vertical && isFinite(width_menu)) || (vertical && isFinite(height_menu))) {
				cumul += (!vertical?width_menu:height_menu);
			}
			else {
				cumul += (!vertical?width_menu[i-1]:height_menu[i-1]);
				if (vertical) height=height_menu[i-1]+"px";
			}
		}
	}

	//ssmenus
	cumul = 0;
	for(i=1;i<=nbmenu;i++) {
		if (document.getElementById("ssmenu"+i))//undefined
		{
			with(document.getElementById("ssmenu"+i).style) {
				if (!follow_scroll || isIE || isIE5mac)
					position="absolute";
				else position="fixed";
				if (!vertical) {
					top=top_ssmenu+"px";

					left=(((i-1)*space_between_menus)+cumul+1+left_menu)+"px";
				} else {
					left=left_ssmenu+"px";

					top=(((i-1)*space_between_menus)+cumul+1+top_menu)+"px";
				}
				if (isIE || isOpera || isIE5mac || !width_auto_ssmenu) {
					if (isFinite(width_ssmenu))
						width = width_ssmenu+(width_ssmenu!="auto"?"px":"");
					else
						width = width_ssmenu[i-1]+(width_ssmenu[i-1]!="auto"?"px":"");
				}
				else width = "auto";
				if (!vertical && !isIE5mac) {
					//repositioning if it overflows on the right
					if ((width != "auto")
						&& ((left.replace(reg,'').valueOf()*1 + width.replace(reg,'').valueOf()*1) > width_window))
						left = (width_window-width.replace(reg,'').valueOf())+"px";
				}
				margin="0";
				zIndex="3";
			}
		}
		if ((!vertical && isFinite(width_menu)) || (vertical && isFinite(height_menu))) {
			cumul += (!vertical?width_menu:height_menu);
		}
		else {
			cumul += (!vertical?width_menu[i-1]:height_menu[i-1]);
		}
	}
}


function ShowMenu(strMenu) {
	if(blnOk) {
		CancelHide();
		HideMenus();
		if (document.getElementById(strMenu))//undefined
			with (document.getElementById(strMenu).style)
				visibility="visible";
	}
	SelectVisible("hidden",document.getElementsByTagName('select'));
}

function HideDelay() {
	if (blnOk) {
		timeout = setTimeout('HideMenus()',delay);
	}
}
function CancelHide() {
	if (blnOk && timeout) {
		clearTimeout(timeout);
	}
}
function HideMenus() {
	  {
		for(i=1;i<=nbmenu;i++) {
			if (document.getElementById("ssmenu"+i))//undefined
				with(document.getElementById("ssmenu"+i).style)
					visibility="hidden";
		}
	}
	SelectVisible("visible",document.getElementsByTagName('select'));
}

function trimespaces() {
	//Circumvent a bug of IE5/win... it does not accept the css for < Li >, therefore we take it off!
	if(blnOk&&isIE5win) {
		for(i=1;i<=nbmenu;i++) {
			if (document.getElementById("ssmenu"+i))//undefined
				with(document.getElementById("ssmenu"+i))
					innerHTML = innerHTML.replace(/<LI>|<\/LI>/g,"");
		}
	}
}

function SelectVisible(v,elem) {
	if (blnOk && hide_selection && (isIE||isIE5win))
		for (var i=0;i<elem.length;i++) elem[i].style.visibility=v;
}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

