(function() { 'use strict'; // Mobile menu toggle const mobileMenuBtn = document.querySelector('.mobile-menu-btn'); const mobileNav = document.querySelector('.mobile-nav'); if (mobileMenuBtn && mobileNav) { mobileMenuBtn.addEventListener('click', function() { const isExpanded = this.getAttribute('aria-expanded') === 'true'; this.setAttribute('aria-expanded', !isExpanded); mobileNav.classList.toggle('active'); }); // Close mobile menu when clicking a link mobileNav.querySelectorAll('a').forEach(function(link) { link.addEventListener('click', function() { mobileMenuBtn.setAttribute('aria-expanded', 'false'); mobileNav.classList.remove('active'); }); }); } // FAQ accordion const faqItems = document.querySelectorAll('.faq-item'); faqItems.forEach(function(item) { const question = item.querySelector('.faq-question'); question.addEventListener('click', function() { const isExpanded = this.getAttribute('aria-expanded') === 'true'; // Close all other items faqItems.forEach(function(otherItem) { if (otherItem !== item) { otherItem.classList.remove('active'); otherItem.querySelector('.faq-question').setAttribute('aria-expanded', 'false'); } }); // Toggle current item this.setAttribute('aria-expanded', !isExpanded); item.classList.toggle('active'); }); }); // Scroll reveal animation const revealElements = document.querySelectorAll('.reveal'); if (revealElements.length > 0 && !window.matchMedia('(prefers-reduced-motion: reduce)').matches) { const revealObserver = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { entry.target.classList.add('visible'); revealObserver.unobserve(entry.target); } }); }, { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }); revealElements.forEach(function(el) { revealObserver.observe(el); }); } else { // If reduced motion is preferred, show all elements immediately revealElements.forEach(function(el) { el.classList.add('visible'); }); } // Smooth scroll for anchor links document.querySelectorAll('a[href^="#"]').forEach(function(anchor) { anchor.addEventListener('click', function(e) { const targetId = this.getAttribute('href'); if (targetId === '#') return; const targetElement = document.querySelector(targetId); if (targetElement) { e.preventDefault(); const headerHeight = document.querySelector('.header').offsetHeight; const targetPosition = targetElement.getBoundingClientRect().top + window.pageYOffset - headerHeight - 20; window.scrollTo({ top: targetPosition, behavior: 'smooth' }); } }); }); // Form submission handling const leadForm = document.querySelector('.lead-form'); if (leadForm) { leadForm.addEventListener('submit', function(e) { e.preventDefault(); const formData = new FormData(this); const submitBtn = this.querySelector('button[type="submit"]'); const originalText = submitBtn.innerHTML; // Show loading state submitBtn.innerHTML = 'שולח...'; submitBtn.disabled = true; // Simulate form submission (replace with actual endpoint) setTimeout(function() { submitBtn.innerHTML = '✓ נשלח בהצלחה!'; submitBtn.style.background = 'linear-gradient(135deg, #10b981 0%, #059669 100%)'; // Reset form leadForm.reset(); // Reset button after delay setTimeout(function() { submitBtn.innerHTML = originalText; submitBtn.style.background = ''; submitBtn.disabled = false; }, 3000); }, 1500); }); } // Header background on scroll const header = document.querySelector('.header'); let lastScroll = 0; window.addEventListener('scroll', function() { const currentScroll = window.pageYOffset; if (currentScroll > 50) { header.style.background = 'rgba(15, 15, 26, 0.95)'; } else { header.style.background = 'rgba(15, 15, 26, 0.8)'; } lastScroll = currentScroll; }, { passive: true }); })();