/*
 * Form validation
 *  
 * Copyright (c) 2011 Edwin de Vries - Add Noise Internet & Design
 *
 */

$(function() {
	// Formulier via Ajax verzenden
	$('#smallform form').ajaxForm({
		url: '/',
		type: 'post',
		data: { blockid: '70189', datatype: 'json', jsoncallback: 'jsonp' },
		dataType: 'json',
		success: verwerkResultaat
	});
});

function verwerkResultaat(data) 
{
	if (data.isValid) 
	{
		location.href = '/bedanktpagina';
		//alert('Formulier succesvol verstuurd');
	}
	else 
	{
		var errorstring = 'Het formulier bevat de volgende fouten:' + '\n\n';

		$.each(data.errors, function(index, value) { 
			errorstring = errorstring + '- ' + value + '\n'
		});

		alert(errorstring)
	}
}

