    'use strict';
  
    let dir = $("html").attr("dir"),
        rtl = true;
    if (dir == "rtl"){
        $("#bs_dir").attr("href", "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.rtl.min.css");
    } else { 
        rtl = false;
        $("#bs_dir").attr("href", "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css");
    }
     
    /*---------------------------------------------------
        Form validation
    ---------------------------------------------------*/

    var forms = document.querySelectorAll('.needs-validation');
    Array.prototype.slice.call(forms).forEach(function (form) {
        form.addEventListener('submit', function (event) {
            if (!form.checkValidity()) {
                event.preventDefault()
                event.stopPropagation()
            }
            form.classList.add('was-validated')
        }, false)
    });
 
    /*---------------------------------------------------
       form-contact-us
    ---------------------------------------------------*/

    $("form").on("submit", function (e){
        e.preventDefault();
        var _form = $(this);
        if (_form[0].checkValidity() === false) {
            e.stopPropagation();
        } else {
            _form.find(".btn-submit .spinner-border").toggleClass("d-none");
            _form.addClass("disabled");

            setTimeout(function (){
                swal({
                    title: "بارك الله فيك",
                    text: "في ميزان حسناتك ان شاء الله ، شكرا لك من القلب",
                    icon: "success",
                    timer: 3000
                });
                _form.find(".btn-submit .spinner-border").toggleClass("d-none");
                _form.removeClass("disabled was-validated");
                _form[0].reset();
            }, 3000);
        }
    });

     
    /*---------------------------------------------------
       tooltip
    ---------------------------------------------------*/

    var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
    var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
        return new bootstrap.Tooltip(tooltipTriggerEl)
    })

    /*---------------------------------------------------
       Fancybox
    ---------------------------------------------------*/
 
    Fancybox.defaults.infinite = 0; 
    Fancybox.bind("[data-fancybox]", {
        infinite: false,
    });
 
    /*---------------------------------------------------
        Pincode
    ---------------------------------------------------*/

    $(document).ready(function() { 
        $(".pincode input").jqueryPincodeAutotab(); 
    });

/*
    $(document).ready(function() {
		$(document).scroll(function () {
			var scroll = $(this).scrollTop();
			var topDist = $(".top-nav").position();
			if (scroll > (topDist.top + 1 )) {
				$(".top-nav").addClass("fixed-top");
			} else {
				$(".top-nav").removeClass("fixed-top"); 
			} 
		}); 
	}); 
	
    /*---------------------------------------------------
		Slider Header ....
    ---------------------------------------------------*/

	$('#header').owlCarousel({
		rtl: rtl,
		loop: false,
		margin: 0,
		nav: false,
		dots: true,
		items:1,
        autoplay: true
	});

	$('#service').owlCarousel({
		rtl: rtl,
		loop: false,
		margin: 15,
		nav: true,
		dots: true,
        navText: ['<i class="bi bi-chevron-right"></i>', '<i class="bi bi-chevron-left"></i>'],
		responsiveClass:true,
        responsive:{
            0:{
                items:2,
                nav:false
            },
            600:{
                items:3,
                nav:false
            },
            1000:{
                items:5,
                nav:false,
            },
            1400:{
                items:7,
                nav:true
            }
        },
        autoplay: true,
	});

	$('#partner').owlCarousel({
		rtl: rtl,
		loop: false,
		margin: 15,
		nav: true,
		dots: false,
        navText: ['<i class="bi bi-chevron-right"></i>', '<i class="bi bi-chevron-left"></i>'],
		responsiveClass:true,
        responsive:{
            0:{
                items:2,
                nav:false
            },
            600:{
                items:3,
                nav:false
            },
            1000:{
                items:5,
                nav:true,
            },
            1400:{
                items:6,
                nav:true
            }
        },
        autoplay: true,
	});

    /*---------------------------------------------------
		countUp
    ---------------------------------------------------*/

	$('.achievements-box .count').countUp({
		'time': 2000,
		'delay': 30
	});
	$('.money-box .count, .research-box .count').countUp({
		'time': 5000,
		'delay': 30
	});

    /*---------------------------------------------------
		loading-page
    ---------------------------------------------------*/

    setTimeout(function(){
        $(".loading-page").slideUp(500)
    }, 1500);

    /*---------------------------------------------------
		AOS
    ---------------------------------------------------*/

    AOS.init();

    /*---------------------------------------------------
		about sidebar
    ---------------------------------------------------*/

    $(".about-sidebar .nav-link").on("click", function(){
        $("#about-sidebar.show").removeClass("show");
    });


    /*---------------------------------------------------
		about sidebar
    ---------------------------------------------------*/

    $(".media-box.gallery").on("click", function(e){
        e.preventDefault();
        var galleryID = $(this).data("gallery-id");
     // alert(galleryID);

        var _gallery_array = [];
        Fancybox.show(
            [
                {
                    src: "https://lipsum.app/id/98/800x600",
                    type: "image",
                },
                {
                    src: "https://lipsum.app/id/99/800x600",
                    type: "image",
                },
            ],
            {
                infinite: false,
            }
        );
    });

    $(".media-box.video").on("click", function(e){
        e.preventDefault();
        var videoID = $(this).data("video-id");
     // alert(videoID); 
        Fancybox.show(
            [
                {
                    src: "https://www.youtube.com/watch?v=Pgc2vzrlwok",
                    type: "video",
                },
                {
                    src: "https://vimeo.com/226053498",
                    type: "video",
                },
            ],
            {
                infinite: false,
            }
        );
    });
 