// Shared JavaScript functions document.addEventListener('DOMContentLoaded', function() { // Initialize animations const animateElements = document.querySelectorAll('.animate-fade-in'); animateElements.forEach((el, index) => { el.style.opacity = 0; el.style.animationDelay = `${index * 0.1}s`; }); // Handle mobile menu toggle (will be used by navbar component) window.toggleMobileMenu = function() { const menu = document.getElementById('mobile-menu'); menu.classList.toggle('hidden'); }; // 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' }); }); }); }); // API functions async function fetchPopularDestinations() { try { const response = await fetch('https://restcountries.com/v3.1/all'); const data = await response.json(); return data.slice(0, 6); // Get first 6 countries for demo } catch (error) { console.error('Error fetching destinations:', error); return []; } }