// JavaScript Document

$(document).ready(function() {

/**
* 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);

/* $("ul#nav li a.dropdown").hoverIntent( { over: openDrop, // function = onMouseOver callback (REQUIRED)    
										  timeout: 500, // number = milliseconds delay before onMouseOut    
										  out: closeDrop // function = onMouseOut callback (REQUIRED)    
										} ); 

}); */


	$("a.dropdown").hoverIntent( 
		{ over: function () {
				$("div."+$(this).attr("id")).slideDown('fast').show(); //Drop down the subnav on click
				$("div."+$(this).attr("id")).hover(
					function(){
					},
					function(){ 
						$(this).slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
						$("a.hovering").removeClass("hovering"); // and put the nav back
					//Following events are applied to the trigger (Hover events for the trigger)
					});
				$(this).addClass("hovering");
			},
			timeout: 200,
			out: function () {
			//$("div."+$(this).attr("id")).slideUp('slow')
			} 
		}
	);










});

/*function openDrop() { //When trigger is clicked...
	
	var whichdrop = $(this).attr("id"); //Find the id of the clicked a.dropdown

	alert(whichdrop);
};
	
		//Following events are applied to the subnav itself (moving subnav up and down)
/*		$("div."+whichdrop).slideDown('fast').show(); //Drop down the subnav on click
		$(this).parent().addClass("hovering"); //and make the nav item stay lit up

		$("div."+whichdrop).hover(function() {
		}, function(){
			$("div."+whichdrop).slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
			$("a.hovering").removeClass("hovering"); // and put the nav back
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

*/



