(function ($) {
    "use strict";

    // Spinner
    var spinner = function () {
        setTimeout(function () {
            if ($('#spinner').length > 0) {
                $('#spinner').removeClass('show');
            }
        }, 1);
    };
    spinner();
    
    
    // Initiate the wowjs
    new WOW().init();


    // Sticky Navbar
    $(window).scroll(function () {
        if ($(this).scrollTop() > 300) {
            $('.sticky-top').addClass('shadow-sm').css('top', '0px');
        } else {
            $('.sticky-top').removeClass('shadow-sm').css('top', '-100px');
        }
    });
    
    
    // Back to top button
    $(window).scroll(function () {
        if ($(this).scrollTop() > 300) {
            $('.back-to-top').fadeIn('slow');
        } else {
            $('.back-to-top').fadeOut('slow');
        }
    });
    $('.back-to-top').click(function () {
        $('html, body').animate({scrollTop: 0}, 1500, 'easeInOutExpo');
        return false;
    });


    // Testimonials carousel
    $(".testimonial-carousel").owlCarousel({
        autoplay: true,
        smartSpeed: 1000,
        items: 1,
        dots: true,
        loop: true,
    });

    
})(jQuery);























// ====================================================================================
// ====================================================================================
// ====================================================================================
// ====================================================================================

  var swiper = new Swiper(".mySwiper", {
    slidesPerView: 3,
    spaceBetween: 30,
    loop: true,
    autoplay: {
      delay: 2000,
      disableOnInteraction: false,
    },
    pagination: {
      el: ".swiper-pagination",
      clickable: true,
    },
    navigation: {
      nextEl: ".swiper-button-next",
      prevEl: ".swiper-button-prev",
    },
    breakpoints: {
      0: {
        slidesPerView: 1,
      },
      576: {
        slidesPerView: 2,
      },
      992: {
        slidesPerView: 3,
      },
    },
  });











  //===========TRANSLATION-CODES===========
document.addEventListener('DOMContentLoaded', () => {
    const tool = document.querySelector('.translateTool');
    const container = document.querySelector('.containerLanguage');
// console.log(tool);
// console.log(container);

    if (tool && container) {
        tool.addEventListener('click', () => {
            container.classList.toggle('active');
        });
    }

    document.querySelectorAll('.lang-option').forEach(item => {
        item.addEventListener('click', function (e) {
            e.preventDefault();
            const selectedLanguage = this.getAttribute('data-lang');
            const currentUrl = new URL(window.location.href);
            currentUrl.searchParams.set('lang', selectedLanguage);
            window.location.href = currentUrl.toString();
        });
    });
});
  const galleryModal = document.getElementById('galleryModal');
  const galleryImage = document.getElementById('galleryModalImage');

document.addEventListener('DOMContentLoaded', () => {
  const galleryModal = document.getElementById('galleryModal');
  const galleryImage = document.getElementById('galleryModalImage');

  if (galleryModal) {
    galleryModal.addEventListener('show.bs.modal', function (event) {
      const trigger = event.relatedTarget; 
      const imageSrc = trigger.getAttribute('data-image'); 
      galleryImage.src = imageSrc; 
    });
  }
});
