$(document).ready(function()	
{

	
	//Show Banner
	var imgAlt = $(".main_image").find('a:rel').attr("rel"); //Get Alt Tag of Image
	if (imgAlt=="")		
	{
		marg=400;
	}
	else
	{
		marg=250;
	}
	if (imgAlt!="")
	{
			$(".main_image .desc").show(); //Show Banner
	}	
	else
	{
			$(".main_image .desc").hide(); //Show Banner
	}
	
	
	
	$(".main_image .desc").show(); //Show Banner
	
	$(".main_image .block").animate({ opacity: 0.85,marginBottom: marg }, 250 ); //Set Opacity


	$(".AfficheNews").hide();
	//Click and Hover events for thumbnail list
	
	$(".image_thumb ul li:first").addClass('active'); 
			
	$(".image_thumb ul li").click(function(){ 
		//Set Variables
		var imgAlt = $(this).find('a:rel').attr("rel"); //Get Alt Tag of Image		
		var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		var height = $(this).find('a').attr("h"); //Get Main Image URL
		var width = $(this).find('a').attr("w"); //Get Main Image URL

		
		var imgDesc = $(this).find('.block').html(); 	//Get HTML of block
		imgDesc=imgDesc.replace("corpsNewsInactif","corpsNews");
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block
		if (imgAlt=="")
		{
			marg=400;
		}
		else
		{
			marg=250;
		}
		
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else 
		{
			//Animate the Teaser				
			// 500 :; vitesse d'affichage
			
			
			$(".main_image .block").animate({  top:100, opacity: 0, marginBottom: - 200}, 500 , function() {
				$(".main_image .block").html(imgDesc).animate({ top:100,opacity: 0.85,	 marginBottom: marg }, 500 );			
				if (imgAlt!="")
				{			
					$(".main_image img").show();		
					$(".main_image img").attr({ src: imgTitle});	
					$(".main_image img").attr({ width: width});
					$(".main_image img").attr({ height: height});
				}	
				else
				{
					$(".main_image img").hide();
				}
				
				$("main_image").find(".titreNews").removeClass("titreNews");
				
			});
		}		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(this).addClass('active');  //add class of 'active' on this list only

		return true;
		
	}) .hover(function(){
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
			
	
});

