/**
* 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);

//<![CDATA[

$(document).ready(function() {

	var userAgent = navigator.userAgent.toLowerCase();

	//Removes hover text from navigation
	$('#horizontalNav a').removeAttr("title");
	$('#leftNav a').removeAttr("title");
	
	//Adds contentFooter container
	$('#topLevelContainer').after("\<div id=\"contentFooter\"\>\<!-- end \#contentFooter --\>\<\/div\>");

	//Adds first and last class name for styling
	$('#horizontalNav ul.level1nav li:first-child').addClass("first");
	$('#horizontalNav ul.level1nav li:last-child').addClass("last");
	
	//Gives home channel class of selected
	if (jQuery.url.attr("path") == '/portal/site/iisplash') {
			$('#horizontalNav ul.level1nav li:first-child a.level1').addClass("selected");
	}

	if (jQuery.url.attr("path") == '/portal/site/iisplash/') {
			$('#horizontalNav ul.level1nav li:first-child a.level1').addClass("selected");
	}

	if (jQuery.url.attr("path") == '/portal/site/iisplash/home/') {
			$('#horizontalNav ul.level1nav li:first-child a.level1').addClass("selected");
	}
	
	
	//removes _HIDE_GLOBAL_NAV leftNav title
	if ($('#leftNav h1#leftNavTitle').html() =='_HIDE_GLOBAL_NAV') {
		$('#leftNav h1#leftNavTitle').css("display","none");
	}
	
	//removes _HIDE_GLOBAL_NAV breadcrumb
	if ($('#breadcrumbs a:nth-child(2)').html() == '_HIDE_GLOBAL_NAV') {
		$('#breadcrumbs').css("display","none");
	}
	//Old jquery.corners.js method of rounding corners - doesn't work in IE
	//$('#horizontalNav ul.level1nav li a.level1').corners('top');
	//$('#leftNav h1#leftNavTitle').corners('top');
	
	//New DD_Roundies method of rounding corners for IE only
	//DD_roundies.addRule('#horizontalNav ul.level1nav li a.level1', '5px 5px 0 0');
	//DD_roundies.addRule('#leftNav h1#leftNavTitle', '5px 5px 0 0');
	
	//$('#horizontalNav ul.level1nav a.hasSubmenu').after("\<span class=\"showArrow\"\>\<\/span\>");
	
	//$('#leftNav').height($(document).height() - 200);

	function addMega(){
      	$(this).addClass("hovering");
		
		$('#horizontalNav li.hovering div ul.level2nav li').width($('#horizontalNav li.hovering div').width()/$('#horizontalNav li.hovering div a.level2').size() - 1);
		
		
		
		$('#horizontalNav li.hovering div').bgiframe();
	}
      
	function removeMega(){
		$(this).removeClass("hovering");
	}
    
	var megaConfig = {
		interval: 250,
		sensitivity: 4,
		over: addMega,
		timeout: 250,
		out: removeMega
	};
	
	$("a.hasSubmenu").parent().hoverIntent(megaConfig)
});

//]]>
