document.addEventListener("DOMContentLoaded", ()=> {
    const headerStyleOne = document.querySelector(".header-style-one"),
          screenReader = document.querySelectorAll(".screen-reader"),
          adaClose = document.getElementById("#ada_close_option"),
          removeMargin = document.querySelector(".hp-slideshow") || document.querySelector(".insidepage");
    if (screenReader.length > 0) {
        screenReader[0].style.zIndex = "11";
        headerStyleOne.style.cssText = `
            position: -webkit-sticky;
            position: sticky;
        `
        if (removeMargin.classList.contains("insidepage")) {
            removeMargin.style.paddingTop = "0";
        } else {
            removeMargin.style.paddingTop = "0";
        }
    }
    
    let currentScrollPoint = 0;
    function checkNavVisibility () {
        if(!headerStyleOne.classList.contains("hidden")) {
            if(window.scrollY > (headerStyleOne.offsetHeight * 2), headerStyleOne.offsetHeight) {
                if(window.scrollY >= currentScrollPoint && window.scrollY > (headerStyleOne.offsetHeight * 2)) {
                    headerStyleOne.classList.remove("sticky");
                } else {
                    headerStyleOne.classList.add("sticky");
                }
            } else {
                headerStyleOne.classList.add("static");
            }
            currentScrollPoint = window.scrollY;
        }
    }
    setTimeout(() => {
       document.addEventListener("scroll", checkNavVisibility, { capture: false, passive: true});
        headerStyleOne.classList.add("sticky"); 
    }, 800)
})