// intialization plugins
$(document).ready(function () {

    //animation icon toggler of navbar
    $(`.navbar-toggler`).click(function() {
        $(`.navbar-toggler`).toggleClass(`active`);
    });

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

    //fancybox
    $("[data-fancybox]").fancybox({
        selector: '[data-fancybox="images"]',
        // loop: true
    });

    //  loader 
    // $(window).on("load", function() {
    //     $("#preloader").addClass("isdone");
    // });

});

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

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





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

});

document.querySelectorAll('.real_card').forEach(function (card) {
    const swiperContainer = card.querySelector('.real_img_swiper');

    const swiper = new Swiper(swiperContainer, {
        speed: 900,
        slidesPerView: 1,
        spaceBetween: 15,
        effect: 'fade',
        autoplay: {
            delay: 100,
            disableOnInteraction: false
        },
        navigation: {
            nextEl: card.querySelector('.swiper-button-next'),
            prevEl: card.querySelector('.swiper-button-prev'),
        },
        pagination: {
            el: card.querySelector('.swiper-pagination'),
            clickable: true
        },
    });

    // نوقف autoplay أول ما الصفحة تفتح
    swiper.autoplay.stop();

    // لما نعمل hover على الكارد ده، نشغل autoplay
    card.addEventListener('mouseenter', function () {
        swiper.autoplay.start();
    });

    // ولما نخرج منه، نوقف autoplay
    card.addEventListener('mouseleave', function () {
        swiper.autoplay.stop();
    });
});


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

document.addEventListener("DOMContentLoaded", function () {
    var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
    tooltipTriggerList.forEach(function (tooltipTriggerEl) {
      new bootstrap.Tooltip(tooltipTriggerEl)
    })
});