function slides() {
  var Home = document.querySelector('.hero .slide');
  if (Home != null) {
    var flkty = new Flickity( Home, {
      cellAlign: 'left',
      autoPlay: true,
      prevNextButtons: false,
      fade: true,
    });
  }

  var prive = document.querySelector('.prive .__slide');
  if (prive != null) {
    var flkty = new Flickity( prive, {
      // options
      cellAlign: 'left',
      autoPlay: true,
    })
  }

  var slide_tpsF = document.querySelectorAll('.tpsF .slide');
  if (slide_tpsF != null) {
    for (var i = 0; i < slide_tpsF.length; i++) {
      var flkty = new Flickity( slide_tpsF[i], {
        // options
        cellAlign: 'left',
        autoPlay: true,
        pageDots: false
      });
    }
  }

  var Partenaires = document.querySelector('.container_slide ul');
  if (Partenaires != null) {
    var flkty = new Flickity( Partenaires, {
      cellAlign: 'left',
      pageDots: false
      // groupCells: true,
      // carousel-cell: true,
    });
   }
}

function masonry() {
  var arrayEnga = document.querySelector('.tableau_engagements.row');

  if (arrayEnga != null) {
    var msnry = new Masonry(arrayEnga , {
      //columnWidth: '.engagement',
      columnWidth: '.engagement',
      itemSelector: '.engagement',
      gutter: '.gutter-sizer',
      percentPosition: true
    });

  }
}

function burger() {
  var hamburgers = document.querySelector(".hamburger");
  var nav = document.querySelector(".nav-main");
  hamburgers.addEventListener("click", function() {
    this.classList.toggle("is-active");
    nav.classList.toggle("is-active");
  });
}


function paralax() {
  var rellax = new Rellax('.paralax', {
    center:true
  });
}

function isotope() {
  var $grid = $('.grid').isotope({
    percentPosition: true,
    masonry: {
      columnWidth: '.item'
    },
    itemSelector: '.item',
    stagger: 30
  });

  $('.filter-button-group li').on( 'click', function(evt) {
    var filterValue = $(this).attr('data-filter');
    $grid.isotope({ filter: filterValue });
  });
}

function drag(){
  $( '.group_drag' ).draggable({
    containment: "html",
    scroll: false
  });
}

function click_nav() {
  $('#nav-main > ul > li:first-child > a').click(function(e) {
      e.preventDefault();
  })
}

$( document ).ready(function() {
  slides();
  masonry();
  burger();
  paralax();
  isotope();
  drag();
  click_nav();
});
