function checkOther(sel,otherfield){
  var optVal = sel.options[sel.selectedIndex].value;
  if (optVal == "andere" || optVal == "autre"){
     document.getElementById(otherfield).style.display="inline";
     document.getElementById(otherfield).focus();
  }
  else{
    document.getElementById(otherfield).style.display="none";
  }
}

function hideOther(otherfield){
  //hide otherdate field
  document.getElementById(otherfield).style.display="none";
}

function checkRijksregister_form(veld){
	getal = replace(document.getElementById(""+veld+"").value,' ','')
	getal = replace(getal,'-','')
	if (((getal.length == 11 && isNaN(getal) == false) && (getal.substr(0,2) < 1 && getal.substr(9,2) == 97-((2000000000+parseFloat(getal.substr(0,9)))%97)) || (getal.substr(0,2) >= 1 && getal.substr(9,2) == 97-(getal.substr(0,9)%97))) || getal.length == 0){
		return true;
		}
	else{
		window.alert("Het ingevulde rijksregisternummer is niet geldig.");
		document.getElementById(""+veld+"").value = '';
		return false;
		}
}

function checkRSZ(getal){
	if ((getal.length == 12 && isNaN(getal) == false) && (getal.substr(10,2) == (96-(getal.substr(3,7)*100)%97))){
		return true;
		}
	else{
		window.alert("RSZ niet OK");
		return false;
		}
}

function checkRSZ_form(veld){
	getal = replace(document.getElementById(""+veld+"").value,' ','')
	getal = replace(getal,'-','')
	if (((getal.length == 12 && isNaN(getal) == false) && (getal.substr(10,2) == (96-(getal.substr(3,7)*100)%97)) || getal.length == 0)){
		return true;
		}
	else{
		window.alert("Het ingevulde RSZ-nummer is niet geldig.");
		document.getElementById(""+veld+"").value = '';
		return false;
		}
}

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm_nl() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm_nl.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=args[i+1]; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- je hebt een ongeldig emailadres ingevuld.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' moet een getal zijn.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' is niet correct.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is niet ingevuld.\n'; }
  } if (errors) alert('Het formulier is niet juist ingevuld:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_validateForm_fr() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm_fr.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=args[i+1]; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- cette addresse email n\'est pas correcte.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' doit être un nombre.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- le champ '+nm+' n\'est pas rempli.\n'; }
  } if (errors) alert('Le formulaire n\'est pas rempli correctement:\n'+errors);
  document.MM_returnValue = (errors == '');
}



