﻿// Paramétrage Jquery

jQuery().ready(function(){
	
	// Effet du menu supérieur
	
	$("#menu ul li").find("a span.menu_elt_alpha").fadeTo( 10, 0.5 );
	
	$("#menu ul li").hover(
		function(){
			$(this).find("a span.menu_elt_alpha").fadeTo( 'slow', 1 );
		},
		function(){
			$(this).find("a span.menu_elt_alpha").fadeTo( 'fast', 0.5 );
		}
	)
	
	// Gestion du panneau client
	
	var panel_state = false;
	
	$("li.elt_menu_client").hover(
		function(){
			if(panel_state){
				$(this).animate( { width:"95px" }, 'slow', 'swing' );
				panel_state = false;
			}else{
				$(this).animate( { width:"300px" }, 'slow', 'swing' );
				panel_state = true;
			}
			return false;
		},
		function(){
			if(panel_state){
				$(this).animate( { width:"95px" }, 'slow', 'swing' );
				panel_state = false;
			}else{
				$(this).animate( { width:"300px"	}, 'slow', 'swing' );
				panel_state = true;
			}
			return false;
		}
	)
	
	// Gestion du carousel
	
		// Affichage des légendes
		
		$(".carousel ul li .carousel_legend").css('opacity', 0 );
		
		$(".carousel ul li").hover(
			function(){
				$(this).find(".carousel_legend").fadeTo( 'fast', 0.6 );
			},
			function(){
				$(this).find(".carousel_legend").fadeTo( 'fast', 0 );
			}
		);
		
		// Déroulement du carousel
		
		$('.carousel_next').click(
			function() {
				
				var numlast;
				
				if($('.carousel').hasClass("carousel_half")){
					numlast = 2;
				}else{
					numlast = 4;
				}
				
				if($('.carousel li').size()!=numlast){
					var xmove = "-240px";
					$('.carousel').find("li:first").animate(
						{  marginLeft: xmove},
						800, 
						function() {
							$(this).parent().find("li:last").after("<li title=\""+$(this).parent().find("li:first").attr("title")+"\">"+$(this).parent().find("li:first").html()+"</li>");
							$(this).parent().find("li:first").remove();
						}
					);
				}else{
					$(this).css("cursor","normal");
				}
				
				$(this).parent().find("li:last").hover(
					function(){
						$(this).find(".carousel_legend").fadeTo( 'fast', 0.6 );
					},
					function(){
						$(this).find(".carousel_legend").fadeTo( 'fast', 0 );
					}
				);
				
				return false;
			}
		);
		
		$('.carousel_prev').click(
			function() {
				
				var numlast;
				
				if($('.carousel').hasClass("carousel_half")){
					numlast = 2;
				}else{
					numlast = 4;
				}
				
				if($('.carousel li').size()!=numlast){
					var xmove = "-240px";
					$(this).parent().find("li:first").before("<li title=\""+$('.carousel').find("li:last").attr("title")+"\">"+$(this).parent().find("li:last").html()+"</li>");
					$(this).parent().find("li:first").css('marginLeft',xmove);
					$(this).parent().find("li:last").remove();
					$(this).parent().find("li:first").animate(
						{  marginLeft: 0},
						800
					);
				}else{
					$(this).css("cursor","normal");
				}
				
				$(this).parent().find("li:first").hover(
					function(){
						$(this).find(".carousel_legend").fadeTo( 'fast', 0.6 );
					},
					function(){
						$(this).find(".carousel_legend").fadeTo( 'fast', 0 );
					}
				);
				
				return false;
			}
		);

});

Cufon.replace('.share_regular');
Cufon.replace('div.post h3');

