var fillin = Class.create();

fillin.prototype = {
	initialize: function(input, message, color, form){
		this.input = $(input);
		this.message = message;
		this.color = color;
		Event.observe(this.input, 'blur', this.check.bind(this));
		Event.observe(this.input, 'focus', function(){
			if($F(this.input)==this.message){
				this.input.value = '';
				this.input.style.color = '';
			}
		}.bind(this));
		if(form){
			Event.observe(form, 'submit', function(e){
				if($F(this.input)=='' || $F(this.input)==this.message)	Event.stop(e);
			}.bind(this));
		}
		if($F(this.input)=='' || $F(this.input)==this.message) this.set();
	},
	set: function(){
		this.input.style.color = this.color;
		this.input.value = this.message;
	},
	check: function(){
		if($F(this.input)==''){
			this.set();
		}else{
			this.input.style.color = '';
		}
	}
}

