jQuery(function ($) {

    //CURRENT ADDRESS
    var loc = $(location).attr("pathname");
    var real = loc.substring(1);

    //PRODUCT SINGLE ACCORDIAN
    $(".card-header").click(function () {
        $(this).next().toggleClass("show");
        $(this).children().toggleClass("opened");
    });


    //SCROLL UP
    var btn = $('#scrollup');

    $(window).scroll(function () {
        if ($(window).scrollTop() > 300) {
            btn.addClass('show');
        } else {
            btn.removeClass('show');
        }
    });

    btn.on('click', function (e) {
        e.preventDefault();
        $('html, body').animate({
            scrollTop: 0
        }, '300');
    });

    // END: SCROLL UP


    //HEADER
    $(".header-search-form.product-search").clone().insertBefore(".header-close-menu.close-style");
    $(".main-navbar").clone().insertAfter(".switcher-tab");
    $("ul.menu-right-list .cart-wrapper").clone().appendTo("ul.header-wrap-right");

//MOBILE MENU TOGGLE
    $(".mobile-collapsed").click(function () {
        $(this).next().slideToggle();
        $(this).children().toggleClass("active");
    });

    //HEADER2

    // SOCIAL LINK ANIMATION
    $(".main-header#main-header2 .widget-right .widget_social_widget .icons-links,.footer#footer2 .widget_social_widget ul").after(`	<div class="icons-clip"><ul>
    <li><span class="icon"><i class="fab fa-facebook-f"></i></li>
    <li><span class="icon"><i class="fab fa-twitter"></i></li>
    <li><span class="icon"><i class="fab fa-instagram"></i></li>
    <li><span class="icon"><i class="fab fa-dribbble"></i></li>
    <li><span class="icon"><i class="fab fa-whatsapp"></i></li>
</ul>
</div>`);


    let $container = $('#main-header2 .widget_social_widget'),
        $links = $container.find('.icons-links'),
        $icons = $links.find('.icon'),
        $clip = $container.find('.icons-clip'),
        $clipList = $container.find('.icons-clip ul'),
        iconNames = $icons.find('i').toArray().map($el => $el.className.replace('fab fa-', '')).join(' '),
        $currIcon = false,

        // Move clip box to current icon position
        moveClip = () => {
            if ($currIcon) {
                let offsetX = $currIcon.position().left,
                    offsetY = $currIcon.position().top;

                $clip.css('transform', 'translate(' + (offsetX) + 'px, ' + (offsetY) + 'px)');
                $clipList.css('transform', 'translate(' + (-offsetX) + 'px, ' + (-offsetY) + 'px)');
            }
        },

        // Set clip width to match links width
        setWidth = () => $clipList.css({
            'width': $links.width()
        });


    $(window).on('resize', function () {
        moveClip();
        setWidth();
    });

    $icons.on('mouseover focusin', function (e) {
        $currIcon = $(this);

        // Update class
        let iconName = $currIcon.find('.fab')[0].className.replace('fab fa-', '');
        $clip.removeClass(iconNames).addClass(iconName);

        moveClip();
        setWidth();
    });


    //FOR FOOTER SOCIAL ICONS HOME2
    let $container2 = $('.footer#footer2 .widget_social_widget'),
        $links2 = $container2.find('.icons-links'),
        $icons2 = $links2.find('.icon'),
        $clip2 = $container2.find('.icons-clip'),
        $clipList2 = $container2.find('.icons-clip ul'),
        iconNames2 = $icons2.find('i').toArray().map($el => $el.className.replace('fab fa-', '')).join(' '),
        $currIcon2 = false,

        // Move clip box to current icon position
        moveClip2 = () => {
            if ($currIcon2) {
                let offsetX = $currIcon2.position().left,
                    offsetY = $currIcon2.position().top;

                $clip2.css('transform', 'translate(' + (offsetX) + 'px, ' + (offsetY) + 'px)');
                $clipList2.css('transform', 'translate(' + (-offsetX) + 'px, ' + (-offsetY) + 'px)');
            }
        },

        // Set clip width to match links width
        setWidth2 = () => $clipList2.css({
            'width': $links2.width()
        });


    $(window).on('resize', function () {
        moveClip2();
        setWidth2();
    });

    $icons2.on('mouseover focusin', function (e) {
        $currIcon2 = $(this);

        // Update class
        let iconName2 = $currIcon2.find('.fab')[0].className.replace('fab fa-', '');
        $clip2.removeClass(iconNames2).addClass(iconName2);

        moveClip2();
        setWidth2();
    });


    /* HAMBURGER ANIMATION */
    $(".hamburger-menu").click(function () {
        $(".main-mobile-wrapper").css({
            "transform": "translateX(0)"
        });
		$('.main-mobile-wrapper > .main-mobile-build').show();

        $(".footer-cart-wrapper,.mouse").toggle();
    });

    $(".header-close-menu").click(function () {
        $(".main-mobile-wrapper").css({
            "transform": "translateX(-150%)"
        });
        $(".footer-cart-wrapper,.mouse").toggle();
        $(".menu-collapsed").focus();
		$('.main-mobile-wrapper > .main-mobile-build').fadeOut();
    });

    $(".switcher-tab > button").click(function (e) {
        if (!$(this).hasClass("active-bg")) {
            $(".product-categories,.main-navbar").toggleClass("d-none");
            $(this).parent().children().toggleClass("active-bg");
        }
    });



	function headerSearch(){
    //HEADER SEARCH
    $(".menu-right-list .search-btn").on("click", function () {
        $("body").addClass("header-search-active");
    });


    $(".header-search-close").click(function () {
        $(".menu-right-list .search-btn").focus();
        $("body").removeClass("header-search-active");
    });
	}
	headerSearch();

    /*------DYNAMIC CLASS ADDITION----*/
    //SPLITTING
    // $("#main-header .menu-item a").attr("data-splitting", "").addClass("slide-vertical");
    // Splitting();

    //Dynamic Owl  Carousel
    $(".new-collection1 .products, .trending-collection1 .products, .feature-collection2 .products, .trending-collection2 .products").addClass("owl-carousel owl-theme");

    //product  row column addition
    $(".trending-collection3 .woocommerce   ul, .new-collection3 .woocommerce   ul").addClass("row");


   

    //shop page
    $(".shop-section ul.products").addClass("row");
    $(".shop-section ul.products>li").addClass("col-12 col-md-6 col-xl-4");

    //product single
    $(".product-single-section #st-primary-content .images .threesixty .nav_bar a:nth-of-type(2)").click(function () {
        if ($(this).hasClass("nav_bar_stop")) {
            $(this).removeClass("nav_bar_stop").addClass("nav_bar_play");
        } else {
            $(this).removeClass("nav_bar_play").addClass("nav_bar_stop");
        }
    })
    /*------END: DYNAMIC CLASS ADDITON----*/


    // PRODUCT FILTER BUTTON
    $(".owl-filter-bar .item").click(function () {
        $(this).parent().children().removeClass("active");
        if (!$(this).hasClass("active")) {
            $(this).addClass("active");
        }
    });

    $("#filter3").on({
        "focusin mouseover": function () {
            $(this).children(".owl-nav").children().fadeIn();
        },
        "blur mouseleave": function () {
            $(this).children(".owl-nav").children().fadeOut();
        }
    });

    // Home3 Deal Of the day bubbles


    //WIDGETS

    $("#footer1 .middle-footer li a").each(function (e) {
        var foot1link = $(this).text();
        var foot1link = foot1link.replaceAll(' ', ' ');
        $(this).attr("data-content", `${foot1link}`);
    });

    //SIDEBAR CART
    $(".cart-trigger").on("click", function () {
        $(".cart-modal").toggleClass("active-cart");
        if ($(".cart-modal").hasClass("active-cart")) {
            $(".cart-modal").fadeIn(100);
            $(".cart-modal").css("right", "0");
        } else {
            $(".cart-modal").css("right", "-100%");
            $(".cart-modal").fadeout(1000);
        }
    });

    $(".cart-close").click(function () {
        $(".cart-modal").toggleClass("active-cart");
        $(".cart-modal").css("right", "-100%");
        $(".cart-modal").fadeOut(1000);
        $(".cart-trigger").focus();
    })
	
	
	 // Quick Veiw Trigger
        $('.quickview-trigger').on('click',function(e){
            e.preventDefault();
            if (!$('.quickview-overlay').hasClass("active")) {
                $('.quickview-overlay').addClass('active');
                $('.quickview-close').focus();
                var e, t, i, n = document.querySelector(".quickview-overlay");
                let a = document.querySelector(".quickview-close"),
                    s = n.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),
                    o = s[s.length - 1];
                if (!n) return !1;
                for (t = 0, i = (e = n.getElementsByTagName("a")).length; t < i; t++) e[t].addEventListener("focus", c, !0), e[t].addEventListener("blur", c, !0);
                function c() {
                    for (var e = this; - 1 === e.className.indexOf("quickview-model-details");) "li" === e.tagName.toLowerCase() && (-1 !== e.className.indexOf("focus") ? e.className = e.className.replace(" focus", "") : e.className += " focus"), e = e.parentElement
                }
                document.addEventListener("keydown", function(e) {
                    ("Tab" === e.key || 9 === e.keyCode) && (e.shiftKey ? document.activeElement === a && (o.focus(), e.preventDefault()) : document.activeElement === o && (a.focus(), e.preventDefault()))
                })
            } else {
                $('.quickview-trigger').focus();
                $('.quickview-overlay').removeClass('active');
            }
        });
        $('.quickview-close').on('click',function(e){
            e.preventDefault();
            $('.quickview-trigger').focus();
            $('.quickview-overlay').removeClass('active');
        });


    //FOCUS TRAPPING

    //MOBILE NAVS + CATEGORIES TRAP
    var startTrap = function (elem) {
        let tabbable = elem.find('select, input, textarea, button, a,button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])').filter(':visible');

        let firstTabbable = tabbable.first();
        let lastTabbable = tabbable.last();
        /*set focus on first input*/
        $('.header-close-menu').focus();

        /*redirect last tab to first input*/
        lastTabbable.on('keydown', function (e) {
            if ((e.which === 9 && !e.shiftKey)) {
                e.preventDefault();
                firstTabbable.focus();
            }
        });

        /*redirect first shift+tab to last input*/
        firstTabbable.on('keydown', function (e) {
            if ((e.which === 9 && e.shiftKey)) {
                e.preventDefault();
                lastTabbable.focus();
            }
        });

        /* allow escape key to close insiders div */
        elem.on('keyup', function (e) {
            if (e.keyCode === 27) {
                $(".header-close-menu").click();
            };
        });
    };


    $('.hamburger-menu').click(function (e) {
        e.preventDefault();
        $('.main-mobile-wrapper').show();
        startTrap($('.main-mobile-wrapper'));
    });

    //Newsletter Trap

    var newsTrap = function (elem) {
        let tabbable = elem.find('select, input, textarea, button, a,button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])').filter(':visible');

        let firstTabbable = tabbable.first();
        let lastTabbable = tabbable.last();
        /*set focus on first input*/
        $('.signin-close').focus();

        /*redirect last tab to first input*/
        lastTabbable.on('keydown', function (e) {
            if ((e.which === 9 && !e.shiftKey)) {
                e.preventDefault();
                firstTabbable.focus();
            }
        });

        /*redirect first shift+tab to last input*/
        firstTabbable.on('keydown', function (e) {
            if ((e.which === 9 && e.shiftKey)) {
                e.preventDefault();
                lastTabbable.focus();
            }
        });

        /* allow escape key to close insiders div */
        elem.on('keyup', function (e) {
            if (e.keyCode === 27) {
                $(".signin-close").click();
            };
        });
    };

    newsTrap($('.signin-overlay'));



    //CART TRAP

    var cartTrap = function (elem) {
        let tabbable = elem.find('select, input, textarea, button, a,button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])').filter(':visible');

        let firstTabbable = tabbable.first();
        let lastTabbable = tabbable.last();
        /*set focus on first input*/
        firstTabbable.focus();

        /*redirect last tab to first input*/
        lastTabbable.on('keydown', function (e) {
            if ((e.which === 9 && !e.shiftKey)) {
                e.preventDefault();
                firstTabbable.focus();
            }
        });

        /*redirect first shift+tab to last input*/
        firstTabbable.on('keydown', function (e) {
            if ((e.which === 9 && e.shiftKey)) {
                e.preventDefault();
                lastTabbable.focus();
            }
        });

        /* allow escape key to close insiders div */
        elem.on('keyup', function (e) {
            if (e.keyCode === 27) {
                $(".cart-close").click();
            };
        });
    };


    $('.cart-trigger').on("click", function (e) {
        // e.preventDefault();
        cartTrap($('.cart-container'));
    });


    //CATEGORY TRAP
    var catTrap = function (elem) {
        let tabbable = elem.find('select, input, textarea, button, a, [href],[tabindex]:not([tabindex="-1"])').filter(':visible');

        let firstTabbable = tabbable.first();
        let lastTabbable = tabbable.last();

        $('.product-categories-list li:first-of-type a').focus();

        lastTabbable.on('keydown', function (e) {
            if ((e.which === 9 && !e.shiftKey)) {
                e.preventDefault();
                firstTabbable.focus();
            }
        });

        firstTabbable.on('keydown', function (e) {
            if ((e.which === 9 && e.shiftKey)) {
                e.preventDefault();
                lastTabbable.focus();
            }
        });

        elem.on('keyup', function (e) {
            if (e.keyCode === 27) {
                $(".header-close-menu").click();
            };
        });
    };


    $('.cat-menu-bt').click(function (e) {
        // e.preventDefault();
        catTrap($('.main-mobile-wrapper'));
    });


    //HEADER SEARCH TRAP
    var startTrap = function (elem) {
        let tabbable = elem.find('select, input, textarea, button, a,button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])').filter(':visible');

        let firstTabbable = tabbable.first();
        let lastTabbable = tabbable.last();
        /*set focus on first input*/
        $(".header-search-form input.search").focus();

        /*redirect last tab to first input*/
        lastTabbable.on('keydown', function (e) {
            if ((e.which === 9 && !e.shiftKey)) {
                e.preventDefault();
                firstTabbable.focus();
            }
        });

        /*redirect first shift+tab to last input*/
        firstTabbable.on('keydown', function (e) {
            if ((e.which === 9 && e.shiftKey)) {
                e.preventDefault();
                lastTabbable.focus();
            }
        });
    };


    $('.search-btn').click(function (e) {
        e.preventDefault();
        startTrap($('.header-search-popup'));
    });

    //Trap Ends



    $(".wc-tabs li").click(function (e) {
        e.preventDefault();
        $(this).parent().siblings().hide();
        var get_id = $(this).attr("id");
        $(this).parent().siblings().filter(`[aria-labelledby*=${get_id}]`).show();
    });

    if ($("section").hasClass("hassidebar")) {
        var test = tns({
            "container": ".testimonial_wrap",
            "autoplay": true,
            "autoplayButtonOutput": false,
            "nav": true,
            "controls": false
        });
        var sale = tns({
            "container": ".sale_wrap",
            "autoplay": true,
            "autoplayButtonOutput": false,
            "nav": true,
            "controls": false
        });
    }

    if ($("section").hasClass("product-single-section")) {
        var prmain = tns({
            "container": ".horizontal-slider",
            "autoplay": true,
            "autoplayButtonOutput": false,
            "nav": false,
            "controls": true,
			"gutter": 20,

            "responsive": {
                0: {
                    "items": 2,
                    "center": false
                },
                320: {
                    "items": 3,
                    "center": true
                },
                480: {
                    "items": 4,
                    "center": false
                },
                768: {
                    "items": 3,
                    "center": true
                },
                1200: {
                    "items": 4,
                    "center": false
                }
            }
        });

        $("ul.products").addClass("owl-carousel owl-theme");
        var relate = $('.owl-carousel').owlCarousel({
            loop: true,
            margin: 10,
            nav: false,
            dots: false,
            margin: 30,
            responsive: {
                0: {
                    items: 1
                },
                768: {
                    items: 2
                },
                992: {
                    items: 3
                },

            }
        });

        $("#new1 .next").click(function () {
            relate.trigger('next.owl.carousel');
        });

        $("#new1 .prev").click(function () {
            relate.trigger('prev.owl.carousel');
        });

        // product zoom
        $('.mainimage').imageZoom({
            zoom: 300
        });

    }

    if (real == "") {
        real = "index.html";
    }
    $(`a.nav__link[href='${real}']`).addClass("active__link");

    $(".nav__link").click(function () {
        $(".nav__link").removeClass("active__link");
        $(this).addClass("active__link");
    });


    // END: ALL PAGE ITEMS
    //====================



// Sticky Header
$(window).on('scroll', function () {
	if ($(window).scrollTop() >= 250) {
		$('.sticky-nav').addClass('sticky-menu');
	} else {
		$('.sticky-nav').removeClass('sticky-menu');
	}
});


//Newsletter Popup
$(".signin-model-details .signin-close").click(function () {
	$(".signin-overlay").addClass("d-none");
	$(".main-header #language").focus();
});


//   Premeter hover

$(".widget_social_widget a, .section-type, #product-single-section .product-single, .menu-right-list li>a, .menu-right-list .arrow .arrow-btn a, .menu-right-list li button, .box-info, .product-grid .grid .slow, .sponsers#sponsers2 .sponser-logo-wrapper, .deal-left-image-wrapper, .sponsers#sponsers1 .sponser-logo-wrapper").on({
    "focus mouseenter": function () {
        $(".widget_social_widget a, .section-type, #product-single-section .product-single, .menu-right-list li>a, .menu-right-list .arrow .arrow-btn a, .menu-right-list li button, .box-info, .product-grid .grid .slow, .sponsers#sponsers2 .sponser-logo-wrapper, .deal-left-image-wrapper, .sponsers#sponsers1 .sponser-logo-wrapper").removeClass("active");
        $(this).addClass("active");
    }
});
//   ______________________________________________________________________

//GRID + LIST VIEW
var defaultcolview = $(".collection ul.products").attr("class");
// console.log(defaultcolview);
$(".gridlist-toggle a").click(function (e) {
    e.preventDefault();
    $(this).siblings().removeClass("view-selected active");
    $(this).addClass("view-selected active");
    var get_attrib = $(this).attr("id");
    $(this).parents("#shop-primary-content").find("ul.products:not(.page-numbers)").removeAttr("class");
    $(this).parents("#shop-primary-content").find("ul:not(.page-numbers)").addClass(`products ${get_attrib} row`);
    if ($(this).parent().siblings("ul.products.row").hasClass("grid")) {
        /* $(this).parents("#st-primary-content").find(".product.type-product").addClass("col-md-6 col-lg-4 col-12"); */
		$(this).parents("#shop-primary-content").find(".product.type-product").removeClass("col-12");
        $(this).parents("#shop-primary-content").find(".product.type-product").addClass("col-md-6 col-lg-4");	
        
        $(this).parents("#shop-primary-content").find(".product-single").removeClass("d-flex");
    }
    if ($(this).parent().siblings("ul.products.row").hasClass("list")) {
        $(this).parents("#shop-primary-content").find(".product.type-product").removeClass("col-md-6 col-lg-4 col-12 col-xl-4");
        $(this).parents("#shop-primary-content").find(".product.type-product").addClass("col-12 ");
        $(this).parents("#shop-primary-content").find(".product-single").addClass("d-flex");
    }
});


// DETAIL-PRODUCT-IMAGE-CHANGING
$(".down-section .product-image-wrapper").click(function (e) {
    var sm_img_add = $(this).find("img").attr("src");
    $("#imageZoom").attr("src", sm_img_add);
    $(".containerZoom").attr("style", `background-image:url('${sm_img_add}'); background-size: 300%;`);
});

// Textwriter
var TxtType = function (el, toRotate, period) {
    this.toRotate = toRotate;
    this.el = el;
    this.loopNum = 0;
    this.period = parseInt(period, 10) || 2000;
    this.txt = '';
    this.tick();
    this.isDeleting = false;
};

TxtType.prototype.tick = function () {
    var i = this.loopNum % this.toRotate.length;
    var fullTxt = this.toRotate[i];

    if (this.isDeleting) {
        this.txt = fullTxt.substring(0, this.txt.length - 1);
    } else {
        this.txt = fullTxt.substring(0, this.txt.length + 1);
    }

    this.el.innerHTML = '<span class="wrap">' + this.txt + '</span>';

    var that = this;
    var delta = 200 - Math.random() * 100;

    if (this.isDeleting) {
        delta /= 2;
    }

    if (!this.isDeleting && this.txt === fullTxt) {
        delta = this.period;
        this.isDeleting = true;
    } else if (this.isDeleting && this.txt === '') {
        this.isDeleting = false;
        this.loopNum++;
        delta = 500;
    }

    setTimeout(function () {
        that.tick();
    }, delta);
};

window.onload = function () {
    var elements = document.getElementsByClassName('typewrite');
    for (var i = 0; i < elements.length; i++) {
        var toRotate = elements[i].getAttribute('data-type');
        var period = elements[i].getAttribute('data-period');
        if (toRotate) {
            new TxtType(elements[i], JSON.parse(toRotate), period);
        }
    }
    // INJECT CSS
    var css = document.createElement("style");
    css.type = "text/css";
    css.innerHTML = ".typewrite > .wrap { border-right: 0.08em solid #fff}";
    document.body.appendChild(css);
};



    // Breadcrumb effect  
    if ($("canvas").attr("id")=="canvas3") {
        const canvas = document.getElementById('canvas3')
        const ctx = canvas.getContext('2d')
        canvas.width = $("#pagetitle").innerWidth()
        canvas.height = $("#pagetitle").innerHeight()
        console.log(canvas);

        let particlesArray = []
        $("#pagetitle").on('resize', function () {
            canvas.width = $("#pagetitle").innerWidth()
            canvas.height = $("#pagetitle").innerHeight()
        })

        const mouse = {
            x: null,
            y: null
        }

        canvas.addEventListener('click', function (e) {
            mouse.x = e.x;
            mouse.y = e.y;
            for (let i = 0; i < 10; i++) {
                particlesArray.push(new Particle())
            }
        })

        canvas.addEventListener('mousemove', function (e) {
            mouse.x = e.x;
            mouse.y = e.y;
            for (let i = 0; i < 10; i++) {
                particlesArray.push(new Particle())
            }
        })
        class Particle {
            constructor() {
                this.x = mouse.x
                this.y = mouse.y
                this.size = Math.random() * 10 + 1;
                this.speedX = Math.random() * 3 - 1.5;
                this.speedY = Math.random() * 3 - 1.5;
                this.color = '#f94892';
            }
            update() {
                this.x += this.speedX;
                this.y += this.speedY;
                if (this.size > 0.2) this.size -= 0.1;
            }

            draw() {
                ctx.strokeStyle = this.color;
                ctx.lineWidth = 0.4;
                ctx.beginPath();
                ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2)
                ctx.stroke()
            }
        }

        function handleParticle() {
            for (let i = 0; i < particlesArray.length; i++) {
                particlesArray[i].update();
                particlesArray[i].draw();

                if (particlesArray[i].size <= 0.3) {
                    particlesArray.splice(i, 1);
                    i--;
                }
            }
        }


        function animate() {
            ctx.clearRect(0, 0, canvas.width, canvas.height)
            handleParticle()
            requestAnimationFrame(animate)
        }


        animate();
    }
	
	
	// <!-- ripples effect -->
	if(jQuery('.offer-sale').length > 0) {
	$(".offer-sale .container-fluid").ripples({
		resolution: 512,
		dropRadius: 20,
		perturbance: 0.04,
	});
	}

	if(jQuery('.page-slider').length > 0) {
	var home_slider = tns({
            "container":".page-slider",
			"nav" : false,
			"controlsText": ["<i class='fa fa-chevron-left'></i>","<i class='fa fa-chevron-right'></i>"],
            "mouseDrag":true,
            "autoplay":true,
            "autoplayButtonOutput":false
        });
	}
	
	if(jQuery('#latest-blog1').length > 0) {
		var blog1 = tns({
			"container": ".blog-slider",
			"mouseDrag": true,
			"nav": false,
			"controlsText": ["<i class='fa fa-chevron-left'></i>","<i class='fa fa-chevron-right'></i>"],
			"controlsPosition": "bottom",
			"autoplayButtonOutput": false,
			"autoplay": true,
			"gutter": "24",
			responsive: {
				0: {
					items: 1
				},
				768: {
					items: 2
				},
				992: {
					items: 3
				}
			}
		});
	}	

		var new_collection1 = $('.testimonial-slider').owlCarousel({
			loop: true,
			margin: 10,
			center: true,
			nav: false,
			dots: false,
			margin: 30,
			items: 3,
			responsive: {
				0: {
					items: 1
				},
				768: {
					items: 1
				},
				992: {
					items: 1
				},
				1200: {
					items: 3
				}
			}
		});
		
		var new_collection1 = $('.widget-testimonial').owlCarousel({
			loop: true,
			center: true,
			nav: false,
			dots: true,
			margin: 0,
			items: 1
		});
		
		
		var new_collection1 = $('.testimonial-slider1').owlCarousel({
			loop: true,
			margin: 10,
			center: true,
			nav: false,
			dots: false,
			margin: 30,
			items: 1,
			responsive: {
				0: {
					items: 1
				},
				768: {
					items: 1
				},
				992: {
					items: 1
				},
				1200: {
					items: 1
				}
			}
		});

		$("#testimonial1 .next").click(function () {
			new_collection1.trigger('next.owl.carousel');
		});

		$("#testimonial1 .prev").click(function () {
			new_collection1.trigger('prev.owl.carousel');
		});

		var new_collection = $('.owl-carousel:not(.testimonial-slider)').owlCarousel({
			loop: true,
			margin: 10,
			nav: true,
			"navText": ["<i class='fa fa-chevron-left'></i>","<i class='fa fa-chevron-right'></i>"],
			dots: false,
			margin: 30,
			responsive: {
				0: {
					items: 1
				},
				768: {
					items: 2
				},
				992: {
					items: 3
				},
				1200: {
					items: 4
				}
			}
		});



		$("#new1 .next").click(function () {
			new_collection.trigger('next.owl.carousel');
		});

		$("#new1 .prev").click(function () {
			new_collection.trigger('prev.owl.carousel');
		});
		$("#trend1 .next").click(function () {
			new_collection.trigger('next.owl.carousel');
		});

		$("#trend1 .prev").click(function () {
			new_collection.trigger('prev.owl.carousel');
		});

		$('.owl-filter-bar').on('click', '.item', function (e) {
			e.preventDefault();
			var $item = $(this);
			var filter = $item.data('owl-filter')
			new_collection.owlcarousel2_filter(filter);
			$item.parentsUntil(".container").next().find(".product.type-product").removeClass(
				"product-shuffle");
			$item.parentsUntil(".container").next().find(".product.type-product").addClass(
				"product-shuffle");
		});

		// cooming soon Timer
		var date = $(".deal-of-the-day .flossy_ct-countdown,.deal_timer .flossy_ct-countdown").attr(
			"data-timer1");
		let msec = Date.parse(`${date}`);
		const d = new Date(msec);
		timer = setInterval(function () {
			timeBetweenDates(d);
		}, 1000);

		function timeBetweenDates(toDate) {
			var dateEntered = toDate;
			var now = new Date();
			var difference = dateEntered.getTime() - now.getTime();
			if (difference <= 0) {
				clearInterval(timer);
			} else {
				var seconds = Math.floor(difference / 1000);
				var minutes = Math.floor(seconds / 60);
				var hours = Math.floor(minutes / 60);
				var days = Math.floor(hours / 24);
				hours %= 24;
				minutes %= 60;
				seconds %= 60;
				$("#days").text(days);
				$("#hours").text(hours);
				$("#minutes").text(minutes);
				$("#seconds").text(seconds);
			}
		}
		// end	
	
	
	//ADD Wishlist POPUP
    $("a").click(function (e) {
        if ($(this).hasClass('add_to_wishlist') || $(this).hasClass('single_add_to_wishlist')) {
            e.preventDefault();
            $(this).attr("href", "javascript:void(0)");
            var check = `
            <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"
                width="70">
                <circle class="checkmark-circle" cx="26" cy="26" r="23" fill="none" />
                <path class="checkmark-check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8" />
            </svg>

            <div>
                <p class="text-center">Item Added to Wishlist</p>
                   </div>`;
            var cart_pop = $('<div id="cart-add-check"></div>').html(check);
            $(cart_pop).appendTo("body");
            setTimeout(function () {
                $(cart_pop).remove();
                $(window).css("pointer-event", "none");
            }, 4000);
            var newval = Number($(".menu-right-list .favourite .yith-wcwl-items-count").html()) + 1;
            $(".menu-right-list .favourite .yith-wcwl-items-count").html(newval);

        }
    });

    //ADD Compare POPUP
    $("a").click(function (e) {
        if ($(this).hasClass('compare-btn') || $(this).hasClass('compare')) {
            e.preventDefault();
            $(this).attr("href", "javascript:void(0)");
            var check = `
            <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"
                width="70">
                <circle class="checkmark-circle" cx="26" cy="26" r="23" fill="none" />
                <path class="checkmark-check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8" />
            </svg>

            <div>
                <p class="text-center">Item Added to Compare</p>
                   </div>`;
            var cart_pop = $('<div id="cart-add-check"></div>').html(check);
            $(cart_pop).appendTo("body");
            setTimeout(function () {
                $(cart_pop).remove();
                $(window).css("pointer-event", "none");
            }, 4000);
            var newval = Number($(".menu-right-list .arrow span").html()) + 1;
            $(".menu-right-list .arrow span").html(newval);

        }
    });
	
	function replaceTextWithIcon() {
		
        // Find all anchor tags with specified classes
        $(".product-action > a").each( function(i) {
            if($(this).hasClass('ajax_add_to_cart')){
				$(this).html('<i class="fa fa-cart-plus"></i>');
			}else if($(this).hasClass('product_type_variable')){
			$(this).html('<i class="fa fa-list"></i>');
			}else {
			$(this).html('<i class="fa fa-arrow-right"></i>');
			}
        });
	}

	// Call the function to replace text with icons
	replaceTextWithIcon();



	/*==========
	Quick View
	==========*/
	// jQuery(".quickview-trigger").click(function(){
		// var product_value =jQuery(this).attr("data-product_id")
	  // var data = {
		// action: 'flossy_quick_view',
		// security : MyAjax.security,
		// flossy_product_d: product_value
	  // };
	  // $.post(MyAjax.ajaxurl, data, function(response) {
		 // jQuery("#theme-quickview-body").html(response);
		 
		
		////Product Slider
        // var $owlProduct = $('.single-product .product .woocommerce-product-gallery__wrapper');
        // var $owlProductThumb = $(".single-product .product .product-control-nav");
        // var $slidesPerPage = 5;
        // var $owledSecondary = true;
        // $owlProduct.owlCarousel({
            // rtl: $("html").attr("dir") == 'rtl' ? true : false,
            // items: 1,
            // autoplay: true,
            // autoplayTimeout: 10000,
            // margin: 0,
            // loop: $('.owl-carousel .item').size() > 1 ? true : false,
            // dots: false,
            // nav: true,
            // navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
            // singleItem: true,
            // transitionStyle: "fade",
            // touchDrag: true,
            // mouseDrag: true,
            // slideSpeed: 2000,
            // responsiveRefreshRate: 200,
            // responsive: {
                // 0: {
                    // nav: false
                // },
                // 992: {
                    // nav: true
                // }
            // }
        // }).on('changed.owl.carousel', owlPosition);
        // $owlProductThumb.on('initialized.owl.carousel', function() {
            // $owlProductThumb.find(".owl-item").eq(0).addClass("current");
        // }).owlCarousel({
            // dots: false,
            // nav: false,
            // margin: 20,
            // smartSpeed: 200,
            // slideSpeed: 500,
            // touchDrag: true,
            // mouseDrag: true,
            // responsiveRefreshRate: 100,
            // responsive: {
                // 0: {
                    // items: 3,
                    // slideBy: 3
                // },
                // 396: {
                    // items: 4,
                    // slideBy: 4
                // },
                // 499: {
                    // items: 5,
                    // slideBy: 5
                // },
                // 768: {
                    // items: 3,
                    // slideBy: 3
                // },
                // 992: {
                    // items: 3,
                    // slideBy: 3
                // },
                // 1400: {
                    // items: 3,
                    // slideBy: 3
                // }
            // }
        // }).on('changed.owl.carousel', owlPosition2);
        // function owlPosition(el) {
            // var count = el.item.count - 1;
            // var current = Math.round(el.item.index - (el.item.count / 2) - .5);
            // if (current < 0) {
                // current = count;
            // }
            // if (current > count) {
                // current = 0;
            // }
            // $owlProductThumb.find(".owl-item").removeClass("current").eq(current).addClass("current");
            // var onscreen = $owlProductThumb.find('.owl-item.active').length - 1;
            // var start = $owlProductThumb.find('.owl-item.active').first().index();
            // var end = $owlProductThumb.find('.owl-item.active').last().index();
            // if (current > end) {
                // $owlProductThumb.data('owl.carousel').to(current, 100, true);
            // }
            // if (current < start) {
                // $owlProductThumb.data('owl.carousel').to(current - onscreen, 100, true);
            // }
        // }
        // function owlPosition2(el) {
            // if ($owledSecondary) {
                // var number = el.item.index;
                // $owlProduct.data('owl.carousel').to(number, 100, true);
            // }
        // }
        // $owlProductThumb.on("click", ".owl-item", function(e) {
            // e.preventDefault();
            // var number = $(this).index();
            // $owlProduct.data('owl.carousel').to(number, 300, true);
        // });


		// jQuery('input[name="quantity"]').change(function(){
			// var q = jQuery(this).val();
			// jQuery('input[name="quantity"]').parent().next().attr('data-quantity', q);
		// });		
	  // });
	  
	   
   // });

});

