document.addEventListener('DOMContentLoaded', function() { // Initialize tooltips const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); tooltipTriggerList.map(function (tooltipTriggerEl) { return new bootstrap.Tooltip(tooltipTriggerEl); }); // Smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); }); // Dark mode toggle const darkModeToggle = document.getElementById('darkModeToggle'); if (darkModeToggle) { darkModeToggle.addEventListener('click', () => { document.documentElement.classList.toggle('dark'); localStorage.setItem('darkMode', document.documentElement.classList.contains('dark')); }); } // Initialize representative search functionality const repSearchBtn = document.querySelector('#representatives button'); if (repSearchBtn) { repSearchBtn.addEventListener('click', () => { const address = document.getElementById('address').value; if (address) { // In a real app, this would call an API to find representatives console.log(`Searching for representatives for address: ${address}`); // Show loading state repSearchBtn.innerHTML = ' Searching...'; setTimeout(() => { repSearchBtn.textContent = 'Search'; alert('Representative search functionality would connect to a real API in production'); }, 1500); } }); } });