var nav_arr = new Array ('places','people','events','nature'); function nav_swap(id){ for(var i=0; i < nav_arr.length; i++){ var Element = document.getElementById(nav_arr[i]); if (i == (id-1)) { if(Element){ Element.className = "active"; } } else { if(Element){ Element.className = "inactive"; } } } }
Rather than help you make this way work, I'd prefer to advise that the way you are approaching the website is not ideal. In my opinion it is relying on Ajax in an unsuitable fashion. I would suggest making each of those links real HTML links to separate pages so that the site's content is accessible to search-engines and non-javascript environments, and also directly bookmarkable and linkable. This method would also solve your current problem as you could then apply an id to each page's body element and do some CSS sort of like this to make the right link look highlighted: