(function($) {  
  $.fn.example = function(text, args) {
    var options = $.extend({}, $.fn.example.defaults, args);
    
    var callback = $.isFunction(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() {
      
      /* Reduce method calls by saving the current jQuery object. */
      var $this = $(this);
      if ($.browser.msie && !$this.attr('defaultValue') &&
          (callback ? $this.val() != '' : $this.val() == text)) {
        $this.val('');
      }

      if ($this.val() == '') {
        $this.addClass(options.class_name);
        $this.val(callback ? text.call(this) : text);
      }
      if (options.hide_label) {
        var label = $('label[@for=' + $this.attr('id') + ']');
        label.next('br').hide();
        label.hide();
      }
    
      $this.focus(function() {
        if ($(this).is('.' + options.class_name)) {
          $(this).val('');
          $(this).removeClass(options.class_name);
        }
      });
    
      $this.blur(function() {
        if ($(this).val() == '') {
          $(this).addClass(options.class_name);
          $(this).val(callback ? text.call(this) : text);
        }
      });
    });
  };
  
  $.fn.example.defaults = {
    class_name: 'example',
    hide_label: false
  };
  
  $.fn.example.bound_class_names = [];
  
})(jQuery);
