document.addEventListener('DOMContentLoaded', () => { const hamburger = document.querySelector('.hamburger'); const navList = document.querySelector('.nav-list'); if (hamburger && navList) { hamburger.addEventListener('click', () => { navList.classList.toggle('active'); hamburger.classList.toggle('open'); }); navList.querySelectorAll('a').forEach(link => { link.addEventListener('click', () => { if (navList.classList.contains('active')) { navList.classList.remove('active'); hamburger.classList.remove('open'); } }); }); } const ageGate = document.getElementById('age-gate'); const confirmAgeButton = document.getElementById('confirm-age'); const body = document.body; if (ageGate && confirmAgeButton) { ageGate.classList.remove('hidden'); body.style.overflow = 'hidden'; confirmAgeButton.addEventListener('click', () => { ageGate.classList.add('hidden'); body.style.overflow = ''; }); } else if (ageGate) { ageGate.classList.add('hidden'); body.style.overflow = ''; } const cookieConsent = document.getElementById('cookie-consent'); const acceptCookiesButton = document.getElementById('accept-cookies'); if (cookieConsent && acceptCookiesButton) { cookieConsent.classList.remove('hidden'); acceptCookiesButton.addEventListener('click', () => { cookieConsent.classList.add('hidden'); }); } else if (cookieConsent) { cookieConsent.classList.add('hidden'); } const contactForm = document.getElementById('contact-form'); if (contactForm) { contactForm.addEventListener('submit', (event) => { event.preventDefault(); const name = document.getElementById('name').value.trim(); const email = document.getElementById('email').value.trim(); const message = document.getElementById('message').value.trim(); let isValid = true; if (name.length < 2) { alert('Vennligst oppgi et gyldig navn (minimum 2 tegn).'); isValid = false; } if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) { alert('Vennligst oppgi en gyldig e-postadresse.'); isValid = false; } if (message.length < 10) { alert('Meldingen må inneholde minst 10 tegn.'); isValid = false; } if (isValid) { alert('Takk for din melding! Vi vil kontakte deg snart.'); contactForm.reset(); } }); } document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); }); });