$(document).ready(function() {

    var wind = $(window);

    wow = new WOW({
        boxClass: 'wow',
        animateClass: 'animated',
        offset: 200,
        mobile: false,
        live: false
    });
    wow.init();




    // ---------- to top -----------
    $('.to-top').click(function() {
        $('html, body').animate({
            scrollTop: 0
        }, 1000);
        return false;
    });

    // share_links in product detils page
    $(`.share_butn`).click(function() {
        $(`.share_links`).toggleClass(`active`);
    });

});



$(document).ready(function() {
    
    //////////////////// header_swiper  ////////////////////
    var swiper = new Swiper('.header .header_swiper', {
        // loop: true,
        speed: 900,
        slidesPerView: 1,
        spaceBetween: 15,
        // autoplay: {
        //     delay: 2500,
        // },
        navigation: {
            nextEl: 'header .swiper-button-next',
            prevEl: 'header .swiper-button-prev',
        },
        pagination: {
            el: 'header .swiper-pagination',
            clickable: true
        },

    });

    //////////////////// prod_swiper  ////////////////////
    var swiper = new Swiper('.products_sec .prod_swiper', {
        // loop: true,
        speed: 900,
        slidesPerView: 1,
        spaceBetween: 15,
        // autoplay: {
        //     delay: 2500,
        // },
        observer: true,
        observeParents: true,
        navigation: {
            nextEl: '.products_sec .swiper-button-next',
            prevEl: '.products_sec .swiper-button-prev',
        },
        pagination: {
            el: '.swiper-pagination',
            clickable: true
        },
        breakpoints: {
            640: {
                slidesPerView: 2,
                spaceBetween: 20,
            },
            768: {
                slidesPerView: 3,
                spaceBetween: 20,
            },
            1024: {
                slidesPerView: 5,
                spaceBetween: 15,
            },
        }
    });

    //////////////////// offers_swiper  ////////////////////
    var swiper = new Swiper('.offers_sec .offers_swiper', {
        // loop: true,
        speed: 900,
        slidesPerView: 1,
        spaceBetween: 15,
        // autoplay: {
        //     delay: 2500,
        // },
        observer: true,
        observeParents: true,
        navigation: {
            nextEl: '.offers_sec .swiper-button-next',
            prevEl: '.offers_sec .swiper-button-prev',
        },
        pagination: {
            el: '.offers_sec .swiper-pagination',
            clickable: true,
            renderBullet: function (index, className) {
                return '<span class=" ' + className + '">' + '<span class="num">' +  (index + 1) + '</span>' + "</span>";
            },  
        },
        breakpoints: {
            768: {
                slidesPerView: 2,
                spaceBetween: 20,
            },
        }
    });


    //////////////////// celebrities_swiper  ////////////////////
    var swiper = new Swiper('.celebrities_sec .celebrities_swiper', {
        // loop: true,
        speed: 900,
        slidesPerView: 1,
        spaceBetween: 15,
        // autoplay: {
        //     delay: 2500,
        // },
        observer: true,
        observeParents: true,
        navigation: {
            nextEl: '.celebrities_sec .swiper-button-next',
            prevEl: '.celebrities_sec .swiper-button-prev',
        },
        pagination: {
            el: '.celebrities_sec .swiper-pagination',
            clickable: true,
            renderBullet: function (index, className) {
                return '<span class=" ' + className + '">' + '<span class="num">' +  (index + 1) + '</span>' + "</span>";
            },  
        },
        breakpoints: {
            768: {
                slidesPerView: 2,
                spaceBetween: 20,
            },
            1024: {
                slidesPerView: 3,
                spaceBetween: 20,
            },
        }
    });

    //////////////////// Swiper  ////////////////////
    var swiper = new Swiper('.insta_sec .swiper-container', {
        loop: true,
        speed: 5500,
        slidesPerView: 1,
        spaceBetween: 2,
        autoplay: {
            delay: 0,
        },
        navigation: {
            nextEl: '.insta_sec .swiper-button-next',
            prevEl: '.insta_sec .swiper-button-prev',
        },
        pagination: {
            el: '.insta_sec .swiper-pagination',
            clickable: true
        },
        breakpoints: {
            640: {
                slidesPerView: 2,
            },
            768: {
                slidesPerView: 3,
            },
            1024: {
                slidesPerView: 5,
            },
        }
    });

    //////////////////// Swiper  ////////////////////
    // var swiper = new Swiper(' .swiper-container', {
    //     // loop: true,
    //     speed: 900,
    //     slidesPerView: 1,
    //     spaceBetween: 15,
    //     // autoplay: {
    //     //     delay: 2500,
    //     // },
    //     //In Tabs
    //     // observer: true,
    //     // observeParents: true,
    //     navigation: {
    //         nextEl: '.swiper-button-next',
    //         prevEl: '.swiper-button-prev',
    //     },
    //     pagination: {
    //         el: '.swiper-pagination',
    //         clickable: true
    //     },
    //     breakpoints: {
    //         640: {
    //             slidesPerView: 2,
    //             spaceBetween: 20,
    //         },
    //         768: {
    //             slidesPerView: 3,
    //             spaceBetween: 20,
    //         },
    //         1024: {
    //             slidesPerView: 5,
    //             spaceBetween: 20,
    //             // Prevent swiper in lg screens
    //             // allowTouchMove: false,
    //             // preventClicks: false
    //         },
    //     }
    // });

})



// ------------ digitsOnly -----------
jQuery('.digitsOnly').keypress(function(event){
	if(event.which !=8 && isNaN(String.fromCharCode(event.which))){
		event.preventDefault();
	}
		console.log(event.which);

});




// ------------ increase products -----------
var buttonPlus  = $(".qty-btn-plus");
var buttonMinus = $(".qty-btn-minus");

var incrementPlus = buttonPlus.click(function() {
    var $n = $(this)
    .parent(".qty-container")
    .find(".input-qty");
    $n.val(Number($n.val())+1 );
});

var incrementMinus = buttonMinus.click(function() {
    var $n = $(this)
    .parent(".qty-container")
    .find(".input-qty");
    var amount = Number($n.val());
    if (amount > 0) {
        $n.val(amount-1);
    }
});

//Countdown
(function () {
    const second = 1000,
          minute = second * 60,
          hour = minute * 60,
          day = hour * 24;
  
    //I'm adding this section so I don't have to keep updating this pen every year :-)
    //remove this if you don't need it
    let today = new Date(),
        dd = String(today.getDate()).padStart(2, "0"),
        mm = String(today.getMonth() + 1).padStart(2, "0"),
        yyyy = today.getFullYear(),
        nextYear = yyyy + 1,
        dayMonth = "12/30/",
        birthday = dayMonth + yyyy;
    
    today = mm + "/" + dd + "/" + yyyy;
    if (today > birthday) {
      birthday = dayMonth + nextYear;
    }
    //end
    
    const countDown = new Date(birthday).getTime(),
        x = setInterval(function() {    
  
          const now = new Date().getTime(),
                distance = countDown - now;
  
          document.getElementById("days").innerText = Math.floor(distance / (day)),
            document.getElementById("hours").innerText = Math.floor((distance % (day)) / (hour)),
            document.getElementById("minutes").innerText = Math.floor((distance % (hour)) / (minute)),
            document.getElementById("seconds").innerText = Math.floor((distance % (minute)) / second);
  
          //do something later when date is reached
          if (distance < 0) {
            // document.getElementById("headline").innerText = "It's my birthday!";
            document.getElementById("countdown").style.display = "none";
            document.getElementById("content").style.display = "block";
            clearInterval(x);
          }
          //seconds
        }, 0)
}());



var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
  return new bootstrap.Tooltip(tooltipTriggerEl)
})
