$(document).ready(function () {

	/* Add class to currently navigated menu item */
	var page = location.pathname;
        // If there is a slash on the end, add a Default.aspx to it... because that's likely the page we're on
        if (page.charAt(page.length-1) == '/')
            page = page.concat('Default.aspx');

        // Remove all the folders above the file...
        var index;
        var counter = 0;
        while (((index = page.indexOf('/')) != -1) && counter < 100) {
            page = page.slice(index+1);
            counter++;
        }

        // See if any of the primary links have a match
        $("#LeftMenu a").each(function () {
            if ($(this).attr('href').indexOf(page) != -1) {
                $(this).addClass("Selected");
            }
        });

        // See if any of the secondary links have a match
        $("#RightMenu a").each(function () {
            if ($(this).attr('href').indexOf(page) != -1) {
                $(this).addClass("Selected");
            }
        });

});