$(document).ready(function(){
	$('#precedantBrandnews').hide(); // Ont cache le boutonn précedant
	$('#precedantVideos').hide(); // Ont cache le boutonn précedant
	$('#precedantInstrumental').hide(); // Ont cache le boutonn précedant
	$('#precedantMixtapes').hide(); // Ont cache le boutonn précedant
	
	$('#slideBrandnews2').hide(); // Ont cache la div
	$('#slideVideos2').hide(); // Ont cache la div
	$('#slideInstrumental2').hide(); // Ont cache la div
	$('#slideMixtapes2').hide(); // Ont cache la div
	
	var tempsTransition = 1000; // Temps de transition 1
	var tempsTransition2 = 1000; // Temps de transition 2
	var slideWidth = 476; // Largeur du slider
	var slides = $('.slidebrand'); // Séléction du slider
	var slides2 = $('.slidevid'); // Séléction du slider
	var slides3 = $('.slideintru'); // Séléction du slider
	var slides4 = $('.slidemixt'); // Séléction du slider
	var numberOfSlides = slides.length;
	var numberOfSlides2 = slides2.length;
	var numberOfSlides3 = slides3.length;
	var numberOfSlides4 = slides4.length;

	// Supprime la scrollbar en JS
	$('#slidesContainerBrand').css('overflow', 'hidden');
	$('#slidesContainerVid').css('overflow', 'hidden');
	$('#slidesContainerinstru').css('overflow', 'hidden');
	$('#slidesContainermixt').css('overflow', 'hidden');
	
	// Attribue  #slideInner  à toutes les div .slide
 	
	$('.slidebrand').wrapAll('<div id="slideInnerbrand"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });
	
	$('.slidevid').wrapAll('<div id="slideInnervid"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });
	
	$('.slideintru').wrapAll('<div id="slideInnerinstru"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });
	
	$('.slidemixt').wrapAll('<div id="slideInnermixt"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });

 	 // Longueur de #slideInner égale au total de la longueur de tous les slides
  	$('#slideInnerbrand').css('width', slideWidth * numberOfSlides);
	$('#slideInnervid').css('width', slideWidth * numberOfSlides2);
	$('#slideInnerinstru').css('width', slideWidth * numberOfSlides3);
	$('#slideInnermixt').css('width', slideWidth * numberOfSlides4);
	
	// Animation pour les brandnews
	$('#suivantBrandnews').click(function(){
		$('#slideBrandnews2').animate({opacity: 'show'}, tempsTransition);
		$('#slideBrandnews1').animate({opacity: 'hide'}, tempsTransition2);
		$('#suivantBrandnews').animate({ opacity: 'hide'}, tempsTransition2);
		$('#precedantBrandnews').animate({ opacity: 'show'}, tempsTransition2);
	});
	$('#precedantBrandnews').click(function(){
		$('#slideBrandnews2').animate({opacity: 'hide'}, tempsTransition);
		$('#slideBrandnews1').animate({opacity: 'show'}, tempsTransition2);
		$('#suivantBrandnews').animate({ opacity: 'show'}, tempsTransition2);
		$('#precedantBrandnews').animate({ opacity: 'hide'}, tempsTransition2);
	});
	// Animation pour les vidéos
	$('#suivantVideos').click(function(){
		$('#slideVideos2').animate({opacity: 'show'}, tempsTransition);
		$('#slideVideos1').animate({opacity: 'hide'}, tempsTransition2);
		$('#suivantVideos').animate({ opacity: 'hide'}, tempsTransition2);
		$('#precedantVideos').animate({ opacity: 'show'}, tempsTransition2);
	});
	$('#precedantVideos').click(function(){
		$('#slideVideos2').animate({opacity: 'hide'}, tempsTransition);
		$('#slideVideos1').animate({opacity: 'show'}, tempsTransition2);
		$('#suivantVideos').animate({ opacity: 'show'}, tempsTransition2);
		$('#precedantVideos').animate({ opacity: 'hide'}, tempsTransition2);
	});
	// Animation pour les instrumental
	$('#suivantInstrumental').click(function(){
		$('#slideInstrumental2').animate({opacity: 'show'}, tempsTransition);
		$('#slideInstrumental1').animate({opacity: 'hide'}, tempsTransition2);
		$('#suivantInstrumental').animate({ opacity: 'hide'}, tempsTransition2);
		$('#precedantInstrumental').animate({ opacity: 'show'}, tempsTransition2);
	});
	$('#precedantInstrumental').click(function(){
		$('#slideInstrumental2').animate({opacity: 'hide'}, tempsTransition);
		$('#slideInstrumental1').animate({opacity: 'show'}, tempsTransition2);
		$('#suivantInstrumental').animate({ opacity: 'show'}, tempsTransition2);
		$('#precedantInstrumental').animate({ opacity: 'hide'}, tempsTransition2);
	});
	// Animation pour les mixtapes
	$('#suivantMixtapes').click(function(){
		$('#slideMixtapes2').animate({opacity: 'show'}, tempsTransition);
		$('#slideMixtapes1').animate({opacity: 'hide'}, tempsTransition2);
		$('#suivantMixtapes').animate({ opacity: 'hide'}, tempsTransition2);
		$('#precedantMixtapes').animate({ opacity: 'show'}, tempsTransition2);
	});
	$('#precedantMixtapes').click(function(){
		$('#slideMixtapes2').animate({opacity: 'hide'}, tempsTransition);
		$('#slideMixtapes1').animate({opacity: 'show'}, tempsTransition2);
		$('#suivantMixtapes').animate({ opacity: 'show'}, tempsTransition2);
		$('#precedantMixtapes').animate({ opacity: 'hide'}, tempsTransition2);
	});
});