$.validator.setDefaults
({
	submitHandler: function(form)
	{
		$('#personal').hide();
		$('#captcha').hide();
		$('#rankingnotsend').hide();
		$('#rankingsend').hide();
		$('#loading').show();
		$.post
		(
			"http://en.traffic4u.nl/wp-content/themes/traffic4u/positie-analyse/positie-analyse.php",
			{
				ranking : "TRUE",
				name : form.name.value,
				email : form.email.value,
				telefoonnummer : form.telefoonnummer.value,
				website : form.website.value,
				kw1 : form.kw1.value,
				kw2 : form.kw2.value,
				kw3 : form.kw3.value,
				kw4 : form.kw4.value
			},
			function(data)
			{				
				$('#loading').hide();
				$('#rankingsend').show();
				pageTracker._trackPageview('positie-analyse-tool');
			}
		);
	}
});

$(document).ready(function()
{
	$('#rankingsend').hide();
	$('#loading').hide();
	$("#ranking").validate
	({
		rules:
		{
			name:
			{
				required: false,
				minlength: 5
			},
			email:
			{
				required: true,
				email: true
			},
			telefoonnummer:
			{
				required: false,
				minlength: 10
			},
			website:
			{
				required: true,
				url: true
			},
			captcha:
			{
				required: true,
				remote: "http://en.traffic4u.nl/wp-content/themes/traffic4u/positie-analyse/process.php"
			}
		},
		messages:
		{
			name:
			{
				required: "<span style='color: red;'>It is required to fill in a name.</span>",
				minlength: jQuery.format("<br /><span style='color: red;'>Your name has to excist out of {0} characters.</span>")
			},
			email: "<br /><span style='color: red;'>The e-mail address where the results will be sent to.</span>",
			telefoonnummer:
			{
				required: "<br /><span style='color: red;'>It is required to fill in a phone number.</span>",
				minlength: jQuery.format("<br />The phone number has to excist out of {0} characters.</span>")
			},
			website: "<br /><span style='color: red;'>Please insert a valid url.</span>",
			captcha: "<br /><span style='color: red;'>Type the characters wich you can see on the left.</span>"
		}
	});
});