      function validateHomeUnits(theForm) {
      var reason = "";
        reason += validateFill(theForm.units,'- How many units do you want to order?\n');
        reason += validateFill(theForm.surname,'- Please enter your First Name\n');
        reason += validateFill(theForm.familyname,'- Please enter your Last Name\n');
        reason += validateEmail(theForm.email);
        if (reason != "") {
          alert("Some fields need correction:\n\n" + reason);
          return false;
        }
        return true;
      }

      function validateOrderNow(theForm) {
      var reason = "";
        reason += validateFill(theForm.surname2,'- Please enter your First Name\n');
        reason += validateFill(theForm.familyname2,'- Please enter your Last Name\n');
        reason += validateFill(theForm.street1,'- Please enter your Street Address\n');
        reason += validateFill(theForm.city,'- Please enter a City\n');
        reason += validateFill(theForm.state,'- Please enter a State or Province (write "NA" for none)\n');
        reason += validateFill(theForm.zip,'- Please enter a ZIP code (write "NA" for none)\n');
        reason += validateFill(theForm.country,'- Please enter a Country\n');
        reason += validateEmail(theForm.email);
        if (reason != "") {
          alert("Some fields need correction:\n\n" + reason);
          return false;
        }
        return true;
      }

      function validateIndustrialUnits(theForm) {
      var reason = "";
        reason += validateFill(theForm.surname,'- Please enter your First Name\n');
        reason += validateFill(theForm.familyname,'- Please enter your Last Name\n');
        reason += validateEmail(theForm.email);
        if (reason != "") {
          alert("Some fields need correction:\n\n" + reason);
          return false;
        }
        return true;
      }

      function validateOpportunities(theForm) {
      var reason = "";
        reason += validateFill(theForm.surname,'- Please enter your First Name\n');
        reason += validateFill(theForm.familyname,'- Please enter your Last Name\n');
        reason += validateEmail(theForm.email);
        reason += validateFill(theForm.type,'- Please choose an area of interest\n');
        reason += validateFill(theForm.message,'- Please write a message\n');
        if (reason != "") {
          alert("Some fields need correction:\n\n" + reason);
          return false;
        }
        return true;
      }



      function validateFill(fld1,fld2) {
          var error = "";
          var illegalChars = /[\W_]/; // allow only letters and numbers

          if (fld1.value == "") {
              fld1.style.background = 'Yellow';
              fld1.value = '';
              error = fld2;
          } else {
              fld1.style.background = '#B5CDEA';
          }
         return error;
      }
      function trim(s)
      {
        return s.replace(/^\s+|\s+$/, '');
      }

      function validateEmail(fld) {
          var error="";
          var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
          var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
          var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;

          if (fld.value == "") {
              fld.style.background = 'Yellow';
              error = "- You did not enter an email address.\n";
           } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
              fld.style.background = 'Yellow';
              error = "- Please enter a valid email address.\n";
          } else if (fld.value.match(illegalChars)) {
              fld.style.background = 'Yellow';
              error = "- The email address contains illegal characters.\n";
          } else {
              fld.style.background = '#B5CDEA';
          }
          return error;
      }

