/**
 * @file jquery-search-block.js
 * Make the onfocus of the search block remove the Search overlay
 * Also focuses the search form element if the Search overlay is clicked
 */

(function ($) {

  var sor_search_onfocus = function() {
    $('div.search-block-text').hide();
  };

  var sor_search_onblur = function() {
    if ($('div.search-block input.form-text').val().length == 0) {
      $('div.search-block-text').show();
    }
  };

  Drupal.behaviors.sorSearchBehaviour = {
    attach: function (context, settings) {
      $(document).ready(function() {
        // add the show hide search text on search box on focus
        $('div.search-block input.form-text').focus(sor_search_onfocus).blur(sor_search_onblur);
        $('div.search-block-text').click(function() {
          $('div.search-block input.form-text').focus();
        });
        if ($('div.search-block input.form-text').val().length == 0) {
          $('div.search-block-text').show();
        }
        else {
          $('div.search-block-text').hide();
        }
      });
    }
  };

}(jQuery));
;

