(function ($) {

  Drupal.behaviors.base = {
    attach: function (context, settings) {

      /**
       * Tabs toggling on parent div hovering.
       */
      var tabs = $('div.tabs');
      tabs.each(function() {
        var $tab = $(this);
        $tab.data('parent', $tab.parent('div'));
        $tab.data('semaphore', false);
        $tab.data('parent')
          .bind('mouseenter', function() {
            if (!$tab.data('semaphore')) {
              $tab.data('semaphore', true);
              $tab.fadeIn('fast', function() {
                $tab.data('semaphore', false);
              });
            }
          })
          .bind('mouseleave', function() {
            if (!$tab.data('semaphore')) {
              $tab.data('semaphore', true);
              $tab.fadeOut('slow', function() {
                $tab.data('semaphore', false);
              });
            }
          });
      });

      var search_nav_box_input = $('#search-block-form .form-text');
      search_nav_box_input.each(function() {
        var $this = $(this);

        $this
          .data('initial-margin', search_nav_box_input.css('margin-left'))
          .data('initial-width', search_nav_box_input.width())

          .data('tiny-margin', '121px')
          .data('tiny-width', '60px')

          .bind('focus', function() {
            $this.animate({
              'margin-left': $this.data('initial-margin'),
              'width': $this.data('initial-width'),
            }, 'fast');
          })
          .bind('blur', function() {
            $this.animate({
              'margin-left': $this.data('tiny-margin'),
              'width': $this.data('tiny-width'),
            }, 'fast');
          })
          .trigger('blur');
      });

    }
  };

}(jQuery));;

