loading = new Image(208,13);
loading.src = "js/loadingAnimation.gif";

function verstuurBericht() {
	var errors = '';
	var txtnaam = $('#nbnaam');
	var txtemail = $('#nbemail');
	var txtbericht = $('#nbbericht');
	var txttelefoon = $('#nbtelefoon');
	var txtadres = $('#nbadres');
	var txtplaats = $('#nbplaats');
	
	if (txtnaam.val()=='') {
		errors += 'Naam - voornaam is verplicht.\n';
	}
	if (txttelefoon.val()=='') {
		errors += 'Telefoon - gsm is verplicht.\n';
	}
	if (!checkEmailAddress(txtemail.val())) {
		errors += 'E-mail is niet goed opgegeven.\n';
	}
	if (txtbericht.val()=='') {
		errors += 'Bericht is verplicht.\n';
	}
	if (errors=='') {
		$('#contactform').html('<img src="js/loadingAnimation.gif"/>');
		$.ajax( {
		   type: "POST",
		   url: "sendcontact.php",
		   data: { naam: txtnaam.val(), bericht: txtbericht.val(), email: txtemail.val(), telefoon: txttelefoon.val(), adres: txtadres.val(), plaats: txtplaats.val() },

		   success: function(msg) {
			  	$('#contactform').html(msg);
		   }
		   
	 	});
	} else {
		alert(errors);
	}
}
function checkEmailAddress(emailaddress) {
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(emailaddress)) {
		return false;
	}
	return true;
}
