window.addEvent('domready', function() {
	
	/**
	 * Menu
	 */	 
	$('menu').getElements('div[class^=menu]').each(function(el){

		var aEffect = new Array();
		el.getElements('li').each(function(elem){
			if(!elem.hasClass('active'))
			{				
				aEffect.push(new Fx.Morph(elem, {duration: 600, transition: Fx.Transitions.Sine.easeOut, link:'cancel'}));
			}
		});
		el.addEvents({
			'mouseenter': function(){
				for(var i = 0; i < aEffect.length; i++)
				{
					aEffect[i].start({
						'display': 'block',
						'height': 18,
						'opacity': 1
					});
				}
				this.setStyle('background-position','right top');
			},
			'mouseleave': function(){
				for(var i = 0; i < aEffect.length; i++)
				{
					aEffect[i].start({
						'height': 0,
						'opacity': 0
					});
				}
				this.setStyle('background-position','left top');
			}
		});
	});


	
	/**
	 * Recherche
	 */
	 if($('search')){
		var bFirstSearchFocus = false;
		$('search').addEvent('focus', function(){
			if(!bFirstSearchFocus){
				// on supprime le texte par défaut du champ de recherche (mot-clé)
				$('search').value = '';
				bFirstSearchFocus = true;
			}
		});
	 }
	 
	 /**
	  * Rollover
	  */
	 aImg = Array();
	 
	$$('.rollover').each(function(el){
		img = el.getChildren('img');
		img = img[0];
		new Asset.image(img.src.replace('_off', '_on'));
		if ( el.hasClass('current') )
		{
			img.src = img.src.replace('_off', '_on');
		}
		else
		{
			el.addEvent('mouseenter', function(e)
			{
				this.src = this.src.replace('_off', '_on');
			}.bind(img));
			el.addEvent('mouseleave', function(e)
			{
				this.src = this.src.replace('_on', '_off');
			}.bind(img));
		}
	});

});
