$( document ).ready(function() {
	
	/*------------------------------------
	    // --- POPUP COOKIE  --- //
	--------------------------------------*/                
	$('#cookie_ok').click(function(a){
		a.preventDefault();
		var cookieCheck = getCookie('cookie_ok')
		if(cookieCheck != "accepted" || !cookieCheck)
		{
			document.cookie = "cookie_ok=accepted; path=/";
			$('.container_priv_state').hide()
		} 
	})
	
	function getCookie(c_name) {
	    var c_value = document.cookie,
	        c_start = c_value.indexOf(" " + c_name + "=");
	    if (c_start == -1) c_start = c_value.indexOf(c_name + "=");
	    if (c_start == -1) {
	        c_value = null;
	    } else {
	        c_start = c_value.indexOf("=", c_start) + 1;
	        var c_end = c_value.indexOf(";", c_start);
	        if (c_end == -1) {
	            c_end = c_value.length;
	        }
	        c_value = unescape(c_value.substring(c_start, c_end));
	    }
	    return c_value;
	}

// =====================================
// --------------- SLICK ---------------
// =====================================
	
	$('.slick-actu').slick({
	  dots: true,
	  infinite: false,
	  arrows: false,
	  speed: 300,
	  slidesToShow: 3,
	  slidesToScroll: 1,
	  //centerMode: true,
	  //centerPadding: '60px',
	  responsive: [
	    {
	      breakpoint: 1024,
	      settings: {
	        slidesToShow: 3,
	        slidesToScroll: 3,
	      }
	    },
	    {
	      breakpoint: 769,
	      settings: {
	        slidesToShow: 2,
	        slidesToScroll: 2
	      }
	    },
	    {
	      breakpoint: 480,
	      settings: {
	        slidesToShow: 1,
	        slidesToScroll: 1
	      }
	    }
	    // You can unslick at a given breakpoint now by adding:
	    // settings: "unslick"
	    // instead of a settings object
	  ]
	});
	
	$('.slick-partenaires').slick({
	  dots: false,
	  arrows: false,
	  infinite: false,
	  speed: 300,
	  slidesToShow: 7,
	  slidesToScroll: 1,
	  responsive: [
	    {
	      breakpoint: 1024,
	      settings: {
			dots: true,
	        slidesToShow: 5,
	        slidesToScroll: 3,
	      }
	    },
	    {
	      breakpoint: 480,
	      settings: {
	        slidesToShow: 3,
	        slidesToScroll: 1
	      }
	    }
	    // You can unslick at a given breakpoint now by adding:
	    // settings: "unslick"
	    // instead of a settings object
	  ]
	});
	

	$('.slick-date').slick({
		dots: false,
		arrows: false,
		slidesToShow: 3,
		slidesToScroll: 1,
		centerMode: true,
		infinite: true,
		autoplay: true,
		autoplaySpeed: 2000,
		speed: 800,
		responsive: [
			{
			  breakpoint: 1024,
			  settings: {
				slidesToShow: 2,
				slidesToScroll: 1,
				centerMode: true
			  }
			},
			{
			  breakpoint: 776,
			  settings: {
				slidesToShow: 1,
				slidesToScroll: 1,
				centerMode: true
			  }
			}
			
		  ]
	});
// =====================================
// ------------- CUSTOM JS -------------
// =====================================

	if ($(window).width() >= 1199) {
		$('.menuMainItem').hover(function()
		{
			$(this).children('.submenu').show();
		});
		$( ".menuMainItem" ).mouseleave(function()
		{
			$(this).children('.submenu').hide();
		});   
	} 
	
	
	// ----- //
	
	$(function() {
	    $('.ratio').each(function() {
	        var width = $(this).width();
	        $(this).css({
	            "height": width*(9/16)
	        });
	    }).resize();
	});
	
	// ----- //
	
	$(function() {
	   $(window).scroll(function () {
	      if ($(this).scrollTop() > 250) {
	         $('menu').addClass('menu_scrolled');
	      }
	      else{
	         $('menu').removeClass('menu_scrolled');
	      }
	   });
	}); 
	
	$('#burger').click(function(){
		$(this).toggleClass('open');
		if($(this).hasClass('open'))
		{
			$('.menuContainermobile').show();
			$('body').css('overflow', 'hidden');
		}
		else
		{
			$('.menuContainermobile').hide();
			$('body').css('overflow', 'auto');
		}
	});
	
	$('.menuPublication .menuItem2').filter(function () {
		 return this.href === location.href;
	  }).addClass('actives');

	
	function preloader() {
		$('.loader_bg').delay(1000).fadeOut('slow', function () {
			$('#main').show();
		});
	}
	
	$('#videohistoire').click(function() {
		$('.titreVid').css("display", "none");
	});
	
	$('.niveau1').click(function () {
		$('.niveauText1').css("display", "block");
		$('.niveauText2').css("display", "none");
		$('.niveauText3').css("display", "none");
		$('.niveau1').css("transform", "scale(1.1)");
		$('.niveau2').css("transform", "scale(1)");
		$('.niveau3').css("transform", "scale(1)");
	})
	$('.niveau2').click(function () {
		$('.niveauText2').css("display", "block");
		$('.niveauText1').css("display", "none");
		$('.niveauText3').css("display", "none");
		$('.niveau2').css("transform", "scale(1.1)");
		$('.niveau1').css("transform", "scale(1)");
		$('.niveau3').css("transform", "scale(1)");
	})
	$('.niveau3').click(function () {
		$('.niveauText3').css("display", "block");
		$('.niveauText1').css("display", "none");
		$('.niveauText2').css("display", "none");
		$('.niveau3').css("transform", "scale(1.1)");
		$('.niveau2').css("transform", "scale(1)");
		$('.niveau1').css("transform", "scale(1)");
	})
	window.onload = preloader();
	
	var widthVid = $('.video-landing').width();
	var heightVid = (widthVid / 16) * 9;
	$('.video-landing').css("height", heightVid+"px");
	var marBottom = heightVid * 0.7;
	$('.projet-landing').css("margin-bottom", marBottom+"px");
	var padBottom = heightVid / 2;
	
	$('.wrapper-landing').css("padding-bottom", padBottom+"px");
	
	var heightImg = $('.projet-landing img').height() * 0.8;

	$('.projet-landing img').css('top', "-"+heightImg+"px");
});