Event.observe(window,"load", function() {
//click to clear functionality
$$('input.clearonfocus').each(function(element) {
new ClearOnClick(element);
});
});

var ClearOnClick = Class.create();

Object.extend(ClearOnClick.prototype, { initialize: function(element) { this.element = $(element); this.originalValue = $F(element); this.element.observe("blur", this.onBlur.bind(this)); this.element.observe("focus", this.onFocus.bind(this)); }, onFocus: function(event) { if($F(this.element) == this.originalValue) { this.element.value = ""; this.element.removeClassName("clearonfocus"); } }, onBlur: function(event) { if($F(this.element).match(/^\s*$/)) { this.element.value = this.originalValue; this.element.addClassName("clearonfocus"); } } })