(function($){
  $.fn.placeholder = function(){
    if ($.fn.placeholder.supported()){
      return $(this);
    }else{
      $(this).parent('form').submit(function(e){
        $('input[placeholder].placeholder', this).val('');
      });

      $(this).each(function(){
        $.fn.placeholder.on(this);
      });

      return $(this)
        .focus(function(){
          if ($(this).hasClass('placeholder')){
            $.fn.placeholder.off(this);
          }
        })
        .blur(function(){
          if ($(this).val() == ''){
            $.fn.placeholder.on(this);
          }
        });
    }
  };

  $.fn.placeholder.supported = function(){
    var input = document.createElement('input');
    return !!('placeholder' in input);
  };

  // Añade el contenido del placeholder en el value del input
  $.fn.placeholder.on = function(el){
    var $el = $(el);
    $el.val($el.attr('placeholder')).addClass('placeholder');
  };
  // Borra el contenido del value
  $.fn.placeholder.off = function(el){
    $(el).val('').removeClass('placeholder');
  };
})(jQuery);
