// Mobile menu toggle document.addEventListener('DOMContentLoaded', function() { const mobileMenuBtn = document.querySelector('.mobile-menu'); const navLinks = document.querySelector('.nav-links'); mobileMenuBtn.addEventListener('click', function() { navLinks.classList.toggle('active'); }); // Close mobile menu when a link is clicked document.querySelectorAll('.nav-links a').forEach(link => { link.addEventListener('click', function() { if (window.innerWidth <= 768) { navLinks.classList.remove('active'); } }); }); // Smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function(e) { e.preventDefault(); const targetId = this.getAttribute('href'); const targetElement = document.querySelector(targetId); if (targetElement) { window.scrollTo({ top: targetElement.offsetTop - 80, behavior: 'smooth' }); } }); }); // Update year in footer document.querySelector('.footer-bottom p').innerHTML = `© ${new Date().getFullYear()} Sangwari Taxi. All rights reserved.`; }); document.addEventListener('DOMContentLoaded', function() { // Set minimum date to today const today = new Date(); const dd = String(today.getDate()).padStart(2, '0'); const mm = String(today.getMonth() + 1).padStart(2, '0'); const yyyy = today.getFullYear(); const minDate = yyyy + '-' + mm + '-' + dd; document.getElementById('date').min = minDate; // Set default time to current time + 1 hour const now = new Date(); now.setHours(now.getHours() + 1); const hours = String(now.getHours()).padStart(2, '0'); const minutes = String(now.getMinutes()).padStart(2, '0'); const defaultTime = hours + ':' + minutes; document.getElementById('time').value = defaultTime; // Booking confirmation dialog const confirmationDialog = document.getElementById('confirmationDialog'); const closeDialogBtn = document.getElementById('closeDialogBtn'); const closeDialog = document.getElementById('closeDialog'); const bookingForm = document.getElementById('bookingForm'); // Show confirmation dialog when form is submitted bookingForm.addEventListener('submit', function(e) { e.preventDefault(); // Get form values const pickup = document.getElementById('pickup').value; const destination = document.getElementById('destination').value; const date = document.getElementById('date').value; const time = document.getElementById('time').value; const vehicle = document.getElementById('vehicle').value; const passengers = document.getElementById('passengers').value; // Format the date for display const formattedDate = new Date(date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }); // Update confirmation dialog with booking details document.getElementById('confirmPickup').textContent = pickup || 'Not specified'; document.getElementById('confirmDestination').textContent = destination || 'Not specified'; document.getElementById('confirmDateTime').textContent = `${formattedDate} at ${time}`; document.getElementById('confirmVehicle').textContent = vehicle === 'standard' ? 'Standard Sedan' : vehicle === 'executive' ? 'Executive Car' : vehicle === 'suv' ? 'SUV' : vehicle === 'minivan' ? 'Minivan' : vehicle === 'luxury' ? 'Luxury Vehicle' : vehicle; document.getElementById('confirmPassengers').textContent = passengers; // Show the dialog confirmationDialog.classList.add('active'); document.body.style.overflow = 'hidden'; }); // Show confirmation dialog when Book Now is clicked (for fleet section) document.querySelectorAll('.book-now').forEach(button => { button.addEventListener('click', function(e) { e.preventDefault(); // Get vehicle details const vehicleCard = this.closest('.vehicle-card'); const vehicleName = vehicleCard.querySelector('h3').textContent; // Update confirmation dialog with default values document.getElementById('confirmPickup').textContent = 'Airport'; document.getElementById('confirmDestination').textContent = 'Your destination'; document.getElementById('confirmVehicle').textContent = vehicleName; document.getElementById('confirmPassengers').textContent = '1'; // Show the dialog confirmationDialog.classList.add('active'); document.body.style.overflow = 'hidden'; }); }); // Close dialog handlers function closeConfirmationDialog() { confirmationDialog.classList.remove('active'); document.body.style.overflow = ''; } closeDialogBtn.addEventListener('click', closeConfirmationDialog); closeDialog.addEventListener('click', closeConfirmationDialog); // Close when clicking outside the dialog confirmationDialog.addEventListener('click', function(e) { if (e.target === confirmationDialog) { closeConfirmationDialog(); } }); // Print button functionality document.querySelector('.btn-print').addEventListener('click', function() { window.print(); }); }); // Animation on scroll document.addEventListener('DOMContentLoaded', function() { const animateElements = document.querySelectorAll('.animate-on-scroll'); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); } }); }, { threshold: 0.1 }); animateElements.forEach(element => { observer.observe(element); }); });