$(document).ready(function(){
	$("#loadCaptcha").load("inc_img_captcha.php");

	$("a#rCaptcha").bind("click", function() {
		var time = $("#imgCaptcha").attr("rel");
		$("#loadCaptcha").load("inc_img_captcha.php?t="+time);
	});

	$("#registrazione").validate({
		errorClass: "error",
		errorPlacement: function(error, element) {},		
		rules: {
			mail: {
				mailCheck:true 

			},
			code: {
				captchaCheck: true
			}
		}
	});

	jQuery.validator.addMethod('mailCheck', function(mail) {
		var postURL = "do_check_mail.php";
			$.ajax({
			cache:false,
			async:false,
			type: "POST",
			data: "mail=" + mail,
			url: postURL,
			success: function(msg) {
			 result = (msg=='TRUE') ? true : false;
			}
		});
		return result;
	}, 'Mail gi&agrave; nel nostro database');	

	jQuery.validator.addMethod('captchaCheck', function(code) {
			var postURL = "inc_check_captcha.php";
				$.ajax({
				cache:false,
				async:false,
				type: "POST",
				data: "code=" + code,
				url: postURL,
				success: function(msg) {
				 result = (msg=='TRUE') ? true : false;
				}
			});
		return result;
	}, 'Codice errato');	

	$("a#priva").fancybox({
		'frameWidth': 700, 
        'frameHeight': 600,
		zoomSpeedIn:300,
		zoomSpeedOut:300
	});
});