﻿var selectedNavigationLi;

$(document).ready(function() {
    $("#topnavigation a").each(function() {
        var lihref = $(this).attr("href").toLowerCase();
        var currhref = window.location.pathname.toLowerCase();
        //alert(lihref + ' == ' + currhref + '(' + (lihref==currhref).toString() + ')');
        if (lihref == currhref) {
            $(this).prepend('<img id="topnavigationmarker" src="/images/navigationmarker.png" alt="navigationmarker"/>');
            $("#topnavigationmarker").css("position","absolute");
            
            if(currhref == "/tools.aspx"){
                $("#topnavigationmarker").css("margin-left","30px");
            }
            
            if(currhref == "/subjects.aspx"){
                $("#topnavigationmarker").css("margin-left","20px");
            }
            
            if(currhref == "/culture.aspx"){
                $("#topnavigationmarker").css("margin-left","12px");
            }
            
            
            if (selectedNavigationLi != null) {
                selectedNavigationLi.removeClass("selected");
                selectedNavigationLi.removeClass("first_selected");
                selectedNavigationLi.removeClass("last_selected");
            }
            selectedNavigationLi = $(this).parent();
            selectedNavigationLi.addClass("selected");
            if(selectedNavigationLi.hasClass("first")){
                selectedNavigationLi.addClass("first_selected");
            }
            else if (selectedNavigationLi.hasClass("last")) {
                selectedNavigationLi.addClass("last_selected");
            }

            //$("#topnavigationmarker").hide();
            //$("#topnavigationmarker").slideDown("slow");
            $("#topnavigationmarker").animate({
                    top: '+=10px'}, 1000);
                     //.animate({top: '-=10px'}, 500)
                     //.animate({top: '+=10px'}, 500);

            return;
        }
    });
});
