<!--
$(function() {
	
	var alle_functies = $('.select_functie option');
	var alle_vestigingen = $('.select_vestiging option');
	
	$('.select_vestiging').change(function() {
		if ($(this).find('option:selected').val() == 'all') {
			reset_selects();
		} else {
			$(this).find('option[value="all"]').remove();
			$(this).append('<option value="all">' + sAlleVestigingen + '</option>');
			
			var sSelectedVestiging = $(this).val();			
			populate_functies(sSelectedVestiging);
		}
	});
	
	function reset_selects() {			
		populate_functies("");
		populate_vestigingen("");
	}
	
	function populate_functies(sFilter) {
		var sElements = "";
		if (sFilter == "") {
			alle_functies.each(function(index) {
				sElements += "<option value='" + $(this).val() + "' title='" + $(this).attr('title') + "' vestiging='" + $(this).attr('vestiging') + "' url='" + $(this).attr('url') + "'>" + $(this).text() + "</option>";
			});	
			$('.select_functie').html(sElements);
		} else {
			alle_functies.each(function(index) {
				if ($(this).attr('vestiging') == sFilter) {
					sElements += "<option value='" + $(this).val() + "' title='" + $(this).attr('title') + "' vestiging='" + $(this).attr('vestiging') + "' url='" + $(this).attr('url') + "'>" + $(this).text() + "</option>";
				}
			});
				
			var sExtraElement = "<option value='all'>" + sAlleFuncties + "</option>";	
			if (sElements == "") {
				sElements = "<option value='geen'>" + sGeenVacatures + "</option>";
			}
			sElements += sExtraElement;
			$('.select_functie').html(sElements);
		}
		
		
	}
	
	$('.select_functie').change(function() {
		if ($(this).find('option:selected').val() == 'all') {
			reset_selects();
		} else {
			$(this).find('option[value="all"]').remove();
			$(this).append('<option value="all">' + sAlleFuncties + '</option>');
			
			var sSelectedFunctie = $(this).find('option:selected').attr('vestiging');
			populate_vestigingen(sSelectedFunctie);
		}
	});
	
	function populate_vestigingen(sFilter) {
		var sElements = "";
		if (sFilter == "") {
			alle_vestigingen.each(function(index) {
				sElements += "<option value='" + $(this).val() + "' title='" + $(this).attr('title') + "'>" + $(this).text() + "</option>";
			});	
			$('.select_vestiging').html(sElements);
		} else {
			alle_vestigingen.each(function(index) {
				if ($(this).val() == sFilter) {
					sElements += "<option value='" + $(this).val() + "' title='" + $(this).attr('title') + "'>" + $(this).text() + "</option>";
				}
			});
			
			var sExtraElement = "<option value='all'>" + sAlleVestigingen + "</option>";
			if (sElements == "") {
				sElements = "<option value='geen'>" + sGeenVacatures + "</option>";
			}
			sElements += sExtraElement;
			$('.select_vestiging').html(sElements);
		}
	}
	
	$('.btn_search_job').click(function(e) {
		sendFormJob(e.pageX, e.pageY);
	});
	
});

function sendFormJob(mouseX, mouseY) {
	var sError = "";
	if ($('.select_vestiging').val() == "" || $('.select_vestiging').val() == "geen" || $('.select_vestiging').val() == "all") {
		sError += sErrSelecteerVestiging + "<br />";
	}
	if ($('.select_functie').val() == "" || $('.select_functie').val() == "geen" || $('.select_functie').val() == "all") {
		sError += sErrSelecteerFunctie + "<br />";
	}
	
	if (sError == "") {
		goto($('.select_functie').find('option:selected').attr('url'));
	} else {
		showError(sError, mouseX, mouseY);
	}
}
-->
