//Function startList pour les rollover CSS UL/LI
//<span id="thescript" style="display: block; border: 1px solid #FF0000; padding: 10px; background: #FFFFCC;"></span>
//var debug = document.getElementById("thescript");

startList = function() {
	navRoot = document.getElementById("nav");
	
	for (i=0; i<navRoot.childNodes.length; i++) {
		li = navRoot.childNodes[i];
		
		if (li.nodeName=="LI") {
			if(li.childNodes[1]){
				var ul = li.childNodes[1];
				ul.maxedHeight = ul.offsetHeight;
				ul.style.display="none";
				ul.style.visibility="visible";

				li.onmouseover=function() {
					var myUL = this.childNodes[1];
					myUL.status = null;					

					for (i=0;i<navRoot.childNodes.length;i++) {
						if(myUL==navRoot.childNodes[i].childNodes[1]){
							doAppear(myUL);
							//debug.innerHTML += 'trigger doAppear: ' + myUL.id + ' ' + myUL.className + '<br />';
						}
						else navRoot.childNodes[i].childNodes[1].style.display = 'none';
					}
				}
				li.onmouseout=function() {
					var myUL = this.childNodes[1];
					myUL.status = "open";
					doFade(myUL);
					//debug.innerHTML += 'trigger doFade: ' + myUL.id + ' ' + myUL.className + '<br />';
				}
				ul.onmouseover=function() {this.status="open";doAppear(this)}
				ul.onmouseout=function() {this.status=null;doFade(this);}
			}
   		}
  	}
}

addLoadEvent(startList);

function doAppear(el){
	var speed = 0.25;
	var myAction = function(){
		if(!el.status && el.offsetHeight==0){
			new Effect.Appear(el, { duration: speed });
			el.status="open";
		}
	}
	var actionTime = (el.offsetHeight==el.maxedHeight) ? (speed*1000) : 10;
	var t = setTimeout(myAction,actionTime);
}
function doFade(el){
	var speed = 0;
	var myAction = function(){
		if(el.status=="open" && el.offsetHeight==el.maxedHeight)
			new Effect.Fade(el, { duration: speed });
	}
	var actionTime = (el.offsetHeight!=el.maxedHeight) ? (speed*1000) : 10;
	var t = setTimeout(myAction,actionTime);
}