function trouverli(oElem)
{
	if( oElem == null )
		return null;
	
	for( var i =0; i < oElem.childNodes.length; i++ )
	{
		if( oElem.childNodes[i].nodeName.toLowerCase() == "li" )
			return oElem.childNodes[i];
	}
	return null;
}
function trouverul(oElem)
{
	if( oElem == null )
		return null;
	
	for( var i =0; i < oElem.childNodes.length; i++ )
	{
		if( oElem.childNodes[i].nodeName.toLowerCase() == "ul" )
			return oElem.childNodes[i];
	}
	return null;
}

var _est_afficher 	= false;
var ItemsSelect 	= null;
function est_afficher(e){ _est_afficher=e==null?_est_afficher:e; return _est_afficher;}
function masquerSelectBox()
{
	if( !est_IE6() && !est_IE5() )
		return false;
	
	if( est_afficher() == false )
		return false;
	
	if( ItemsSelect == null )
		ItemsSelect = YAHOO.util.Dom.getElementsBy((function(){return true;}), "select");
	
	for( var i=0; i < ItemsSelect.length; i++ )
		ItemsSelect[i].style.visibility = "hidden";
	
	est_afficher(false);
}
function afficherSelectBox()
{
	if( !est_IE6() && !est_IE5() )
		return false;
	
	if( est_afficher() == true )
		return false;
	
	if( ItemsSelect == null )
		ItemsSelect = YAHOO.util.Dom.getElementsBy((function(){return true;}), "select");
	
	for( var i=0; i < ItemsSelect.length; i++ )
		ItemsSelect[i].style.visibility = "visible";
	
	est_afficher(true);
}

function ajouterEvenements( oElem )
{
	var li = null;
	
	li = trouverli( oElem );
	
	if( li != null )
	{
		li.oUl = trouverul(li);
		li.onmouseover = function(e)
		{
			if (!e) var e = window.event;
			e.cancelBubble = true;
			if (e.stopPropagation) e.stopPropagation();
			
			if( li.oUl != null )
			{
				li.oUl.style.display = "block";
			}
			
			masquerSelectBox();
		}
		li.onmouseout = function( e )
		{
			if (!e) var e = window.event;
			e.cancelBubble = true;
			if (e.stopPropagation) e.stopPropagation();
			
			if( li.oUl != null )
			{
				li.oUl.style.display = "none";
			}
				
			afficherSelectBox();
		}
		
		if( li.oUl != null )
		{
			for( var i =0; i< li.oUl.childNodes.length; i++ )
			{
				if( li.oUl.childNodes[i].nodeName.toLowerCase() == "li" )
				{
					li.oUl.childNodes[i].onmouseover = function ()
					{
						//this._backgroundColor = this.style.backgroundColor;
						//this.style.backgroundColor = "#D2CBC5";
					}
					li.oUl.childNodes[i].onmouseout = function ()
					{
						//this.style.backgroundColor = this._backgroundColor;
					}
				}
			}
		}
		
		
		li.oTDs = YAHOO.util.Dom.getElementsBy((function(e){return e.className.indexOf("btmenu_off")>-1;}), "td" , li);
		if( li.oTDs != null )
		{
			for( var i=0; i < li.oTDs.length; i++ )
			{
				li.oTDs[i].onmouseover = function ()
				{
					//this.className = "btmenu_hover_"+(i+1);
					//this.style.backgroundImage = "url(/_autres/theme/images/btmenu_hover_"+(i+1)+".gif)";
				}
				li.oTDs[i].onmouseout = function ()
				{
					//this.className = "btmenu_off_"+(i+1);
					//alert(this.style.backgroundImage);
					//this.style.backgroundImage = "url(/_autres/theme/images/btmenu_off_"+(i+1)+".gif)";
				}
			}
		}
		
	}
}
function est_IE5()
{ 
	return (navigator.appName=="Microsoft Internet Explorer" && parseInt(navigator.appVersion) <= 5);
}
function est_IE6()
{ 
	return (navigator.appName=="Microsoft Internet Explorer" && parseInt(navigator.appVersion) <= 6);
}
function est_OPERA()
{
	var browserName=navigator.appName;
	if (browserName=="Opera")
	{
		return true;
	}
	return false;
}
function fixerTailleMenu()
{
	var menuItems 			= document.getElementById("menuItems");
	
	if( menuItems == null ) return false;
	
	/*
	var marge 				= 0;
	var longueurAOccupee	= 0;
	*/
	var longueurOccupee		= 0;
	var Uls 				= new Array();
	var li					= null;
	
	for( var i = 0; i < menuItems.childNodes.length; i++)
	{
		if(menuItems.childNodes[i].nodeName.toLowerCase() =="ul" )
			Uls.push(menuItems.childNodes[i]);
	}
	
	for( var i = 0; i < Uls.length; i++)
	{
		ajouterEvenements( Uls[i] );
	}
	
	var cache_jaune = document.getElementById("cache_jaune");
	
	if( cache_jaune != null )
	{
		cache_jaune.style.width = cache_jaune.parentNode.clientWidth+"px";
	}
	
	if( est_IE5() )
	{
		var corps = document.getElementById("corps");
		
		if( corps != null )
		{
			corps.style.width = "908px";
		}
	}
	
	if( est_OPERA() )
	{
		for( var i = 0; i < Uls.length; i++)
		{
			longueurOccupee += Uls[i].clientWidth;
		}
		menuItems.style.width = longueurOccupee+"px";
	}
}
YAHOO.util.Event.addListener(window, "load", fixerTailleMenu); 



