/**
 *	TextAreaMessage class formats a text area element to have a
 *	custom message inside it,
 *  verify function should be used to make sure that the user has not left area
 *  blank before submitting (or whatever)
 */

var TextAreaMessage=new Class({
	options:
	{
	allowEmpty:false,
	message:"enter text here",
	onFocus:function(me)
	{
	//mm_executeBrowser("Explorer", function(){alert("["+me.el.value.replace(/ /g,'!')+"] - ["+me.options.message.replace(/ /g,'!')+"]");});
	if(me.el.value==me.options.message)
	{
		me.el.value='';
		me.el.setStyle('color','black');
	}
	},
	onBlur:function(me){
		if(me.el.value==''){
			me.el.value=me.options.message;
			me.options.message=me.el.value;	//Explorer Bug (makes some change to string causeing comparison failure)
			me.el.setStyle('color','gray');
		}
	}
	},
	initialize:function(element,options)
	{
		var me=this;

		me.el=$(element);
		me.setOptions(options);
		me.el.value=me.options.message;
		me.options.message=me.el.value;
		me.el.setStyle('color','gray');
		me.el.addEvents({
			'focus':function()
			{
			me.fireEvent('onFocus',me);
			},

			'blur':function()
			{
				me.fireEvent('onBlur',me);
			}
		});
		me.addEvent('onBlur',me.options.onBlur);
		me.addEvent('onFocus',me.options.onFocus);
	},
	/**
	 * check to see if value of text area is acceptable.
	 * this means that the text area cannot be empty (normally) or equal to 
	 * the message string.
	 */
	verify:function(){
		var me=this;
		if((!me.options.allowEmpty&&me.el.value=='')||me.el.value==me.options.message)
			return false;
		return true;		
	}
});
TextAreaMessage.implement(new Options(),new Events());


