function saveRegFR(vStep,nextStep) {
  var form = document.forms[0];
  if (vStep=='1') {
    if (parent.failNull (form.Name, 'Veuillez compl' + unescape('%E9') + 'ter votre Nom.','text')) {return};
    if (parent.failNull (form.FName, 'Veuillez compl' + unescape('%E9') + 'ter votre Pr' + unescape('%E9') + 'nom.','text')) {return};
    if (parent.failNull (form.Gender, 'Veuillez compl' + unescape('%E9') + 'ter votre sexe.','radio')) {return};
    if (parent.failNull (form.BirthPlace, 'Veuillez compl' + unescape('%E9') + 'ter votre lieu de naissance.','text')) {return};
    if (!isDate(form.Birthdate)) { alertBox (form.Birthdate, "Votre date de naissance n'est pas correct (j/m/aaaa).", 'text'); return; };
    if (parent.failNull (form.Birthdate, 'Veuillez compl' + unescape('%E9') + 'ter votre Date de naissance.','text')) {return};
    if (parent.failNull (form.Nationality, 'Veuillez compl' + unescape('%E9') + 'ter votre Nationalit' + unescape('%E9') + '.','radio')) {return};
    if (parent.failNull (form.Street, 'Veuillez compl' + unescape('%E9') + 'ter votre Adresse.','text')) {return};
    if (parent.failNull (form.Nr, 'Veuillez compl' + unescape('%E9') + 'ter votre Num' + unescape('%E9') + 'ro.','text')) {return};
    if (parent.failNull (form.Zip, 'Veuillez compl' + unescape('%E9') + 'ter votre Code Postal.','text')) {return};
    if (parent.failNull (form.City, 'Veuillez compl' + unescape('%E9') + 'ter votre Localit' + unescape('%E9') + '.','text')) {return};
    if (getFieldValue (form.Phone, 'text')=="") { 
         if (parent.failNull (form.Mobile, 'Veuillez compl' + unescape('%E9') + 'ter votre T' + unescape('%E9') + 'l' + unescape('%E9') + 'phone ou GSM.','text')) {return};
    };
    if (parent.failNull (form.Email, 'Veuillez compl' + unescape('%E9') + 'ter votre E-mail.','text')) {return};
  }
  if (vStep=='2') {
    setFileName('CV',form.CV_filename);
    if (parent.failNull (form.CV, 'Veuillez t' + unescape('%E9') + 'l' + unescape('%E9') + 'charger votre CV.','text')) {return};
  }
  if (vStep=='3') {
    if (parent.failNull (form.License, 'Veuillez compl' + unescape('%E9') + 'ter votre Permis de conduire.','radio')) {return};
    if (parent.failNull (form.ServiceLine, 'Veuillez compl' + unescape('%E9') + 'ter votre pr' + unescape('%E9') + 'f' + unescape('%E9') + 'rence de Serviceline.','radio')) {return};
  }
  if (vStep=='4') {
    if (parent.failNull (form.Event, 'Veuillez compl' + unescape('%E9') + 'ter votre Recruitment Event.','radio')) {return};
    //if (parent.failNull (form.Travel, 'Veuillez compl' + unescape('%E9') + 'ter votre mani' + unescape('%E8') + 're de transport.','radio')) {return};
  }

  form.submit();
}

function saveRegNL(vStep,nextStep) {
  var form = document.forms[0];
  if (vStep=='1') {
    if (parent.failNull (form.Name, 'Vul aub je Naam in.','text')) {return};
    if (parent.failNull (form.FName, 'Vul aub je Voornaam in.','text')) {return};
    if (parent.failNull (form.Gender, 'Selecteer aub je Geslacht.','radio')) {return};
    if (parent.failNull (form.BirthPlace, 'Vul aub je Geboorteplaats in.','text')) {return};
    if (!isDate(form.Birthdate)) { alertBox (form.Birthdate, 'Geef aub een correcte Geboortedatum (d/m/jjjj).', 'text'); return; };
    if (parent.failNull (form.Birthdate, 'Vul aub je Geboortedatum in.','text')) {return};
    if (parent.failNull (form.Nationality, 'Selecteer aub je Nationaliteit.','radio')) {return};
    if (parent.failNull (form.Street, 'Vul aub je Straat in.','text')) {return};
    if (parent.failNull (form.Nr, 'Vul aub je Straat Nr. in.','text')) {return};
    if (parent.failNull (form.Zip, 'Vul aub je Postcode in.','text')) {return};
    if (parent.failNull (form.City, 'Vul aub je Woonplaats in.','text')) {return};
    if (getFieldValue (form.Phone, 'text')=="") { 
         if (parent.failNull (form.Mobile, 'Vul aub je Telefoon of GSM in.','text')) {return};
    };
    if (parent.failNull (form.Email, 'Vul aub je Email in.','text')) {return};
  }
  if (vStep=='2') {
    setFileName('CV',form.CV_filename);
    if (parent.failNull (form.CV, 'Wil je aub je CV uploaden.','text')) {return};
  }
  if (vStep=='3') {
    if (parent.failNull (form.License, 'Vul aub je Rijbewijs in.','radio')) {return};
    if (parent.failNull (form.ServiceLine, 'Vul aub je voorkeur ivm de Serviceline in.','radio')) {return};
  }
  if (vStep=='4') {
    if (parent.failNull (form.Event, 'Wil je aub je Recruitment Event selecteren.','radio')) {return};
    //if (parent.failNull (form.Travel, 'Wil je aub je Verplaatsing selecteren.','radio')) {return};
  }

  form.submit();
}

// ---------------------------------------------
// --- Field Validation                       --
// ---------------------------------------------

function failNull ( vField, vMessage, vType) { 

//this function will stop the submit if a field is null or contains all spaces 

//get the field value...
theValue = getFieldValue (vField, vType); 

//if the field value is null, we fail and return true...
if ( theValue == "" ) { 

   alertBox ( vField, vMessage, vType ); 

return ( true ); 

} 

//remove any spaces from the value 

trimField = trimBlanks( theValue ); 

//if the field value is all spaces, fail and return true...
if ( trimField =="" ) { 

   alertBox ( vField, vMessage, vType ); 

return ( true ); 

} 

//otherwise continue... 

return ( false ); 

}

function getFieldValue ( theField, vType ) { 

//this function will return the field value (or value list) based on the element type 

theValue = ""; 
sep = ""; 
hits = 0; 

//text is the user-entered value as a string
if ( vType == "text" ) return ( theField.value ); 

//textarea is the user-entered value as a string array of one element
if ( vType == "textarea" ) return ( theField[0].value ); 

//checkboxes & radio buttons are not so simple
if ( vType == "checkbox" || vType == "radio" ) { 

if ( theField.value == null ) { 

//if we're here, we are validating a radio button or a nn multi-element checkbox 

for ( i = 0; i < theField.length; i++ ) { 
   if ( theField[i].checked ) { 
        hits++; 
        if ( hits > 1 ) {
            sep = "; ";
        } 
        theValue += sep + theField[i].value; 
   } 
 }
} else {
    theValue = theField.value;
} 
return ( theValue );

} else { 

//if we are here, must be an ie checkbox, or nn with a one-element checkbox) 

if ( navigator.appName == "Microsoft Internet Explorer" ) { 

//ie. return some data so we can validate on the server; 
return ("can't validate on client")
} 

//nn one-element checkbox, see if its checked ...
if (theField.checked ) { 
return ( theField.value ); 

} else {
return ( "" ); 
} 
} 

//select is an array of selection pointers to an array of strings representing the choices
if ( vType == "select" ) { 

for ( i = 0; i < theField.options.length; i++ ) {
if ( theField.options[i].selected ) theValue += theField.options[i].text 
} 
return ( theValue );
}
}

 function trimBlanks ( theString, repChar ) { 

//this function replaces the spaces in a string with the provided character 

trimString=""; 

for ( i = 0; i < theString.length; i++) {
theChar=theString.substring ( i, i+1);
if ( theChar == " ") { 

trimString += repChar 

} else { 

trimString+=theString.substring ( i, i+1); 

}
}
return (trimString);
}

function alertBox (vField, vMessage, vType ) { 

//if we pass a null message, we are doing a multiple validation test. return so we can check other conditions.
if ( vMessage == "null" ) return; 

//otherwise, display the error message
alert ( "\n" + vMessage ) 

//and set focus (plus select the text if a text element) 
if ( vType == "text" ) { 

vField.focus(); 

vField.select(); 

} else { 

//vField.focus(); 

} 

return; 

}

function setFileName( strDesiredControl , objFileNameField ) { 
  var thefile=document.getElementById(strDesiredControl);
  var fullFileName = thefile.value;
  posLastSlash = fullFileName.lastIndexOf("\\");
  objFileNameField.value = fullFileName.substring(posLastSlash+1, fullFileName.length);
  return true;
} 

function checkNumber(field)
     {
          var check = true;
          var value = field.value; //get characters
          //check that all characters are digits, ., -, or ""
          for(var i=0;i < field.value.length; ++i)
          {
               var new_key = value.charAt(i); //cycle through characters
               if(((new_key < "0") || (new_key > "9")) && !(new_key == "") && !(new_key == "."))
               {
                    check = false;
                    break;
               }
          }
          //apply appropriate colour based on value
          if(!check)
          {
               field.style.backgroundColor = "red";
          }
          else
          {
               field.style.backgroundColor = "white";
          }
     }

//Function to validate number input
function isNumber(vField) 
{
     //If anything in our string is not a number, fail validation
     theValue = getFieldValue (vField, 'text'); 
     if (!theValue.match(/^\d*\.?\d*$/))
     //if (!theValue.match(/^\d*(\.|\,)?\d*$/))
        { return false; }
     return true;
}

//Function to validate date input
function isDate(vField) 
{
    //If anything in our string is not a date, fail validation
    theValue = getFieldValue (vField, 'text'); 
    trimField = trimBlanks( theValue ); 
    if ( trimField =="" ) { return true };

    if (!theValue.match(/(^((((0[1-9])|([1-2][0-9])|(3[0-1]))|([1-9]))\x2F(((0[1-9])|(1[0-2]))|([1-9]))\x2F(([0-9]{2})|(((19)|([2]([0]{1})))([0-9]{2}))))$)/))
       { return false; }
    return true;
}
