$(document).ready(function() {
  // Sticky Navigation
  let lastScrollTop = 0;
  document.addEventListener("scroll", function(e){ 
    let header = document.querySelector('.headercontainer')
    let st = window.pageYOffset || document.documentElement.scrollTop; 
    if (st > lastScrollTop){
      if(window.pageYOffset > 0){
        header.classList.add('sticky'); 
     }
     if(window.pageYOffset > 500){
         header.classList.add('sticky-hide');
     }
     } else {
       if(window.pageYOffset == 0){
          header.classList.remove('sticky'); 
       }else {
          header.classList.remove('sticky-hide');
       }
     }
     lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling
  }, false);
});