function diet_consultant_openNav() {
  jQuery(".sidenav").addClass('show');
}
function diet_consultant_closeNav() {
  jQuery(".sidenav").removeClass('show');
}

( function( window, document ) {
  function diet_consultant_keepFocusInMenu() {
    document.addEventListener( 'keydown', function( e ) {
      const diet_consultant_nav = document.querySelector( '.sidenav' );

      if ( ! diet_consultant_nav || ! diet_consultant_nav.classList.contains( 'show' ) ) {
        return;
      }
      const elements = [...diet_consultant_nav.querySelectorAll( 'input, a, button' )],
        diet_consultant_lastEl = elements[ elements.length - 1 ],
        diet_consultant_firstEl = elements[0],
        diet_consultant_activeEl = document.activeElement,
        tabKey = e.keyCode === 9,
        shiftKey = e.shiftKey;

      if ( ! shiftKey && tabKey && diet_consultant_lastEl === diet_consultant_activeEl ) {
        e.preventDefault();
        diet_consultant_firstEl.focus();
      }

      if ( shiftKey && tabKey && diet_consultant_firstEl === diet_consultant_activeEl ) {
        e.preventDefault();
        diet_consultant_lastEl.focus();
      }
    } );
  }
  diet_consultant_keepFocusInMenu();
} )( window, document );

var diet_consultant_btn = jQuery('#button');

jQuery(window).scroll(function() {
  if (jQuery(window).scrollTop() > 300) {
    diet_consultant_btn.addClass('show');
  } else {
    diet_consultant_btn.removeClass('show');
  }
});

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

window.addEventListener('load', (event) => {
  jQuery(".loading").delay(2000).fadeOut("slow");
  jQuery(".loading2").delay(2000).fadeOut("slow");
});

jQuery(window).scroll(function() {
  var data_sticky = jQuery('.main-header').attr('data-sticky');

  if (data_sticky == "true") {
    if (jQuery(this).scrollTop() > 1){
      jQuery('.main-header').addClass("stick_header");
    } else {
      jQuery('.main-header').removeClass("stick_header");
    }
  }
});