function activatePlaceholders() {
	var detect = navigator.userAgent.toLowerCase(); 
	if (detect.indexOf("safari") > 0) return false;
	var inputs = document.getElementsByTagName("input");
	for (var i=0;i<inputs.length;i++) {
		if (inputs[i].getAttribute("type") == "text") {
			if (inputs[i].getAttribute("placeholder") && inputs[i].getAttribute("placeholder").length > 0 ) {
				if(inputs[i].value=='' || inputs[i].value===null) {
					inputs[i].value = inputs[i].getAttribute("placeholder");
					inputs[i].style.color="gray";
				}
				inputs[i].onclick = function() {
					if (this.value == this.getAttribute("placeholder")) {
						this.value = "";
						this.style.color="black";
					}
					return false;
				}
				inputs[i].onblur = function() {
					if (this.value.length < 1 || this.value===this.getAttribute("placeholder")) {
						this.value = this.getAttribute("placeholder");
						this.style.color="gray";
					}
				}
			}
		}
	}
	
	var forms = document.getElementsByTagName("form");
	for (var i=0;i<forms.length;i++) {
		forms[i].onsubmit = function() {
			clearPlaceHolders();
		}
	}
	
}
window.onload=function() {
activatePlaceholders();
}

/*
	The clearPlaceHolders() function should be called whenever a form is submitted
*/


function clearPlaceHolders() {
	var detect = navigator.userAgent.toLowerCase(); 
	if (detect.indexOf("safari") > 0) return false;
	var inputs = document.getElementsByTagName("input");
	for (var i=0;i<inputs.length;i++) {
		if (inputs[i].getAttribute("type") == "text") {
			if (inputs[i].getAttribute("placeholder") && inputs[i].getAttribute("placeholder").length > 0 ) {
				if(inputs[i].value==inputs[i].getAttribute("placeholder")) {
					inputs[i].value='';
				}
			}
		}
	}
}

