(function($) {
    $.fn.visible = function(partial) {

    var $t            = $(this),
        $w            = $(window),
        viewTop       = $w.scrollTop(),
        viewBottom    = viewTop + $w.height(),
        _top          = $t.offset().top,
        _bottom       = _top + $t.height(),
        compareTop    = partial === true ? _bottom : _top,
        compareBottom = partial === true ? _top : _bottom;

     return ((compareBottom <= viewBottom) && (compareTop >= viewTop));

    };

    })(jQuery);

   

    $(window).scroll(function(event) {
      $(".animate-swipe-right").each(function(i, el) {
        var el = $(el);
        if (el.visible(true)) {
            el.addClass("swipe"); 
        } else {
            el.removeClass("swipe");
        }
      });
      $(".animate-swipe-left").each(function(i, el) {
        var el = $(el);
        if (el.visible(true)) {
            el.addClass("swipe"); 
        } else {
            el.removeClass("swipe");
        }
      });
      $(".animate-swipe-up").each(function(i, el) {
        var el = $(el);
        if (el.visible(true)) {
            el.addClass("swipe"); 
        } else {
            el.removeClass("swipe");
        }
      });
      $(".animate-swipe-down").each(function(i, el) {
        var el = $(el);
        if (el.visible(true)) {
            el.addClass("swipe"); 
        } else {
            el.removeClass("swipe");
        }
      });

    });

    $(function() {
        $(window).on("scroll", function() {
            if($(window).scrollTop() > 50) {
                $(".header").addClass("active");
            } else {
                //remove the background property so it comes transparent again (defined in your css)
               $(".header").removeClass("active");
            }
        });
    });

    $(document).ready(function () {

  // destroy if already initialized (prevents double init issues)
  if ($('.my-slider').hasClass('slick-initialized')) {
    $('.my-slider').slick('unslick');
  }

  $('.my-slider').slick({
    slidesToShow: 3,
    slidesToScroll: 1,
    arrows: true,
    dots: true,
    speed: 300,
    infinite: true,
    autoplay: true,
    autoplaySpeed: 5000,
    pauseOnHover: false,
    pauseOnFocus: false,
    pauseOnDotsHover: false,
    responsive: [
      { breakpoint: 991, settings: { slidesToShow: 2 } },
      { breakpoint: 767, settings: { slidesToShow: 1 } }
    ]
  });

  // ✅ hard force: even if slick tries to pause, immediately play again
  $('.my-slider')
    .on('mouseenter mouseleave focusin focusout', function () {
      $(this).slick('slickPlay');
    });
});




  const contactRadio = document.getElementById("toggle-contact");
  const mainRadio = document.getElementById("toggle-main");

  contactRadio.addEventListener("change", function () {
    if (this.checked) window.location.href = "/contact";
  });

  mainRadio.addEventListener("change", function () {
    if (this.checked) window.location.href = "/";
  });