$(function(){
	$(".refreshimg").click(function(){
		$.post('lib/captcha/newsession.php');
		//Afegim un random perquè l'Internet Explorer refresqui la captcha (si no ho fem, fa servir caché i no recarrega la imatge)
		$(".refreshimg").load('lib/captcha/image_req.php?'+Math.random()*99999);
		return false;
	});


	$("#captchaform").validate({
		rules: {
			captcha: {
				required: true,
				remote: "process.php"
			}
		},
		messages: {
			captcha: "Correct captcha is required. Click the captcha to generate a new one"	
		},
		submitHandler: function() {
			alert("Correct captcha!");
		},
		success: function(label) {
			label.addClass("valid").text("Valid captcha!")
		},
		onkeyup: false
	});
	
});

