$(document).ready(function() {
  // Navigation CUFON Hover actions ---------------------------------------------------------------      
  var hasLinkClass = false;
  $("#chromemenu li.chromemenu_li").hover(
    function () {
      if ($(this).children("h3").hasClass("thisNav")) {
        hasLinkClass = false;
      } else {
        hasLinkClass = true;
        
        $(this).children().children().children().children(".linkHover_left").addClass("active");
        $(this).children().children().children().children(".linkHover_middle").addClass("active");
        $(this).children().children().children().children(".linkHover_right").addClass("active");
        
        $(this).children("h3").addClass("currentNav");
        Cufon.replace('h3.currentNav', { 
          fontFamily: 'ApexSansBoldT',
          color: '#ab176a'
        });
      }
    }, 
    function () {
      if (hasLinkClass == true) {
        hasLinkClass = false;
        $(this).children().children().children().children(".linkHover_left").removeClass("active");
        $(this).children().children().children().children(".linkHover_middle").removeClass("active");
        $(this).children().children().children().children(".linkHover_right").removeClass("active");
        Cufon.replace('h3.currentNav', { 
          fontFamily: 'ApexSansBoldT',
          color: '#FFFFFF'
        });
        $(this).children("h3").removeClass("currentNav");
      }
    }
  );
  
  // MEGA HOVER OVER DROPDOWN ACTIONS -------------------------------------------------------------
  function megaHoverOver(){
    //$(".sub").hide();
    //$(".sub div.topNavDrop").hide();
    
    $(this).children(".sub").fadeIn(80);
    $(this).children(".sub").children("div").show();
    //$(this).find(".sub").stop().fadeTo(200, 1).show();
    //$(this).find(".sub div.topNavDrop").stop().fadeTo(200, 1).show();
    //alert($(this).children(".sub").attr("class"));
    
    //$(this).find(".sub").stop().fadeTo(200, 1).show();
    //$(this).find(".sub div.topNavDrop").stop().fadeTo(200, 1).show();
  }
  
  function megaHoverOut(){
    $(this).find(".sub").hide();
    $(this).find(".sub div.topNavDrop").hide();
    /*$(this).find(".sub").fadeTo(1, 0, function() {
      $(this).hide();
    });
    $(this).find(".sub div.topNavDrop").fadeTo(1, 0, function() {
      $(this).hide();
    });*/
  }
 
 
  var config = {    
     sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
     interval: 0, // number = milliseconds for onMouseOver polling interval    
     over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
     timeout: 20, // number = milliseconds delay before onMouseOut    
     out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
  };
 
  $("#chromemenu li.sub").css({'opacity':'0', 'display':'none'});
  $("#chromemenu li.sub div.topNavDrop").css({'opacity':'0', 'display':'none'});
  $("#chromemenu li.chromemenu_li").hoverIntent(config);
  //Cufon.refresh();
 
 
});
