﻿/*
** SideMenu.js
*/
$(function() {
	// Current url offset.  Note, we need to rely on the directory name
	// to identify the active menu group, so we strip off the page name
	// from the url.
	var root = (this.location.protocol + "//" + this.location.host + "/").toLowerCase(); 
	var path = this.location.href.toLowerCase();
	path = path.substring(0, path.lastIndexOf("/") + 1);

	// If 'root === path' then we are on the Home page and therefore
	// we don't want to expand any menus.  If this should ever change
	// then we will need to modify the following if statement to allow
	// for both situations.	Note, the issue her is that the root folder
	// will always match all the sub-folders, therefore we must manage
	// it directly.
	if (root !== path) {
		// Find all the top level item links
		$("ul.sideMenu > li > a").each(function() {
			var href = this.href.toLowerCase();
			if (href.indexOf(path) >= 0) {
				$(this).parent().children("ul").show();
			}
		});
	}
});
