/**
* 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);




/**
* OmniMountPro Main nav r1 // 2010.04.09 // jQuery 1.4.2+
* <http://www.fervorcreative.com>
*
* @authors	Kevin Phillips and Aaron Smitthipong with Fervor Creative
* 
*/


$().ready(function() {	
	// initialize the maximum height of the lists
	var max = 0;
	// loop through the nav lists and get their height
	// then check to see if it is higher than the highest one
	$("#main-nav ul.products").each(
		function(i) {
			var temp = $(this).height();
			if(temp > max) {
				max = temp;	
			}
		}
	);
	// now set all of their height to the highest list
	$("#main-nav ul.products").css("height", max);
	
	max = 0;
	// loop through the nav lists and get their height
	// then check to see if it is higher than the highest one
	$("#main-nav ul.company").each(
		function(i) {
			var temp = $(this).height();
			if(temp > max) {
				max = temp;	
			}
		}
	);
	// now set all of their height to the highest list
	$("#main-nav ul.company").css("height", max);
	
	
	// loop through each list item and see if it has a subnav
	// if it does, add a class to make it have an arrow
	$("#main-nav ul li").each(
		function(i) {
			if($(this).has("ul").length) {
				$(this).find("a:first").addClass("sub");
			}
		}
	);
	
	
	
	
	var config = {    
		 sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: showMenu, // function = onMouseOver callback (REQUIRED)    
		 timeout: 0, // number = milliseconds delay before onMouseOut    
		 out: hideMenu // function = onMouseOut callback (REQUIRED)    
	};
	
	// when hovering over a list item in the nav, show any subnavs
	$("#main-nav li").hoverIntent(config);
	$("#main-nav li").hover(function(){}, function() {
		if(!$(this).has("ul").length) {
			$(this).find("a").removeClass("active");
		}
	});
	
});

var hideMenuTimeouts   = [];

function showMenu() {
   // Clear timeouts for closing menus
   for (var i in hideMenuTimeouts) {
      clearTimeout(hideMenuTimeouts[i]);
   }
   hideMenuTimeouts = [];

   // Hide those items not on the current menu path.
   var this_path = $(this)
      .add($(this).find('li'))      // Submenus of this
      .add($(this).parents('li'));  // Parents of this
   $('#main-nav li').not(this_path).each(function(){
      $(this).find('ul:first').hide();
      $(this).find("a").removeClass("active");
   });

	$(this).find("a:first").addClass("active");
	$(this).find('ul:first').show();
} // showMenu()

function hideMenu() {
   // We assume the mouse is off all menus and set a large timeout and then
   // cancel on next call to showMenu() if the mouse was only leaving for a
   // short bit or just changing submenu items.
   var _this   = this;
   hideMenuTimeouts.push(
      setTimeout(function(){
         $(_this).find('ul:first').fadeOut(100);
         $(_this).find("a").removeClass("active");
      }, 2000)
   );
} // hideMenu()

