// Literally speaking, this below line is needed to work jQuery window.addEventListener('load', function() { var allIds = "#cheap_cars, #popular_cars, #cars_by_year, #popular_cities"; var locale = "en" var currentLocation = window.location.pathname if(currentLocation === "/es") { currentLocation = "/es/" } if(locale === "en") { $("#handleChangeLanguage, #assign-lang").attr("href","/es"+currentLocation); } else if (locale === "es"){ var withOutEs = currentLocation.replace("/es",""); // After removing "es", if the pathname is empty, then we should give the full path from href var nextLocation = withOutEs === "" ? window.location.href.replace("/es","") : withOutEs; $("#handleChangeLanguage, #assign-lang").attr("href",nextLocation); } // this mouseup handles the click outside the nav tab $(document).mouseup(function(event) { var container = $(allIds + ", #hamburger_btn"); // if the target of the click isn't the container nor a descendant of the container if (!container.is(event.target) && container.has(event.target).length === 0) { // On Mobile device, if the user clicks outside the nav, // and if that nav is open, then we will close the nav $("#hamburger_btn").removeClass("close"); $("#main_navigation, .nav-stage").removeClass("active"); // On any device, the active class of the navs should be closed $(allIds).removeClass("active"); } }); $(allIds).click(function() { var itHasClass = $(this).hasClass("active"); $(allIds).removeClass("active"); if (!itHasClass) { $(this).toggleClass("active"); } }); $("#hamburger_btn").click(function() { $("#hamburger_btn").toggleClass("close"); $("#main_navigation, .nav-stage").toggleClass("active"); }); $("#back-to-result").click(function() { if($(this).data('backLink') === 'back') { window.history.back(); } else { window.location.assign($(this).data('backLink')); } }) });

Car Dealers by State