// NPD Custom JavaScript
// Start Document Ready Calls
var $j  = jQuery.noConflict();
$j(document).ready(function() {
});

$(document).ready(function(){
	/********************************************/
	//		Home Page Rotating Banners
	/********************************************/
        if($('#leftNavColumn').length) {
	      $('#leftNavColumn').replaceWith( $('#sideNav>ul'));
        }
        if($('#metatags').length) {
		$('#metatags').remove();
        }
        if($("#leftNavColumnTitle").length) {
	      $('#leftNavColumnTitle').replaceWith( $('#leftNavTitle'));
              document.getElementById("leftNavTitle").style.display = 'block';
        }
	if($('#wptheme-mainContent').length) {
		$('#wptheme-mainContent').css('margin-left', '14px');
	}
	var strcontent = "/wps/wcm/connect";
	var wcmlibname = "";
	if($('#UserLoggedIn').length != 0) {
		strcontent = "/wps/wcm/myconnect";
	}
	
	if($('#WCMLibraryName').length != 0) {
		wcmlibname = "/"+$('#WCMLibraryName').text();
	}
	
	if($('#headerimg').length) {
		if($.browser.msie && $.browser.version=="6.0") {
			$('#headerimg').css('background', 'url("'+strcontent+'/2573c0004852106996b7d7b16b48523f/bg-maincontent-top_no_halo.png?MOD=AJPERES") no-repeat scroll 0 0 transparent');
			$('#headerimg').css('margin-left','15px');
			$('#headerimg').css('display','inline');
		}
        }

	var counter = 1;
	$("#wptheme-mainContent>table>tbody>tr").each(function(i, tr) {
	    if($('#wptheme-mainContent>table>tbody>tr:nth-child('+counter+')').length && $('#wptheme-mainContent>table>tbody>tr:nth-child('+counter+')').text().indexOf('bgmaincontentfill') > -1) {
	    	if($.browser.msie && $.browser.version=="6.0") {
	    		$('#wptheme-mainContent>table>tbody>tr:nth-child('+counter+')').css('background', 'url("'+strcontent+'/cf4c6d004852118d96bfd7b16b48523f/bg-maincontent-fill_no_halo.png?MOD=AJPERES") repeat-y scroll 11pt 0 transparent');	
	    	} else {
	    		$('#wptheme-mainContent>table>tbody>tr:nth-child('+counter+')').css('background', 'url("'+strcontent+'/5b1b6e804589d757a6dcbfea9abab3fc/bg-maincontent-fill.png?MOD=AJPERES") repeat-y scroll 0 0 transparent');
	    	}
		
	    }
	    counter=counter+1;	    
	});

	/*
	$('#contentPage>.leftColumn>ul>li').each(function(id, pele) {
			if($(pele).children().length == 0) {
				//$(pele).remove();
			}
		});
	$('#contentPage>.leftColumn>ul>li>ul').each(function(id, pele) {			
			var test = $(pele).children('li');
			$(test).each(function(){
				if($(test).children().length == 0) {
					//$(test).css('display', 'none');
				}
			});
	});

	
	if($('#wptheme-mainContent>table>tbody>tr:nth-child()').length && $('#wptheme-mainContent>table>tbody>tr:nth-child()').text().indexOf('bgmaincontentfill') > -1) {		
		$('#wptheme-mainContent>table>tbody>tr:nth-child()').css('background', 'url("'+strcontent+'/5b1b6e804589d757a6dcbfea9abab3fc/bg-maincontent-fill.png?MOD=AJPERES") repeat-y scroll 0 0 transparent');
	}
	
	if($('#leftContent').parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().length) {	
		$('#leftContent').parent().parent().parent().parent().parent().parent().parent().parent().parent().parent().css('background', 'url("'+strcontent+'/5b1b6e804589d757a6dcbfea9abab3fc/bg-maincontent-fill.png?MOD=AJPERES") repeat-y scroll 0 0 transparent');
	}
	*/
	//Large Home Page Banner
	$('#navPosition').before('<div id="pagernav">').cycle({ 
		fx:     'fade',             
		speed:   1000, 
		timeout: 8000, 
		pager:  '#pagernav' 
	});
	//Home Page Featured Reports
	$('#featuredPosition').before('<div id="featuredNav">').cycle({ 
		fx:     'scrollUp',             
		speed:   500, 
		timeout: 0, 
		pager:  '#featuredNav' 
	});
	
	//Right Column Rotating Module
	$('#rotatingModule').before('<div id="moduleNav">').cycle({ 
		fx:     'fade',             
		speed:   500, 
		timeout: 0, 
		pager:  '#moduleNav' 
	});
	
	//Right Column Arrows
	$('#arrowsModule').cycle({ 
		fx:     'fade', 
		startingSlide: Math.floor(Math.random()*($('#arrowsModule .module').size())),
		speed:  'fast', 
		timeout: 0, 
		next:   '#next2', 
		prev:   '#prev2'
	});
	
	/********************************************/
	//		IE6 PNG Fix
	/********************************************/
	$(function() {
		$('.bannerLeft').png();
		$('.wpsPortletBody').png();
		$('#bgmaincontentfill').png();

		$('#mainContent').png();
		$('#mainContent #content').png();
		$('#mainContent #footer').png();
		$('#bannerHub .bannerRight').png();
		$('.bannerContent .bannerRight').png();
	});
	
	//Run when images are being loaded
	$('img').load(function() {
		$(this).png();
	});
	
	/********************************************/
	//		Mega Menu Dropdown
	/********************************************/
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) 
	{
		jQuery(".megamenu").megamenu({ 'activate_action':'click' })
	}
	else
	{
		jQuery(".megamenu").megamenu();
	}
	
	/********************************************/
	//		Accordion
	/********************************************/
	//Set the class 'ON' and "OPEN" the first Accordion Trigger
	$('.accordionButton').first().addClass('on');
	$('.accordionContent').first().css("display","block");
		
	$('.accordionButton').click(function() {
		//Remove the 'ON' once the Trigger is clicked
		$('.accordionButton').removeClass('on');
		//NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
	 	$('.accordionContent').slideUp('normal');
		//IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT
		if($(this).next().is(':hidden') == true) {
			//ADD THE ON CLASS TO THE BUTTON
			$(this).addClass('on');
			//OPEN THE SLIDE
			$(this).next().slideDown('normal');
		 }
	 });
	
	/********************************************/
	//		Equal Heights Colums
	/********************************************/
	equalHeight($(".equalFooter"));
	
	//********************************************/
	//		AJAX - Loading External Pages (Industries Hub Page) 
	/********************************************/
	// load Default (USA) Industries when the page loads
	if($("#selectedcountry").text().split(' ').join('') == "UnitedStates") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=usa.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Autralia") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=autralia.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Austria") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=austria.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Belgium") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=belgium.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Brazil") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=brazil.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Canada") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=canada.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "China") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=china.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "France") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=france.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Germany") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=germany.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Italy") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=italy.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Japan") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=japan.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Mexico") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=mexico.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Netherlands") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=netherlands.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "NewZealand") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=newzealand.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Poland") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=poland.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Portugal") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=portugal.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Russia") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=russia.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Spain") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=spain.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "Sweden") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=sweden.html");
	} else if($("#selectedcountry").text().split(' ').join('') == "UnitedKingdom") {
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=uk.html");
	}
	
	$("#usa").click(function(){
	// load USA Industries on click
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=usa.html");
	});

	$("#australia").click(function(){
	// load australia Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=australia.html");
	});

	$("#austria").click(function(){
	// load austria Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=austria.html");
	});

	$("#belgium").click(function(){
	// load belgium Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=belgium.html");
	});

	$("#brazil").click(function(){
	// load brazil Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=brazil.html");
	});

	$("#canada").click(function(){
	// load canada Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=canada.html");
	});

	$("#china").click(function(){
	// load china Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=china.html");
	});

	$("#france").click(function(){
	// load france Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=france.html");
	});

	$("#germany").click(function(){
	// load germany Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=germany.html");
	});

	$("#italy").click(function(){
	// load italy Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=italy.html");
	});

	$("#japan").click(function(){
	// load japan Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=japan.html");
	});

	$("#mexico").click(function(){
	// load mexico Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=mexico.html");
	});

	$("#netherlands").click(function(){
	// load netherlands Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=netherlands.html");
	});

	$("#newzealand").click(function(){
	// load new zealand Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=newzealand.html");
	});

	$("#poland").click(function(){
	// load poland Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=poland.html");
	});

	$("#portugal").click(function(){
	// load portugal Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=portugal.html");
	});

	$("#russia").click(function(){
	// load russia Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=russia.html");
	});

	$("#spain").click(function(){
	// load spain Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=spain.html");
	});

	$("#sweden").click(function(){
	// load sweden Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=sweden.html");
	});

	$("#uk").click(function(){
	// load united kingdom Industries form onclick
		$("#industryWrap").load(strcontent + wcmlibname + "/npd?srv=cmpnt&source=library&cmpntname=uk.html");
	});



	
	//********************************************/
	//		COUNTRY SELECTION - Industry Hub Page
	/********************************************/
	$(".dropdown img.flag").addClass("flagvisibility");
	$(".dropdown dt a").click(function() {
		$(".dropdown dd ul").toggle();
	});

	$(".dropdown dd ul li a").click(function() {
		var text = $(this).html();
		$(".dropdown dt a span").html(text);
		$(".dropdown dd ul").hide();
		$("#result").html("Selected value is: " + getSelectedValue("sample"));
	});

	function getSelectedValue(id) {
		return $("#" + id).find("dt a span.value").html();
	}

	$(document).bind('click', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("dropdown"))
			$(".dropdown dd ul").hide();
	});

	$("#flagSwitcher").click(function() {
		$(".dropdown img.flag").toggleClass("flagvisibility");
	});
	
	/********************************************/
	//		Font Replacement
	/********************************************/
	Cufon.replace('.cufon', { fontFamily: 'Helvetica Neue' });
	

		
});
// End Document Ready Calls

/////////////////////////////////////////////
//Force FIX for IE7/IE8 Animated PNGs
/////////////////////////////////////////////

$(function() {
    $('.featured').png({
        shimImage: '/wps/wcm/connect/ad5593004589d749a67cbfea9abab3fc/blank.gif?MOD=AJPERES',
        force: true,
        children: true
    });
});

/********************************************/
//		Tabs
/********************************************/
$(function() {
	// setup ul.tabs to work as tabs for each div directly under div.panes
	$("ul.tabs").tabs("div.panes > div");
});


/////////////////////////////////////////////
//Press Releases JavaScript
/////////////////////////////////////////////

function displaySelectedIndustry(category) {
	if (category == "CAT-All"){
		$(".PR-Industry").show();
	} else {
		$(".PR-Industry").hide();
		var preFix =".-" + category;
		var postFix = "." + category + "-";	
		$(preFix).show();
		$(postFix).show();		
	}
}


/////////////////////////////////////////////
//Equal Heights with JavaScript
/////////////////////////////////////////////

function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

/////////////////////////////////////////////

//Mega Menu

/////////////////////////////////////////////
	
/*
  jQuery MegaMenu Plugin
  Author: GeekTantra
  Author URI: http://www.geektantra.com
*/
var isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;

jQuery.fn.megamenu = function(options) {
  options = jQuery.extend({
	  activate_action: "mouseenter",
	  deactivate_action: "mouseleave",
	  show_method: "slideDown",
	  hide_method: "slideUp",
	  justify: "left",
	  enable_js_shadow: true,
	  //shadow_size: 0,
	  mm_timeout: 250
  }, options);
  var $megamenu_object = this;
  if( options.activate_action == "click" ) options.mm_timeout = 0;
  $megamenu_object.children("li").each(function(){
    jQuery(this).addClass("mm-item");
    jQuery(".mm-item").css({ 'float': options.justify });
    
    jQuery(this).find("div:first").addClass("mm-item-content");
    jQuery(this).find("a:first").addClass("mm-item-link");
    var $mm_item_content = jQuery(this).find(".mm-item-content");
    var $mm_item_link = jQuery(this).find(".mm-item-link");
    $mm_item_content.hide();
    
    jQuery(document).bind("click", function(){
      jQuery(".mm-item-content").hide();
      jQuery(".mm-item-link").removeClass("mm-item-link-hover");
      jQuery(".mm-item-link").removeClass("mm-item-link-nochild-hover");
    });
    jQuery(this).bind("click", function(e){
      e.stopPropagation();
    });

	//iPad Fix
	jQuery(this).find("a.mm-item-link").bind("click", function(e){
		if (jQuery(this).parent().find("div.mm-item-content").is(":visible"))
		{
			//Follow the link
		}
		else
		{
			e.preventDefault();
		}
    });

    $mm_item_content.wrapInner('<div class="mm-content-base"></div>');
    if(options.enable_js_shadow == true) {
      $mm_item_content.append('<div class="mm-js-shadow">&nbsp;</div>');
    }
    var $mm_timer = 0;
    // Activation Method Starts
    jQuery(this).bind(options.activate_action, function(e){
      e.stopPropagation();
      var mm_item_link_obj = jQuery(this).find("a.mm-item-link");
      var mm_item_content_obj = jQuery(this).find("div.mm-item-content");
      clearTimeout($mm_timer);
      $mm_timer = setTimeout(function(){ //Emulate HoverIntent
	if(mm_item_content_obj.attr('id') == "nochild-dropdown") {
		mm_item_link_obj.addClass("mm-item-link-nochild-hover");

	} else {
	        mm_item_link_obj.addClass("mm-item-link-hover");
	}
        
        mm_item_content_obj.css({
          'top': ($mm_item_link.offset().top + $mm_item_link.outerHeight()) - 1 +"px",
          'left': ($mm_item_link.offset().left) - 0 + 'px'
        })
        
        if(options.justify == "left"){
          var mm_object_right_end = $megamenu_object.offset().left + $megamenu_object.outerWidth();
                                    // Coordinates of the right end of the megamenu object
          var mm_content_right_end = $mm_item_link.offset().left + $mm_item_content.outerWidth() - 2 ;
                                    // Coordinates of the right end of the megamenu content
          if( mm_content_right_end >= mm_object_right_end ) { // Menu content exceeding the outer box
            mm_item_content_obj.css({
              'left': ($mm_item_link.offset().left - (mm_content_right_end - mm_object_right_end)) - 65 + 'px'
            }); // Limit megamenu inside the outer box
          }
        } else if( options.justify == "right" ) {
          var mm_object_left_end = $megamenu_object.offset().left;
                                    // Coordinates of the left end of the megamenu object
          var mm_content_left_end = $mm_item_link.offset().left - mm_item_content_obj.outerWidth() + 
                                    $mm_item_link.outerWidth() + 5;
                                    // Coordinates of the left end of the megamenu content
          if( mm_content_left_end <= mm_object_left_end ) { // Menu content exceeding the outer box
            mm_item_content_obj.css({
              'left': mm_object_left_end + 0 + 'px'
            }); // Limit megamenu inside the outer box
          } else {
            mm_item_content_obj.css({
              'left': mm_content_left_end + 'px'
            }); // Limit megamenu inside the outer box
          }
        }
        if(options.enable_js_shadow == true) {
          mm_item_content_obj.find(".mm-js-shadow").height( mm_item_content_obj.height() );
          mm_item_content_obj.find(".mm-js-shadow").width( mm_item_content_obj.width() );
          /*mm_item_content_obj.find(".mm-js-shadow").css({
            'top': (options.shadow_size) + (isIE6 ? 2 : 0) + "px",
            'left': (options.shadow_size) + (isIE6 ? 2 : 0) + "px"
            //'opacity': 0.2
          });*/
        }
        switch(options.show_method) {
          case "simple":
                mm_item_content_obj.show();
                break;
          case "slideDown":
                mm_item_content_obj.height("auto");
                mm_item_content_obj.slideDown('fast');
                break;
          case "fadeIn":
                mm_item_content_obj.fadeTo('fast', 1);
                break;
          default:
                mm_item_content_obj.each( options.show_method );
                break;
        }
      }, options.mm_timeout);
    });
    // Activation Method Ends
    // Deactivation Method Starts
    jQuery(this).bind(options.deactivate_action, function(e){
      e.stopPropagation();
      clearTimeout($mm_timer);
      var mm_item_link_obj = jQuery(this).find("a.mm-item-link");
      var mm_item_content_obj = jQuery(this).find("div.mm-item-content");
//      mm_item_content_obj.stop();
      switch(options.hide_method) {
        case "simple":
              mm_item_content_obj.hide();
              mm_item_link_obj.removeClass("mm-item-link-hover");
              break;
        case "slideUp":
              mm_item_content_obj.slideUp( 'fast',  function() {
              	if(mm_item_content_obj.attr('id') == "nochild-dropdown") {
                	mm_item_link_obj.removeClass("mm-item-link-nochild-hover");
                } else {
                	mm_item_link_obj.removeClass("mm-item-link-hover");
                }
                
              });
              break;
        case "fadeOut":
              mm_item_content_obj.fadeOut( 'fast', function() {
                mm_item_link_obj.removeClass("mm-item-link-hover");
              });
              break;
        default:
              mm_item_content_obj.each( options.hide_method );
              mm_item_link_obj.removeClass("mm-item-link-hover");
              break;
      }
    });
//    Deactivation Method Ends
  });
  this.find("li:last").after('<li class="clear-fix"></li>');
  this.show();
};


/***********************************************/

/**
* 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);

