<!--

if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }

function validateFormOnSubmit(callbackform) {
	var reason = "";
	
	reason += validateName(callbackform.name);
	reason += validatePhone(callbackform.tel);
	      
	  if (reason != "") {
	    alert("The fields highlighted in red text correction:\n\n" + reason);
	    return false;
	  }
	
	  return true;
	}
	
	function validateName(fld) {
	    var error = "";
	    
	    if (fld.value == "") {
	        fld.style.color = 'Red'; 
	        error = "You didn't enter a name.\n";
	    } else if (fld.value == "Name") {
		fld.style.color = 'Red'; 
	        error = "You didn't enter a name.\n";    
	   } else {
	        fld.style.color = '#898989';
	    }
	    return error;
	}
	
	function validatePhone(fld) {
	    var error = "";
	    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    
	
	   if (fld.value == "") {
	        error = "You didn't enter a phone number.\n";
	        fld.style.color = 'Red';
	    } else if (isNaN(parseInt(stripped))) {
	        error = "The phone number contains illegal characters.\n";
	        fld.style.color = 'Red';
	    } else if (!(stripped.length == 11)) {
	        error = "The phone number is the wrong length. Make sure you included an area code.\n";
	        fld.style.color = 'Red';
	    } else {
		fld.style.color = '#898989';    
	    }
	    return error;
	}
	
	
  
  
//-->


