function ValidationManager(oForm){
  this.message = 'De volgende problemen moeten opgelost worden:\n';
  this.oForm = oForm;
  this.aFields = new Array();
}

ValidationManager.prototype.addField = function (oField){
  this.aFields.push(oField);
}


ValidationManager.prototype.validate = function (oField){
  var msg = '';

  for(var i=0;i<this.aFields.length;i++){
    msg+=this.aFields[i].validate() ? '' : this.aFields[i].getMessage() + '\n';
  }

  if(msg!=''){
    alert(this.message+msg);
    return false;
  }

  return true;

}

function Field(name,message){
  // AS: name of the field to check
  this.name = name;
  this.message = message;
  // AS: default regular expression check for checking empty field
  this.regex = /.+/;
}

Field.prototype.setRegex = function (regex){
  this.regex = regex;
}

Field.prototype.getRegex = function (){
  return this.regex;
}

Field.prototype.getMessage = function (){
  return this.message;
}

// AS: default implementation
Field.prototype.validate = function (){
  return this.regex.test(document.getElementById(this.name).value);
}

checkPassword = function(password,password_check,password_old){
  var f1 = document.getElementById(password);
  var f2 = document.getElementById(password_check);
  var f3 = document.getElementById(password_old);
  var bValid = true;
  //MJ: field and check field contain same value
  bValid = (f1.value==f2.value) && (f1.value.length>=8||(f1.value.length==0 && f3.value.length>0)) && (f2.value.length>=8||(f2.value.length==0 && f3.value.length>0));
  return (bValid);
}
