// JavaScript Document FOR LEFT NAV

$(document).ready(function() {


$("#openleftnav li").addClass("c");  //add close class to all li's in #nav

/*
This menu script requires the jQuery library.  It will turn a standard html list (using ul/li tags) into a basic menu THAT OPENS TO THE APPROPRIATE SUB SECTION. It has been altered to work with the above script which target the link to the active page.  This will open the menu to the link to the current page, in addition to adding a class to it.

To use:
1. Add the id "openleftnav" to the containing ul tag of the entire left menu.
2. add the following style to a linked stylesheet.
.c ul {display: none}
*/

// This section highlights the page itself
//pathfile=location.href.replace("http://www.law.umaryland.edu","");
pathfile=location.href.replace("http://www.mdsmokefreeapartments.org","");

pathfile=pathfile.replace("index.html","");
$('a[@href="' + pathfile + 'index.html"]').addClass("activeLink").parents().removeClass("c");
$('a[@href="' + pathfile + '"]').addClass("activeLink").parents().removeClass("c");

// Get immediate parent directory & highlight any links to it
//if (pathfile.indexOf(".html") > -1 ){
parentpath=pathfile.substring(0,pathfile.lastIndexOf("/")) + "/";
//$('a[@href="' + parentpath + 'index.html"]').addClass("activeLink").parents().removeClass("c");
//$('a[@href="' + parentpath + '"]').addClass("activeLink").parents().removeClass("c");
//}


//get parents all the way back & highlight links to them
while (parentpath.indexOf("/") > -1 ) {
parentpath=parentpath.substring(0,parentpath.substring(0,parentpath.length-1).lastIndexOf("/"));
$('a[@href="' + parentpath + 'index.html"]').addClass("activeLink").parents().removeClass("c");
$('a[@href="' + parentpath + '"]').addClass("activeLink").parents().removeClass("c");
}

// We may need something like this for an override.  If we find we need an override.
// New, easier matching! You can skip the above steps and just add links to the page you want to match in the hidden div "navmatch"
//if ($("a.leftmatch")) {
//	$("a[@href=" + $("a.leftmatch").attr("href") + "]").addClass("activeLink").parents().removeClass("c");
//}
//if ($("a.rightmatch")) {
//	$("a[@href=" + $("a.rightmatch").attr("href") + "]").addClass("activeLink").parents().removeClass("c");
//}
//if ($("a.centermatch")) {
//	$("a[@href=" + $("a.centermatch").attr("href") + "]").addClass("activeLink").parents().removeClass("c");
//}

});