﻿/**
* 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);

var dropping=false;

$(document).ready(function() {
	$(".nav-global > ul > li").hoverIntent({
		sensitivity: 2,
		interval: 100,
		over: showGlobalMenu,
		timeout: 100,
		out: hideGlobalMenu
	});

	$(".nav-selector div").hoverIntent({
		sensitivity: 2,
		interval: 100,
		over: showWorldMenu,
		timeout: 100,
		out: hideWorldMenu
	});
	//Adding code for wrapping of top navigation
	$(".primaryNav").each(function(){
    		if($(this).height()>25)
      			$(this).css("padding","5px 0px 2px")
  	});
});

function showGlobalMenu() {
	dropping=true;
	$("html.msie div#content").css({"z-index":"-1","position":"relative"});//ie6/ie7 drop down broswer fix
	var $menu = $(this).children("div");
	$("div", $menu).show();
	$menu.slideDown("fast", function(){
		dropping=false;
	});
	

}
		
function hideGlobalMenu(){
	$("div", this).slideUp("fast", function(){
		if(!dropping)
		  $("html.msie div#content").css("z-index","0");//ie6/ie7 drop down broswer fix
	});
	
}

function showWorldMenu(){
	$(this).find("li#countrySelector img").attr({
			src: "/common/images/icon-world-on.gif"
	 });

	var $menu = $("#world", this);
	$("div", $menu).show();
	$menu.slideDown("fast");
}

function hideWorldMenu(){
	$(this).find("li#countrySelector img").attr({
			src: "/common/images/icon-world.gif"
	 });

	var $menu = $("#world", this);
	$menu.slideUp("fast");
}

