/**
  * Class to toggle default value in input fields
  * 
  * @author Kai Hommel <kaho@db-n.com>
  */
var InputValue = Class.create({
	/* set input and event handlers */
	initialize:function(obj){
		this.input=obj;
		this.removeValue=this.removeValue.bindAsEventListener(this);
		this.setValue=this.setValue.bindAsEventListener(this);
		this.input.observe('focus',this.removeValue);
		this.input.observe('blur',this.setValue);
	}, 
	/* buffer value */
	removeValue:function(event){
		this.input.oldvalue=this.input.value;
		this.input.value="";
	},
	/* set buffered value if no new value */
	setValue:function(event){
		if(this.input.value=="") { this.input.value=this.input.oldvalue; }
	}
});
var inputvalue;
/* looking for inputs with default value */
Event.observe(window,'load',function(){
	$$('input[value!=""]').each(function(input){
		inputvalue=new InputValue(input);
	});
});
