// JavaScript Document
var selectedMenuItem = function() {
// get url string
var location = new String(window.location);

// get page/file name
var pageName = new String(location.substring(location.lastIndexOf('/')+1));

// check if pagename is blank, this assumes that it's the home page
if(pageName == '') {
pageName = 'index.php';
}

// jquery : find nav item and apply selected class
// iterate through each UL first child LI elements
$('ul > li').each(function() {

// if a link item href matches current page/file name
if($(this).find('a[@href$='+pageName+']').length > 0) {
// apply selected class to first anchor link child of list item.
$(this).find('a:eq(0)').addClass("selected");
$(this).addClass("selected");
}
if($(this).find('a[@href=/'+pageName+']').length > 0) {
// apply selected class to first anchor link child of list item.
$(this).find('a:eq(0)').addClass("selected");
$(this).addClass("selected");
}

// if a link item href exists in a subdirectory
// if($(this).find('a[@href=/'+pageName+']').length > 0) {
// apply selected class to parent list item.
// $(this).find('a:eq(0)').addClass("selected");
// $(this).addClass("selected");
// }
// get the parent list item and apply the selected class to it


});
}

$(document).ready(function() {
selectedMenuItem();
});