/* Your header is fixed/overlay, so it floats on top of page content.
Push the bar down by the header's height so the nav and logo sit on
the normal page background instead of on top of the dark bar.
Re-measured on resize, and again after layout settles. */
function offsetForHeader(bar) {
var header = document.querySelector('#header')
|| document.querySelector('header#header')
|| document.querySelector('.header');
if (!header) return;
var pos = window.getComputedStyle(header).position;
if (pos === 'fixed' || pos === 'sticky' || pos === 'absolute') {
var h = Math.round(header.getBoundingClientRect().height);
bar.style.marginTop = h > 0 ? h + 'px' : '';
} else {
bar.style.marginTop = '';
}
}
var tries = 0;
function place() {
if (document.getElementById('lbt-awards-bar')) return;
var host = document.getElementById('sections')
|| document.querySelector('main#page')
|| document.querySelector('#page')
|| document.querySelector('main');
if (!host) {
if (++tries < 40) setTimeout(place, 150);
return;
}
var bar = build();
host.insertBefore(bar, host.firstChild);
offsetForHeader(bar);
setTimeout(function () { offsetForHeader(bar); }, 400);
setTimeout(function () { offsetForHeader(bar); }, 1200);
var t;
window.addEventListener('resize', function () {
clearTimeout(t);
t = setTimeout(function () { offsetForHeader(bar); }, 150);
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', place);
} else {
place();
}
})();