inputs = document.getElementsByTagName('input');
textareas = document.getElementsByTagName('textarea');
attributeInputs = [];
attributeTextareas = [];

window.onload = function(){
	//document.onclick = refreshPlaceholders;
	for (var i = 0; i<inputs.length - 1; i++) {
		attributeInputs.push(inputs[i].placeholder);
		refreshPlaceholders;
		inputs[i].onclick =removePlaceholder;
		inputs[i].onmouseenter = refreshPlaceholders;
	}
	for (var i = 0; i<textareas.length ; i++) {
		attributeTextareas.push(textareas[i].placeholder);
		refreshPlaceholders;
		textareas[i].addEventListener("click", removePlaceholder);
		textareas[i].onmouseenter = refreshPlaceholders;
	}
}

function removePlaceholder () {
	tempPlaceholder = this.placeholder;
	for (var i = 0; i <inputs.length; i++) {
		if (inputs[i].placeholder != tempPlaceholder) {
			inputs[i].setAttribute("placeholder",attributeInputs[i]);
		}
	}
	for (var i = 0; i <textareas.length; i++) {
		if (textareas[i].placeholder != tempPlaceholder) {
			textareas[i].setAttribute("placeholder",attributeTextareas[i]);
		}
	}
	this.setAttribute("placeholder", "");
}

function refreshPlaceholders() {
	console.log("clic on body");
	for (var i = 0; i <inputs.length; i++) {
		inputs[i].setAttribute("placeholder",attributeInputs[i]);
	}
	for (var i = 0; i <textareas.length; i++) {
		textareas[i].setAttribute("placeholder",attributeTextareas[i]);
		}
}