$('document').ready(function(){
		homeBoxes();
		menu();
		diapo();
		windowSize();
		$('#slideShower').simpleFader();
        
        
});

$(window).load(function(){
       if ($('#player').length > 0)  flowplayer("player", { src: "http://releases.flowplayer.org/swf/flowplayer-3.2.7.swf", wmode: 'opaque' }, {clip : {autoPlay: false, autoBuffering: true } });
});

function windowSize()
{
		fullScreen();
		
		$(window)
				.resize
				(
						function()
						{
								fullScreen();		
						}
				);
}

function fullScreen()
{
		
		//alert($('#centerContainer').height()+'///'+$(window).height());
		var centerHeight = $('#centerContainer').height();
		
		if (centerHeight<$(window).height())
		{
				$('#centerContainer').height($(window).height()-20);		
		}
		if (720>$(window).height())
		{
				
				$('#centerContainer').height(720);
		}
		
		//alert($('#bigContainer').outerHeight()+420+'//'+$(window).height());
		
}





function diapo()
{
		$('#thumbs').show(150);
		
		$('#mainPic')
				.colinSlide
				(
						{
								controlerClass : '.controlSlide'
								,time:800
						}
				);
				
		$('#thumbs_list')
				.akislide
				({
						width:562
						,height:120
						,multipage:false
						,marge : 51
						,plus:'photos suivantes'
						,moins:'photos précédentes'
				});
				
		$('#thumbs_list li')
				.each
				(
						function()
						{
								if ($(this).find('.controlSlide').length==3)
								{
										$(this).find('.controlSlide').css({'position':'absolute'});
										$(this).find('img').css({'margin':0});
										$(this).find('.controlSlide').eq(0).css({'top':0,'left':0});
										var middle = ($(this).width()/2) - 56;
										$(this).find('.controlSlide').eq(1).css({'top':0,'left':middle+'px'});
										$(this).find('.controlSlide').eq(2).css({'top':0,'right':'0px'});
								}
								else if ($(this).find('.controlSlide').length==2)
								{
										$(this).find('.controlSlide').css({'position':'absolute','margin':0});
										$(this).find('img').css({'margin':0});
										$(this).find('.controlSlide').eq(0).css({'top':0,'left':0});
										$(this).find('.controlSlide').eq(1).css({'top':0,'right':'0px'});
								}
								else if ($(this).find('.controlSlide').length==1)
								{
										$(this).find('.controlSlide').css({'position':'absolute','margin':0});
										$(this).find('img').css({'margin':0});
										var middle = ($(this).width()/2) - 56;
										$(this).find('.controlSlide').eq(0).css({'top':0,'left':middle+'px'});
								}
						}
				)
				
		
}





function menu()
{
		
		
		/// La Largeur des colonnes du menu
		$('.ulLevel_1').show().css({opacity:0});
		
		$('.liLevel_0')
				.each
				(
						function()
						{
								
								
								var ColCounter = 0;
								var finalWidth =0;
								
								
								while($(this).find('.col_'+ColCounter).length)
								{
										var col_width = 0;
										
										$(this).find('.col_'+ColCounter)
												.each
												(
														function()
														{
																if ($(this).width()>col_width)
																{
																		col_width = $(this).width();
																}
														}
												)
										finalWidth += col_width+5;
										$(this).find('.col_'+ColCounter).width(col_width+5);
										
										ColCounter++;
								}
								
								$(this).find('.ulLevel_1').width(finalWidth+((ColCounter+1)*10));
								
								
								
						}
				);
				
		$('.ulLevel_1').hide().css({opacity:1});
				
				
				
				
				
		//L'interactivité
		$('.ulLevel_0 li')
				.hover
				(
						function()
						{
								if ($(this).find('ul:first').length)
								{
										$(this).find('ul:first').stop(true,true).show();
								}
						}
						,
						function()
						{
								if ($(this).find('ul:first').length)
								{
										$(this).find('ul:first').stop(true,true).hide();
								}
						}
				)
}
















//--------------------------------------------------		HOMEBOXES		-----------------------------------------------
function homeBoxes()
{
		if ($('.homeLink').length)
		{
				
				setInterval(hideHome,2000);
				
				$('.homeLink')
						.hover
						(
								function()
								{
										$(this).find('img').stop(true,true).animate({opacity:1},150);
										$(this).find('.photoDescription').stop(true,true).animate({'bottom':'1px'},150);
										
										
								}
								,function()
								{
										$(this).find('img').stop(true,true).animate({opacity:0.8},150);
										$(this).find('.photoDescription').stop(true,true).animate({'bottom':'-53px'},150);
								}
						)
				
				
		}
}

function hideHome()
{
		var i = 0;
		$('.homeLink')
				.each
				(
						function()
						{
								var interval = 1000;
									$(this).find('img').delay(i*interval).animate({opacity:0.8},350);
									$(this).find('.photoDescription').delay(i*interval).animate({'bottom':'-53px'},350);
								i++;
						}
				)
}
