function focusClear(thefield){
  if (thefield.defaultValue==thefield.value) thefield.value = "";
}
function blurRestore(thefield){
  if (thefield.value=="") thefield.value = thefield.defaultValue;
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function prepareInputsForHints() {
  var inputs = document.getElementsByTagName("input");
  for (var i=0; i<inputs.length; i++){
	// test to see if the hint span exists first
	if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
	  // the span exists!  on focus, show the hint
	  inputs[i].onfocus = function () {
		this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
		if(this.defaultValue==this.value) {
		  this.value = ""   
		}
	  }
	  // when the cursor moves away from the field, hide the hint
	  inputs[i].onblur = function () {
		this.parentNode.getElementsByTagName("span")[0].style.display = "none";
		if(this.value=="") {
		  this.value = this.defaultValue   
		}
	  }
	}
  }
  // repeat the same tests as above for selects
  var selects = document.getElementsByTagName("select");
  for (var k=0; k<selects.length; k++){
	if (selects[k].parentNode.getElementsByTagName("span")[0]) {
	  selects[k].onfocus = function () {
		this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
		if(this.defaultValue==this.value) {
		  this.value = ""   
		}
	  }
	  selects[k].onblur = function () {
		this.parentNode.getElementsByTagName("span")[0].style.display = "none";
		if(this.value=="") {
		  this.value = this.defaultValue   
		}
	  }
	} 
  }
        
  var textarea = document.getElementsByTagName("textarea");
  for (var j=0; j<textarea.length; j++){
  // test to see if the hint span exists first
	if (textarea[j].parentNode.getElementsByTagName("span")[0]) {
	  // the span exists!  on focus, show the hint
	  textarea[j].onfocus = function () {
		this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
		if(this.defaultValue==this.value) {
		  this.value = ""   
		}
	  }
	  // when the cursor moves away from the field, hide the hint
	  textarea[j].onblur = function () {
		this.parentNode.getElementsByTagName("span")[0].style.display = "none";
		if(this.value=="") {
		  this.value = this.defaultValue   
		}
	  }
	} 
		  
  }
        
}
addLoadEvent(prepareInputsForHints);