`;
formWrapper.style.maxWidth = 'none';
formWrapper.style.padding = '0';
}
window.scrollTo(0,0);
return;
} else {
console.warn('wpcf7mailsent fired for an unhandled CF7 Form ID:', submittedFormIdString, '- Expected', expectedFormId);
tsResetLoadingButtons();
if (formWrapper) {
formWrapper.innerHTML = `
Thank You!
Your information has been submitted.
`;
}
}
}, false);
function tsResetButton(buttonElement, defaultText) {
if (buttonElement) {
buttonElement.classList.remove('ts-loading');
buttonElement.disabled = false;
buttonElement.innerHTML = defaultText;
}
}
function tsResetLoadingButtons() {
const btns = document.querySelectorAll('.ts-btn.ts-loading');
btns.forEach(b => tsResetButton(b, b.classList.contains('ts-btn-skip') ? 'Skip Details & Book a Call' : (b.textContent.includes('Quote') ? 'Get Your Quote' : 'Continue')));
}
document.addEventListener('wpcf7invalid', function(event) {
console.error('CF7 validation failed:', event.detail);
tsResetLoadingButtons();
alert('Validation failed. Please check all required fields and try again.');
});
document.addEventListener('wpcf7mailfailed', function(event) {
console.error('CF7 mail failed:', event.detail);
tsResetLoadingButtons();
alert('Submission failed. Please check your internet connection and try again. If the issue persists, please contact us directly.');
});
})(); // End of IIFE