//===== navbar =====//
const burgerLinks = document.querySelector('.burger-links');
const burger = document.querySelector('.burger');
const body = document.querySelector('body');

burgerButton = function(){
    burgerLinks.classList.toggle('active');
    burger.classList.toggle('active');
    body.classList.toggle('active');
}
//===== pre section =====//
function checkForVisibility() {
    var headers = document.querySelectorAll(".pre-header");
    headers.forEach(function(preheader) {
      if (isElementInViewport(preheader)) {
        preheader.classList.add("headerVisible");
      } else {
        preheader.classList.remove("headerVisible");
      }
    });
}
function isElementInViewport(el) {
    var rect = el.getBoundingClientRect();
    return (
      rect.top >= 0 &&
      rect.left >= 0 &&
      rect.bottom <=
        (window.innerHeight || document.documentElement.clientHeight) &&
      rect.right <= (window.innerWidth || document.documentElement.clientWidth)
    );
}

if (window.addEventListener) {
    addEventListener("DOMContentLoaded", checkForVisibility, false);
    addEventListener("load", checkForVisibility, false);
    addEventListener("scroll", checkForVisibility, false);
}
//===== background color (jquery) =====//
$(window).scroll(function() {
    var $window = $(window),
      $body = $('body'),
      $panel = $('.panel');
    var scroll = $window.scrollTop() + ($window.height() / 3);
    $panel.each(function () {
      var $this = $(this);
      if ($this.position().top <= scroll && $this.position().top + $this.height() > scroll) {
        $body.removeClass(function (index, css) {
          return (css.match (/(^|\s)color-\S+/g) || []).join(' ');
        });
        $body.addClass('color-' + $(this).data('color'));
      }
    });    
}).scroll();
//===== swiper =====//
var swiper = new Swiper(".mySwiper", {
    spaceBetween: 30,
    centeredSlides: true,
    effect: "fade",
    autoplay: {
      delay: 2500,
      disableOnInteraction: false,
    },
});
var swiper = new Swiper(".swiper-testimonials", {
  spaceBetween: 30,
  centeredSlides: true,
  autoplay: {
    delay: 2500,
    disableOnInteraction: false,
  },
});