.viator-search-container { font-family: sans-serif; width: 100%; position: relative; z-index: 1000; }
.search-row { display: flex; align-items: flex-end; background: #fff; padding: 10px 15px 15px; border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); gap: 0; }
.field-group { display: flex; flex-direction: column; flex: 1; border-right: 1px solid #ddd; position: relative; }
.field-dest { flex: 2; }
.field-btn { border: none; flex: 0.8; margin-left: 15px; }
.v-label { font-size: 12px; color: #666; margin: 0 0 5px 10px; font-weight: bold; }
.viator-search-container input { border: none !important; padding: 10px; outline: none !important; width: 100%; background: transparent !important; color: #333 !important; }
#vSug { position: absolute; top: 100%; left: 0; width: 100%; background: #fff; border: 1px solid #ddd; z-index: 9999; display: none; max-height: 200px; overflow-y: auto; }
.s-item { padding: 10px; cursor: pointer; border-bottom: 1px solid #eee; font-size: 14px; color: #333; }
.s-item:hover { background: #f0fbfc; }
.v-btn { background: #33c3db; color: #fff; border: none; padding: 12px; border-radius: 4px; cursor: pointer; width: 100%; font-weight: bold; }
Destination
Start Date
End Date
SEARCH
(function() {
const initForm = () => {
const inp = document.getElementById('vInp');
const sug = document.getElementById('vSug');
const btn = document.getElementById('vGo');
if (!inp || inp.dataset.active) return;
inp.dataset.active = "true";
inp.addEventListener('input', function() {
if (this.value.length < 2) { sug.style.display = 'none'; return; }
fetch('/ajax_viator_dest_search.php?q=' + encodeURIComponent(this.value))
.then(r => r.json()).then(data => {
if (data && data.length) {
sug.innerHTML = data.map(i => `📍 ${i.name}`).join('');
sug.style.display = 'block';
}
});
});
sug.addEventListener('click', e => {
const item = e.target.closest('.s-item');
if (item) {
inp.value = item.dataset.name;
document.getElementById('vId').value = item.dataset.id;
sug.style.display = 'none';
}
});
btn.onclick = () => {
const id = document.getElementById('vId').value;
if (!id) return alert('Please select a destination');
let url = '/index.php?option=com_content&view=article&id=83&dest=' + id;
const start = document.getElementById('vS').value;
if (start) url += '&d1=' + start;
window.location.href = url;
};
};
setInterval(initForm, 500);
})();