(function ($) {
  
  Drupal.behaviors.searchText = {
    attach: function(context, settings) {
      //Add search text to search box
      var defaultSearchVal = $('form#aif-search-block input#keys', context).val();
      $('form#aif-search-block input#keys', context).val(defaultSearchVal ? defaultSearchVal : 'search').focus(function() {
        $(this).val($(this).val() == 'search' ? '' : $(this).val()).addClass('active');
      }).blur(function() {
        if ($(this).val() == '') {
          $(this).val('search').removeClass('active');
        }
      });
    }
  };
  
  // replace parent links href w/ hash so that parent's aren't clickable,
  // we just want them to hover and show children
  Drupal.behaviors.removeHref = {
    attach: function(context, settings) {
      $('#main-menu ul.menu li ul.menu li.expanded > a').attr('href', '#')
    }
  };
  
  // fadeToggle speaker-bio hover
  Drupal.behaviors.speakerHover = {
    attach: function(context, settings) {
      $('div.view.view-speakers div.wrapper').hover(function() {
        $(this).find('.speaker-bio').fadeToggle(300);
      });
    }
  };
  
  // if menu item is expanded then adjust main-menu height (menu hack attack!)
  Drupal.behaviors.menuHeight = {
    attach: function(context, settings) {
      if ($('ul.menu li.expanded').length > 0) {
        $('#main-menu').css('height', '64px');
      }
    }
  };
  
  // if preface-second is not present then reduce preface-wrapper height
  Drupal.behaviors.prefaceHeight = {
    attach: function(context, settings) {
      if ($('#preface-wrapper #preface-second').length == 0) {
        $('#preface-wrapper').css('height', '390px');
      }
    }
  };

})(jQuery);
;

