jQuery(function($) {

    /* -----------------------------------------
    Preloader
    ----------------------------------------- */
    $('#preloader').delay(1000).fadeOut();
    $('#loader').delay(1000).fadeOut("slow");

    /* -----------------------------------------
    Navigation
    ----------------------------------------- */
    $('.menu-toggle').click(function() {
        $(this).toggleClass('open');
    });

    /* -----------------------------------------
    Keyboard Navigation
    ----------------------------------------- */
    $(window).on('load resize', technology_software_firm_navigation)

    function technology_software_firm_navigation(event) {
        if ($(window).width() < 1200) {
            $('.main-navigation').find("li").last().bind('keydown', function(e) {
                if (e.technology_software_firm_shiftKey && e.which === 9) {
                    if ($(this).hasClass('focus')) {
                    }

                } else if (e.which === 9) {
                    e.preventDefault();
                    $('#masthead').find('.menu-toggle').focus();
                }                
            })
        } else {
            $('.main-navigation').find("li").unbind('keydown')
        }
    }

    technology_software_firm_navigation()

    var technology_software_firm_primary_menu_toggle = $('#masthead .menu-toggle');
    technology_software_firm_primary_menu_toggle.on('keydown', function(e) {
        var technology_software_firm_tabKey = e.keyCode === 9;
        var technology_software_firm_shiftKey = e.technology_software_firm_shiftKey;

        if (technology_software_firm_primary_menu_toggle.hasClass('open')) {
            if (technology_software_firm_shiftKey && technology_software_firm_tabKey) {
                e.preventDefault();
                const $technology_software_firm_the_last_li = $('.main-navigation').find("li").last()
                $technology_software_firm_the_last_li.find('a').focus()
                if (!$technology_software_firm_the_last_li.hasClass('focus')) {

                    const $technology_software_firm_is_parent_on_top = true
                    let $technology_software_firm_the_parent_ul = $technology_software_firm_the_last_li.closest('ul.sub-menu')

                    let technology_software_firm_count = 0

                    while (!!$technology_software_firm_the_parent_ul.length) {
                        ++technology_software_firm_count

                        const $technology_software_firm_the_parent_li = $technology_software_firm_the_parent_ul.closest('li')

                        if (!!$technology_software_firm_the_parent_li.length) {
                            $technology_software_firm_the_parent_li.addClass('focus')
                            $technology_software_firm_the_parent_ul = $technology_software_firm_the_parent_li.closest('ul.sub-menu')

                            // Blur the cross
                            $(this).blur()
                            $technology_software_firm_the_last_li.addClass('focus')
                        }

                        if (!$technology_software_firm_the_parent_ul.length) {
                            break;
                        }
                    }

                }

            };
        }
    })

    // Determine if the document is RTL
    var isRtl = $('html').attr('dir') === 'rtl';

    /* -----------------------------------------
    Scroll Top
    ----------------------------------------- */
    var technology_software_firm_scrollToTopBtn = $('.technology-software-firm-scroll-to-top');

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

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

});