document.addEventListener('DOMContentLoaded', function() { // Testimonial Slider const testimonials = document.querySelectorAll('.testimonial'); const dots = document.querySelectorAll('.slider-dot'); let currentTestimonial = 0; function showTestimonial(index) { testimonials.forEach(testimonial => testimonial.classList.add('hidden')); dots.forEach(dot => dot.classList.remove('bg-indigo-600')); testimonials[index].classList.remove('hidden'); dots[index].classList.add('bg-indigo-600'); currentTestimonial = index; } // Initialize first testimonial showTestimonial(0); // Add click events to dots dots.forEach((dot, index) => { dot.addEventListener('click', () => showTestimonial(index)); }); // Auto-rotate testimonials setInterval(() => { let nextIndex = (currentTestimonial + 1) % testimonials.length; showTestimonial(nextIndex); }, 5000); // Form submission const contactForm = document.querySelector('.contact-form'); if (contactForm) { contactForm.addEventListener('submit', function(e) { e.preventDefault(); // Simple validation const name = document.getElementById('name').value; const email = document.getElementById('email').value; if (!name || !email) { alert('Please fill in all required fields.'); return; } // Here you would typically send the form data to a server alert('Thank you for your message! We will get back to you soon.'); contactForm.reset(); }); } // Smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function(e) { e.preventDefault(); const targetId = this.getAttribute('href'); if (targetId === '#') return; const targetElement = document.querySelector(targetId); if (targetElement) { window.scrollTo({ top: targetElement.offsetTop - 80, behavior: 'smooth' }); } }); }); // Navbar scroll effect const navbar = document.querySelector('custom-navbar'); window.addEventListener('scroll', function() { if (window.scrollY > 100) { navbar.shadowRoot.querySelector('nav').classList.add('bg-white', 'shadow-md'); navbar.shadowRoot.querySelector('nav').classList.remove('bg-transparent'); } else { navbar.shadowRoot.querySelector('nav').classList.add('bg-transparent'); navbar.shadowRoot.querySelector('nav').classList.remove('bg-white', 'shadow-md'); } }); });