$(function(){ $('input[name="numberofadults"], input[name="numberofchildren"]').keyup(function() { var form = '#' + $(this).closest('form').attr('id'); $('.attendeeslist > div > div', form).not('div:eq(0)').remove(); var numberofadults = Number($('#numberofadults', form).val()); var numberofchildren = Number($('#numberofchildren', form).val()); var totalattendees = Number((numberofadults + numberofchildren)); if (totalattendees > 0) { $('.attendeeslist', form).css('display', 'block'); for (var i = 1; i <= totalattendees; i++) { var inputlist = '
'; $('.attendeeslist div:eq(1)', form).after(inputlist); } } else { $('.attendeeslist > div > div', form).not('div:eq(0)').remove(); $('.attendeeslist', form).css('display', 'none'); $(".scroll").getNiceScroll().remove(); } $(".scroll").getNiceScroll().resize(); }); $('.modal').on('hidden.bs.modal', function() { $(".scroll").getNiceScroll().remove(); $('.attendeeslist > div > div').not('div:eq(0)').remove(); $('.attendeeslist').css('display', 'none'); $('.modal form')[0].reset(); }); $(document).on('click', '.openmodaloffer', function() { var eventid = $(this).data("event-id"); var eventtype = $(this).data("event-type"); var validator = $('form').validate(); validator.resetForm(); $('#booknowform' + eventtype + ' #titolo').html($(this).data("event-title")); $('#booknowform' + eventtype + ' #tipo').val(eventtype); $('#booknowform' + eventtype + ' #offerta').val(eventid); $('#booknowform' + eventtype + ' #data').attr('data-offerta-id',eventid); var datesel = $(this).data("cal-date"); if ($(this).data("cal-date") != '' && $(this).data("cal-date") != undefined) { var dateexpl = datesel.split('-'); datesel = dateexpl[2] + '/' + dateexpl[1] + '/' + dateexpl[0]; $('#booknowform' + eventtype + ' #data').val(datesel); if(eventtype == 1 || eventtype == 3) { var timing = ''; $.post('/_apps/post.inc.html?sys_lang=1&act=gethours&offer=' + eventid + '&date=' + datesel, function(result) { timing = '
'; $('#booknowform' + eventtype + ' #timing').html(timing); }); } } if(eventtype == 2) { var timing = '
'; $('#booknowform' + eventtype + ' #timing').html(timing); } else if(eventtype == 3) { $('#booknowform' + eventtype + ' #div-numberofadults').hide(); $('#booknowform' + eventtype + ' #infonumberofchildren').hide(); $('#booknowform' + eventtype + ' #label-allergie').html('Allergie alimentari*'); } else if(eventtype == 4) { var datesplit = $(this).data("cal-date").split('-'); $('#booknowform' + eventtype + ' #data').val(datesplit[2]+'/'+datesplit[1]+'/'+datesplit[0]); $('#booknowform' + eventtype + ' #ora').val($(this).data("cal-hour")); } }); var datetimepicker = $('.datetimepicker').datepicker(); $(document).on('click', '.datetimepicker', function() { var id = $(this).data("offerta-id"); $.post('/_apps/post.inc.html?sys_lang=1&act=datesnotavailables&id=' + id, function(result) { var array = result.split(','); var dateToday = new Date(); var DateOptions = { controlType: myControl, firstDay: 1, minDate: dateToday, monthNames: [ "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" ], dateFormat: "dd/mm/yy", dayNames: [ "Domenica", "Lunedi", "Martedi", "Mercoledi", "Giovedi", "Venerdi", "Sabato" ], dayNamesMin: [ "Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa" ], beforeShowDay: function(date){ var string = jQuery.datepicker.formatDate('dd-mm-yy', date); return [array.indexOf(string) == -1]; }, onSelect: function() { $.post('/_apps/post.inc.html?sys_lang=' + $('form #sys_lang').val() + '&act=gethours&offer=' + $('form #offerta').val() + '&date=' + $('form #data').val(), function(result) { $('form #ora').html(result).attr('disabled', false); $('form #numberofadults').html(result).attr('disabled', false); $('form #numberofchildren').html(result).attr('disabled', false); }); } } $.datepicker.setDefaults(DateOptions); datetimepicker.datepicker('refresh'); }); }); }); function checklimitattendees(offer,data,ora,form) { var attendees = Number(Number($(form + ' #numberofadults').val()) + Number($(form + ' #numberofchildren').val())); if(ora > 0) { $.post('/_apps/post.inc.html?sys_lang=' + $('form #sys_lang').val() + '&act=getlimitattendees&offer=' + offer + '&data=' + data + '&ora=' + ora + '&attendees=' + attendees, function(result) { var resultsplit = result.split('|'); if(resultsplit[0]) { showalertmsg('warning', resultsplit[1], '1500'); $(document).find(form + ' .b-btn').hide(); } else { $(document).find(form + ' .b-btn').show(); } }); } else { showalertmsg('warning', 'Seleziona un orario', '1500'); $(document).find(form + ' .b-btn').hide(); } } function checklimitattendeesspecial(offer,data,ora,form) { var attendees = Number(Number($(form + ' #numberofadults').val()) + Number($(form + ' #numberofchildren').val())); if(ora != undefined) { $.post('/_apps/post.inc.html?sys_lang=' + $('form #sys_lang').val() + '&act=getlimitattendeesspecial&offer=' + offer + '&data=' + data + '&ora=' + ora + '&attendees=' + attendees, function(result) { var resultsplit = result.split('|'); if(resultsplit[0]) { showalertmsg('warning', resultsplit[1], '1500'); $(document).find(form + ' .b-btn').hide(); } else { $(document).find(form + ' .b-btn').show(); } }); } } $(function(){ var contactusform = $("#contactusform").validate({ // Rules for form validation rules: { nome: { required: true }, cognome: { required: true }, telefono: { required: true }, email: { required: true, email: true }, richiesta: { required: true }, privacyokctrl: { required: true } }, // Messages for form validation messages: { nome: { required: 'Campo obbligatorio.' }, cognome: { required: 'Campo obbligatorio.' }, telefono: { required: 'Campo obbligatorio.' }, email: { required: 'Campo obbligatorio.', email: 'Si prega di inserire un indirizzo e-mail valido.' }, richiesta: { required: 'Campo obbligatorio.' }, privacyokctrl: { required: 'Campo obbligatorio.' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create( document.querySelector( '#contactusform button' ) ); l.start(); var vars = $("#contactusform").serialize(); vars = vars + '&PSMS_v=' + getCookie('PSMS_v'); $.post('/_apps/post.inc.html', vars, function(result) { var resultsplit = result.split('|'); showalertmsg(resultsplit[0], resultsplit[1], '1500'); $('#contactusform')[0].reset(); l.stop(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var booknowform = $("#booknowform").validate({ // Rules for form validation rules: { data: { required: true }, numberofadults: { required: true }, numberofchildren: { required: true }, nome: { required: true }, cognome: { required: true }, email: { required: true, email: true }, telefono: { required: true }, statotxt: { required: true }, lingua: { required: true }, privacyokctrl: { required: true } }, // Messages for form validation messages: { data: { required: true }, numberofadults: { required: 'Campo obbligatorio.' }, numberofchildren: { required: 'Campo obbligatorio.' }, nome: { required: 'Campo obbligatorio.' }, cognome: { required: 'Campo obbligatorio.' }, email: { required: 'Campo obbligatorio.', email: 'Si prega di inserire un indirizzo e-mail valido.' }, telefono: { required: 'Campo obbligatorio.' }, statotxt: { required: 'Campo obbligatorio.' }, lingua: { required: 'Campo obbligatorio.' }, privacyokctrl: { required: 'Campo obbligatorio.' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create( document.querySelector( '#booknowform button' ) ); l.start(); var vars = $("#booknowform").serialize(); vars = vars + '&PSMS_v=' + getCookie('PSMS_v'); $.post("/_apps/post.inc.html", vars, function(result) { $('#booknowform')[0].reset(); l.stop(); var resultsplit = result.split('|'); showalertmsg(resultsplit[0], resultsplit[1], '1500'); $('#bookmodal').modal('hide'); //Facebook Pixel Code FacebookPixelPurchase(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var booknowform1 = $("#booknowform1").validate({ // Rules for form validation rules: { data: { required: true }, ora: { required: true }, numberofadults: { required: true }, numberofchildren: { required: true }, nome: { required: true }, cognome: { required: true }, email: { required: true, email: true }, telefono: { required: true }, statotxt: { required: true }, lingua: { required: true }, privacyokctrl: { required: true } }, // Messages for form validation messages: { data: { required: true }, ora: { required: 'Campo obbligatorio.' }, numberofadults: { required: 'Campo obbligatorio.' }, numberofchildren: { required: 'Campo obbligatorio.' }, nome: { required: 'Campo obbligatorio.' }, cognome: { required: 'Campo obbligatorio.' }, email: { required: 'Campo obbligatorio.', email: 'Si prega di inserire un indirizzo e-mail valido.' }, telefono: { required: 'Campo obbligatorio.' }, statotxt: { required: 'Campo obbligatorio.' }, lingua: { required: 'Campo obbligatorio.' }, privacyokctrl: { required: 'Campo obbligatorio.' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create( document.querySelector( '#booknowform1 button' ) ); l.start(); var vars = $("#booknowform1").serialize(); vars = vars + '&PSMS_v=' + getCookie('PSMS_v'); $.post("/_apps/post.inc.html", vars, function(result) { $('#booknowform1')[0].reset(); l.stop(); var resultsplit = result.split('|'); showalertmsg(resultsplit[0], resultsplit[1], '1500'); $('#bookmodal1').modal('hide'); //Facebook Pixel Code FacebookPixelPurchase(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var booknowform2 = $("#booknowform2").validate({ // Rules for form validation rules: { data: { required: true }, periodo: { required: true }, numberofadults: { required: true }, numberofchildren: { required: true }, nome: { required: true }, cognome: { required: true }, email: { required: true, email: true }, telefono: { required: true }, statotxt: { required: true }, lingua: { required: true }, privacyokctrl: { required: true } }, // Messages for form validation messages: { data: { required: 'Campo obbligatorio.' }, periodo: { required: 'Campo obbligatorio.' }, numberofadults: { required: 'Campo obbligatorio.' }, numberofchildren: { required: 'Campo obbligatorio.' }, nome: { required: 'Campo obbligatorio.' }, cognome: { required: 'Campo obbligatorio.' }, email: { required: 'Campo obbligatorio.', email: 'Si prega di inserire un indirizzo e-mail valido.' }, telefono: { required: 'Campo obbligatorio.' }, statotxt: { required: 'Campo obbligatorio.' }, lingua: { required: 'Campo obbligatorio.' }, privacyokctrl: { required: 'Campo obbligatorio.' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create( document.querySelector( '#booknowform2 button' ) ); l.start(); var vars = $("#booknowform2").serialize(); vars = vars + '&PSMS_v=' + getCookie('PSMS_v'); $.post("/_apps/post.inc.html", vars, function(result) { $('#booknowform2')[0].reset(); l.stop(); var resultsplit = result.split('|'); showalertmsg(resultsplit[0], resultsplit[1], '1500'); $('#bookmodal2').modal('hide'); //Facebook Pixel Code FacebookPixelPurchase(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var booknowform3 = $("#booknowform3").validate({ // Rules for form validation rules: { data: { required: true }, periodo: { required: true }, numberofchildren: { required: true }, nome: { required: true }, cognome: { required: true }, email: { required: true, email: true }, telefono: { required: true }, statotxt: { required: true }, lingua: { required: true }, foodallergies: { required: true }, privacyokctrl: { required: true } }, // Messages for form validation messages: { data: { required: 'Campo obbligatorio.' }, periodo: { required: 'Campo obbligatorio.' }, numberofchildren: { required: 'Campo obbligatorio.' }, nome: { required: 'Campo obbligatorio.' }, cognome: { required: 'Campo obbligatorio.' }, email: { required: 'Campo obbligatorio.', email: 'Si prega di inserire un indirizzo e-mail valido.' }, telefono: { required: 'Campo obbligatorio.' }, statotxt: { required: 'Campo obbligatorio.' }, lingua: { required: 'Campo obbligatorio.' }, foodallergies: { required: 'Campo obbligatorio.' }, privacyokctrl: { required: 'Campo obbligatorio.' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create( document.querySelector( '#booknowform3 button' ) ); l.start(); var vars = $("#booknowform3").serialize(); vars = vars + '&PSMS_v=' + getCookie('PSMS_v'); $.post("/_apps/post.inc.html", vars, function(result) { $('#booknowform3')[0].reset(); l.stop(); var resultsplit = result.split('|'); showalertmsg(resultsplit[0], resultsplit[1], '1500'); $('#bookmodal3').modal('hide'); //Facebook Pixel Code FacebookPixelPurchase(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var booknowform4 = $("#booknowform4").validate({ // Rules for form validation rules: { numberofadults: { required: true }, numberofchildren: { required: true }, nome: { required: true }, cognome: { required: true }, email: { required: true, email: true }, telefono: { required: true }, statotxt: { required: true }, lingua: { required: true }, privacyokctrl: { required: true } }, // Messages for form validation messages: { numberofadults: { required: 'Campo obbligatorio.' }, numberofchildren: { required: 'Campo obbligatorio.' }, nome: { required: 'Campo obbligatorio.' }, cognome: { required: 'Campo obbligatorio.' }, email: { required: 'Campo obbligatorio.', email: 'Si prega di inserire un indirizzo e-mail valido.' }, telefono: { required: 'Campo obbligatorio.' }, statotxt: { required: 'Campo obbligatorio.' }, lingua: { required: 'Campo obbligatorio.' }, privacyokctrl: { required: 'Campo obbligatorio.' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create( document.querySelector( '#booknowform1 button' ) ); l.start(); var vars = $("#booknowform1").serialize(); vars = vars + '&PSMS_v=' + getCookie('PSMS_v'); $.post("/_apps/post.inc.html", vars, function(result) { $('#booknowform1')[0].reset(); l.stop(); var resultsplit = result.split('|'); showalertmsg(resultsplit[0], resultsplit[1], '1500'); $('#bookmodal1').modal('hide'); //Facebook Pixel Code FacebookPixelPurchase(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var newsletterform = $("#newsletterform").validate({ // Rules for form validation rules: { nome: { required: true }, cognome: { required: true }, email: { required: true, email: true }, statotxt: { required: true }, privacyokctrl: { required: true } }, // Messages for form validation messages: { nome: { required: 'Campo obbligatorio.' }, cognome: { required: 'Campo obbligatorio.' }, email: { required: 'Campo obbligatorio.', email: 'Si prega di inserire un indirizzo e-mail valido.' }, statotxt: { required: 'Campo obbligatorio.' }, privacyokctrl: { required: 'Campo obbligatorio.' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create( document.querySelector( '#newsletterform button' ) ); l.start(); var vars = $("#newsletterform").serialize(); vars = vars + '&PSMS_v=' + getCookie('PSMS_v'); $.post("/_apps/post.inc.html?" + vars, function(result) { var resultsplit = result.split('|'); showalertmsg(resultsplit[0], resultsplit[1], '1500'); $('#newsletterform')[0].reset(); l.stop(); $('#newslettermodal').modal('hide'); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); });