Element.Properties.empty = {
  get: function() {
    return this.retrieve('empty');
  },
  set: function(text) {
    this.store('empty', text);
    
    if (!this.retrieve('emptyMethodsAdded', false)) {
      // Clear the empty value on focus
      this.addEvent('focus', function() {
        if (this.get('value') == this.retrieve('empty')) {
          this.set('value', '');
          this.removeClass('empty');
        }
      });
      
      // Reset the empty value on blur
      this.addEvent('blur', function() {
        if (this.get('value') == '') {
          this.set('value', this.retrieve('empty'));
          this.addClass('empty');
        }
      });
      
      // If the intial value is the empty text
      if (this.get('value') == this.retrieve('empty')) {
        this.addClass('empty');
      }
      
      // Clear the default value when the form is submitted
      this.getParent('form').addEvent('submit', (function() {
        if (this.get('value') == this.retrieve('empty')) {
          this.set('value', '');
        }
      }).bind(this));
      
      this.store('emptyMethodsAdded', true);
    }
    
    if (this.get('value') == '') {
      this.addClass('empty');
      this.set('value', this.retrieve('empty'));
    }
  }
};

String.implement({
  'uriEncode' : function() { return encodeURIComponent(this); }
});