Looking at the page here, what I see:
1) The magic line of the script determines the width of the underline based on the element that has the class "current_page_item".
Since this is all javascript. You will want to configure the bindings / links in the menu to contain javascript that will update the current_page_item class to the selected element and remove it from the previous one. This should also update your highlighting problem, as it seems that CSS is created.
The main script for this would look like this:
function updateCurrent(e) { $('.current_page_item').removeClass('current_page_item'); $(e).parent('li').addClass('current_page_item'); }
And all your anchors will have onClick, which looks like this:
<a href="print.html" onclick="updateCurrent(this);">Print</a>
2) I do not fully follow the main question of your second question. The navigator looks at the right content when I experience it.
EDIT for my added comment below:
$('#topnav li a').click(function(){ // Update the current item. $('.current_page_item').removeClass('current_page_item'); $(this).parent('li').addClass('current_page_item'); var toLoad = $(this).attr('href')+' #content'; $('#content').hide('fast',loadContent); window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5); function loadContent() { $('#content').load(toLoad,'',showNewContent()) } function showNewContent() { $('#content').show('normal',hideLoader()); } function hideLoader() { $('#load').fadeOut('normal'); } return false; });
EDIT Part 2: I see that you are still having problems so that the magic line ignores your width, what you need to do is that while the snap button is pressed, the same math should be done that you applied at boot time.
The updated js magic line should look like this:
// DOM Ready $(function() { $("#topnav").append("<li id='magic-line'></li>"); // get the left margin of current page item var marg = parseInt($(".current_page_item a").css("marginLeft")); /* Cache it */ var $magicLine = $("#magic-line"); $magicLine .width($(".current_page_item a").width()) .css("left", $(".current_page_item a").position().left + marg) .data("origLeft", $magicLine.position().left) .data("origWidth", $magicLine.width()); $("#topnav li").find("a").click( $el = $(this); // Do the math for each click leftPos = $el.position().left + marg; newWidth = $el.parent().width() - marg; $magicLine.stop().animate({ left: leftPos, width: newWidth }); }, function() { $magicLine.stop().animate({ left: $magicLine.data("origLeft"), width: $magicLine.data("origWidth") }); }); /* Kick IE into gear */ $(".current_page_item_two a").mouseenter();
});