function InputHandler(field_name, field_value, font_default, font_in){
	var this_copy     = this;
	this.field_name   = field_name;
	this.field_value  = field_value;
	this.font_default = font_default;
	this.font_in      = font_in;
	
	if (document.getElementById(this.field_name)) {
		document.getElementById(this.field_name).value = field_value;
		this.element      = document.getElementById(this.field_name);	
		this.element.style.color = this.font_default;

		this.setEvent('focus', function(){return this_copy.onFocus()});
		this.setEvent('blur', function(){return this_copy.onBlur()});
		this.setEvent('click', function(){return this_copy.onClick()});
	}

	return this;
}

InputHandler.prototype.setEvent = function (event_type, handler) {	
	if (this.element.attachEvent){
		this.element.attachEvent ('on' + event_type, handler)
	}

	if (this.element.addEventListener){
		this.element.addEventListener (event_type, handler, false)
	}
}

InputHandler.prototype.onFocus = function(){
	if (this.element.value == this.element.deft) {
		this.element.value = "";
		this.element.style.color = this.font_in;
	}
}

InputHandler.prototype.onClick = function(){
	if (this.element.value == this.field_value) {
		this.element.value = "";
		this.element.style.color = this.font_in;
	}
}

InputHandler.prototype.onBlur = function(){
	if (this.element.value == "") {
		this.element.value = this.field_value;
		this.element.style.color = this.font_default;
	}
}
