$(document).ready(function() {
    $(".product-simple-body-description").hide();
    $(".product-simple-body-other").hide();
    $(".product-simple-body-reviews").show();
    $("#dashboard-tab").show();
    $("#orders-tab").hide();
    $("#payment-tab").hide();
    $("#address-tab").hide();
    $("#account-tab").hide();
});

(function ($) {
    "use strict";

    // Spinner
    var spinner = function () {
        setTimeout(function () {
            if ($('#spinner').length > 0) {
                $('#spinner').removeClass('show');
            }
        }, 1);
    };
    spinner();
    
    
    // Initiate the wowjs
    new WOW().init();


    // Sticky Navbar
    $(window).scroll(function () {
        if ($(this).scrollTop() > 45) {
            $('.navbar').addClass('sticky-top shadow-sm');
        } else {
            $('.navbar').removeClass('sticky-top shadow-sm');
        }
    });
    
    
    // Back to top button
    $(window).scroll(function () {
        if ($(this).scrollTop() > 100) {
            $('.back-to-top').fadeIn('slow');
        } else {
            $('.back-to-top').fadeOut('slow');
        }
    });
    $('.back-to-top').click(function () {
        $('html, body').animate({scrollTop: 0}, 1500, 'easeInOutExpo');
        return false;
    });


    // Skills
    $('.skill').waypoint(function () {
        $('.progress .progress-bar').each(function () {
            $(this).css("width", $(this).attr("aria-valuenow") + '%');
        });
    }, {offset: '80%'});


    // Facts counter
    $('[data-toggle="counter-up"]').counterUp({
        delay: 10,
        time: 2000
    });


    // Testimonials carousel
    $(".testimonial-carousel").owlCarousel({
        autoplay: true,
        smartSpeed: 1000,
        margin: 25,
        dots: false,
        loop: true,
        nav : true,
        navText : [
            '<i class="bi bi-chevron-left"></i>',
            '<i class="bi bi-chevron-right"></i>'
        ],
        responsive: {
            0:{
                items:1
            },
            992:{
                items:2
            }
        }
    });


    // Portfolio isotope and filter
    var portfolioIsotope = $('.portfolio-container').isotope({
        itemSelector: '.portfolio-item',
        layoutMode: 'fitRows'
    });
    $('#portfolio-flters li').on('click', function () {
        $("#portfolio-flters li").removeClass('active');
        $(this).addClass('active');

        portfolioIsotope.isotope({filter: $(this).data('filter')});
    });
    
})(jQuery);

$(".ProductFrontPage").click(function () {
    location.href = "product-simple.html";
});

$("#search-button-product").click(function () {
    location.href = "list-layout.html";
});

//Product Simple [electronics]
$(".product-details-choose-image-1").click(function () {
    $(".product-details-image").attr("src","img/product-details-main-2.jpg");
});

$(".product-details-choose-image-2").click(function () {
    $(".product-details-image").attr("src","img/product-details-main-3.jpg");
});

$(".product-details-choose-image-3").click(function () {
    $(".product-details-image").attr("src","img/product-details-main-5.jpg");
});

$(".product-simple-btn-description").click(function () {
    $(".product-simple-body-description").show();
    $(".product-simple-body-other").hide();
    $(".product-simple-body-reviews").hide();
});

$(".product-simple-btn-other").click(function () {
    $(".product-simple-body-description").hide();
    $(".product-simple-body-other").show();
    $(".product-simple-body-reviews").hide();
});

$(".product-simple-btn-reviews").click(function () {
    $(".product-simple-body-description").hide();
    $(".product-simple-body-other").hide();
    $(".product-simple-body-reviews").show();
});

$(".btn-add-to-cart").click(function () {
    location.href = "cart.html";
});

//Product Simple [fashion]
$(".product-details-choose-image-1-b").click(function () {
    $(".product-details-image-b").attr("src","img/product-details-main-6.jpg");
});

$(".product-details-choose-image-2-b").click(function () {
    $(".product-details-image-b").attr("src","img/product-details-main-7.jpg");
});

$(".product-details-choose-image-3-b").click(function () {
    $(".product-details-image-b").attr("src","img/product-details-main-8.jpg");
});

$(".btn-buy-now").click(function () {
    location.href = "checkout.html";
});

//Cart
$(".btn-delete-element-1").click(function () {
    $(".cart-element-1").hide();
});

$(".btn-delete-element-2").click(function () {
    $(".cart-element-2").hide();
});

$(".btn-delete-element-3").click(function () {
    $(".cart-element-3").hide();
});

//Profile
$("#dashboard-nav").click(function() {
    $("#dashboard-tab").show();
    $("#orders-tab").hide();
    $("#payment-tab").hide();
    $("#address-tab").hide();
    $("#account-tab").hide();
    $("#dashboard-nav").addClass("active");
    $("#orders-nav").removeClass("active");
    $("#payment-nav").removeClass("active");
    $("#address-nav").removeClass("active");
    $("#account-nav").removeClass("active");
});

$("#orders-nav").click(function() {
    $("#dashboard-tab").hide();
    $("#orders-tab").show();
    $("#payment-tab").hide();
    $("#address-tab").hide();
    $("#account-tab").hide();
    $("#dashboard-nav").removeClass("active");
    $("#orders-nav").addClass("active");
    $("#payment-nav").removeClass("active");
    $("#address-nav").removeClass("active");
    $("#account-nav").removeClass("active");
});

$("#payment-nav").click(function() {
    $("#dashboard-tab").hide();
    $("#orders-tab").hide();
    $("#payment-tab").show();
    $("#address-tab").hide();
    $("#account-tab").hide();
    $("#dashboard-nav").removeClass("active");
    $("#orders-nav").removeClass("active");
    $("#payment-nav").addClass("active");
    $("#address-nav").removeClass("active");
    $("#account-nav").removeClass("active");
});

$("#address-nav").click(function() {
    $("#dashboard-tab").hide();
    $("#orders-tab").hide();
    $("#payment-tab").hide();
    $("#address-tab").show();
    $("#account-tab").hide();
    $("#dashboard-nav").removeClass("active");
    $("#orders-nav").removeClass("active");
    $("#payment-nav").removeClass("active");
    $("#address-nav").addClass("active");
    $("#account-nav").removeClass("active");
});

$("#account-nav").click(function() {
    $("#dashboard-tab").hide();
    $("#orders-tab").hide();
    $("#payment-tab").hide();
    $("#address-tab").hide();
    $("#account-tab").show();
    $("#dashboard-nav").removeClass("active");
    $("#orders-nav").removeClass("active");
    $("#payment-nav").removeClass("active");
    $("#address-nav").removeClass("active");
    $("#account-nav").addClass("active");
});

//Cart
$("#updateCart").click(function() {
    document.location.reload();
});

$("#checkOut").click(function() {
    location.href = "checkout.html";
});

$(".btn-cart-row-1").click(function() {
    $(".cart-row-1").hide();
});

$(".btn-cart-row-2").click(function() {
    $(".cart-row-2").hide();
});

$(".btn-cart-row-3").click(function() {
    $(".cart-row-3").hide();
});

$(".btn-cart-row-4").click(function() {
    $(".cart-row-4").hide();
});

$(".btn-cart-row-5").click(function() {
    $(".cart-row-5").hide();
});