var opmerking_div = document.getElementById('opmerking');
var opmerking_nok = '* Vul alle verplichte velden in.';
var opmerking_ok = 'Alle velden zijn ingevuld!';

function check(o,type) {
	var status = false;
	
	// types doorlopen
	if(type == 'text' || type == 'textarea') {
		if(o.value.length>3) {
			compleet[o.name] = true;
			status = true;
		} else {
			compleet[o.name] = false;
			status = false;
		}
	}
	if(type=='email') {
		if(checkMail(o) == true) {
			compleet[o.name] = true;
			status = true;
		} else {
			compleet[o.name] = false;
			status = false;
		}
	}
	
	// geef status terug
	if (status == true) {
		o.className = 'goed';
	} else {
		o.className = 'fout';
	}
	
	check_form();
	
}

function check_form() {
	var i = 0;
	for(x in compleet) {
		(compleet[x]==true) ? i++ : '';
	}
	opmerking_div.innerHTML = (i==aantal) ? opmerking_ok : opmerking_nok;
}

var r={
  'special':/[\W]/g,
  'puntkomma':/['.'&',']/g,
  'cijfers':/[^\d]/g,
  'letter':/[^A-Za-z]/g,
  'tel':/[^\d&\-&\+]/g,
  'tijd':/[^\d&\:]/g
}

function valid(o,typea,typeb){
  o.value = o.value.replace(r[typea],'');
  if(typeb) {
	  o.value = o.value.replace(r[typeb],'');
  }
}

function Convert(o,type){
  if(type=='upper') {
	  o.value = o.value.toUpperCase();
  }
  if(type=='lower') {
	  o.value = o.value.toLowerCase();
  }
}

function checkMail(o){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(o.value) == false){
		return false;
	} else {
		return true;
	}
}

