//Checks if the supplied fields are empty and highlights field in red if so
function ContactFormValidation (sFieldIDs) {
   var i;
   var arrFields = sFieldIDs.split(":");
   var currField;
   var bSubmitForm = true;
   var email= /^[\w-\.]+\@[\w\.-]+\.[a-zA-Z]{2,4}$/;
   
   for (i = 0; i < arrFields.length; i++) {
      // Get form field reference
      currField = document.getElementById(arrFields[i]);
      
      // Check for null in the case of a non existing html element
      if (currField != null) {      
         // Set fields style to default
         SetBorderStyle(currField, "default");
         
         // If field is empty then set the style to red background and border
         if (currField.name.toLowerCase() == "email" && (!(email.test(currField.value)))) {
            SetBorderStyle(currField, "error");
            bSubmitForm = false;
         }
         else if (currField.value == "") {
            SetBorderStyle(currField, "error");
            bSubmitForm = false;
         }
      }
   }
   return bSubmitForm;
}
function SetBorderStyle(fldFormField, fDefaultOrError){
   if (fDefaultOrError.toLowerCase() == "error") {
      borderstyle = "1px solid #ea172a";
      bgcolorstyle = "#ffc0c0";
   }
   else if (fDefaultOrError.toLowerCase() == "default") {
      borderstyle = "1px solid #969696";
      bgcolorstyle = "#FFFFFF";
   }
   
   fldFormField.style.border = borderstyle;
   fldFormField.style.background = bgcolorstyle;
}

