﻿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.value == this.defaultValue) {
    this.value = "";
   }
  }
  element.onblur = function() {
   if (this.value == "") {
    this.value = this.defaultValue;
   }
  }
 }
}

function prepareForms() {
 for (var i=0; i<document.forms.length; i++) {
  var thisform = document.forms[i];
  resetFields(thisform);
  thisform.onsubmit = function() {
   return validateForm(this);
  }
 }
}

addLoadEvent(prepareForms);
