function checkForm() {
//	alert("start check v10");
  	var errMsg = "";

	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	
	if($F("fname") == "") { errMsg += "<p>Pr&eacute;nom est un champ obligatoire!</p>";}
	if($F("name") == "") { errMsg += "<p>Nom est un champ obligatoire!</p>";}
  	if($F("mail") == "") { errMsg += "<p>E-mail est un champ obligatoire!</p>";} 
	else {if(!$F("mail").match(emailRegex)) {errMsg += "<p>U heeft geen geldig e-mailadres ingegeven!</p>";}}
  	if($F("statuut") == "0") { errMsg += "<p>Situation actuelle est un champ obligatoire!</p>";}
	if($F("diploma") == "0") { errMsg += "<p>Niveau de formation est un champ obligatoire!</p>";}
	if($F("functie") == "0") { errMsg += "<p>Niveau de votre fonction est un champ obligatoire!</p>";}
	
	if ($("domein")){		
		var domein = $F("domein");
	  	if(domein == "0") { errMsg += "<p>Fonction est un champ obligatoire!</p>";}
	}
	if ($("sector")){		
		var sector = $F("sector");
	  	if(sector == "0") { errMsg += "<p>Secteur est un champ obligatoire!</p>";}
	}
	if ($F('leiding') != 0 || $F('budget') != 0 || $F('contract') != 0 || $F('overuren') != "" || $F('organisatie') != 0 || $F('regio') != ""){
		// ook validatie voor het tweede block
		if($F("leiding") == "0") { errMsg += "<p>Gestion d'&eacute;quipe est un champ obligatoire!</p>";}
		if($F("budget") == "0") { errMsg += "<p>Gestion de budgets est un champ obligatoire!</p>";}
		if ($F('statuut') < 5){
			if($F("contract") == "0") { errMsg += "<p>Type de contract est un champ obligatoire!</p>";}
			if($F("overuren") == "") { errMsg += "<p>Heures suppl&eacute;mentaires est un champ obligatoire!</p>";}
			if($F("organisatie") == "0") { errMsg += "<p>Organisation est un champ obligatoire!</p>";}
			if($F("regio") == "") { errMsg += "<p>Lieu de travail est un champ obligatoire!</p>";}
		} else {
			if($F("overuren") == "") { errMsg += "<p>Heures suppl&eacute;mentaires est un champ obligatoire!</p>";}
			if($F("organisatie") == "0") { errMsg += "<p>Organisation est un champ obligatoire!</p>";}
		}
	}
	
	if (errMsg != ""){
	  	//alert(errMsg);
		$('errormsg').update(errMsg);
		$('errormsg').show();
		$('salaris_text').scrollIntoView();
		return false;
	} else {
		return true;
	}
}

function showExtra(){
	$('extra_zoekcriteria').toggle();
}

function getOptions(option_id){
	var statuut = $F('statuut');
	var selected_val = $F(option_id);
	//console.log(selected_val);
	id_to_update = option_id + "-sel";
	new Ajax.Updater(id_to_update, 'getoptions.php', {
	parameters: {
		opts: option_id,
		statuut: statuut,
		selected_val: selected_val
	}
});
}
function handleStatuut(){
	if ($F('statuut') == 5){
		// statutairen
		$('opt-regio').hide();
		$('opt-contract').hide();
	} else if ($F('statuut') == 7){
		// contractuelen
		$('opt-regio').hide();
	} else {
		$('opt-regio').show();
		$('opt-contract').show();
	}
	getOptions("sector");
	getOptions("domein");
}