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;
}

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";
		}
		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";
		}
		
		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;
					}
				}
			}
		}
	}
}
function fixerTailleMenu()
{
	var menuItems 			= document.getElementById("menuItems");
	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++)
	{
		longueurAOccupee += Uls[i].clientWidth;
		ajouterEvenements( Uls[i] );
	}
	
	marge = parseInt((793-longueurAOccupee) / (Uls.length-1));
	
	for( var i = 0; i < Uls.length-1; i++)
	{
		li = trouverli(Uls[i]);
		Uls[i].style.width 					= Uls[i].clientWidth+"px";
		if( li != null )
			li.style.width 					= Uls[i].clientWidth+"px";
		Uls[i].style.marginRight 			= marge+"px";
		longueurOccupee 					+= Uls[i].clientWidth+marge;
		
		li = null;
	}

	longueurOccupee += Uls[i].clientWidth;
	
	li = trouverli(Uls[i]);
	if( li != null )
		li.style.width 			= Uls[i].clientWidth+"px";
	Uls[i].style.textAlign 		= "left";
	Uls[i].style.marginLeft 	= (793-longueurOccupee)+"px";
}
YAHOO.util.Event.addListener(window, "load", fixerTailleMenu); 



