function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function prepareInputsForHints() {
	var formElements = ["input", "select", "textarea"];
	for(var g=0; g < formElements.length; g++){
	
		var inputs = document.getElementsByTagName(formElements[g]);
	
		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 () {
					if(this.type != "button" && this.type != "submit" && this.id != "searchBox"){
						formAreaHighlight(this.parentNode.parentNode.id);
					}
					//formAreaHighlight(this.parentNode.getAttribute(id));
					this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
				}
				// when the cursor moves away from the field, hide the hint
				inputs[i].onblur = function () {
					this.parentNode.getElementsByTagName("span")[0].style.display = "none";
				}
			} else{
				
				inputs[i].onfocus = function () {
					if(this.type != "button" && this.type != "submit" && this.id != "searchBox" && this.id != "contactBox"){
						formAreaHighlight(this.parentNode.parentNode.id);
					}
				}
			}
		}
	}
}

var currentObj = null;

function formAreaHighlight(obj) {
	if (currentObj != null) {
		document.getElementById(currentObj).style.backgroundColor = "#ffffff";
	}
	document.getElementById(obj).style.backgroundColor = "#F1F9F8";
	currentObj = obj;
}

addLoadEvent(prepareInputsForHints);