(function() {
  var all, blur, blurAll, focus, focusAll, placeholder, setValue;
  if (!('placeholder' in document.createElement('input'))) {
    setValue = function(element, value) {
      if (element.tagName.toLowerCase() === 'textarea') {
        return element.innerHTML = value;
      } else {
        return element.value = value;
      }
    };
    placeholder = function(element) {
      return element.getAttribute('placeholder');
    };
    focus = function(element) {
      element.removeClassName('html5-placeholder');
      if ($F(element) === placeholder(element)) {
        return setValue(element, '');
      }
    };
    blur = function(element) {
      var _ref;
      if ((_ref = $F(element)) === '' || _ref === placeholder(element)) {
        setValue(element, placeholder(element));
        return element.addClassName('html5-placeholder');
      }
    };
    all = function() {
      return $$('input[placeholder]');
    };
    focusAll = function() {
      return all().each(focus);
    };
    blurAll = function() {
      return all().each(blur);
    };
    $(document).observe('dom:loaded', function() {
      all().each(function(e) {
        return e.observe('focus', function() {
          return focus(e);
        });
      });
      all().each(function(e) {
        return e.observe('blur', function() {
          return blur(e);
        });
      });
      $$('form').each(function(f) {
        return f.observe('submit', function() {
          return focusAll();
        });
      });
      return blurAll();
    });
  }
}).call(this);

