var DefaultMessage = Class.create({
	initialize: function(id, options) {
		this.textarea = $(id);		
		
		if (typeof options == 'string') {
		    this.options = $H({message: options})
		} else {
		    this.options = $H({
			    message: 'Enter text'
		    }).merge(options);
		}

		// If the user has not already entered a message, set it to our default
		if (!this.textarea.value) {
		    textarea.value = this.options.get('message');
		}
		
		this.registerEventHandlers();
	},
	
	registerEventHandlers: function() {

		this.textarea.observe('focus', function() {
			if (this.textarea.value == this.options.get('message'))
			    this.textarea.value = '';
			    this.textarea.addClassName('active');
		}.bind(this)).observe('blur', function() {
			if (!this.textarea.value)
			    this.textarea.value = this.options.get('message');
			    this.textarea.removeClassName('active');
		}.bind(this));
	}
});  				    

// If you pass a string instead of an object for 'options', it will use the string as the default message.
//
// Sample instantiation:
//
// HTML:
// <input type="text" id="search" />
//
// JavaScript:
// new DefaultMessage('search', 'Please enter your search query');

