(function($) {
  var settings = {};

  $.extend(
    $.support,
    {placeholder: !!('placeholder' in document.createElement('input'))}
  );

  $.fn.placeholder = function(conf) {
    var s = $.extend({}, settings, conf);

    return this.each(function() {
      if ($.support.placeholder) {
        return false;
      }

      if (!(this.tagName.toLowerCase() == 'input' ||
              this.tagName.toLowerCase() == 'textarea')) {
        return true;
      }

      var $this = $(this),
          ph = this.getAttribute('placeholder');

      if (!ph) {
        return true;
      }

      var val = $this.val(),
          c = s.phClass;

      if (!val || ph == val) {
        $this.val(ph).addClass(c);
      }

      $this.focusin(function() {
        if ($this.hasClass(c)) {
          $this.removeClass(c).val('');
        }
      }).focusout(function() {
        if (!$this.val()) {
          $this.val(ph).addClass(c);
        }
      });
    });
  };
})(jQuery);

