// Menu : Nad 14-05-2004
// init des variables
var menunbr = 4;// init du nombre de listes dans le menu
var isIE		= (((typeof(document.all) != 'undefined') && (parseInt(navigator.appVersion) >= 4)) ? 1 : 0);
var isDOM	= (( (typeof(document.getElementsByTagName) != 'undefined')&&(!isIE)) ? 1 : 0);
var isNS4	= ((typeof(document.layers) != 'undefined') ? 1 : 0);
var menuWmx	= 240; // largeur du menu //largeur max du menu si fixe
var menuWmy	= 27; // hauteur du menu
var farX=0,neerX=0,farY=0,neerY=0;
var hideAllTimer;
var resetTime= 0;
var startpos = 0;
var bodyLarge = 746;// largeur du contenant principal (tableau,body...) pour centrage
//var topY=null;

function splmenu(divnum, divPos, divHi, topY, menuWmx) {

// thank you mac users... re-init des valeur car les mac ne comprennent rien à position absolute
	document.getElementById("mDiv"+divnum).style.position	= "absolute";
	document.getElementById("mDiv"+divnum).style.top	= 0;
	document.getElementById("mDiv"+divnum).style.left	= 0;
// \
	resetTime=2;
	clearTimeout(hideAllTimer);
	hideAllTimer = null;
//	if (isDOM) topY=topY-6;
	hideAll();
	document.getElementById("mDiv"+divnum).style.top = topY;
	document.getElementById("mDiv"+divnum).style.display='';
	if ((document.body.clientWidth)<bodyLarge) bodyLarge=document.body.clientWidth;
	else bodyLarge=bodyLarge;

	document.getElementById("mDiv"+divnum).style.left=(((document.body.clientWidth)-bodyLarge)/2)+startpos+divPos;

	farX	= (((document.body.clientWidth)-bodyLarge)/2)+startpos+divPos+menuWmx;
	neerX	= (((document.body.clientWidth)-bodyLarge)/2)+startpos+divPos;
	farY	= divHi+menuWmy;
	if (topY) {farY = farY+topY ; neerY = topY; }
	else neerY = 0;
	
//	window.status="passe 1";
	return;
}
function splmenu2() {
	clearTimeout(hideAllTimer);
	hideAllTimer = null;
	resetTime=2;
//	window.status="passe 2";
	return;
}

if (isDOM) {// Netscape
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = captureMousePosition;
} else {
	document.onmousemove = captureMousePosition;
}
function captureMousePosition(e)
{
	if (resetTime==2){
		if (isDOM){
			var x = e.pageX;
			var y = e.pageY;
		} else if (isIE) {
			var x = window.event.clientX;
			var y = window.event.clientY;
		}
		if (x > farX || x < neerX) hidemenu();
		else if (y > farY || y < neerY) hidemenu();
	}
}

function hidemenu() {
	clearTimeout(hideAllTimer);
	hideAllTimer = null;
	hideAllTimer = setTimeout("hideAll()",400);
	resetTime=1;
}
function hideAll() {
	for (umk=1;umk<(menunbr+1);umk++) {
		document.getElementById('mDiv'+umk).style.display='none';
		closingDivElm("menuchavonnet-content")
		closingDivElm("menudelabie-content");
	}
	farX=0;
	neerX=0;
	farY=0;
	neerY=0;
}

function overcolor(oThis){
	oThis.onmouseout	= function(){ this.style.backgroundColor=''; }
	oThis.onmouseover	= function(){ this.style.backgroundColor='#EBF2F9'; }
}

function $(d){
	return document.getElementById(d)
}

function closingDivElm(d){
	d=$(d)
	d.style.display="none";
	clearInterval(d.t);
}

function openingDivElm(d){
	d=$(d)
	d.style.display="";
	clearInterval(d.t);
}

function accordeon(d,s,f){
	var l=$(d).getElementsByTagName("div");
	var a=[];

	for(i=0;i<l.length;i++){
		d=l[i];
		if(d.id.substr(d.id.indexOf("-"),d.id.length)=="-content"){
			a.push(d);
		}
	}
	x=null;
	for(i=0;i<l.length;i++){
		(function(h){
			c=h.id.substr(0,h.id.indexOf("-"));
			if(c+"-header"==h.id){
				c=$(c+"-content");
				c.style.display="none";
				c.style.overflow="hidden";
				c.h = 100;

				c.s=(s==undefined)?7:s;
				h.f=f;
				h.c=a;
				if(h.className.match(new RegExp(f+"+"))){
					x=h
				}
				h.onclick=function(){
					for(j=0;j<this.c.length;j++){
						var n=this.c[j].id;n=n.substr(0,n.indexOf("-"));
						d=$(n+"-header");
						n=$(n+"-content");
						s=d.className.split(new RegExp("\\s+"));
						for(p=0;p<s.length;p++){
							if(s[p]==""+d.f){
								s.splice(p,1);
								d.className=s.join(" ");
								break
							}
						}
						clearInterval(n.t);
						if(d.id==this.id){
							if(n.style.display=="none"){

								z= 100;
								n.t=setInterval('openingDivElm("'+n.id+'")',9);

							}
							d.className+=" "+d.f
						}else{
							if(n.style.display==""){
								z= 1;
								n.t=setInterval('closingDivElm("'+n.id+'")',9);
							}
						}
					}
				}
			}
		}
		)
		(l[i])
	}
	if(x!=null){
		x.onclick();
	}
}

function setAccordeon(){
	new accordeon('topdelabie',5,'header_highlight');
}

window.document.onload = setAccordeon();