function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function resetFields(whichform) {
  for (var i=0; i<whichform.elements.length; i++) {
    var element = whichform.elements[i];
    if (element.type == "submit") continue;
	    //if (!element.defaultValue) continue;
		element.onfocus = function() {
		    if ( (this.name == "name") && (this.value == "Your Name") ) {
		      this.value = "";
		    }
			if ( (this.name == "phone") && (this.value == "Email") ) {
		      this.value = "";
		    }
			if ( (this.name == "comments") && (this.value == "Your Comments") ) {
		      this.value = "";
		    }
	    }
	    element.onblur = function() {
	      if (this.value == "") {
	        if(this.name == "name") {
				this.value = "Your Name";
			}
			if(this.name == "phone") {
				this.value = "Email";
			}
			if(this.name == "comments") {
				this.value = "Your Comments";
			}
	      }
    }
  }
}

function prepareForms() {
  if (!document.getElementById) return false;
  if (!document.getElementById("name")) return false;
  if (!document.getElementById("phone")) return false;
  if (!document.getElementById("comments")) return false;
  var yourName = document.getElementById("name");
  yourName.value = "Your Name";
  var yourPoE = document.getElementById("phone");
  yourPoE.value = "Email";
  var yourComments = document.getElementById("comments");
  yourComments.value = "Your Comments";
  
  
  for (var i=0; i<document.forms.length; i++) {
    var thisform = document.forms[i];
	resetFields(thisform);
  }
}

addLoadEvent(prepareForms);
