$('head').append('<style>ul.level-3, dd{display:none;}</style>')

$(document).ready(function(){
	
	$('a.print').click(function(){
		window.print();
		return false;
	});
	
	// rotate banner in header
	$('#banner').innerfade({
		speed: 'slow',
		timeout: 4000,
		type: 'sequence',
		containerheight: '43px'
	});	
	
	// if the menu is present
	if( $('dl#side-nav').length ){

		// hide all level-3
		$('ul.level-3').hide();
		
		// show any level 3s that have active children
		$('li.nav-active-2').parent().show();
		$('li.nav-active-2').parent().parent().addClass('current');
		
		// find a list item of nav-active and give the parent dd an id of active (to keep it open)
		$('li.nav-active').parent().parent('dd').attr('id','active');
		$('.nav-active-2').parent().parent().parent().parent().attr('id','active');
		
		// give the child anchor tag a class of current
		$('dd#active').prev('dt').children('a').addClass('current');
		
		// hide all inactive dds -- show all active dds
		$("dl#side-nav dd:not(#active)").hide();
		$("dl#side-nav dd#active").show();		
	
		$("dd:not(#active)").hide();
		$("dd#active").show();	
		
		// make sure we have menus present
		if( $('ul.level-2').length && $('ul.level-3').length ){
		
			// use hoverintent to prevent firing of the moveMenu function when the curser incidentally hits another dt a because of expanding/contracting		
			$("ul.level-2 > li:not(.current)").hoverIntent({
				interval: 100,
				over: moveMenu, 
				timeout: 500, 
				out: moveMenuDone
			});		
			
			function moveMenu(){
				//event.stopPropagation();
				$('li:not(.current) ul.level-3:visible').slideUp();
				$(this).find('ul:hidden').css('background-color', 'red').slideDown();
			}function moveMenuDone(){};

		
		};
		
	};	
	
});
