(function() {
function adjustZIndex() {
const accordions = document.querySelectorAll('.multi-visa-accordion');
accordions.forEach(function(accordion) {
const hasOpenItem = accordion.querySelector('.multi-visa-accordion-item.brx-open');
if (hasOpenItem) {
accordion.classList.add('adjust-zindex');
} else {
accordion.classList.remove('adjust-zindex');
}
});
}
// Run immediately
adjustZIndex();
// Run when the DOM is fully loaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', adjustZIndex);
}
// Run when the window has finished loading
window.addEventListener('load', adjustZIndex);
// Optional: Run periodically (every 500ms) for a short time after page load
let checkCount = 0;
const intervalId = setInterval(function() {
adjustZIndex();
checkCount++;
if (checkCount >= 10) { // Stop after 5 seconds (10 * 500ms)
clearInterval(intervalId);
}
}, 500);
})();