	$(function() {
		$( "#contact-dialog" ).click(function() {
			$(this).next(".dialog").fadeIn("slow");
			return false;
		});
		$( "#search-dialog" ).click(function() {
			$(this).next(".dialog").fadeIn("slow");
			return false;
		});
		$( ".dialog .dialog-cap-t" ).click(function() {
			$(this).parent(".dialog").hide("drop", { direction: "down" }, 500);
		});
		
		// Hide the children but show the current selected sub-section
		$("#section-nav ul").css("display","none");
		$("#section-nav a.selected").next("ul").css("display","block");
		//$("#section-nav ul a.selected").parent("li").parent("ul").addClass("open");
		
		// Add an icon to indicate child pages
		$("#section-nav li").has("ul").children("a").addClass("has-children");
		
		// Append the closing <li> to the end of each sub section
		$('<li class="close"><a href="#"><span>X</span> Close This Section</a></li>').appendTo('#section-nav li ul');
		
		// Now hide the closing <li> for the section that is open by default
		$("#section-nav a.selected").next("ul").find("li.close").css("display","none");
		
		// Show the sub section after the mouse has rested for a moment and indicate it is now open		
			
			// set a couple functions for hoverIntent.js
			function menuOpen(){
				$(this).addClass("open");
				$(this).next("ul").show(250);
			}		
			function menuClose() {} //do nothing, we're going to close it manually
			
			// set the configs for hoverIntent.js
			var config = {    
				sensitivity: 3, 
				interval: 200,  
				over: menuOpen, 
				timeout: 1000,    
				out: menuClose     
			};
		
		$("#section-nav li").has("ul").children("a").hoverIntent( config 	);
		
		 // Manually close the sub section and reset the open class
		$("#section-nav ul li.close").click(
			function(){
				$(this).parent("ul").prev("a").removeClass("open");
				$(this).parent("ul").hide("fast");
				return false;
			}
		);
		
	});
