var elements = document.getElementsByClassName("menu");

var menuClick = function() {
    Array.from(elements).forEach(function(element) {
        element.children[0].classList.remove("active");
      });
    this.children[0].classList.add("active");
    document.getElementById("navbar").getElementsByTagName("i")[0].click();
};

Array.from(elements).forEach(function(element) {
    element.addEventListener('click', menuClick);
  });
  document.addEventListener("DOMContentLoaded", function(){
    window.addEventListener('scroll', function() {
        if (window.scrollY > 50) {
          document.getElementById('header').classList.add('fixed-top');
          // add padding top to show content behind navbar
          navbar_height = document.querySelector('.header').offsetHeight;
          document.body.style.paddingTop = navbar_height + 'px';
        } else {
          document.getElementById('header').classList.remove('fixed-top');
           // remove padding top from body
          document.body.style.paddingTop = '0';
        } 
    });
  }); 