//chargement images hover
i1 = new Image;
i1.src = "images/bouton_hover.png";
i2 = new Image;
i2.src = "images/slideshow_fond_hover.png";
i3 = new Image;
i3.src = "images/recherche_submit_hover.png";

/*MENU*/
$(function(){
   $(".elt-menu").hover(function(){
		$(this).children("ul").show();
		$(this).children("a").addClass("hover");
	}, function() {
		$(this).children("ul").hide();
		$(this).children("a").removeClass("hover");
	});
});

/*SLIDESHOW*/
$(function(){
	$(".main_image .desc").show();
	$(".main_image .desc").animate({ opacity: 0.8 }, 1 );
	$(".image_thumb ul li:first").addClass('active');
	$(".image_thumb ul li").click(function(){
		clearInterval(timer);
		var imgAlt = $(this).find('img').attr("alt");
		var imgTitle = $(this).find('a').attr("href");
		var imgDesc = $(this).find('.desc').html();
		var imgDescHeight = $(".main_image").find('.desc').height();
	
		if ($(this).is(".active")) {
			return false;
		} else {
			$(".main_image img").animate({ opacity: 0}, 250 );
			$(".main_image .desc").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				$(".main_image .desc").html(imgDesc).animate({ opacity: 0.8,  marginBottom: "0" }, 250 );
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt}).animate({ opacity: 1}, 250 );
			});
		}
		$(".image_thumb ul li").removeClass('active');
		$(this).addClass('active');
		return false;
	
	}) .hover(function(){
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
	$("a.collapse").click(function(){
		$(".main_banner .desc").slideToggle();
	});
});

function gallery() {
		$active=$(".image_thumb ul li.active");
		if($active.next().length == 0) {
			$next=$(".image_thumb ul li:first");
		} else {
			$next=$active.next();
		}
    	var imgAlt = $next.find('img').attr("alt");
		var imgTitle = $next.find('a').attr("href");
		var imgDesc = $next.find('.desc').html();
		var imgDescHeight = $(".main_image").find('.desc').height();
		$(".main_image img").animate({ opacity: 0}, 250 );
		$(".main_image .desc").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
			$(".main_image .desc").html(imgDesc).animate({ opacity: 0.8,  marginBottom: "0" }, 250 );
			$(".main_image img").attr({ src: imgTitle , alt: imgAlt}).animate({ opacity: 1}, 250 );
		});
		$(".image_thumb ul li").removeClass('active');
		$next.addClass('active');
		return false;
}

timer = setInterval('gallery()',8000);
