(function($) {

  $.fn.example = function(text, args) {

    /* Merge the arguments and given example text into one options object. */
    var options = $.extend({}, args, {example: text});

    return this.each(function() {
      /* Reduce method calls by saving the current jQuery object. */
      var input = $(this);

      input.data('example', options.example);
      
      if (input.val() == '')
      {
        input.attr('value', options.example);
      }

      input.bind('focus.examplePlugin', function() {
        if (input.data('example') == $(this).val()) {
          $(this).val('');
        }
      });

      /* Make the example text reappear if the input is blank on blurring. */
      input.bind('blur.examplePlugin', function() {
        if ($(this).val() == '') {
          $(this).val(input.data('example'));
        }
      });
      
      input.parents('form').one('submit.examplePlugin', function() {
        var inputs = $(this).find(':input');
        
        $(this).find('input[type=text], textarea').each(function(i) {
          if ($(this).val() == $(this).data('example'))
          {
            $(this).val('');
          }
        })
      });
    });
}})(jQuery);