// ===== Mobile Menu ===== const hamburger = document.getElementById('hamburger'); const mobileNav = document.getElementById('mobileNav'); const mobileNavClose = document.getElementById('mobileNavClose'); const mobileNavLinks = mobileNav.querySelectorAll('a'); hamburger.addEventListener('click', () => { mobileNav.classList.add('active'); document.body.style.overflow = 'hidden'; }); mobileNavClose.addEventListener('click', closeMobileNav); mobileNavLinks.forEach(link => { link.addEventListener('click', closeMobileNav); }); function closeMobileNav() { mobileNav.classList.remove('active'); document.body.style.overflow = ''; } // ===== Contact Form ===== const contactForm = document.getElementById('contactForm'); const formSuccess = document.getElementById('formSuccess'); contactForm.addEventListener('submit', (e) => { e.preventDefault(); // Clear previous errors document.querySelectorAll('.form-error').forEach(el => el.style.display = 'none'); const name = document.getElementById('formName'); const email = document.getElementById('formEmail'); const phone = document.getElementById('formPhone'); const message = document.getElementById('formMessage'); let valid = true; if (!name.value.trim()) { showError(name, 'Prosím vyplňte své jméno'); valid = false; } if (!email.value.trim() || !isValidEmail(email.value)) { showError(email, 'Prosím zadejte platný e-mail'); valid = false; } if (!phone.value.trim()) { showError(phone, 'Prosím zadejte telefonní číslo'); valid = false; } if (!message.value.trim()) { showError(message, 'Prosím napište zprávu'); valid = false; } if (!valid) return; // Hide form, show success contactForm.style.display = 'none'; formSuccess.style.display = 'block'; }); function showError(input, msg) { const errorEl = input.parentElement.querySelector('.form-error'); if (errorEl) { errorEl.textContent = msg; errorEl.style.display = 'block'; } } function isValidEmail(email) { return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); } // ===== Plan selection from pricing buttons ===== const formPlan = document.getElementById('formPlan'); document.querySelectorAll('.plan-btn').forEach(btn => { btn.addEventListener('click', (e) => { e.preventDefault(); const plan = btn.getAttribute('data-plan'); if (formPlan && plan) { formPlan.value = plan; formPlan.parentElement.classList.add('highlight-field'); setTimeout(() => formPlan.parentElement.classList.remove('highlight-field'), 1500); } document.getElementById('kontakt').scrollIntoView({ behavior: 'smooth' }); }); }); // ===== Smooth Scroll for anchor links ===== document.querySelectorAll('a[href^="#"]').forEach(anchor => { if (anchor.classList.contains('plan-btn')) return; anchor.addEventListener('click', (e) => { const target = document.querySelector(anchor.getAttribute('href')); if (target) { e.preventDefault(); target.scrollIntoView({ behavior: 'smooth' }); } }); }); // ===== Header shadow on scroll ===== const header = document.querySelector('.header'); window.addEventListener('scroll', () => { if (window.scrollY > 10) { header.style.boxShadow = '0 2px 12px rgba(0,0,0,.08)'; } else { header.style.boxShadow = 'none'; } }, { passive: true }); // ===== Close mobile nav on resize past breakpoint ===== window.addEventListener('resize', () => { if (window.innerWidth > 960 && mobileNav.classList.contains('active')) { closeMobileNav(); } });