requirejs(['jquery'], function( $ ) {
    $(window).scroll(function () {
        //variables    
        var getHeaderHeight = $('.page-header').innerHeight();
        console.log(getHeaderHeight);
        var scroll = $(window).scrollTop();
        if(scroll >= getHeaderHeight) {
            $(".page-wrapper").addClass("sticky active");
        } else {
            $(".page-wrapper").removeClass("sticky active");
        }
    }); 
});

requirejs(['jquery'], function( $ ){
    $(document).ready(function() {
        let isVerified = getCookie('froot-isAgeVerified');
        console.log("is verified: " + isVerified);
        if (isVerified == "" || isVerified != 'Ja') {
            /* APPEND BOX TO CONTENT */
            $('.page-wrapper').addClass('froot-noscroll');
            var loginBox = '<div id="froot-verification" class="froot-verification-wrapper"><div class="froot-verification-outer"><div class="froot-verification-inner"><p class="froot-verification-headline">Bist du 18, oder älter?</p><div class="froot-linklist"><div class="froot-verification-accept froot-verification-button">Ja</div><div class="froot-verification-decline froot-verification-button">Nein</div></div></div></div></div>';
            $('body').append(loginBox);
            $('.froot-verification-accept').on('click', function() {
                setCookie('froot-isAgeVerified', 'Ja', 365);
                $('.page-wrapper').removeClass('froot-noscroll');
                $('#froot-verification').remove();
            });
            $('.froot-verification-decline').on('click', function() {
                document.location.href = "https://www.schaukastl-lofer.at/";
            });
        }
    });
    function getCookie(cname) {
        let name = cname + "=";
        let decodedCookie = decodeURIComponent(document.cookie);
        let ca = decodedCookie.split(';');
        for(let i = 0; i <ca.length; i++) {
            let c = ca[i];
            while (c.charAt(0) == ' ') {
            c = c.substring(1);
            }
            if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
            }
        }
    return "";
    }
    function setCookie(cname, cvalue, exdays) {
        const d = new Date();
        d.setTime(d.getTime() + (exdays*24*60*60*1000));
        let expires = "expires="+ d.toUTCString();
        document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
    }
});