jQuery(document).ready(function ($) {
    // clone the header and set up the cloned header to show on scroll
    var $header = $('header');
    var $body = $('body');
    
    $(window).scroll(function () {
        var distance_from_top = $(window).scrollTop();
        if (distance_from_top > 150) {
            $body.addClass('scrolled');
        }
        else {
            $body.removeClass('scrolled');
        }
    });
    
    
    var menu_hover_timeout;
    $("header li.menu_header_item_parent").hover(
        function() {
            
            let $menu_pane = $(this).find('> ul');
            
            if (!menu_hover_timeout) {
                menu_hover_timeout = window.setTimeout(function() {
                    menu_hover_timeout = null;
                    $menu_pane.slideDown(100);
               }, 100);
            }
        },
        function () {
            
            let $menu_pane = $(this).find('> ul');
            
            if (menu_hover_timeout) {
                window.clearTimeout(menu_hover_timeout);
                menu_hover_timeout = null;
            }
            else {
               $menu_pane.slideUp(100);
            }
        }
    );


});
