document.addEventListener('DOMContentLoaded', function () { const contactForm = document.getElementById('contact-form'); const contactAlert = document.getElementById('contact-alert'); if (contactForm) { contactForm.addEventListener('submit', function (e) { e.preventDefault(); const formData = new FormData(contactForm); const button = contactForm.querySelector('button[type="submit"]'); const originalButtonText = button.innerHTML; button.disabled = true; button.innerHTML = ' Sending...'; fetch('contact.php', { method: 'POST', body: formData }) .then(response => response.json()) .then(data => { if (data.success) { contactAlert.innerHTML = ``; contactForm.reset(); } else { contactAlert.innerHTML = ``; } }) .catch(error => { contactAlert.innerHTML = ``; }) .finally(() => { button.disabled = false; button.innerHTML = originalButtonText; }); }); } // Activate scrollspy var scrollSpy = new bootstrap.ScrollSpy(document.body, { target: '#navbar' }); });