// ./_js/side_nav.js 

$(document).ready(function(){
						   
    // use JS to hide the following elements instead of css
	$("ul.sn_tier2.hidden").hide(0);
	$("ul.sn_tier2.hidden").removeClass('hidden');
	$("ul.sn_tier3.hidden").hide(0);
	$("ul.sn_tier3.hidden").removeClass('hidden');
						   
	$("ul#sn_tier1 li.submenu_parent a").click(function() { // actions are applied to the <a> rather than its parent <li>, so that clicks to other nested elements within the <li> do not trigger events
		if($(this).parent().attr("rel") == "sn_tier1") { // make sure only to apply these actions to tier1 <li>'s
			if($(this).attr('href') == '#' && $(this).parent().find("ul.sn_tier2").hasClass('expanded') == false) { // ... and only to null (anchor) parent links, who are not the current (expanded) section
				if($(this).parent().find("ul.sn_tier2").is(":hidden")) {
					$(this).parent().addClass('active');
					$(this).parent().find("ul.sn_tier2:not('.expanded')").slideDown("fast");
				} else {
					$(this).parent().find("ul.sn_tier2:not('.expanded')").slideUp("fast");
					$(this).parent().removeClass('active');
				}
				
				return false; // prevent a href="#" from causing page scroll jump		
			}
		}
	});
	
	
	$("ul.sn_tier2 li.submenu_parent").hover(function() { 
		$(this).find("ul.sn_tier3").show(0); // show tier3
	 }, function() {	
		$(this).find("ul.sn_tier3").hide(0); // hide tier3		
	});
	
	
});
