jQuery(document).ready(function()
{
		
	jQuery(".newsletter form").validate({submitHandler: function(form) { jQuery(".newsletter form").ajaxSubmit({ dataType:  'json', success:   processNewsletter });}});
	jQuery(".cancellazione-newsletter form").validate({submitHandler: function(form) { jQuery(".cancellazione-newsletter form").ajaxSubmit({ dataType:  'json', success:   processCancellazioneNewsletter });}});	
	jQuery(".prenotazione form").validate({submitHandler: function(form) { jQuery(".prenotazione form").ajaxSubmit({ dataType:  'json', success:   processPrenotazione });}});

});

function processCancellazioneNewsletter(data) {     if(data.message == 1){     jQuery('.cancellazione-newsletter form').css('opacity','.2').delay(500,function(){jQuery('.cancellazione-newsletter .messaggi').show().delay(10,function(){     jQuery('.cancellazione-newsletter .loader').fadeIn().delay(3000,function(){jQuery('.cancellazione-newsletter .loader').fadeOut().delay(500,function(){jQuery('.cancellazione-newsletter .success').fadeIn().delay(2000,function(){if(data.cancellazionenewsletter == 1){jQuery('.cancellazione-newsletter .success').fadeOut().delay(300,function(){location.href = "index.html";return false;});}})})})})})     }else{    jQuery('.errore').fadeIn().delay(2000,function(){    jQuery('.cancellazione-newsletter .errore').fadeOut();    });    }}

function processNewsletter(data) {     if(data.message == 1){     jQuery('.newsletter form').css('opacity','.2').delay(500,function(){jQuery('.newsletter .messaggi').show().delay(10,function(){     jQuery('.newsletter .loader').fadeIn().delay(3000,function(){jQuery('.newsletter .loader').fadeOut().delay(500,function(){jQuery('.newsletter .success').fadeIn().delay(2000,function(){if(data.cancellazionenewsletter != 1){jQuery('.newsletter .success').fadeOut().delay(300,function(){location.href = "";return false;});}})})})})})     }else{    jQuery('.errore').fadeIn().delay(2000,function(){    jQuery('.newsletter .errore').fadeOut();    });    }}

function processPrenotazione(data) {     if(data.message == 1){     jQuery('.prenotazione form').css('opacity','.2').delay(500,function(){jQuery('.prenotazione .messaggi').show().delay(10,function(){     jQuery('.prenotazione .loader').fadeIn().delay(3000,function(){jQuery('.prenotazione .loader').fadeOut().delay(500,function(){jQuery('.prenotazione .success').fadeIn().delay(2000,function(){if(data.cancellazionenewsletter != 1){jQuery('.prenotazione .success').fadeOut().delay(300,function(){location.href = "";return false;});}})})})})})     }else{    jQuery('.prenotazione .errore').fadeIn().delay(2000,function(){    jQuery('.prenotazione .errore').fadeOut();    });    }}
    
    



