(function() { 'use strict'; // Mobile Menu Toggle var mobileMenuToggle = document.querySelector('.mobile-menu-toggle'); var mobileMenu = document.getElementById('mobile-menu'); if (mobileMenuToggle && mobileMenu) { mobileMenuToggle.addEventListener('click', function() { var isExpanded = this.getAttribute('aria-expanded') === 'true'; this.setAttribute('aria-expanded', !isExpanded); mobileMenu.hidden = isExpanded; // Animate hamburger var lines = this.querySelectorAll('.hamburger-line'); if (!isExpanded) { lines[0].style.transform = 'rotate(45deg) translate(5px, 5px)'; lines[1].style.opacity = '0'; lines[2].style.transform = 'rotate(-45deg) translate(5px, -5px)'; } else { lines[0].style.transform = ''; lines[1].style.opacity = ''; lines[2].style.transform = ''; } }); // Close menu when clicking a link mobileMenu.querySelectorAll('a').forEach(function(link) { link.addEventListener('click', function() { mobileMenuToggle.setAttribute('aria-expanded', 'false'); mobileMenu.hidden = true; var lines = mobileMenuToggle.querySelectorAll('.hamburger-line'); lines[0].style.transform = ''; lines[1].style.opacity = ''; lines[2].style.transform = ''; }); }); } // Scroll Reveal var revealElements = document.querySelectorAll('.service-card, .benefit-item, .stat-card, .section-header'); if ('IntersectionObserver' in window) { var revealObserver = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { entry.target.classList.add('reveal', 'revealed'); revealObserver.unobserve(entry.target); } }); }, { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }); revealElements.forEach(function(el, index) { el.classList.add('reveal'); el.style.transitionDelay = Math.min((index % 4) * 0.08, 0.3) + 's'; revealObserver.observe(el); }); } else { revealElements.forEach(function(el) { el.classList.add('reveal', 'revealed'); }); } // Form Validation var contactForm = document.getElementById('contact-form'); var formStatus = document.getElementById('form-status'); if (contactForm) { contactForm.addEventListener('submit', function(e) { e.preventDefault(); var isValid = true; var formGroups = this.querySelectorAll('.form-group'); formGroups.forEach(function(group) { group.classList.remove('has-error'); }); // Validate name var nameInput = this.querySelector('#name'); if (nameInput && nameInput.value.trim().length < 2) { nameInput.closest('.form-group').classList.add('has-error'); isValid = false; } // Validate phone var phoneInput = this.querySelector('#phone'); var phoneRegex = /^[\d\-+\s()]{9,}$/; if (phoneInput && !phoneRegex.test(phoneInput.value.trim())) { phoneInput.closest('.form-group').classList.add('has-error'); isValid = false; } // Validate service selection var serviceSelect = this.querySelector('#service'); if (serviceSelect && !serviceSelect.value) { serviceSelect.closest('.form-group').classList.add('has-error'); isValid = false; } if (isValid) { // Announce to screen readers if (formStatus) { formStatus.textContent = 'הבקשה נשלחה בהצלחה. ניצור איתכם קשר בהקדם.'; } // Show success message contactForm.innerHTML = '
ניצור איתכם קשר בהקדם האפשרי
' + '