$(document).ready(function(){
	var config = {    
	     sensitivity: 3,
	     interval: 100,
	     over: showSubMenu,
	     timeout: 200,
	     out: hideSubMenu
	};
	
	var config2 = {    
	     sensitivity: 3,
	     interval: 100,
	     over: showFlyout,
	     timeout: 200,
	     out: hideFlyout
	};
	
	var config3 = {    
	     sensitivity: 3,
	     interval: 100,
	     over: showNFlyout,
	     timeout: 200,
	     out: hideNFlyout
	};

	$("#nav li.dropdown-link").hoverIntent(config);
	
	function showSubMenu() { $("a.mnav", $(this)).css('background-position','0 -30px');$("ul", $(this)).slideDown('fast'); }
	function hideSubMenu() { $("a.mnav", $(this)).css('background-position','0 0');$("ul", $(this)).slideUp('fast'); }
	
	$("#nav li.flyout-link").hoverIntent(config2);
	
	function showFlyout() { $("a.mnav", $(this)).css('background-position','0 -30px');$("#flyout-topics", $(this)).slideDown('normal'); }
	function hideFlyout() { $("a.mnav", $(this)).css('background-position','0 0');$("#flyout-topics", $(this)).slideUp('fast'); }
	
	$('a.print_link').click(function(){
		print_window = window.open($(this).attr('href'),'print_window','toolbar=no, scrollbars=yes, menubar=no, width=800, height=500');
		return false;
		if (window.focus) { print_window.focus(); }
	});
	
	$('#search-top ul li a').click(function(){
		$('#search-top ul li a').removeClass('selected');
		$(this).addClass("selected").blur();
		$('#ipq').focus();
		$('#top_search_type').attr("value",$(this).attr('title'));
	});
	
	 $('#side-accordion').accordion({
		autoheight: false,
		header: '.head',
		active: '.current',
		event: 'mouseover'
	});
	
	$('#side-accordion a').each(function(i){
		if ($(this).hasClass('current')) {
			$(this).next('div').css('display', 'block');
		}
	});
	
	if ($('#aeqdisclaimer').length > 0) {
		$('.disclaimer_link').click(function(){
			$('#aeqdisclaimer').toggle();
		});
	}
	
	$(".has_nflyout").hoverIntent(config3);
	
	function showNFlyout() { 
		$('.nflyout').hide();
		$("a.mnav").css('background-position','0 0');
		$("a.mnav", $(this)).css('background-position','0 -30px');
		$('.nflyout',this).show();
	}
	function hideNFlyout() { $('.nflyout').hide();$("a.mnav").css('background-position','0 0'); }
	
	$('.close_flyout').click(function(){
		$('.nflyout').hide();
		$("a.mnav").css('background-position','0 0');
	});
	
	
	/*
	if ($('#three-col-col2').length > 0) {
		$("#three-col-col2 a[href^=http]").each(function(){
			if (!this.href.match('pregnancytoday.com')) {
				$(this).attr({
					target: "_blank"
				});
			}
		});
	}
	*/
	
	jQuery.preloadImages = function()
	{
	  for(var i = 0; i<arguments.length; i++)
	  {
	    jQuery("<img>").attr("src", arguments[i]);
	  }
	}
	
	$.preloadCssImages();
	
	
	//$.preloadImages('/images/flyout_tl.png','/images/flyout_tc.png','/images/flyout_tr.png','/images/flyout_tlb.png','/images/flyout_trb.png','/images/flyout_cl.png','/images/flyout_cr.png','/images/flyout_bl.png','/images/flyout_bc.png','/images/flyout_bl.png');
	
	
});

/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);