


// Fonction de base d'animation
function animboxIn(box) {		$(box).animate({  width: "260"  }, 100 );}
function animboxOut(box) {	$(box).animate({  width: "225"  }, 100 );}


$(document).ready(function() {
		setTimeout(function(){
		//console.log($('.matchheight').css('height'));
	}, 400);
	

	/* Start */
	 $("#imgcentreyc1").fadeIn(1000); 
	 $("#box1").fadeIn(1500); 
	 $("#info1").fadeIn(1500); 
	 var bg1 = $('#box1').css('background-color'); 
	 $('#leftyc').css('background-color', bg1);
	 animboxIn("#box1");	
	 $("#box1").addClass('selected'); 
	 
	 /* Event */
	 $('.homebox').mouseover(function() { if(!$(this).hasClass('selected')){animboxIn(this); }}); 
	 $('.homebox').mouseleave(function() { if(!$(this).hasClass('selected')){animboxOut(this); }}); 

	$('.homebox').click(function(){
	
		if(!$(this).hasClass('selected')){
			/* Animation des boites */
			$('.homebox').each(function(index) { if($(this).hasClass('selected')){animboxOut(this);} }); 
			$('.homebox').removeClass('selected'); 
			$(this).animate({  width: "260"  }, 100 );
			$(this).addClass('selected'); 
			// Changement de l'image de base
			var s = this.id;
			$('.homeimg').hide(); 
			var subs = +s.substr(3,2); 
			var bg = $('#box'+subs).css('background-color'); 
		   	$('#leftyc').css('background-color', bg);
			$("#imgcentreyc"+subs).fadeIn(300); 
			$('.homeinfo').hide(); 
			$("#info"+subs).fadeIn(1500);
			
		}else{
			return false; 
		}
		
	});
});
