// When the user scrolls the page, execute myFunction
// Get the navbar
let navbar = document.getElementById("navbar");
if (navbar) {
    window.onscroll = function () {
        myFunction()
    };
    // Get the offset position of the navbar
    let sticky = navbar.offsetTop;

// Add the sticky class to the navbar when you reach its scroll position. Remove "sticky" when you leave the scroll position
    function myFunction() {
        if (window.pageYOffset >= sticky + navbar.clientHeight) {
            navbar.classList.add('sticky');
            document.getElementById('header').style.paddingTop = navbar.clientHeight + 'px';

        } else if (window.pageYOffset < 2) {
            navbar.classList.remove('sticky');
            document.getElementById('header').style.paddingTop = 0 + 'px';
        }
    }
}
