/*$('.quickContactbtn').click(function () {
    $(".quickContact").addClass('active');
});
$('.quickContactclose').click(function () {
    $(".quickContact").removeClass('active');
});*/

$(document).ready((e) => {
    $(".ce_sliderStart .slider-wrapper").slick({
        autoplay: true,
        autoplaySpeed: 5000,
        slidesToShow: 1,
        slidesToScroll: 1,
        infinite: true,
        arrows: false,
        dots: true,
        // responsive: [{
        //     breakpoint: 1640,
        //     settings: {
        //         autoplaySpeed: 2000,
        //         slidesToShow: 4,
        //         slidesToScroll: 1,
        //         arrows: true,
        //     }
        // }, {
        //     breakpoint: 992,
        //     settings: {
        //         slidesToShow: 3,
        //         slidesToScroll: 1,
        //         arrows: true,
        //     }
        // }, {
        //     breakpoint: 576,
        //     settings: {
        //         slidesToShow: 2,
        //         slidesToScroll: 1,
        //         arrows: true,
        //     },
        // }]
    });

    $(".product-slider .product_list, .mod_iso_relatedproducts .product_list").slick({
        autoplay: false,
        slidesToShow: 3,
        slidesToScroll: 1,
        infinite: true,
        arrows: true,
        dots: false,
    });

    $(".spwn-image-gallery").slick({
        autoplay: false,
        slidesToShow: 1,
        slidesToScroll: 1,
        infinite: true,
        arrows: false,
        dots: true
    });
    
    // Hide caption of youtube
    $(".ce_youtube .responsive a").on("click", (e) => {
        $("iframe").parents(".video_container").find(".caption").hide();
    });
    
    // Add number to header basket
    $("#header-basket-items").appendTo("header a.isotope-basket, header strong.isotope-basket");
    
    // FAQ list toggle
    $(".mod_faqlist ul li h3").on("click", (e) => {
        if ($(this).parents("li").hasClass("open")) {
            $(this).parents("li").find(".answer").slideUp(300);
            $(this).parents("li").removeClass("open");
        } else {
            $(this).parents("li").find(".answer").slideDown(300);
            $(this).parents("li").addClass("open");
        }
    });
    
    // Blog-Detail: Change Position of first video to top and hide img
    let spwnJsImg = $(".spwn-js-img");
    if (spwnJsImg.length && $(".ce_youtube").length) {
        $(".ce_youtube:first").insertAfter(spwnJsImg);
        spwnJsImg.hide();
    }
    
    // Product detail: Add amount
    $(".spwn-add-amount").on("click", function() {
        let amountInput = $(this).parents(".quantity_container").find("input");
        let newAmount = parseInt(amountInput.val()) + 1;
        if (amountInput.val() === "") {
            newAmount = 2;
        }
        amountInput.val(newAmount);
    });

    // Product detail: Remove amount
    $(".spwn-remove-amount").on("click", function() {
        let amountInput = $(this).parents(".quantity_container").find("input");
        let newAmount = parseInt(amountInput.val()) - 1;
        if (amountInput.val() <= 1) {
            newAmount = "1";
        }
        amountInput.val(newAmount);
    });
    
    // Move cart voucher box
    $(".mod_iso_coupons h2").prependTo($(".spwn-coupons"));
    $(".mod_iso_coupons").appendTo($(".voucher-box"));
    
    // Hack checkout
    $("<div id='spwn-info-boxes'></div>").insertBefore(".review .clear");
    $(".review .info_container").appendTo($("#spwn-info-boxes"));
    $(".review .info_container .edit").each(function() {
        let h3 = $(this).parents(".info_container").find("h3");
        h3.append("<span class='edit-span'>(<span></span>)</span>");
        $(this).appendTo(h3.find(".edit-span span"));
    });
});

jQuery(function ($) {
    /*if ($(window).width() > 769) {
      $('.navbar .dropdown').hover(function() {
        $(this).find('.dropdown-menu').first().stop(true, true).delay(250).slideDown();
  
      }, function() {
        $(this).find('.dropdown-menu').first().stop(true, true).delay(100).slideUp();
  
      });
  
      $('.navbar .dropdown > a').click(function() {
        location.href = this.href;
      });
  
    }*/
});