// Utility functions function showToast(message, type = 'success') { const toast = document.createElement('div'); toast.className = `toast toast-${type}`; toast.textContent = message; document.body.appendChild(toast); setTimeout(() => { toast.classList.add('show'); setTimeout(() => { toast.classList.remove('show'); setTimeout(() => toast.remove(), 300); }, 3000); }, 100); } // Form handling function setupForms() { document.querySelectorAll('form').forEach(form => { form.addEventListener('submit', async (e) => { e.preventDefault(); const submitBtn = form.querySelector('button[type="submit"]'); const originalText = submitBtn.textContent; try { submitBtn.disabled = true; submitBtn.innerHTML = ' מע מעבד...'; // Simulate form submission await new Promise(resolve => setTimeout(resolve, 1500)); showToast('ההפעולה בוצעה בהצלחה!', 'success'); form.reset(); } catch (error) { showToast('אירעה שגיאה. נסה שוב.', 'danger'); console.error(error); } finally { submitBtn.disabled = false; submitBtn.textContent = originalText; } }); }); } // Initialize when DOM is loaded document.addEventListener('DOMContentLoaded', () => { setupForms(); // Set active nav link const currentPath = window.location.pathname; document.querySelectorAll('.nav-links a').forEach(link => { if (link.getAttribute('href') === currentPath) { link.classList.add('active'); } }); });