(function ($) {
    jQuery(document).ready(function () {

        /* ---------------------------------------------- /*
         * SLIDER
         /* ---------------------------------------------- */
        $(".owl-carousel").on("initialized.owl.carousel", () => {
            setTimeout(() => {
                $(".owl-item.active .owl-slide-animated").addClass("is-transitioned");
                $("section").show();
            }, 200);
        });

        jQuery('.owl-Testimonial').owlCarousel({
            loop: true,
            margin: 10,
            nav: false,
            dots: false,
            navText: ["<i class='fa fa-chevron-left'></i>", "<i class='fa fa-chevron-right'></i>"

            ],
            autoplay: true,
            autoplayHoverPause: true,
            responsive: {
                0: {
                    items: 1
                },
                600: {
                    items: 1
                },
                1200: {
                    items: 3
                }
            }
        });

        const $owlCarousel = $(".sliderhome").owlCarousel({
            items: 1,
            loop: true,
            dots: false,
            autoplay: true,
            navElement: 'div',
            nav: true,
            navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"]
        });

        $owlCarousel.on("changed.owl.carousel", e => {
            $(".owl-slide-animated").removeClass("is-transitioned");

            const $currentOwlItem = $(".owl-item").eq(e.item.index);
            $currentOwlItem.find(".owl-slide-animated").addClass("is-transitioned");

            const $target = $currentOwlItem.find(".owl-slide-text");
            doDotsCalculations($target);
        });

        $owlCarousel.on("resize.owl.carousel", () => {
            setTimeout(() => {
                setOwlDotsPosition();
            }, 50);
        });

        /*if there isn't content underneath the carousel*/
//$owlCarousel.trigger("refresh.owl.carousel");

        setOwlDotsPosition();

        function setOwlDotsPosition() {
            const $target = $(".owl-item.active .owl-slide-text");
            doDotsCalculations($target);
        }

        function doDotsCalculations(el) {
            const height = el.height();

            const res = height;

        }

        /**
         * Scroll top
         */
        jQuery(window).scroll(function () {
            if (jQuery(this).scrollTop() > 100) {
                jQuery('.page-scroll-up').fadeIn();
            } else {
                jQuery('.page-scroll-up').fadeOut();
            }
        });

        jQuery('a[href="#totop"]').click(function () {
            jQuery('html, body').animate({scrollTop: 0}, 'slow');
            return false;
        });


        /**
         * @todo
         */
//        jQuery('.prt_view').magnificPopup({
//            type: 'image',
//            gallery: {
//                enabled: true
//            }
//        });

        jQuery('.page-scroll-up').click(function () {
            jQuery("html, body").animate({
                scrollTop: 0
            }, 700);
            return false;
        });

        jQuery('.owl-client').owlCarousel({
            loop: true,
//            margin: 10,
            dots: false,
            nav: false,
            navText: ["<i class='fa fa-chevron-left'></i>", "<i class='fa fa-chevron-right'></i>"

            ],
            autoplay: true,
            autoplayHoverPause: true,
            responsive: {
                0: {
                    items: 1
                },
                600: {
                    items: 3
                },
                1200: {
                    items: 5
                }
            }
        });

        new WOW().init();

    });
})(jQuery);