$('.slider-for').slick({
    slidesToShow: 1,
    slidesToScroll: 1,
    arrows: false,
    fade: true,
     autoplay: true,
    autoplaySpeed: 3000,
    infinite: true,
    speed: 300,
    dots:true,
    asNavFor: '.slider-nav'
});
$('.slider-nav').slick({
    slidesToShow: 5,
    slideToScroll: 5,
    asNavFor: '.slider-for',
    centerMode: true,
    centerPadding: '100px',
    focusOnSelect: true,
    autoplay: true,
    arrows: false,
    autoplaySpeed: 3000,
    infinite: true,
    speed: 300
});
window.onscroll = function () {
    var header = document.querySelector("header");
    if (window.pageYOffset > 0) {
      header.classList.add("sticky");
    } else {
      header.classList.remove("sticky");
    }
  };
  
    
    const swiper_container = document.querySelectorAll('.cus-services-slider');
    const container = document.getElementById('container');
    
    function offsetSwiperContainer() {
      let leftOffset = (window.innerWidth - container.offsetWidth) / 1;
      
      swiper_container.forEach((el) => {
        el.style.paddingLeft = `${leftOffset}px`;
      });
    }
    
    window.addEventListener('resize', () => { 
      offsetSwiperContainer();
    });
  
  
    $('#maindiv').width($('#div1').width());
  
  
    /*
  text-shadow from smooth-16 was created with steps = 16
  */
  function calculateStrokeTextCSS(steps) {
      var css = "";
      for (var i = 0; i < steps; i++) {
        var angle = (i * 2 * Math.PI) / steps;
        var cos = Math.round(10000 * Math.cos(angle)) / 10000;
        var sin = Math.round(10000 * Math.sin(angle)) / 10000;
        css +=
          "calc(var(--stroke-width) * " +
          cos +
          ") calc(var(--stroke-width) * " +
          sin +
          ") 0 var(--stroke-color),";
      }
    
      return css;
    }
    function customCursor() {
      let e = document.querySelector(".cursor-inner"),
        o = document.querySelector(".cursor-outer"),
        t = 0,
        r = 0,
        a = !1;
      window.addEventListener("mousemove", function(s) {
        a || gsap.to(o, {
          x: s.clientX,
          y: s.clientY
        }), gsap.to(e, {
          x: s.clientX,
          y: s.clientY
        }), r = s.clientY, t = s.clientX
      });
      let s = document.querySelectorAll("a, img, .cursor-pointer");
      s.forEach(t => {
        t.addEventListener("mouseenter", function() {
          e.classList.add("cursor-hover"), o.classList.add("cursor-hover"), a = !0
        }), t.addEventListener("mouseleave", function() {
          "A" === t.tagName || "IMG" === t.tagName || t.closest(".cursor-pointer") || (e.classList.remove("cursor-hover"), o.classList.remove("cursor-hover")), a = !1
        })
      }), gsap.set(e, {
        visibility: "visible"
      }), gsap.set(o, {
        visibility: "visible"
      })
    }
    
    function loopIt() {
      $("#topboxesmenu span").each(function(e) {
        var o = $(this);
        setTimeout(function() {
          o.addClass("current"), setTimeout(function() {
            o.removeClass("current"), e == $("#topboxesmenu span").length - 1 && loopIt()
          }, 1e3)
        }, 1100 * e)
      })
    }
    document.addEventListener("DOMContentLoaded", function() {
      customCursor(), AOS.init({
        duration: 1700
      });
      let e = new Lenis;
    
      function o(t) {
        e.raf(t), requestAnimationFrame(o)
      }
      requestAnimationFrame(o);
      let t = document.querySelector(".shape-overlays"),
        r = new preLoader(t, {
          numPoints: 2
        });
      document.querySelector(".preloader") && setTimeout(function() {
        document.querySelector(".preloader").remove(), r.close(), preLoader1(tl)
      }, 500)
    });

    var max = 100;
    var maxHeight = $(document).height();
    var width = 0;
    var offset = 0;
    $(document).scroll(function(){
      offset = Math.floor($(window).scrollTop() / ($(document).height() - $(window).height())* 100) ;
      $('.loading').css('width',offset + '%');
    });

    
var btn = $('#button');

$(window).scroll(function() {
  if ($(window).scrollTop() > 400) {
    btn.addClass('show');
  } else {
    btn.removeClass('show');
  }
});

btn.on('click', function(e) {
  e.preventDefault();
  $('html, body').animate({scrollTop:0}, '400');
});