/**
* Tous les input de class effacable vont �tre affect�.
* On met la valeur par d�faut dans l'attribut rel de l'input.
* Si on ajoute class="password" dans l'input, celui-ci changera son type en type="password"
*/
window.addEvent('domready', active_input_effacable);

function active_input_effacable() {
	$$('input.effacable').each(function(input){
		if($(input).value=='') {
			$(input).value = input.getAttribute('rel');
		}
		$(input).addEvent('focus',function() {
			if($(input).value == input.getAttribute('rel')){
				$(input).style.color = '#000';
				$(input).value = '';
				if($(input).className.test('password')) {
					var newObject = document.createElement('input');
					newObject.style.color = $(input).style.color;
					newObject.value = input.value;
					newObject.name = input.name;
					newObject.className = input.className;
					newObject.style.background = input.style.background;
					newObject.style.padding = input.style.padding;
					newObject.style.margin = input.style.margin;
					newObject.style.height = input.style.height;
					newObject.style.width = input.style.width;
					newObject.type = 'password';
					input.parentNode.replaceChild(newObject,input);
					newObject.focus();
				}
			}
		});
		$(input).addEvent('blur',function() {
			if($(input).value == ''){
				$(input).value = input.getAttribute('rel');
			}
		});
	});
}
