var Substitute = Class.create();

Substitute.prototype = {	
	initialize: function(item) {
		item.alt = item.value;
		Event.observe(item, 'focus', this.focus);
		Event.observe(item, 'blur', this.blur);
	},
	
	focus: function(e) {
	    var item = e.element();
		if (item.value==item.alt) {
			item.value='';
		}
	},
	
	blur: function(e) {
		var item = Event.findElement(e, 'INPUT');

		if (item.value=='') {
			item.value=item.alt;
		}
	}
}

Substitute.setAll = function () {
	var substitutes = $$('.substitute')
	for(var i=0; i<substitutes.length; i++)
	{
    	if (substitutes[i].id) {
    		new Substitute(substitutes[i]);
    	}
    }
}

document.observe("dom:loaded", Substitute.setAll);

