/* <![CDATA[ */

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

/*

* Main navigation drop down menu

* Controls the hover intent function 
* Also has hack for IE6 bug
* and members area highlight function

* Written: 31st July 2009
* Author: Carl Brown <carl@theinternet.co.uk>

*/
 
$(document).ready(function()
{

/* !=== Hover Intent on Menus    ========================================== */    

  // Set up CSS classes to show dropdowns with a delay
  // remove the style which starts hover functionality when javascript is off
  $('ul#navigationLinks li').removeClass('navHover');
  $('ul#membersArea li').removeClass('navHover');

  // add CSS class to show dropdown on Navigation
  function addNavHoverIntent()
  {
    $(this).addClass("intent");    
  }
  // remove CSS class to hide dropdown on navigation
  function removeNavHoverIntent()
  {
    $(this).removeClass("intent");
  }

  // add CSS class to show dropdown on members area
  function addMembersHoverIntent()
  {
    $(this).addClass("intent");
    //make navigation z-index negative. IE fix.
    $('#navigationLinks').addClass('hidePrimaryNav');     
  }
  // remove CSS class to hide dropdown on members area
  function removeMembersHoverIntent()
  {
    $(this).removeClass("intent");
    //restore normal stacking order for navigation
    $('#navigationLinks').removeClass('hidePrimaryNav');
  }
  
  // set up the parameters for the hover intent function on the primary nav
  var navigationHover = 
  {
    interval:    300,              // time to wait before firing
    sensitivity: 4,                // mouse must move less than 4 pixels to fire
    over:        addNavHoverIntent,   // function to display dropdown
    timeout:     500,              // time to wait before hiding dropdown
    out:         removeNavHoverIntent // function to remove dropdown
  };
  
  // set up the parameters for the hover intent function on the members area
  var membersHover = 
  {
    interval:    300,              // time to wait before firing
    sensitivity: 4,                // mouse must move less than 4 pixels to fire
    over:        addMembersHoverIntent,   // function to display dropdown
    timeout:     500,              // time to wait before hiding dropdown
    out:         removeMembersHoverIntent // function to remove dropdown
  };
  
  /* initialise the functions */
  $("ul#navigationLinks li").hoverIntent(navigationHover);
  $("ul#membersArea > li").hoverIntent(membersHover);

/* !=== IE6 Tab Image Fix    ========================================== */

  //The following jQuery function creates extra classes to make the navigation drop downs work properly in IE6
  //THIS IS NOT BROWSER SPECIFIC. The relevant styles only exist is browser specific styesheets

  $('#navigationLinks li').mouseover(function()
  {
    //Turn on Primary Nav Styles in IE6
    $(this).addClass('turnIe6On');
  });
  $('#navigationLinks>li').mouseout(function()
  {
    //Remove Primary Nav Styles in IE6     
    $(this).removeClass('turnIe6On');
  }); 

/* !=== Highlight the members area    ========================================== */       

  //Give <a> tags a href="#membersArea" class="showMembersArea" to make them highlight the members area when clicked
  //Don't set "return false;" so that when the link is clicked it jumps to the top of the page
  
  $(".showMembersArea").click(function()
  {
    //fade in the highlight
    $("#highlightMembersArea").fadeIn("fast");
    
    // setTimeout function will wait 3 seconds
    // after the initialiser has been clicked
    // and then make the highlight dissappear
    setTimeout(function() {
      $("#highlightMembersArea").fadeOut("slow");
    }, 3000);
  });
});

/* ]]> */