// Shared JavaScript functions 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' }); }); }); // Add animation classes to elements const animateElements = document.querySelectorAll('.fade-in, .slide-up'); animateElements.forEach(el => { el.style.opacity = '0'; }); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add(entry.target.dataset.animation || 'fade-in'); entry.target.style.opacity = '1'; observer.unobserve(entry.target); } }); }, { threshold: 0.1 }); animateElements.forEach(el => { observer.observe(el); }); });