// Initialize animations when page loads document.addEventListener('DOMContentLoaded', function() { // Smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); }); // Intersection Observer for scroll animations const observerOptions = { threshold: 0.1 }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('animate-fade-in'); observer.unobserve(entry.target); } }); }, observerOptions); document.querySelectorAll('.service-card-container, .floating-3d-image').forEach(el => { observer.observe(el); }); // Initialize feather icons feather.replace(); }); // Form validation for contact form function validateForm(formId) { const form = document.getElementById(formId); if (form) { form.addEventListener('submit', function(e) { let isValid = true; const inputs = form.querySelectorAll('input[required], textarea[required]'); inputs.forEach(input => { if (!input.value.trim()) { isValid = false; input.classList.add('border-red-500'); } else { input.classList.remove('border-red-500'); } }); if (!isValid) { e.preventDefault(); alert('Veuillez remplir tous les champs obligatoires.'); } }); } } // Initialize forms on page load document.addEventListener('DOMContentLoaded', function() { validateForm('contact-form'); validateForm('training-form'); });