jQuery(document).ready(function(){

if ( ! jQuery('body').hasClass('product-single') ) {

  jQuery(function (){
   const product_mini_SwiperSlider = new Swiper(
     ".product-mini-swiper-slider",
     {
       // Optional parameters
       spaceBetween: 10,

       // Navigation arrows
       navigation: {
         nextEl: ".swiper-button-next.mini_nav",
         prevEl: ".swiper-button-prev.mini_nav",
       },

       breakpoints: {
         1200: {
           slidesPerView: 6,
         },
         992: {
           slidesPerView: 5,
           spaceBetween: 10,
         },
         576: {
           slidesPerView: 7,
           spaceBetween: 8,
         },
         480: {
           slidesPerView: 5,
           spaceBetween: 8,
         },
         360: {
           slidesPerView: 4,
           spaceBetween: 8,
         },
         260: {
           slidesPerView: 3,
           spaceBetween: 8,
         },
       },
     }
   );
  });

  jQuery(function (){
    const productcarouselSwiperSlider = new Swiper(
      ".post-carousel-swiper-slider",
      {
        // Optional parameters
        spaceBetween: 15,

        // If we need pagination
        pagination: {
          el: ".swiper-pagination",
          clickable: true,
          dynamicBullets: true,
        },

        // Navigation arrows
        navigation: {
          nextEl: ".swiper-button-next.mpostcarusel_nav",
          prevEl: ".swiper-button-prev.mpostcarusel_nav",
        },

        breakpoints: {
          1200: {
            slidesPerView: 4,
          },
          992: {
            slidesPerView: 3,
            spaceBetween: 10,
          },
          576: {
            slidesPerView: 3,
            spaceBetween: 10,
          },
          480: {
            slidesPerView: 2,
            spaceBetween: 8,
          },
          0: {
            slidesPerView: 1,
            spaceBetween: 8,
          },
        },
      }
    );

  });

  jQuery(function (){
    const productcarouselSwiperSlider = new Swiper(
      ".post-carousel-swiper-slider.box-imager",
      {
        // Optional parameters
        spaceBetween: 35,

        // If we need pagination
        pagination: {
          el: ".swiper-pagination",
          clickable: true,
          dynamicBullets: true,
        },

        // Navigation arrows
        navigation: {
          nextEl: ".swiper-button-next.mpostcarusel_nav",
          prevEl: ".swiper-button-prev.mpostcarusel_nav",
        },

        breakpoints: {
          1200: {
            slidesPerView: 4,
          },
          992: {
            slidesPerView: 3,
            spaceBetween: 10,
          },
          576: {
            slidesPerView: 3,
            spaceBetween: 10,
          },
          480: {
            slidesPerView: 2,
            spaceBetween: 8,
          },
          0: {
            slidesPerView: 1,
            spaceBetween: 8,
          },
        },
      }
    );

  });


}

// داینامیک سازی اتریبیوتیک کاروسل های آیتم
setInterval(function(){
    if (jQuery(".carousel-items").length) {
    var carousel = jQuery(".carousel-items").each(function () {

      var settings = JSON.parse(jQuery(this).attr("settings-slider"));

      jQuery(this).owlCarousel({
      items: settings.item,
      autoplay:false,
      margin: settings.margins,
      loop:settings.loop == "true" ? true : false,
      autoplayTimeout: settings.delay,
      nav:settings.nav == "true" ? true : false,
      navText:'',
      rtl:true,
      navElement:'span class="far fa-chevron-left"',
      responsiveClass:true,
      dots:false,
      responsive:{
          990:{
              items:8,
            },
             860:{
                 items:6,
                 nav:false,
                 loop:false,
            },
            480:{
                items:4,
                nav:false,
                loop:false,
           },
           360:{
               items:3,
               nav:false,
               loop:false,
          },
            0:{
                items:3,
                nav:false,
                loop:false,
           }

        }

      });
    });
   }
});

// داینامیک سازی اتریبیوتیک کاروسل های محصولات
setInterval(function(){
  if (jQuery(".article-off").length) {
    var carousel = jQuery(".article-off").each(function () {

      var settings = JSON.parse(jQuery(this).attr("settings-slider"));

      jQuery(this).owlCarousel({
  			items: settings.item,
  			loop: settings.loop == "true" ? true : false,
        margin: settings.margins,
        stagePadding: settings.Paddings,
  		  autoplayTimeout: settings.delay,
  		  autoplay: settings.autoplay == "true" ? true : false,
  		  nav: settings.nav == "true" ? true : false,
  		  navText:'',
  			rtl:true,
        autoplayHoverPause:true,
  		  navElement:'span class="far fa-chevron-left"',
  		  responsiveClass:true,
        dots: settings.dots == "true" ? true : false,
  		  responsive:{
  		      1310:{
  		          items: settings.item,
  							nav: settings.nav == "true" ? true : false,
                margin: settings.margins,
  		        },
              1150:{
                  items: 5,
                  nav: settings.nav == "true" ? true : false,
                  margin: settings.margins,
                },
              1024:{
                  items: 5,
                  nav: settings.nav == "true" ? true : false,
                  margin: settings.margins,
                },
              780:{
                  items:4,
                  autoplay: settings.autoplay == "true" ? true : false,
                  nav: false,
                  margin: settings.margins_mob,

             },
  		         570:{
  		             items:2,
  		             autoplay: settings.autoplay == "true" ? true : false,
  								 nav: false,
                   margin: settings.margins_mob,
                   stagePadding: 30,
  		        },
              470:{
                  items:2,
                  autoplay: settings.autoplay == "true" ? true : false,
                  nav: false,
                  margin: settings.margins_mob,
                  stagePadding: 10,
             },
              400:{
                  items:2,
                  autoplay: settings.autoplay == "true" ? true : false,
                  nav: false,
                  margin: settings.margins_mob,
                 stagePadding: 10,
             },
             340:{
                 items:1,
                 autoplay: settings.autoplay == "true" ? true : false,
                 nav: false,
                 margin: settings.margins_mob,
                stagePadding: 70,
            },
             0:{
                 items:1,
                 autoplay: settings.autoplay == "true" ? true : false,
                 nav: false,
                 margin: settings.margins_mob,
                 stagePadding: 55,
            },

  		    }



      });
    });
 }
});


// داینامیک سازی اسلایدر اختصاصی
setInterval(function(){

  var carousel = jQuery(".slide-carousel").each(function () {

    var settings = JSON.parse(jQuery(this).attr("settings-slider"));

    jQuery(this).owlCarousel({
			items: 1,
			loop: settings.loop == "true" ? true : false,
		  autoplayTimeout: settings.delay,
		  autoplay: settings.autoplay == "true" ? true : false,
		  nav: settings.nav == "true" ? true : false,
			rtl:true,
      navText:'',
      navElement:'span class="chevron-left"',
		  responsiveClass:true,
		  dots: settings.dots == "true" ? true : false,
    });

  });
}
);

});


function toEnglishNumber(faphonenumber) {
  var pn = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"];
  var en = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
  var an = ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"];
  var cache = faphonenumber;
  for (var i = 0; i < 10; i++) {
      var regex_fa = new RegExp(pn[i], 'g');
      var regex_ar = new RegExp(an[i], 'g');  
      cache = cache.replace(regex_fa, en[i]);
      cache = cache.replace(regex_ar, en[i]);
  }

  return cache;
}
 jQuery(".phone-loginbox input[name='login[email_phone]'] ").on("keyup change", function(e) {
      
      let faphonenumber = jQuery(this).val();
      var cache=toEnglishNumber(faphonenumber);
      
        jQuery(".phone-loginbox input[name='login[email_phone]']").val(cache);
    }
    
  )
  jQuery(".prk_sms_newsletter_mobile").on("keyup change", function(e) {
      
    let faphonenumber = jQuery(this).val();
    var cache=toEnglishNumber(faphonenumber);
    
      jQuery(".prk_sms_newsletter_mobile").val(cache);
  }
  
)


