Skip to content
Skip to content
document.addEventListener('DOMContentLoaded', function () {
var btn = document.getElementById('submit-ai-question');
var input = document.getElementById('ai-question');
var loading = document.getElementById('ai-loading');
var box = document.getElementById('ai-response');
var text = document.getElementById('ai-response-text');
if (!btn || !input || !loading || !box || !text) return;
btn.addEventListener('click', function () {
var q = input.value.trim();
if (!q) return;
loading.style.display = 'block';
box.style.display = 'none';
box.style.opacity = 0;
fetch('https://hooks.zapier.com/hooks/catch/21429105/2nkr6c1/', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ question: q })
})
.then(function () {
loading.style.display = 'none';
box.style.display = 'block';
setTimeout(function () {
box.style.opacity = 1;
}, 50);
text.innerText = "✅ Question submitted. AI response will appear soon.";
})
.catch(function () {
loading.style.display = 'none';
box.style.display = 'block';
text.innerText = "❌ Error sending question.";
});
});
btn.addEventListener('mouseover', function () {
btn.style.backgroundColor = '#4f8a61';
});
btn.addEventListener('mouseout', function () {
btn.style.backgroundColor = '#6daa75';
});
});