document.addEventListener('DOMContentLoaded', function() { const menuToggle = document.querySelector('.menu-toggle'); const navLinks = document.querySelector('.nav-links'); if (menuToggle && navLinks) { menuToggle.addEventListener('click', function() { navLinks.classList.toggle('open'); this.textContent = navLinks.classList.contains('open') ? '✕' : '☰'; }); navLinks.querySelectorAll('a').forEach(link => { link.addEventListener('click', () => { navLinks.classList.remove('open'); menuToggle.textContent = '☰'; }); }); } const header = document.querySelector('.header'); if (header) { window.addEventListener('scroll', () => { header.classList.toggle('scrolled', window.scrollY > 50); }); } const faqItems = document.querySelectorAll('.faq-item'); faqItems.forEach(item => { const question = item.querySelector('.faq-question'); const answer = item.querySelector('.faq-answer'); question.addEventListener('click', () => { const isActive = item.classList.contains('active'); faqItems.forEach(i => { i.classList.remove('active'); i.querySelector('.faq-answer').style.maxHeight = null; }); if (!isActive) { item.classList.add('active'); answer.style.maxHeight = answer.scrollHeight + 'px'; } }); }); const searchForm = document.querySelector('.search-bar'); if (searchForm) { searchForm.addEventListener('submit', function(e) { e.preventDefault(); const query = this.querySelector('input').value.trim().toLowerCase(); if (!query) return; const searchMap = { 'law': 'pages/dubai-escort-laws.html', 'legal': 'pages/dubai-escort-laws.html', 'price': 'pages/dubai-escort-prices.html', 'cost': 'pages/dubai-escort-prices.html', 'rate': 'pages/dubai-escort-prices.html', 'safe': 'pages/dubai-escort-safety-tips.html', 'safety': 'pages/dubai-escort-safety-tips.html', 'agency': 'pages/dubai-escort-agencies.html', 'agencies': 'pages/dubai-escort-agencies.html', 'find': 'pages/how-to-find-escorts-in-dubai.html', 'type': 'pages/types-of-escort-services-dubai.html', 'nightlife': 'pages/dubai-nightlife-escort-guide.html', 'night': 'pages/dubai-nightlife-escort-guide.html', 'luxury': 'pages/luxury-escort-experience-dubai.html', 'vip': 'pages/luxury-escort-experience-dubai.html', }; for (const [keyword, url] of Object.entries(searchMap)) { if (query.includes(keyword)) { window.location.href = url; return; } } const faqSection = document.getElementById('popular-faqs'); if (faqSection) { faqSection.scrollIntoView({ behavior: 'smooth' }); } }); } const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('fade-in'); observer.unobserve(entry.target); } }); }, observerOptions); document.querySelectorAll('.card, .faq-item, .section-header').forEach(el => { observer.observe(el); }); const currentPage = window.location.pathname.split('/').pop() || 'index.html'; document.querySelectorAll('.nav-links a').forEach(link => { const href = link.getAttribute('href'); if (href && (href.endsWith(currentPage) || (currentPage === 'index.html' && href === '/'))) { link.classList.add('active'); } }); 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' }); } }); }); });