(function($) {
  
  $.fn.example = function(text, args) {
    var options = $.extend({},
                           $.fn.example.defaults,
                           args,
                           {example_text: text});
    
    var callback = $.isFunction(options.example_text);
    
    if (!$.fn.example.bound_class_names[options.class_name]) {
      
      $(window).unload(function() {
        $('.' + options.class_name).val('');
      });
      
      $('form').submit(function() {
        
        $(this).find('.' + options.class_name).val('');
      });
      
      $.fn.example.bound_class_names[options.class_name] = true;
    }
    
    return this.each(function() {
      var $this = $(this);
      
      var o = $.metadata ? $.extend({}, options, $this.metadata()) : options;
      
      if ($.browser.msie && !$this.attr('defaultValue') &&
          (callback ? $this.val() != '' : $this.val() == o.example_text)) {
        $this.val('');
      }
      
      /* Initially place the example text in the field if it is empty. */
      if ($this.val() == '') {
        $this.addClass(options.class_name);
        $this.val(callback ? o.example_text.call(this) : o.example_text);
      }
      if (options.hide_label) {
        var label = $('label[@for=' + $this.attr('id') + ']');
        label.next('br').hide();
        label.hide();
      }
      $this.focus(function() {
        
        /* jQuery 1.1 has no hasClass(), so is() must be used instead. */
        if ($(this).is('.' + options.class_name)) {
          $(this).val('');
          $(this).removeClass(options.class_name);
        }
      });
    
      /* Make the example text reappear if the input is blank on blurring. */
      $this.blur(function() {
        if ($(this).val() == '') {
          $(this).addClass(options.class_name);
          
          /* Re-evaluate the callback function every time the user
           * blurs the field without entering anything. While this
           * is not as efficient as caching the value, it allows for
           * more dynamic applications of the plugin.
           */
          $(this).val(callback ? o.example_text.call(this) : o.example_text);
        }
      });
    });
  };
  
  $.fn.example.defaults = {
    example_text: '',
    class_name: 'example',
    
    /* DEPRECATION WARNING: I am considering removing this option. */    
    hide_label: false
  };
  
  /* All the class names used are stored as keys in the following array. */
  $.fn.example.bound_class_names = [];
  


    jQuery(function($) {
        $('#search').example(function() {
            return $(this).attr('title');
        });

        $('#top_nav_language').click(
            function () {
                $('#language_select').fadeIn("slow");
          });
       $("#language_select").hover(
          function () {
            $(this).removeClass("hidden");
          },
          function () {
            $(this).fadeOut("slow");
          }
        );
    })
})(jQuery);
