document.addEventListener('DOMContentLoaded', () => { const brandNav = document.querySelector('#brandNav'); if (brandNav) { brandNav.addEventListener('click', () => { window.location.href = '/'; }); } const homeNav = document.querySelector('#homeNav'); if (homeNav) { homeNav.addEventListener('click', () => { window.location.href = '/'; }); } const inventoryNav = document.querySelector('#inventoryNav'); if (inventoryNav) { inventoryNav.addEventListener('click', () => { window.location.href = '/inventory'; }); } const loginNav = document.querySelector('#loginNav'); if (loginNav) { loginNav.addEventListener('click', () => { window.location.href = '/login'; }); } const logoutNav = document.querySelector('#logoutNav'); if (logoutNav) { logoutNav.addEventListener('click', (event) => { event.preventDefault(); // Prevent default link behavior $.get('/auth/logout', function(data) { window.location.href = '/login'; }).fail((jqXHR) => { alert('Logout failed: ' + jqXHR.responseText); }); }); } });