$(document).ready(function()
{
	// Figure out the location based on the browser URL
	var path = location.pathname.substring();
	
	// Set your homepage here, eg. /index.php or /
	var home = "/pages";

	 // 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 $headerNav = $('#headerNav a[@href$="' + home + '"]');
		var $subNav = $('#subNav a[@href="' + home + '"]');
	}
	else
	{
		var $headerNav = $('#headerNav a[@href$="' + path + '"]');
		var $subNav = $('#subNav a[@href$="' + path + '"]');
	}

	// Hide all subnavigation
	$('#headerNav li ul').hide();
	$('#subNav li ul').hide();
	
	// Add the active class to the current path and activate it's subnavigation
	//$headerNav.addClass('active').siblings("ul").slideDown();
	//$subNav.addClass('active').siblings("ul").slideDown();
	$subNav.addClass('active');
	
	// If the active class has subnavigation, show it
	//$headerNav.parents("ul").show();
	//$subNav.parents("ul").show();
	
	// Activate top level navigation, too.
	$headerNav.parents("li").children().addClass('active');	
});

