function labelFields() {
	if (!document.getElementsByTagName){ return; }
	var allfields = document.getElementsByTagName("input");	
	for (var i=0; i<allfields.length; i++){ 	// loop through all input tags and add events
		initField(allfields[i]);
	}
	var allfields2 = document.getElementsByTagName("textarea");	
	for (var i=0; i<allfields2.length; i++){ 	// loop through all textarea tags and add events
		initField(allfields2[i]);
	}
}
function initField(field) {
	if (field) { //prevent misfire
		var graycolor = "#444";
		if ((field.type == "text" || field.type == "textarea") && (field.value != null)) {	// include text boxes, exclude empty ones
			field.style.color = graycolor;
			field.graytext = field.value;
			field.onfocus = function () {
				if (this.value==this.graytext){
					this.style.color="#444";
					this.value="";
				} else {
					this.select();
				}
			}
			field.onblur = function () {
				if (this.value=="") {
					this.style.color=graycolor;
					this.value=this.graytext;
				}
			}
		}
	}
}
window.onload = function() {
	labelFields();
}