var TextFieldLabel = new Class({ 

	initialize: function(options) {
		this.textFieldName = options.textFieldName;
		this.defaultValue = options.defaultValue;
		this.formId = (options.formId ? options.formId : Class.empty);
		this.greyOutClass = 'greyOut';
		this.enabled = true;
		
		window.addEvent('load', this.create.bind(this));
	},
	
	setInitialValue: function(){
		if ($(this.textFieldName).value == '' && this.enabled){ 
			$(this.textFieldName).value = this.defaultValue;
			$(this.textFieldName).addClass(this.greyOutClass);	
		}
	},
	
	clearTextFieldValue: function(){
		if ($(this.textFieldName).value == this.defaultValue) {
			$(this.textFieldName).value = '';	
			$(this.textFieldName).removeClass(this.greyOutClass);	
		}
	},
	
	clearHint: function(){
		if ($(this.textFieldName).value != this.defaultValue) {
			$(this.textFieldName).removeClass(this.greyOutClass);
		}
	},
	
	disableHint: function(){
		this.clearTextFieldValue();
		this.enabled = false;
	},
	
	enableHint: function(){
		this.enabled = true;
		this.setInitialValue();
	},
	
	/**
	* This method is to be called directly when creating a hint after the page is loaded and element is created
	*/
	create: function(){
		$(this.textFieldName).addEvent('focus', this.clearTextFieldValue.bind(this));
		$(this.textFieldName).addEvent('blur', this.setInitialValue.bind(this));
		if ($(this.formId))
			$(this.formId).addEvent('submit', this.clearTextFieldValue.bind(this));
		this.setInitialValue();	
	}

});
