// See: http://www.sohtanaka.com/web-design/mega-drop-downs-w-css-jquery/

jQuery(document).ready(function() {

  // START - Hover Effects

	//On Hover Over
  function megaHoverOver(){
      jQuery(this).find(".inner_sub").stop().fadeTo('fast', 0.96).show(); //Find sub and fade it in
      (function(jQuery) {
          //Function to calculate total width of all ul's
          jQuery.fn.calcSubWidth = function() {
              rowWidth = 0;
              //Calculate row
              jQuery(this).find("ul").each(function() { //for each ul...
                  rowWidth += jQuery(this).width(); //Add each ul's width together
              });
          };
      })(jQuery); 

      //Here the original script set the width of .inner_sub. However, we don't need that functionality.


      // START - Drop Shadow Effects
      jQuery(this).find(".inner_sub").dropShadow({left:6, top:6});
      // END - Drop Shadow Effects

  }
  //On Hover Out
  function megaHoverOut(){
    jQuery(this).find(".inner_sub").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
        jQuery(this).hide();  //after fading, hide it
    });
    // START - Drop Shadow Effects
    jQuery(this).find(".inner_sub").removeShadow();
    // END - Drop Shadow Effects
  }

  //Set custom configurations
  var config = {
       sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
       interval: 100, // number = milliseconds for onMouseOver polling interval
       over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
       timeout: 500, // number = milliseconds delay before onMouseOut
       out: megaHoverOut // function = onMouseOut callback (REQUIRED)
  };

  jQuery("#top_navigation .outer_sub .inner_sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
  jQuery("#top_navigation td").hoverIntent(config); //Trigger Hover intent with custom configurations


  // END - Hover Effects



});

