function toggleContent(id, btn) {
const target = document.getElementById(id);
const isOpen = target.classList.contains(‘open’);
document.querySelectorAll(‘.expandable-content’).forEach(el => el.classList.remove(‘open’));
document.querySelectorAll(‘.nav-btn, .hamburger-btn’).forEach(el => el.classList.remove(‘open’));
if (!isOpen) {
target.classList.add(‘open’);
btn.classList.add(‘open’);
}
}
function toggleSearch() {
const sw = document.getElementById(‘search-wrapper’);
sw.classList.toggle(‘open’);
if (sw.classList.contains(‘open’)) {
setTimeout(() => document.getElementById(‘search-input’).focus(), 300);
}
}
function handleSearch(e) {
if (e.key === ‘Enter’) {
const q = document.getElementById(‘search-input’).value.trim();
if (q) window.open(‘https://www.eafit.edu.co/search?keys=’ + encodeURIComponent(q), ‘_blank’);
}
}
document.addEventListener(‘click’, function(e) {
const header = document.getElementById(‘eafit-header’);
if (!header.contains(e.target)) {
document.querySelectorAll(‘.expandable-content’).forEach(el => el.classList.remove(‘open’));
document.querySelectorAll(‘.nav-btn, .hamburger-btn’).forEach(el => el.classList.remove(‘open’));
}
});