/*
// ----- Insert Demand-IQ widget container (CORRECT: not self-closing) -----
(function insertDemandIQDiv() {
// avoid inserting twice
if (document.getElementById('demand-iq-journey')) return;
var html = '';
document.body.insertAdjacentHTML('afterbegin', html);
})();
// ----- Attach click handler to CTA (safe: works even if DemandIQ loads later) -----
(function attachCTAClick() {
function openDemandIQ() {
// Preferred API name (may differ per account). Try common names:
if (window.DemandIQ && typeof window.DemandIQ.openJourney === "function") {
window.DemandIQ.openJourney();
return true;
}
if (window.DemandIQ && typeof window.DemandIQ.open === "function") {
window.DemandIQ.open();
return true;
}
const widget = document.getElementById('demand-iq-journey');
if (widget) { try { widget.click(); return true; } catch(e) { /*ignore } }
return false;
}
document.querySelectorAll('.cta-get-estimate').forEach(function(btn){
btn.addEventListener('click', function(e){
e.preventDefault();
// If embed script not ready, attempt a few times
if (!openDemandIQ()) {
// try again after short delay (gives embed time to initialize)
let attempts = 0;
let id = setInterval(function(){
attempts++;
if (openDemandIQ() || attempts > 10) clearInterval(id);
}, 300);
}
});
});
})();
*/
});