// Fonctions du slider de la homepage

$(document).ready(function(){
slideThumb();	
});

function show(num) {
cont.fadeOut(400);
$(".slideBlock"+num).stop().fadeIn(400);		
}

function rotate() {
$(".next").click();
}

function slideThumb(){
	var speed = 10000;
	var run = setInterval('rotate()', speed); 
	$(".slide-content").each(function(index, element){$(element).attr("class", 'slide-content hide');});
    $(".slide-content").each(function(index, element){$(element).attr("id", 'img'+index);});
 
	var mainImg ='img0';
    var current = 'img0';
	
	$(".slider-text .backShadow").css({ opacity: 0.7 });

    //grab the width and calculate left value
    var item_width = $('.slide-content').outerWidth();
	var nb_item = $('.slide-content').length;
    var left_value = item_width * (-1);
	var size = item_width * nb_item;
	
	$('#img0').css('display', 'block');
    $('#img0').addClass('current');
	$('.active img').css({opacity:1});
	$('.thumb_holder li a:not(.active) img').css({opacity:0.6});
	
       $('.bloc-banner').css({'width':size});   
   $('.thumb_holder li img').hover (function(){  
	$(this).css({opacity:1});
	}, function (){
	$('.thumb_holder li a:not(.active) img').css({opacity:0.6});
	})
 $('.thumb_holder li a').click (function(){
		clearInterval(run);	
	
		$('.bloc-banner div').removeClass('current');


        mainImg = $(this).attr('rel');
       
		
		$('.hide').css('display','none');
		$('.backShadow').fadeOut('slow');	
        $('.current').fadeOut('slow');
		$('.slider-nav').fadeOut('slow');
		$('.contentSlide').fadeOut('slow');
		$('#'+mainImg).addClass('current');
        $('#'+mainImg).fadeIn('slow', function(){		
        current = mainImg;
 		$('.slider-nav').fadeIn('normal');
		$('.contentSlide').fadeIn('normal');
		
        });
		$('.backShadow').fadeIn('normal');
		 $('.bloc-banner .slide-content:last').after($('.bloc-banner .slide-content:first'));
       
    });
  $('.next').click(function() {
			var currentDiv=$('.current').attr('id');
			 mainImg02=currentDiv;
		$('.bloc-banner div').removeClass('current');
		$('.hide').fadeOut('fast');
		//$('.backShadow').stop().animate({opacity: 0}, 3000);
        $('.current').fadeOut('fast');
		$('.slider-text').fadeOut('fast');
		$('.slider-nav').fadeOut('fast');
		//$('.contentSlide').stop().animate({opacity: 0}, 3000);
        $('#'+mainImg02).fadeIn('normal', function(){							   
        $('.slide-content:first').addClass('current');
		//$('.slide-content:first .contentSlide').stop().animate({opacity: 1}, 250);
		$('.current').fadeIn('fast');
		
        });
		$('.slider-text').fadeIn('normal');
		$('.slider-nav').fadeIn('normal');
		$('.hide').fadeIn('normal');
         

	    $('.bloc-banner .slide-content:last').after($('.bloc-banner .slide-content:first'));
                  
        return false;
         
    });       
}

