/**
 * Contattaci
 * @author mario bianco prevot <prevot@pianetalotto.it>
 * @copyright Copyright &copy; 2008-2009, www.pianetalotto.it
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * @version $Id: /jquery.forum.js ,v 1.0 27/12/2009 10:35 ;
 */

function showRequest(formData, jqForm, options) { 
    return true; 
} 
function showSuccess(responseText, statusText)  { 
	$('#captcha').simpleCaptcha();
		if ( !$(this).is ( ":checked" ) )
		{
			$("#submitbutton").attr ( "disabled" , true );
		}
		else
		{
			$("#submitbutton").removeAttr ( "disabled" );
		}
    return true; 
}

jQuery(document).ready(function(){
	$('#captcha').simpleCaptcha();
	$('input.simpleCaptchaInput').addClass('required'); 
	var v = $("#frm_mailer").validate({
		submitHandler: function(form) {
			$(form).ajaxSubmit({
				target: "#result",
				url:'contatti_sendmail.php',
				//clearForm: true,
				resetForm: true,
				//beforeSubmit:  showRequest,
				success:showSuccess
				//type:'post'
				//dataType:  null // 'xml', 'script', or 'json' (expected server response type) 
				// $.ajax options can be used here too, for example: 
				//timeout:   3000 
			});
		}
	});

	$("#submitbutton").attr ( "disabled" , true );
	$("#consenso").click ( function() {
		if ( !$(this).is ( ":checked" ) )
		{
			$("#submitbutton").attr ( "disabled" , true );
		}
		else
		{
			$("#submitbutton").removeAttr ( "disabled" );
		}
	});


});  // end jQuery(document).ready(function()

