
mybutton = document.getElementById("myBtn");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};
document.addEventListener("DOMContentLoaded", function(){
  window.addEventListener('scroll', function() {
      if (window.scrollY > 50) {
        document.getElementById('navbar').classList.add('is-sticky');
        // add padding top to show content behind navbar
        navbar_height = document.querySelector('.navbar').offsetHeight;
        document.body.style.paddingTop = navbar_height + 'px';
      } else {
        document.getElementById('navbar').classList.remove('is-sticky');
         // remove padding top from body
        document.body.style.paddingTop = '0';
      } 
  });
  
}); 

function scrollFunction() {
  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
    mybutton.style.display = "block";
  } else {
    mybutton.style.display = "none";
  }
}
function stickynavbar(){
	var a=document.getElementById("navbar");
	document.addEventListener("scroll",(function(){
		window.scrollY>170?a.classList.add("is-sticky"):a.classList.remove("is-sticky")
		}));
	}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
  document.body.scrollTop = 0; // For Safari
  document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}

// document.onreadystatechange = function() {
            // if (document.readyState !== "complete") {
                // document.querySelector(
                  // "body").style.visibility = "hidden";
                // document.querySelector(
                  // ".loader-content").style.visibility = "visible";
            // } else {
                // document.querySelector(
                  // ".loader-content").style.display = "none";
                // document.querySelector(
                  // "body").style.visibility = "visible";
            // }
        // };



