jQuery(document).ready(function () {
  // Gallery
  var swiper = new Swiper(".mySwiper", {
    effect: "coverflow",
    grabCursor: true,
    centeredSlides: false,
    autoplay: {
      delay: 3000,
      disableOnInteraction: false,
    },
    speed: 1200,
    breakpoints: {
      0: {
        slidesPerView: 1,
      },
      768: {
        slidesPerView: 2,
      },
      992: {
        slidesPerView: 3,
      }
    },
    coverflowEffect: {
      rotate: 30,
      stretch: 0,
      depth: 150,
      modifier: 1,
      slideShadows: false,
    },
    navigation: {
      nextEl: ".gallery-swiper-button-next",
      prevEl: ".gallery-swiper-button-prev",
    }
  });

  // Testimonial
  var swiper3 = new Swiper(".testimonial-section .mySwiper3", {
    breakpoints: {
      0: {
        slidesPerView: 1,
      },
      768: {
        slidesPerView: 2,
      },
      992: {
        slidesPerView: 3,
      }
    },
    speed: 1200,
    autoplay: {
      delay: 3000,
      disableOnInteraction: false,
    },
    spaceBetween: 30,
    navigation: {
      nextEl: ".testimonial-swiper-button-next",
      prevEl: ".testimonial-swiper-button-prev",
    },
  });

  // Post Slider
  var $vw_shopping_mall_swiperEl = jQuery(".mySwiper4");

  if ($vw_shopping_mall_swiperEl.find("ul.swiper-wrapper").length) {
    var $vw_shopping_mall_ul = $vw_shopping_mall_swiperEl.find("ul.swiper-wrapper");
    var $vw_shopping_mall_slides = $vw_shopping_mall_ul.find("li");

    var $vw_shopping_mall_wrapper = jQuery("<div class='swiper-wrapper news-box'></div>");
    $vw_shopping_mall_slides.each(function () {
      var $vw_shopping_mall_slide = jQuery("<div class='swiper-slide'></div>");
      $vw_shopping_mall_slide.html(jQuery(this).html());
      $vw_shopping_mall_wrapper.append($vw_shopping_mall_slide);
    });

    $vw_shopping_mall_ul.replaceWith($vw_shopping_mall_wrapper);
  }

  // Initialize Swiper
  var swiper4 = new Swiper(".mySwiper4", {
    breakpoints: {
      0: {
        slidesPerView: 1,
      },
      768: {
        slidesPerView: 2,
      },
      992: {
        slidesPerView: 3,
      }
    },
    speed: 1200,
    autoplay: {
      delay: 3000,
      disableOnInteraction: false,
    },
    spaceBetween: 30,
    navigation: {
      nextEl: ".news-swiper-button-next",
      prevEl: ".news-swiper-button-prev",
    },
  });

});

// Scroll to Top
window.onscroll = function() {
  const vw_shopping_mall_button = document.querySelector('.scroll-top-box');
  if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
    vw_shopping_mall_button.style.display = "block";
  } else {
    vw_shopping_mall_button.style.display = "none";
  }
};

document.querySelector('.scroll-top-box a').onclick = function(event) {
  event.preventDefault();
  window.scrollTo({top: 0, behavior: 'smooth'});
};