﻿// checks page name, then highlights corresponding left nav item
// So far, only works with two levels (no more)

window.onload = function()
{
	// find the URL, then get the page name at the end
	var folderPath = document.location.href;
   	var pageName = folderPath.substring(folderPath.lastIndexOf('/') + 1);

	// href of the link
	var linkPath = $("#left-nav a").attr("href");
	
	/* Because this works by page name, there's a problem when multiple levels link to a
	   "index.html". Both levels will highlight.
	   To get around this, we check if there is a top level "index.html" by searching for
	   "../../index.html". If we find one, then highlight only the second level link.
	   If there isn't one, we can highlight the top level of the navigation. */
   	if( linkPath == "../../index.html" ){
		$('#left-nav li ul li a[href$="' + pageName + '"]').addClass('selected');
	}else{
		$('#left-nav a[href$="' + pageName + '"]').addClass('selected');
    };

}

