jQuery(function($) {
	// Figure out the location based on the browser URL
	var path = location.pathname;
	
	if (path.toLowerCase().match(/home.html$/)) {
	  // path ends with home.html
	  var path = path.slice(0,-9);
	}

	if (path.toLowerCase().match(/societies.html$/)) {
		var path = "/giving/wheatonfund/";
	}

	// Set your homepage here, eg. /home.html or /
	var home = "/giving/home.html";
	// Check the home link against the path and set the navigation accordingly. 
	if (path == home || path == "/") {
		// Note that the jQuery selector matches *only* the home link
		var $nav = $('#navbar a[@href="' + home + '"]');
	} else {
		var $nav = $('#navbar a[@href$="' + path + '"]');
	}
	
	
	// Hide all subnavigation
	$('#navbar li ul').hide();

	// Add the active class to the current path and activate it's subnavigation
	$nav.addClass('xyzzy2').siblings("ul").slideDown("normal");
	
	// If the active class has subnavigation, show it
	$nav.parents("ul").show();
});
