$(document).ready(function() {

    var wind = $(window);

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


    // ------------ SHOW HED PASS ----------
    $(document).ready(function() {
        $(".show_hide_password .show_pass").on('click', function(event) {
            event.preventDefault();
            if($(this).siblings("input").attr("type") == "text"){
                $(this).siblings("input").attr('type', 'password');
                $(this).addClass( "fa-eye-slash" );
                $(this).removeClass( "fa-eye" );
            }else if($(this).siblings("input").attr("type") == "password"){
                $(this).siblings("input").attr('type', 'text');
                $(this).removeClass( "fa-eye-slash" );
                $(this).addClass( "fa-eye" );
            }
        });
    });


    // ---------- more text ----------
    $(".more").on("click", function(){
        $(this).parent().toggleClass("active");
    })
    $(".more").parent().on("mouseleave", function(){
        $(this).removeClass("active");
    })


    // ------------ imagePreview -----------
    $(document).ready(function() {
        function readURL(input) {
            if (input.files && input.files[0]) {
                var reader = new FileReader();
                reader.onload = function(e) {
                    $('#imagePreview').css('background-image', 'url(' + e.target.result + ')');
                    $('#imagePreview').hide();
                    $('#imagePreview').fadeIn(650);
                }
                reader.readAsDataURL(input.files[0]);
            }
        }
        $("#imageUpload").change(function() {
            readURL(this);
        });
    });


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

    $('.megamenu-menu .links a').on('mouseenter click', function () {
        var tab_id = $(this).attr('data-tab');
        $('.megamenu-menu .links a').removeClass('current');
        $(this).addClass('current');

        $('.megamenu-menu .mega-img .tab-img').removeClass('current');
        $("#" + tab_id).addClass('current');

        if ($(this).hasClass('current')) {
            return false;
        }
    });


    // ------------ 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);
        }
    });

    // const navHeight = $(".navbar").outerHeight();
    // $("body").css("paddingTop", navHeight); 

    // ------- like button -------
    $(".like").on("click", function(){
        $(this).toggleClass("active");
    })


});




// ------------ swiper sliders -----------
$(document).ready(function() {

    var swiper = new Swiper('.header-slider', {
        slidesPerView: 1,
        spaceBetween: 30,
        // centeredSlides: true,
        speed: 1500,
        pagination: false,
        navigation: {
            nextEl: 'header .swiper-button-next',
            prevEl: 'header .swiper-button-prev',
        },
        mousewheel: false,
        keyboard: true,
        autoplay: {
            delay: 5000,
        },
        loop: true,
    });


    var swiper = new Swiper('.sections .sections-slider', {
        slidesPerView: 3,
        spaceBetween: 30,
        // centeredSlides: true,
        speed: 1500,
        pagination: false,
        navigation: {
            nextEl: '.sections .swiper-button-next',
            prevEl: '.sections .swiper-button-prev',
        },
        mousewheel: false,
        keyboard: true,
        autoplay: {
            delay: 5000,
        },
        loop: true,
        breakpoints: {
            0: {
                slidesPerView: 1,
            },
            480: {
                slidesPerView: 2,
            },
            787: {
                slidesPerView: 3,
            },
            991: {
                slidesPerView: 4,
            },
            1200: {
                slidesPerView: 4.6,
            }
        }
    });


    var swiper = new Swiper('.instagram .marq-slider', {
        slidesPerView: "auto",
        spaceBetween: 50,
        centeredSlides: true,
        pagination: false,
        navigation: false,
        mousewheel: false,
        keyboard: true,
        speed: 30000,
	    allowTouchMove: false,
        autoplay: {
            delay: 1,
        },
        loop: true,
    });


    var swiper = new Swiper('.gellery-sec .gellery-slider', {
        slidesPerView: 3,
        spaceBetween: 30,
        // centeredSlides: true,
        speed: 1500,
        pagination: false,
        navigation: {
            nextEl: '.gellery-sec .swiper-button-next',
            prevEl: '.gellery-sec .swiper-button-prev',
        },
        mousewheel: false,
        keyboard: true,
        autoplay: false,
        loop: false,
        breakpoints: {
            0: {
                slidesPerView: 1,
            },
            480: {
                slidesPerView: 2,
            },
            787: {
                slidesPerView: 2,
            },
            991: {
                slidesPerView: 2,
            },
            1200: {
                slidesPerView: 2,
            }
        }
    });


    var swiper = new Swiper('.products-slider', {
        slidesPerView: 3,
        spaceBetween: 30,
        // centeredSlides: true,
        speed: 1500,
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
        },
        navigation: {
            nextEl: '.products-slider .swiper-button-next',
            prevEl: '.products-slider .swiper-button-prev',
        },
        mousewheel: false,
        keyboard: true,
        autoplay: {
            delay: 5000,
        },
        loop: true,
        breakpoints: {
            0: {
                slidesPerView: 1,
            },
            480: {
                slidesPerView: 2,
            },
            787: {
                slidesPerView: 3,
            },
            991: {
                slidesPerView: 4,
            },
            1200: {
                slidesPerView: 5,
            }
        }
    });


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



});


$(document).on("scroll", function() {
    if ($(window).scrollTop() > 100) {
        $(".navbar").addClass("fixed");
    } else {
        $(".navbar").removeClass("fixed");
    }
});


$(document).ready(function() {
    var btnTop = $(".fixed-floating-btn").offset().top;
    $(document).on("scroll", function() {
        if ($(window).scrollTop() + 140 >= btnTop) {
            $(".fixed-cart-btn").addClass("fixed-btn");
        } else {
            $(".fixed-cart-btn").removeClass("fixed-btn");
        }
    });
});


