// Main JavaScript file for shared functionality // Initialize animations when elements come into view document.addEventListener('DOMContentLoaded', function() { // Intersection Observer for scroll animations const observerOptions = { root: null, rootMargin: '0px', threshold: 0.1 }; const observer = new IntersectionObserver((entries, observer) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('animate-fadeInUp'); observer.unobserve(entry.target); } }); }, observerOptions); // Observe all elements with the animate-on-scroll class document.querySelectorAll('.animate-on-scroll').forEach(el => { observer.observe(el); }); // Smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function(e) { e.preventDefault(); const targetId = this.getAttribute('href'); const targetElement = document.querySelector(targetId); if (targetElement) { window.scrollTo({ top: targetElement.offsetTop - 100, behavior: 'smooth' }); } }); }); }); // Form submission handler function handleFormSubmission(formId, successMessage) { const form = document.getElementById(formId); if (form) { form.addEventListener('submit', function(e) { e.preventDefault(); // Here you would typically send the form data to your server // For demo purposes, we'll just show an alert alert(successMessage || 'Thank you for your submission!'); form.reset(); }); } } // Initialize all forms document.addEventListener('DOMContentLoaded', function() { handleFormSubmission('signup-form', 'Thanks for signing up! We\'ll be in touch soon.'); });