// Bespoke navigation control implemented by Kevin Harrison (2e2) for Best of the Best:
// Dependancies: JQuery

$(document).ready(function() {
    page = document.location.pathname.substring(1).toUpperCase();
    if ((page == "") || (page == "/"))
        page = "/DEFAULT.ASPX";

    var navLIs = $(".nav_unselected_mid");
    maxNavIdx = navLIs.length - 1;
    navLIs.children("a").each(function(i) {
        if ($(this).attr("href").toUpperCase().indexOf(page) > -1) {
            $(this).parent().attr("class", "nav_selected_mid");

            if (i == 0)
                $(".nav_unselected_start1").attr("class", "nav_selected_start1");
            else
                $(this).parent().prev().attr("class", "nav_selected_start2");

            if (i == maxNavIdx)
                $(".nav_unselected_end").attr("class", "nav_selected_end2");
            else
                $(this).parent().next().attr("class", "nav_selected_end1");
        }
    });
});

function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) {
        vars[key] = value;
    });
    return vars;
}

