/**
 * Initialize the main navigation menu at the top of the layout template.  If
 * the menu container is not accessible in the DOM at the time this function is
 * called, initialization will be deferred until the entire DOM is ready.
 */
window.initMainNav = function() {
  var initMainNavReady = function() {
    $('a#main_nav_fc').hover(function(){
      $('#family-finance-sr').fadeIn('fast');
      $(this).addClass('stayactive');
    }, function(){
      $('#family-finance-sr').hide();
      $(this).removeClass('stayactive');
    });
    
    $('div#family-finance-sr').hover(function(){
      $(this).show();
      $('a#main_nav_fc').addClass('stayactive');
    }, function() {
      $(this).hide();
      $('a#main_nav_fc').removeClass('stayactive');
    });
  };
  
  if ($('div.main_nav, div.sub_nav').length == 2) {
    initMainNavReady();
  } else {
    $(function(){ initMainNavReady(); });
  }
};