window.addEvent('domready', function(e){
	
	/*effets du menu*/	
	$$('.content_menu').setStyle('opacity', 0);
	new TweenTab(
		'containerMenu',
		{
			change: {
				link : 'mouseenter',
				delay : 0
			},
			cssSelector : {
				link : '.first_lvl li',
				block : '.content_menu'
			},
			element: {
				blockPrefix : 'TweenMenu',
				linkPrefix	: 'TweenMenuLink'
			},
			move : {
				display     : true,
				property	: 'opacity',
				from		: '0',
				to			: '1',				
				delay: 500
			},
			auto_close : {
				active	: true,
				delay : 500
			},			
			
			activeLink: function(sId)
			{
				var el = $(sId);
				if(el.getElement('.bg') != null)
				{
					el.getElement('.bg').morph(
					{
						'background-color': '#e3001b',
						'width': (el.getStyle('width').toInt() + el.getStyle('padding-right').toInt())+'px' //image will move from left to right - Values are in pixels.
					}).getParent().setStyle('border-left', '1px').setStyle('padding-left', '5px');
					
					$$('.content_menu_'+el.get('class')).tween.delay(0, $$('.content_menu_'+el.get('class')), ['opacity', [0, 1]]);
				}

			},
			
			disableLink: function(sId)
			{
				var el = $(sId);		
				if(el.getElement('.bg'))
				{
					el.getElement('.bg').morph(
					{
							'background-color': '#2c2c2c',
							'width': '0px'
					}).getParent().set('style', '');
					
					$$('.content_menu_'+el.get('class')).tween.delay(0, $$('.content_menu_'+el.get('class')), ['opacity', [1, 0]]);
				}
			}
		}
	);
	
	/**
	* rollover on images
	*
	*/
	$$('img.rollover').each(function(el){
		new Asset.image(el.src.replace('_off', '_on'));

		el.addEvent('mouseenter', function(e){
			el.src = el.src.replace('_off', '_on');

		});
		
		el.addEvent('mouseleave', function(e){
			el.src = el.src.replace('_on', '_off');

		});
	});
	
	
	/**
	 * min height for page
	 *
	 */
	function getCanvasMinHeight()
	{
		var aBodySize = $('body').getSize();

		return aBodySize.y - 180 - 40 - 30;
	}
	
	if ( $('page') && !(Browser.Engine.trident && Browser.Engine.version <= 4) )
	{
		//redimenssionnement
		window.addEvent('resize', function(){
			$('page').setStyle('min-height', getCanvasMinHeight());

			
		});
		window.fireEvent('resize');
	}
	else if ( $('page') )
	{
		$('page').setStyle('height', getCanvasMinHeight());
	}
	

	/*display infobulle on rollover*/
	var aInfobulle = $$('.bubble');

	$$('.content_tools li a').each(function(el,index)
	{
		el.addEvent('mouseenter', function(e){	
			aInfobulle[index].setStyle('display', 'block');
			$$('.tools').setStyle('z-index', '99');
		});

		el.addEvent('mouseleave', function(e){
			aInfobulle[index].setStyle('display', 'none');
			$$('.tools').setStyle('z-index', '70');
		});
	});	
});	
