// Main JavaScript for FleetFlex Pro Solutions // Initialize Feather Icons document.addEventListener('DOMContentLoaded', function() { if (typeof feather !== 'undefined') { feather.replace(); } // Add smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { target.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); // Add intersection observer for fade-in animations const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver(function(entries) { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('fade-in-up'); observer.unobserve(entry.target); } }); }, observerOptions); // Observe all sections for animation document.querySelectorAll('section').forEach(section => { observer.observe(section); }); // Stats counter animation const statsSection = document.querySelector('.bg-white'); const statsObserver = new IntersectionObserver(function(entries) { entries.forEach(entry => { if (entry.isIntersecting) { animateStats(); statsObserver.unobserve(entry.target); } }); }, { threshold: 0.5 }); if (statsSection) { statsObserver.observe(statsSection); } }); // Animate statistics counters function animateStats() { const counters = document.querySelectorAll('.text-4xl'); const speed = 200; // The lower the slower counters.forEach(counter => { const target = +counter.innerText.replace(',', ''); const increment = target / speed; let current = 0; const updateCount = () => { current += increment; if (current < target) { counter.innerText = Math.floor(current).toLocaleString(); setTimeout(updateCount, 1); } else { counter.innerText = target.toLocaleString(); } }; updateCount(); }); } // Handle form submissions function handleContactForm(event) { event.preventDefault(); // Show loading state const submitBtn = event.target.querySelector('button[type="submit"]'); const originalText = submitBtn.innerHTML; submitBtn.innerHTML = '