$(document).ready(function()
{
	// Handles fade operations in the .nav_header_sub which are triggered in the .nav_header
	$(".nav_header a").click(function()
	{
		// Fade in the related subitem if it exists
		var target_id = this.id+"_sub";
		if(this.id !== "" && document.getElementById(target_id) !== null)
		{
			// Is the target_id already open?
			var current_opac = $("#"+target_id).css('opacity');
			var current_disp = $("#"+target_id).css('display');
			if(current_disp != "block" || current_opac <= 0)
			{
				// Fade out everything
				$(".nav_header_sub p").fadeOut(500);
				$(".nav_header a").removeClass("selected");
				
				// Fade in the target_id
				$('#'+target_id).fadeIn(500, function(){
					$(this).css('opacity', 1); // To prevent IE's ClearType from turning itself back on
				});
				
				// Make this nav item 'selected'
				$("#"+this.id).addClass("selected");
			}
			return false;
		}
		
		// There isn't a target id, or it doesn't exist
		else
		{
			// Fade out everything and execute the link
			$(".nav_header_sub p").fadeOut(500);
			$(".nav_header a").removeClass("selected");
			return true;
		}
		
	});
});