function emptyField(textStr) {
 if(textStr.length == 0) return true;
  for (var i=0; i<textStr.length; ++i) {
    var ch = textStr.charAt(i);
    if(ch != ' ' && ch != '	') return false;
  }
  return true;
}
function checkStandardText(objLabel,objValue) {
 if (emptyField(objValue)){
   return(objLabel + " cannot be null \n");
 } else {
   return ("");
 }
}
function checkEmailAddr(objValue,ObjLabel) {
  if (emptyField(objValue))  {
     return (ObjLabel + " cannot be blank \n");
  } else {
     // check to see if valid entry -(modified code from Travelocity.com)
     var indexofAtsign  = objValue.indexOf('@');   // -1 returned fi not found
     var indexofPeriod  = objValue.indexOf('.',indexofAtsign);
     var indexofSpace  = objValue.indexOf(' ');
     if (indexofSpace >= 0 || indexofAtsign <= 0 || indexofPeriod == -1 || indexofPeriod <= indexofAtsign + 1) {
       if (indexofSpace >= 0) {
         return (ObjLabel + " is not valid.  Please check for spaces. \n");
       } else {
         return (ObjLabel + " is not valid. \n");
       }
     } else {
     return ("");
     }
  }
} // end checkEmailAddr function
function FormValidation(formObj) {
// first validate required fields

var alert_text = "You have entered incomplete or invalid information.  Please use the list below to correct \n "
var start_text = alert_text;

var alert_text1 = checkStandardText("Please enter First Name",formObj.FN.value)
var alert_text2 = checkStandardText("Please enter Last Name",formObj.LN.value)
var alert_text3 = checkEmailAddr(formObj.email.value,"Email Address");
var alert_text4 = checkStandardText("Please enter Phone(Day)",formObj.DYph.value)
var alert_text5 = checkStandardText("Please enter Phone(Evening)",formObj.EVph.value)
var alert_text6 = checkStandardText("Please enter Comments",formObj.comment.value)
if (alert_text1 == ""){
      alert_text += "";
}else{
      alert_text += alert_text1;
}
if (alert_text2 == ""){
      alert_text += "";
}else{
      alert_text += alert_text2;
}
if (alert_text3 == ""){
      alert_text += "";
}else{
      alert_text += alert_text3;
}
if (alert_text4 == ""){
      alert_text += "";
}else{
      alert_text += alert_text4;
}
if (alert_text5 == ""){
      alert_text += "";
}else{
      alert_text += alert_text5;
}
if (alert_text6 == ""){
      alert_text += "";
}else{
      alert_text += alert_text6;
}

if (alert_text != start_text) {
        alert(alert_text)
        return false;
} else {
        // strip zip code of non numbers and truncate to 5 digits
        return true;
} // end of if condition
}


