var  UserNameInput=Class.create();

UserNameInput.prototype={
	initialize:function(input){
		this.input=$(input);
		Event.observe(this.input, "focus", this.clear.bind(this));
		Event.observe(this.input, "blur", this.checkRestore.bind(this));
	},
	clear:function(){
		this.input.removeClassName("user_name_input");
		if(!this.preset || this.preset==this.input.value){
			this.preset=this.input.value;
			this.input.value="";
		}
	},
	checkRestore:function(){
		this.input.addClassName("user_name_input");
		if(this.input.value==""){
			this.input.value=this.preset;
		}
	}
}
document.observe('dom:loaded', function () {
	inputs=$$(".user_name_input");
	inputs.each(function(input){new UserNameInput(input)});
});
