PARAM_FIRST_NAME = 'firstName';
  PARAM_EMAIL_ADDRESS = 'emailAddress';
  PARAM_PASSWORD = 'password';
  PARAM_TC_AGREE = 'tcagree';
  PARAM_TC_VERSION = 'tcVersion';
  PARAM_SUBMIT = 'submit';
  AT='@';
  DOT='.';
  
    function validateIndex(f) {
      var errorMsg = new Array();
      var errorObjs = new Array();
      
          if (f.elements[PARAM_FIRST_NAME].value == '') {
              errorMsg[errorMsg.length] = 'First name is required.';
              errorObjs[errorObjs.length] = f.elements[PARAM_FIRST_NAME];
          } else {
            f.elements[PARAM_FIRST_NAME].style.backgroundColor = '#FFFFFF';
          }
        
          if (f.elements[PARAM_EMAIL_ADDRESS].value == '') {
              errorMsg[errorMsg.length] = 'E-mail address is required.';
              errorObjs[errorObjs.length] = f.elements[PARAM_EMAIL_ADDRESS];
          } else {
            f.elements[PARAM_EMAIL_ADDRESS].style.backgroundColor = '#FFFFFF';
          }
          if ((f.elements[PARAM_EMAIL_ADDRESS].value.indexOf(AT) == -1) || (f.elements[PARAM_EMAIL_ADDRESS].value.indexOf(DOT) == -1)) {
              errorMsg[errorMsg.length] = 'Invalid E-mail address.';
              errorObjs[errorObjs.length] = f.elements[PARAM_EMAIL_ADDRESS];
          } else {
            f.elements[PARAM_EMAIL_ADDRESS].style.backgroundColor = '#FFFFFF';
          }

          if (f.elements[PARAM_PASSWORD].value == '') {
              errorMsg[errorMsg.length] = 'Password is required.';
              errorObjs[errorObjs.length] = f.elements[PARAM_PASSWORD];
          } else {
            f.elements[PARAM_PASSWORD].style.backgroundColor = '#FFFFFF';
          }
        
          if (!f.elements[PARAM_TC_AGREE].checked) {
              errorMsg[errorMsg.length] = 'Terms and Conditions is required.';
              errorObjs[errorObjs.length] = f.elements[PARAM_TC_AGREE];
          }
        
    
      if (errorObjs.length > 0) {
          var alertMsg = '';
          for (var x = 0; x< errorMsg.length ;x++) {
              alertMsg += '' + errorMsg[x] + '\n';
          }
          for (var x = 0; x< errorObjs.length ;x++) {
              if (errorObjs[x].style) {
                errorObjs[x].style.backgroundColor = '#FFFF99';
              }
          }
          if ( errorObjs[0].style) { // TODO what should be checked here?
            errorObjs[0].focus();
            }
          alert(alertMsg);
          return false;
      } else {
          return true;
      }
      
    }
  