// jQuery Input Default Document

(function($) {

$.fn.inputdefault = function(opts) {

  var defaults = {  
    param:    'default',
    newclass: 'defaulted'
  };
  
  // Extend our default options with those provided.
  var opts = $.extend(defaults, opts);
  
  return this
    .each(function() {
      addDefault( $(this) );
    })
    .focus(function() {
      removeDefault( $(this) );
    })
    .blur(function() {
      addDefault( $(this) );
    });
    
  function addDefault($obj) {
    if ($obj.val() == '' | $obj.val() == $obj.attr(opts.param) &&
    typeof( $obj.attr(opts.param) ) != 'undefined' )   {
      $obj.val( $obj.attr(opts.param) );
      $obj.addClass(opts.newclass);
    }
  };
  
  function removeDefault($obj) {
    if ($obj.hasClass(opts.newclass)) {
      $obj.val('');
      $obj.removeClass(opts.newclass);
    }
  };

};

})(jQuery);