function isMob() {
  if ($(window).width() <= 1024) {
    return true;
  } else {
    return false;
  }
}


function homebanner() {
  if ($('.homebanner').length) {
    var homebanner = new Swiper(".homebanner", {
      autoplay: {
        delay: 4000,
      },
      initialSlide: 0,
      speed: 700,
      simulateTouch: false,
      pagination: {
        el: ".swiper-pagination",
        clickable: true,
      },
      navigation: {
        nextEl: ".homebanner-next",
        prevEl: ".homebanner-prev",
      },
      on: {
        slideChangeTransitionStart: function () {
          this.autoplay.start();
          const i = this.activeIndex + 1;
          $('.homebanner-num .top').html('0' + (i))
          $('.homebanner-num .bot').html('0' + (i + 1))
          if (i == this.slides.length) {
            $('.homebanner-num .bot').html('01');
          }
        }
      }
    });

    window.homebanner = homebanner;
  }

}
homebanner();



$(function(){
  let bodyWidth=$(document).width()
  if(bodyWidth <= 768){
    proswiper()
  }
})


$(window).resize(function(){
  let bodyWidth=$(document).width()
  if(bodyWidth <= 768){
    proswiper()
  }
})

function proswiper() {
  var mySwiper = new Swiper ('#homeproducts', {
    loop: true, 
    slidesPerView: 1,
    autoplay: {
      delay: 4000,
    },
  
    pagination: {
      el: '.swiper-pagination',
    },
  })      
}


function advitem(){
  $('.home-recommended .homerecommended-list .item:nth-child(3)').after($('.home-recommended .homerecommended-list .item:nth-child(2)'))
}
if(isMob()){
  advitem();
}