/**
 * COOKIE PRO FALLBACK SCROLLING
 *
 * class hook name: EUc-message-active
 */

window.addEventListener('load', function(){
  var cookieInterval = setInterval(function(){
    if (document.querySelector('#optanon')) {
      
      var html = document.querySelector('html');
      
      if (!html.classList.contains('noScroll')) {
        html.classList.add('noScroll');
      }
      
      if(document.querySelector('.optanon-allow-all.accept-cookies-button')) {
        document.querySelector('.optanon-allow-all.accept-cookies-button').addEventListener('click', function(){
          html.classList.remove('noScroll');
        });
      }
      
      if(document.querySelector('.optanon-alert-box-close.banner-close-button')) {
        document.querySelector('.optanon-alert-box-close.banner-close-button').addEventListener('click', function(){
          html.classList.remove('noScroll');
        });
      }
      
      clearInterval(cookieInterval);
    }
  }, 100);
});
