function stickyHeader() {
  if ($('.header').length) {
      var strickyScrollPos = 100;
      if ($(window).scrollTop() > strickyScrollPos) {
          $('.header').addClass('stricky-fixed');
      } else if ($(this).scrollTop() <= strickyScrollPos) {
          $('.header').removeClass('stricky-fixed');
      }
  };
}

jQuery(window).on('scroll', function () {
  (function ($) {
      stickyHeader();
  })(jQuery);
});

if ($(".navigation").length) {
  $(".navigation .navbar button").on("click", function () {
      $(".navigation .menu").slideToggle();
      $(this).toggleClass('open');
      return false;
  });
  $(".navigation .cs-submenu").children("a").append(function () {
      return '<button class="dropdown-expander"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/></svg></button>';
  });

}

if (document.documentElement.clientWidth < 1023) {
  $(".navigation .menu .dropdown-expander").on("click", function () {
      $(this).parent().parent().children(".cs-dropdown").slideToggle();
      console.log($(this).parents("li"));
      console.log($(this).parents().children(".dropdown-expander").toggleClass("rotated"));
      return false
  })
  $(document).click(function (e) {
      if (!$(e.target).closest('.navigation .navbar button').length) {
          $('.navigation .menu').stop(true).slideUp();
          $(".navigation .navbar button").removeClass('open');

      }
  });
}

var swiper = new Swiper(".homeSlider", {
  pagination: ".swiper-pagination",
  slidesPerView: "auto",
  paginationClickable: true,
  loop: true,
  autoplay: {
    delay: 3000,
  },
  effect: "fade",
  spaceBetween: 0,
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev",
  },

});


new Swiper('.categorySlider', {
  navigation: {
      nextEl: ".swiper-button-next",
      prevEl: ".swiper-button-prev",
    },
    pagination: {
      el: '.swiper-pagination',
      clickable: true,
  },
  slidesPerView: 3,
  paginationClickable: true,
  spaceBetween: 15,
  breakpoints: {
      1920: {
          slidesPerView: 4
      },
      1028: {
          slidesPerView: 4
      },
      480: {
          slidesPerView: 2
      },
      0: {
          slidesPerView: 1
      }
  }
});

new Swiper('.testimonialSlider', {
  loop: true,
  navigation: {
      nextEl: ".swiper-button-next",
      prevEl: ".swiper-button-prev",
    },
    pagination: {
      el: '.swiper-pagination',
      clickable: true,
  },
  slidesPerView: 2,
  paginationClickable: true,
  spaceBetween: 20,
  breakpoints: {
      1920: {
          slidesPerView: 2
      },
      1028: {
          slidesPerView: 2
      },
      480: {
          slidesPerView: 2
      },
      0: {
          slidesPerView: 1
      }
  }
});

new Swiper('.stepSlider', {
    loop: false,
    navigation: {
        nextEl: ".swiper-button-next",
        prevEl: ".swiper-button-prev",
      },
      pagination: {
        el: '.swiper-pagination',
        clickable: true,
    },
    slidesPerView: 3,
    paginationClickable: true,
    spaceBetween: 20,
    breakpoints: {
        1920: {
            slidesPerView: 3
        },
        1028: {
            slidesPerView: 3
        },
        480: {
            slidesPerView: 1
        },
        0: {
            slidesPerView: 1
        }
    }
  });
  new Swiper('.clientSlider', {
    paginationClickable: true,
    loop: true,
    spaceBetween: 10,
    speed: 3000,
    autoplay: {
        delay: 1,
        disableOnInteraction: false,
    },
    breakpoints: {
        0:{
            slidesPerView: 3,
            spaceBetween: 10,
        },
        768: {
          slidesPerView: 4,
          spaceBetween: 10,
        },
        1024: {
          slidesPerView: 7,
          spaceBetween: 10,
        },
      },
});

wow = new WOW({
    animateClass: 'animated',
    offset: 100,
    mobile: false
});
wow.init();
$(window).on('scroll', function () {
    if ($(this).scrollTop() > 100) {
        $('#web-pulse-scroll-up').fadeIn();
    } else {
        $('#web-pulse-scroll-up').fadeOut();
    }
});
$('#web-pulse-scroll-up').on('click', function () {
    $("html, body").animate({
        scrollTop: 0
    }, 600);
    return false;
});

$('#thumbs img').click(function () {
    $('#largeImage').attr('src', $(this).attr('src').replace('thumb', 'large'));
    if ($(this).hasClass("active")) {
        $("#thumbs img").removeClass("active");
    } else {
        $("#thumbs img").removeClass("active");
        $(this).addClass("active");
    }
});
