// Shared JavaScript across all pages document.addEventListener('DOMContentLoaded', function() { // Initialize Vanta.js background if (document.getElementById('vanta-bg')) { VANTA.GLOBE({ el: "#vanta-bg", mouseControls: true, touchControls: true, gyroControls: false, minHeight: 200.00, minWidth: 200.00, scale: 1.00, scaleMobile: 1.00, color: 0xec4899, color2: 0xfbcfe8, backgroundColor: 0xfffdfd }); } // 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) { window.scrollTo({ top: target.offsetTop - 80, behavior: 'smooth' }); } }); }); // Form submission handling const form = document.getElementById('consultation-form'); if (form) { form.addEventListener('submit', function(e) { e.preventDefault(); // Get form values const name = document.getElementById('name').value; const age = document.getElementById('age').value; const phone = document.getElementById('phone').value; const email = document.getElementById('email').value; // In a real application, you would send this data to a server console.log('Form submitted:', { name, age, phone, email }); // Show success message alert(`${name}님, 상담 신청이 완료되었습니다. 빠른 시일 내에 연락드리겠습니다.`); // Reset form form.reset(); }); } // Intersection Observer for animations const observerOptions = { root: null, rootMargin: '0px', threshold: 0.1 }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('animate-fade-in-up'); } }); }, observerOptions); // Observe sections for animation document.querySelectorAll('section').forEach(section => { section.classList.add('opacity-0', 'translate-y-10', 'transition-all', 'duration-700'); observer.observe(section); }); // Animation classes const style = document.createElement('style'); style.textContent = ` @keyframes fade-in-up { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } .animate-fade-in-up { animation: fade-in-up 0.7s ease-out forwards; } `; document.head.appendChild(style); });