/* ========================================================================== MannySpeaking.com — JS ========================================================================== */ document.addEventListener('DOMContentLoaded', function () { // ---------- Sticky Nav on Scroll ---------- const nav = document.querySelector('.nav'); const handleScroll = () => { if (window.scrollY > 30) { nav.classList.add('scrolled'); } else { nav.classList.remove('scrolled'); } }; window.addEventListener('scroll', handleScroll, { passive: true }); handleScroll(); // ---------- Mobile Nav Toggle ---------- const navToggle = document.querySelector('.nav__toggle'); const navLinks = document.querySelector('.nav__links'); if (navToggle && navLinks) { navToggle.addEventListener('click', () => { navLinks.classList.toggle('active'); }); // Close mobile menu when link clicked navLinks.querySelectorAll('a').forEach(link => { link.addEventListener('click', () => { navLinks.classList.remove('active'); }); }); } // ---------- Reveal Animations on Scroll ---------- const revealElements = document.querySelectorAll('.reveal'); if ('IntersectionObserver' in window) { const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('in-view'); observer.unobserve(entry.target); } }); }, { threshold: 0.15, rootMargin: '0px 0px -50px 0px' }); revealElements.forEach(el => observer.observe(el)); } else { revealElements.forEach(el => el.classList.add('in-view')); } // ---------- Animated Counter for Stats ---------- const statNumbers = document.querySelectorAll('.stat__number[data-target]'); if ('IntersectionObserver' in window && statNumbers.length > 0) { const animateCounter = (el) => { const target = parseInt(el.getAttribute('data-target'), 10); const suffix = el.getAttribute('data-suffix') || ''; const duration = 1800; const start = Date.now(); const startVal = 0; const tick = () => { const elapsed = Date.now() - start; const progress = Math.min(elapsed / duration, 1); // Ease-out cubic const eased = 1 - Math.pow(1 - progress, 3); const current = Math.floor(startVal + (target - startVal) * eased); el.textContent = current.toLocaleString() + suffix; if (progress < 1) requestAnimationFrame(tick); }; requestAnimationFrame(tick); }; const statsObserver = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { animateCounter(entry.target); statsObserver.unobserve(entry.target); } }); }, { threshold: 0.4 }); statNumbers.forEach(el => statsObserver.observe(el)); } // ---------- Booking Form Handler ---------- const bookingForm = document.getElementById('booking-form'); if (bookingForm) { bookingForm.addEventListener('submit', function (e) { e.preventDefault(); const submitBtn = bookingForm.querySelector('button[type="submit"]'); const originalText = submitBtn.innerHTML; submitBtn.innerHTML = 'Submitting…'; submitBtn.disabled = true; // Simulate submission — replace with real endpoint in production setTimeout(() => { bookingForm.innerHTML = `
Your booking inquiry has been received. A member of Manny's team will contact you within 24 hours to schedule an initial conversation before confirming any engagement.
Thank you for reaching out. We will respond within one business day.