// Smooth scrolling for navigation links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { target.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); // Navbar scroll effect window.addEventListener('scroll', function() { const navbar = document.querySelector('.navbar'); if (window.scrollY > 50) { navbar.classList.add('scrolled'); navbar.style.backgroundColor = 'rgba(255, 255, 255, 0.95)'; navbar.style.backdropFilter = 'blur(10px)'; } else { navbar.classList.remove('scrolled'); navbar.style.backgroundColor = 'white'; navbar.style.backdropFilter = 'none'; } }); // Counter animation function animateCounters() { const counters = document.querySelectorAll('h3.fw-bold.text-primary'); counters.forEach(counter => { const target = parseInt(counter.textContent.replace(/[^\d]/g, '')); const increment = target / 100; let current = 0; const updateCounter = () => { if (current < target) { current += increment; if (counter.textContent.includes('+')) { counter.textContent = Math.ceil(current).toLocaleString() + '+'; } else if (counter.textContent.includes('%')) { counter.textContent = Math.ceil(current) + '%'; } else { counter.textContent = Math.ceil(current).toLocaleString(); } requestAnimationFrame(updateCounter); } else { counter.textContent = counter.textContent; // Reset to original } }; updateCounter(); }); } // Trigger counter animation when stats section is visible const statsSection = document.querySelector('#about'); if (statsSection) { const statsObserver = new IntersectionObserver(function(entries) { entries.forEach(entry => { if (entry.isIntersecting) { animateCounters(); statsObserver.unobserve(entry.target); } }); }, { threshold: 0.5 }); statsObserver.observe(statsSection); } // Lazy loading for images document.addEventListener('DOMContentLoaded', function() { const images = document.querySelectorAll('img[data-src]'); const imageObserver = new IntersectionObserver(function(entries) { entries.forEach(entry => { if (entry.isIntersecting) { const img = entry.target; img.src = img.dataset.src; img.classList.remove('lazy'); imageObserver.unobserve(img); } }); }); images.forEach(img => imageObserver.observe(img)); }); document.addEventListener('wpcf7submit', function(event) { const submitBtn = event.target.querySelector('input[type="submit"]'); if (submitBtn) submitBtn.disabled = true; }, false); jQuery(document).ready(function($) { $('.wpcf7 form').each(function() { let source = ""; if ($(this).closest('#consultationModal').length) { source = "Popup"; } else if ($(this).closest('#consult_form').length) { source = "Page"; } if (source) { $(this).find('input[name="Form-source"]').val(source); } }); }); document.addEventListener('wpcf7submit', function(event) { var submitBtn = event.target.querySelector('input[type="submit"], button[type="submit"]'); if (submitBtn) submitBtn.removeAttribute('disabled'); }, false);