jQuery(document).ready(function(){

	/* Activity List Tree */
	$('#ActivityHolder > ul > li > a').each(
		function(){
			$(this).click(IP_ActToggle);
			
			// If the current page is this entry OR a subpage of it, don't close it.
			var pattern = new RegExp("" + $(this).attr('href') + "");
			if(pattern.test(document.location.href)){

			}else{
				$(this).click();
			}
			
			$(this).attr('href','javascript:void(0);');
		}
	);

	// Highlight the current page	
	$('#ActivityHolder a').each(
		function(){
			var pattern =  new RegExp("" + $(this).attr('href') + "");
			if(pattern.test(document.location.href)){
				$(this).addClass('Active');
			}
		}
	);
						
});

function IP_ActToggle(){
	if($(this).closest('li').children('ul').css('display') == "none"){
		$(this).closest('li').children('ul').show();
		$(this).addClass('Active');
	}else{
		$(this).closest('li').children('ul').hide();
		$(this).removeClass('Active');
	}
}