(function() {
  var swiperArgs = {
    init: false,
    loop: true,
    slidesPerView: 'auto',
    centeredSlides: true,
    a11y: true,
    keyboardControl: true,
    grabCursor: true,
    pagination: {
      el: '.swiper-pagination',
      type: 'bullets',
      clickable: true
    }
  };

  var mySwiper = document.querySelector('.swiper-container') ? new Swiper('.swiper-container', swiperArgs) : false;

  function swiperSwitch() {
    var width = window.innerWidth;

    if (width < 700) {
      if (mySwiper.destroyed) {
        mySwiper = new Swiper('.swiper-container', swiperArgs);
      }
      mySwiper.init();
    } else {
      if (!mySwiper.destroyed) {
        mySwiper.destroy();
      }
    }
  }

  if (mySwiper) {
    mySwiper.destroyed = true;
    swiperSwitch();
    window.onresize = swiperSwitch;
  }
})();
