// jQuery-based code for the L9 template
(function($){
  $(function() {
    // Search field at top of page
    var $Fkeywords = $('#Fkeywords');

    // Event Handlers ---------------------------------------------------------

    // Search field "get focus"/"lose focus" behavior
    $Fkeywords.focus(function() {
      if ($(this).val() === 'Looking for something?') {
        $(this).val('').css('color','#000');
      } else {
        $(this).select();
      }
    });
    $Fkeywords.blur(function() {
      if ($(this).val() === '') {
        $(this).val('Looking for something?').css('color', '#888');
      }
    });

    // Initialization ---------------------------------------------------------

    // Setup the search field
    $Fkeywords.val('Looking for something?').css('color', '#888');

    // Navigation drop-down menu
    $('#mainNav li div:has(ul)').each(function() {
      var divH = $(this).height();
      var ulH = $(this).find('ul').height();

      // If the <ul> is taller than the <div>...
      if (ulH > divH) {
        $(this)
          .next()                               // Select the next <div> (next sibling)
          .append('<div class="downArrow" />'); // Add a <div> with a class defined to show the down arrow
      }
    });

  });
})(jQuery);


