$(document).ready(function(){
const lightbox = GLightbox({ });
moment.locale("es");
$(document).on("click", "#gatewayok", function() {
$(this).hide();
$("#gatewayko").show();
$("#concordatoselect").val(0);
$("#creditcardform").show();
$("#ssldiv").show();
})
$(document).on("change", "input[type=radio][name=ricfat]", function(){
if($(this).val() == "fattura"){
$("#formfattura").show();
}
else {
$("#formfattura").hide();
}
})
$(document).on("click", "#gatewayko", function() {
$(this).hide();
$("#gatewayok").show();
$("#concordatoselect").val(1);
$("#creditcardform").hide();
$("#ssldiv").hide();
})
$(document).on("click", "#yescard", function() {
$(this).removeClass("fa-square");
$(this).addClass("fa-check-square");
$("#nexi").removeClass("fa-check-square");
$("#nexi").addClass("fa-square");
$("#axerve").removeClass("fa-check-square");
$("#axerve").addClass("fa-square");
$("#nocard").removeClass("fa-check-square");
$("#nocard").addClass("fa-square");
$("#nocardinput").val(0);
$("#nexiinput").val(0);
$("#axerveinput").val(0);
mostra_form_carta()
});
$(document).on("click", "#nocard", function() {
$(this).removeClass("fa-square");
$(this).addClass("fa-check-square");
$("#nexi").removeClass("fa-check-square");
$("#nexi").addClass("fa-square");
$("#axerve").removeClass("fa-check-square");
$("#axerve").addClass("fa-square");
$("#yescard").removeClass("fa-check-square");
$("#yescard").addClass("fa-square");
$("#nocardinput").val(1);
$("#nexiinput").val(0);
$("#axerveinput").val(0);
mostra_form_carta()
});
$(document).on("click", "#nexi", function() {
$(this).removeClass("fa-square");
$(this).addClass("fa-check-square");
$("#nocard").removeClass("fa-check-square");
$("#nocard").addClass("fa-square");
$("#axerve").removeClass("fa-check-square");
$("#axerve").addClass("fa-square");
$("#yescard").removeClass("fa-check-square");
$("#yescard").addClass("fa-square");
$("#nocardinput").val(0);
$("#nexiinput").val(1);
$("#axerveinput").val(0);
mostra_form_carta()
});
$(document).on("click", "#axerve", function() {
$(this).removeClass("fa-square");
$(this).addClass("fa-check-square");
$("#nocard").removeClass("fa-check-square");
$("#nocard").addClass("fa-square");
$("#nexi").removeClass("fa-check-square");
$("#nexi").addClass("fa-square");
$("#yescard").removeClass("fa-check-square");
$("#yescard").addClass("fa-square");
$("#nocardinput").val(0);
$("#nexiinput").val(0);
$("#axerveinput").val(1);
mostra_form_carta()
});
function mostra_form_carta() {
if($("#nocardinput").val() == 0 && ($("#nexiinput").length == 0 || $("#nexiinput").val() == 0) && ($("#axerveinput").length == 0 || $("#axerveinput").val() == 0)){
$("#creditcardform").show();
}
else {
$("#creditcardform").hide();
}
}
var width = window.innerWidth;
var calendarFormat = "dddd DD MMMM YYYY";
var calendarFormatMobile = "ddd DD MMM YYYY";
var unixFormat = "YYYY-MM-DD";
var pickerstart = moment();
var pickerend = moment().add(1, "days");
var pax = 0;
var bookedrooms = 0;
var showalert = true;
$(".checkbuttons").click(function(){
})
$("#autoform").click(function(){
if(bookedrooms>0 ){
$("#concordato").val($("#concordato").val().replace(",","."));
var serial = $("#theform").serialize();
var validays = $("#validays").val();
$.ajax({
url: "ajax_shorturl.php",
method: "POST",
data: serial+"&validays="+validays,
success: function(data){
if(data){
$("#shorturl").html(data);
}
}
})
}
else{
alert("Seleziona almeno una camera");
}
});
$("#indatepicker").daterangepicker({
singleDatePicker: true,
startDate: pickerstart,
opens: "right"
},function(start,end){
$("#checkintext").html("
"+start.format(calendarFormat)+"
"+start.format(calendarFormatMobile)+"
");
$("#unixin").val(start.format(unixFormat));
var checkin = $("#indatepicker").data("daterangepicker").startDate.format(unixFormat);
var checkout = $("#outdatepicker").data("daterangepicker").endDate.format(unixFormat);
$("#indatepicker").data("daterangepicker").setEndDate(start);
$("#indatepicker").data("daterangepicker").setStartDate(start);
$("#form_checkin").val($("#indatepicker").data("daterangepicker").startDate.format(unixFormat))
$("#form_checkout").val($("#outdatepicker").data("daterangepicker").startDate.format(unixFormat))
if(checkin >= checkout){
pickerend = start.add(1, "days");
$("#outdatepicker").data("daterangepicker").setEndDate(pickerend);
$("#outdatepicker").data("daterangepicker").setStartDate(pickerend);
$("#form_checkin").val($("#indatepicker").data("daterangepicker").startDate.format(unixFormat))
$("#form_checkout").val($("#outdatepicker").data("daterangepicker").startDate.format(unixFormat))
$("#checkouttext").html(""+pickerend.format(calendarFormat)+"
"+pickerend.format(calendarFormatMobile)+"
");
}
});
$("#indatepicker").on("show.daterangepicker",function(ev, picker){
$("#outdatepicker").fadeTo(100, 0.3);
$("#indatepicker").css("background-color","#d9edf7");
$("#indatepicker").css("border-color","#bce8f1");
$("#indatepicker").css("position","relative");
$("#indatepicker").css("z-index","2");
$("#overlay").show();
})
$("#indatepicker").on("hide.daterangepicker",function(ev, picker){
$("#outdatepicker").fadeTo(100, 1);
$("#indatepicker").css("background-color","#ffffff");
$("#indatepicker").css("border-color","#d6dde6");
$("#indatepicker").css("position","static");
$("#indatepicker").css("z-index","1");
$("#overlay").hide();
})
$("#outdatepicker").daterangepicker({
singleDatePicker: true,
startDate: pickerend,
opens: "left"
},function(start,end){
$("#checkouttext").html(""+start.format(calendarFormat)+"
"+start.format(calendarFormatMobile)+"
");
$("#unixout").val(start.format(unixFormat));
var checkin = $("#indatepicker").data("daterangepicker").startDate.format(unixFormat);
var checkout = $("#outdatepicker").data("daterangepicker").startDate.format(unixFormat);
$("#outdatepicker").data("daterangepicker").setEndDate(start);
$("#outdatepicker").data("daterangepicker").setStartDate(start);
$("#form_checkin").val($("#indatepicker").data("daterangepicker").startDate.format(unixFormat))
$("#form_checkout").val($("#outdatepicker").data("daterangepicker").startDate.format(unixFormat))
if(checkin >= checkout){
pickerstart = start.add(-1, "days");
$("#indatepicker").data("daterangepicker").setStartDate(pickerstart);
$("#indatepicker").data("daterangepicker").setEndDate(pickerstart);
$("#form_checkin").val($("#indatepicker").data("daterangepicker").startDate.format(unixFormat))
$("#form_checkout").val($("#outdatepicker").data("daterangepicker").startDate.format(unixFormat))
$("#checkintext").html(""+pickerstart.format(calendarFormat)+"
"+pickerstart.format(calendarFormatMobile)+"
");
}
})
$("#outdatepicker").on("show.daterangepicker",function(ev, picker){
$("#indatepicker").fadeTo(100, 0.3);
$("#outdatepicker").css("background-color","#d9edf7");
$("#outdatepicker").css("border-color","#bce8f1");
$("#outdatepicker").css("position","relative");
$("#outdatepicker").css("z-index","2");
$("#overlay").show();
})
$("#outdatepicker").on("hide.daterangepicker",function(ev, picker){
$("#indatepicker").fadeTo(100, 1);
$("#outdatepicker").css("background-color","#ffffff");
$("#outdatepicker").css("border-color","#d6dde6");
$("#outdatepicker").css("position","static");
$("#outdatepicker").css("z-index","1");
$("#overlay").hide();
})
$("#checkintext").html(""+pickerstart.format(calendarFormat)+"
"+pickerstart.format(calendarFormatMobile)+"
");
$("#checkouttext").html(""+pickerend.format(calendarFormat)+"
"+pickerend.format(calendarFormatMobile)+"
");
$(".peopleselect").bind("click", function(){
$(".peopleselect").removeClass("btn-info");
$(".peopleselect").addClass("btn-default");
$(this).removeClass("btn-default");
$(this).addClass("btn-info");
var people = $(this).data("pax");
var peopleicon = "";
for(var i = 1;i<=people;i++){
peopleicon += " ";
}
peopleicon = peopleicon.substr(0,peopleicon.length - 1);
$(".peoplelabel").html(peopleicon);
$(".roomrow").hide();
$(".roomfor"+people).show();
$(".roomrow.success").show();
})
function getGuestsInRoom() {
var pax = 0
$('.guestsInRoom:visible').each(function(){
pax += parseInt($(this).val())
});
return pax;
}
$(".guestsinroom").change(function(){
$("#adultsinput").val(getGuestsInRoom());
})
$(".selectrooms").change(function(){
$("#roomalert").hide();
var val = $(this).val();
var room = $(this).data("room");
for(var i=1;i<=50;i++){
if(val>=i){
$("#beds_"+room+"_"+i).show();
$("#guests_"+room+"_"+i).show();
$("#adults_"+room+"_"+i).show();
$("#children_"+room+"_"+i).show();
}
else{
$("#beds_"+room+"_"+i).hide();
$("#guests_"+room+"_"+i).hide();
$("#adults_"+room+"_"+i).hide();
$("#children_"+room+"_"+i).hide();
}
}
$("#form_room"+room).val(val);
if(val>0){
$("#policy_"+room).show();
$("#roomname_"+room).css("font-weight","bold");
$("#row_"+room).addClass("success");
}
else{
$("#policy_"+room).hide();
$("#roomname_"+room).css("font-weight","normal");
$("#row_"+room).removeClass("success");
}
pax = 0;
bookedrooms = 0;
$(".roomrow").each(function(i){
if($(this).hasClass("success")){
pax = pax + parseInt($(this).data("pax")) * parseInt($(this).find(".selectrooms").val());
bookedrooms ++;
}
});
$("#adultsinput").val(getGuestsInRoom());
if(bookedrooms){
$("#morerooms").show();
goToByScroll("indatepicker")
}
});
$(".privacyclick").click(function(){
$("#bottomprivacy").toggle();
});
$(".dropdownvalue").click(function(){
$("#roomalert").hide();
var val = $(this).data("val");
var room = $(this).data("room");
for(var i=1;i<=50;i++){
if(val>=i){
$("#beds_"+room+"_"+i).show();
$("#adults_"+room+"_"+i).show();
$("#children_"+room+"_"+i).show();
}
else{
$("#beds_"+room+"_"+i).hide();
$("#adults_"+room+"_"+i).hide();
$("#children_"+room+"_"+i).hide();
}
}
$("#form_room"+room).val(val);
if(val!="0"){
$("#dropdownbutton"+room).html(val);
$("#policy_"+room).show();
$("#roomname_"+room).css("font-weight","bold");
$("#row_"+room).addClass("success");
}
else{
$("#dropdownbutton"+room).html("");
$("#policy_"+room).hide();
$("#roomname_"+room).css("font-weight","normal");
$("#row_"+room).removeClass("success");
}
pax = 0;
bookedrooms = 0;
$(".roomrow").each(function(i){
if($(this).hasClass("success")){
pax = pax + parseInt($(this).data("pax")) * parseInt($(this).find(".dropdownadults").html());
bookedrooms ++;
}
});
$("#adultsinput").val(getGuestsInRoom());
if(bookedrooms){
$("#morerooms").show();
goToByScroll("indatepicker")
}
})
var ccinterval = setInterval(function()
{
var value = $("#formnumero").val();
value = value.replace(/\D/g,"");
value = value.replace(/[^a-z0-9]+/gi, "").replace(/(.{4})/g, "$1 ");
if(value[value.length -1] == " "){
value = value.substring(0, value.length -1);
}
if(value.length>19){
value = value.substring(0, 19);
}
$("#formnumero").val(value);
var thecard = cardname(value);
$("#creditcard").val(thecard);
$(".ccicon").hide();
if(thecard)
{
$("#"+thecard).show();
}
},50);
$("#privacycheck").bootstrapSwitch({
size: "small",
onColor: "success",
offColor: "danger",
onText: "SI",
offText: "NO"
});
$("#newslettercheck").bootstrapSwitch({
size: "small",
onColor: "success",
offColor: "danger",
onText: "SI",
offText: "NO"
});
$("#cancellationcheck").bootstrapSwitch({
size: "small",
onColor: "success",
offColor: "danger",
onText: "SI",
offText: "NO"
});
$("#concordato").blur(function(){
var schei = $("#concordato").val() / 100 * $("#wirepercent").val();
$("#concordato_gateway").val($("#concordato").val())
$("#wirevalue").html(schei);
$("#deposit").val(schei)
})
$("#wiretransferbutton").click(function(){
$(this).removeClass("btn-light").addClass("btn-primary");
$("#creditcardbutton").removeClass("btn-primary").addClass("btn-light");
$("#wireform").show();
var schei = $("#concordato").val() / 100 * $("#wirepercent").val();
$("#deposit").val(schei)
$("#paymentmethod").val("wire")
$("#wirevalue").html(schei);
$("#creditcardform").hide();
});
$("#creditcardbutton").click(function(){
$(this).removeClass("btn-light").addClass("btn-primary");
$("#wiretransferbutton").removeClass("btn-primary").addClass("btn-light");
$("#creditcardform").show();
$("#paymentmethod").val("creditcard")
$("#wireform").hide();
})
$('#toaxerve').click(function() {
if (!dati_form_ok()) {
return false;
}
var id = $(this).data('hotel');
var token = $(this).data('token');
var futuroid = $(this).data('futuroid');
var unindexed_array = $('#theform').serializeArray();
var indexed_array = {};
$.map(unindexed_array, function(n, i){
indexed_array[n['name']] = n['value'];
});
indexed_array['shorturl'] = '';
var serialize = JSON.stringify(indexed_array)
$.ajax({
url : 'ajax_send_to_axerve.php',
method : 'POST',
data : 'id=' + id + '&token=' + token + '&serial=' + btoa(serialize) + '&futuroid=' + futuroid,
success : function (data){
if (data) {
alert(data);
}
}
})
});
function dati_form_ok() {
var errore = '';
re = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm
if (!$('#privacycheck').is(':checked') || !$('#cancellationcheck').is(':checked')) {
$('#privacyalert').show();
errore = 'privacyalert';
}
if ($('#formnome').val().length < 2) {
$('#personalalert').show();
errore = 'personalalert';
$('#formnome').addClass('wrongform');
}
if ($('#formcognome').val().length < 2) {
$('#personalalert').show();
errore = 'personalalert';
$('#formcognome').addClass('wrongform');
}
if ($('#formindirizzo').val().length < 5) {
$('#personalalert').show();
errore = 'personalalert';
$('#formindirizzo').addClass('wrongform');
}
if ($('#formcitta').val().length < 3) {
$('#personalalert').show();
errore = 'personalalert';
$('#formcitta').addClass('wrongform');
}
if ($('#formemail').val().length < 3) {
$('#personalalert').show();
errore = 'personalalert';
$('#formemail').addClass('wrongform');
}
if (!re.test($('#formemail').val())) {
$('#personalalert').show();
errore = 'personalalert';
$('#formemail').addClass('wrongform');
}
if ($('#formemail2').val()!=$('#formemail').val()) {
$('#personalalert').show();
errore = 'personalalert';
$('#formemail2').addClass('wrongform');
}
if ($('#formcell').val().length < 3) {
$('#personalalert').show();
errore = 'personalalert';
$('#formcell').addClass('wrongform');
}
if ($('#adultsinput').val() < 1) {
$('#summaryalert').show();
$('#adultsinput').addClass('wrongform');
errore = 'summaryalert';
}
if (bookedrooms < 1) {
$('#roomalert').show();
errore = 'roomalert';
}
if (errore) {
goToByScroll(errore);
}
return errore == '';
}
$("#tonexi").click(function(){
var errore = "";
re = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm
if (!$("#privacycheck").is(':checked') || !$("#cancellationcheck").is(':checked')) {
$("#privacyalert").show();
errore = "privacyalert";
}
if($("#formnome").val().length < 2){
$("#personalalert").show();
errore = "personalalert";
$("#formnome").addClass("wrongform")
}
if($("#formcognome").val().length < 2){
$("#personalalert").show();
errore = "personalalert";
$("#formcognome").addClass("wrongform")
}
if($("#formindirizzo").val().length < 5){
$("#personalalert").show();
errore = "personalalert";
$("#formindirizzo").addClass("wrongform")
}
if($("#formcitta").val().length < 3){
$("#personalalert").show();
errore = "personalalert";
$("#formcitta").addClass("wrongform")
}
if($("#formemail").val().length < 3){
$("#personalalert").show();
errore = "personalalert";
$("#formemail").addClass("wrongform")
}
if(!re.test($("#formemail").val())){
$("#personalalert").show();
errore = "personalalert";
$("#formemail").addClass("wrongform")
}
if($("#formemail2").val()!=$("#formemail").val()){
$("#personalalert").show();
errore = "personalalert";
$("#formemail2").addClass("wrongform")
}
if($("#formcell").val().length < 3){
$("#personalalert").show();
errore = "personalalert";
$("#formcell").addClass("wrongform")
}
if($("#adultsinput").val() < 1){
$("#summaryalert").show();
$("#adultsinput").addClass("wrongform")
errore = "summaryalert";
}
if(bookedrooms < 1){
$("#roomalert").show();
errore = "roomalert";
}
//
if(errore)
{
goToByScroll(errore);
return false;
}
else
{
$("#nexiframe").show();
var serialize = $("#theform").serialize();
$.ajax({
url: "ajax_send_to_nexi.php",
method: "POST",
data: "s=",
success: function(data){
if(data){
alert(data);
}
var intervallo = setInterval(function(){
$.ajax({
url: "ajax_wait_for_nexi.php",
method: "POST",
data: "s=",
success: function(data){
if(data){
console.log(data)
}
if(data == ""){
clearInterval(intervallo);
$.ajax({
url: "ajax_process.php",
method: "POST",
data: serialize,
success: function(data){
if(data){
//return;
clearInterval(ccinterval);
$("#resresult").html(data);
var windowheight = $(window).height();
var containerheight = $("#container").height();
if(windowheight > containerheight)
{
$("#container").css({"height":windowheight+"px"});
}
setInterval(function () {;$("#nexiframe").hide();}, 5000)
}
}
});
}
}
})
}, 1000);
}
});
}
});
$("#togateway").click(function(){
var errore = "";
re = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm
if (!$("#privacycheck").is(':checked') || !$("#cancellationcheck").is(':checked')) {
$("#privacyalert").show();
errore = "privacyalert";
}
if($("#formnome").val().length < 2){
$("#personalalert").show();
errore = "personalalert";
$("#formnome").addClass("wrongform")
}
if($("#formcognome").val().length < 2){
$("#personalalert").show();
errore = "personalalert";
$("#formcognome").addClass("wrongform")
}
if($("#formindirizzo").val().length < 5){
$("#personalalert").show();
errore = "personalalert";
$("#formindirizzo").addClass("wrongform")
}
if($("#formcitta").val().length < 3){
$("#personalalert").show();
errore = "personalalert";
$("#formcitta").addClass("wrongform")
}
if($("#formemail").val().length < 3){
$("#personalalert").show();
errore = "personalalert";
$("#formemail").addClass("wrongform")
}
if(!re.test($("#formemail").val())){
$("#personalalert").show();
errore = "personalalert";
$("#formemail").addClass("wrongform")
}
if($("#formemail2").val()!=$("#formemail").val()){
$("#personalalert").show();
errore = "personalalert";
$("#formemail2").addClass("wrongform")
}
if($("#formcell").val().length < 3){
$("#personalalert").show();
errore = "personalalert";
$("#formcell").addClass("wrongform")
}
if($("#adultsinput").val() < 1){
$("#summaryalert").show();
$("#adultsinput").addClass("wrongform")
errore = "summaryalert";
}
if(bookedrooms < 1){
$("#roomalert").show();
errore = "roomalert";
}
//
if(errore)
{
goToByScroll(errore);
return false;
}
else
{
$("#togateway").hide();
$("#thecog").show();
var serialize = $("#theform").serialize();
$.ajax({
url: "ajax_send_to_gateway.php",
method: "POST",
data: "s=",
success: function(data){
if(data){
alert(data);
}
var intervallo = setInterval(function(){
$.ajax({
url: "ajax_wait_for_gateway.php",
method: "POST",
data: "s=",
success: function(data){
if(data){
console.log(data)
}
if(data == ""){
clearInterval(intervallo);
$.ajax({
url: "ajax_process.php",
method: "POST",
data: serialize,
success: function(data){
if(data){
//return;
clearInterval(ccinterval);
$("#resresult").html(data);
var windowheight = $(window).height();
var containerheight = $("#container").height();
if(windowheight > containerheight)
{
$("#container").css({"height":windowheight+"px"});
}
}
}
});
}
}
})
}, 1000);
}
});
}
});
$("#sendvoucher").click(function(){
//console.log("qui");
$('#theform *').filter(':input').each(function(){
var a = $(this).val();
a = a.replaceAll('&','%and%');
$(this).val(a);
});
var controllacarta = $("#paymentmethod").val() == "creditcard";
$(".alert-danger").hide();
var mesi = ["01","02","03","04","05","06","07","08","09","10","11","12"];
var anni = []
var d = new Date();
var n = d.getFullYear();
for(var i = 0; i < 20; i++){
anni.push((n + i).toString());
}
var errore = "";
re = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm
if (!$("#privacycheck").is(':checked') || !$("#cancellationcheck").is(':checked')) {
$("#privacyalert").show();
errore = "privacyalert";
}
if(controllacarta){
// MODIFICA DI MARCO
// gestici la data con 2 digits (quick mode)
// LAYER 1 test new controls
// Calculate max and min year
var cc_yearCheck = false;
var cc_yearMax = d.getFullYear().toString().substr(-2);;
cc_yearMax = parseInt( cc_yearMax , 10 ) + 20 ;
var cc_yearMin = d.getFullYear().toString().substr(-2);;
cc_yearMin = parseInt( cc_yearMin , 10 ) ;
// Check user input cc year 2 digits only
var ccyear = $("#cardexpy")[0].value
if( !ccyear || ccyear.length!=2 )
{
$("#creditcardalert").show();
$("#cardexpy").addClass("wrongform")
//return;
}
cc_year = parseInt( ccyear , 10 ) ;
// User cc year is in rage from current year to yearMax (check over 2 digits year)
// True -> the card year is valid, false otherwise
cc_yearCheck = cc_year>=cc_yearMin && cc_year<=cc_yearMax ;
// Check cc data
if(!cardname($("#formnumero").val())){
$("#creditcardalert").show();
errore = "creditcardalert";
$("#formnumero").addClass("wrongform");
}
if($("#ccname").val().length < 5){
$("#creditcardalert").show();
errore = "creditcardalert";
$("#ccname").addClass("wrongform");
}
if ($("#cvv").length && $("#cvv").val().length < 3){
$("#creditcardalert").show();
errore = "creditcardalert";
$("#cvv").addClass("wrongform");
}
if(mesi.indexOf($("#cardexpm").val())==-1){
$("#creditcardalert").show();
errore = "creditcardalert";
$("#cardexpm").addClass("wrongform");
}
if(!cc_yearCheck){
$("#creditcardalert").show();
errore = "creditcardalert";
$("#cardexpy").addClass("wrongform");
}
if(($("#cardexpm").val() < "09" && $("#cardexpy").val()<= "24")) // CHECK both month and year
{
$("#creditcardalert").show();
errore = "creditcardalert";
$("#cardexpm").addClass("wrongform");
}
// FINE MODIFICA DI MARCO
}
/*
|| ($("#cardexpm").val() < "09" && $("#cardexpy").val()<= "2024")
*/
if($("#formnome").val().length < 2){
$("#personalalert").show();
errore = "personalalert";
$("#formnome").addClass("wrongform")
}
if($("#formcognome").val().length < 2){
$("#personalalert").show();
errore = "personalalert";
$("#formcognome").addClass("wrongform")
}
if($("#formindirizzo").val().length < 5){
$("#personalalert").show();
errore = "personalalert";
$("#formindirizzo").addClass("wrongform")
}
if($("#formcitta").val().length < 3){
$("#personalalert").show();
errore = "personalalert";
$("#formcitta").addClass("wrongform")
}
if($("#formemail").val().length < 3){
$("#personalalert").show();
errore = "personalalert";
$("#formemail").addClass("wrongform")
}
if(!re.test($("#formemail").val())){
$("#personalalert").show();
errore = "personalalert";
$("#formemail").addClass("wrongform")
}
if($("#formemail2").val()!=$("#formemail").val()){
$("#personalalert").show();
errore = "personalalert";
$("#formemail2").addClass("wrongform")
}
if($("#formcell").val().length < 3){
$("#personalalert").show();
errore = "personalalert";
$("#formcell").addClass("wrongform")
}
if($("#adultsinput").val() < 1){
$("#summaryalert").show();
$("#adultsinput").addClass("wrongform")
errore = "summaryalert";
}
if(bookedrooms < 1){
$("#roomalert").show();
errore = "roomalert";
}
//
if(errore)
{
goToByScroll(errore);
}
else
{
$("#sendvoucher").hide();
$("#thecog").show();
var serialize = $("#theform").serialize();
$.ajax({
url: "ajax_process.php",
method: "POST",
data: serialize + "&shorturl=",
success: function(data){
if(data){
//return;
clearInterval(ccinterval);
$("#resresult").html(data);
var windowheight = $(window).height();
var containerheight = $("#container").height();
if(windowheight > containerheight)
{
$("#container").css({"height":windowheight+"px"});
}
}
}
});
}
});
$("#adultsinput").focus(function(){
$("#summaryalert").hide();
$(this).removeClass("wrongform")
});
$("#formnome, #formcognome, #formindirizzo, #formcitta, #formemail, #formemail2, #formcell").focus(function(){
$("#personalalert").hide();
$(this).removeClass("wrongform")
});
$("#privacycheck").focus(function(){
$("#privacyalert").hide();
});
$("#formnumero, #ccname, #cardexpm, #cardexpy, #cvv").focus(function(){
$("#creditcardalert").hide();
$(this).removeClass("wrongform")
});
$("#defaultpeople").click();
paypal.Button.render({
env: 'sandbox', // sandbox | production
locale: 'fr_FR',
style:{
size: 'small',
color: 'gold',
shape: 'pill',
label: 'checkout'
},
client: {
sandbox: 'ASL2Dg-xYQjZsI34akADGP8suxfqGAk1LIsgvY2G0Fin-cUMfAhDhKzIN4AdmMOa8c4J95tKCFfZyky5',
production: 'ASF3slS8QW8mK2gmwE6yD_Umgg5fneTPSDiZRglhbCts_ETJ4WQ8K8boDoOdyG93cjaSUtnan9LNNnMD'
},
commit: true,
payment: function(data, actions) {
// Make a call to the REST api to create the payment
return actions.payment.create({
transactions: [
{
amount: { total: $("#concordato").val(), currency: 'EUR' }
}
]
});
},
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function() {
window.alert('Payment Complete!');
});
}
}, '#paypal-button');
})
function cardname(n){
if(!n){
return false;
}
var cards = new Array();
cards[0]={
name: "Visa",
length: "13,16",
prefixes: "4",
checkdigit: true,
className: "visa"
};
cards[1]={
name: "MasterCard",
length: "16",
prefixes: "51,52,53,54,55,56,57,58",
checkdigit: true
};
cards[2]={
name: "DinersClub",
length: "14,16",
prefixes: "36,38,54,55",
checkdigit: true
};
cards[3]={
name: "AmEx",
length: "15",
prefixes: "34,37",
checkdigit: true
};
cards[4]={
name: "JCB",
length: "16",
prefixes: "35",
checkdigit: true
}
n = n.replace (/\s/g, "");
var checksum = 0;
var mychar = "";
var mult = 1;
for (i=n.length-1;i>=0;i--){
var calc = Number(n.charAt(i))*mult;
if(calc>9){
checksum++;
calc-=10;
}
checksum+=calc;
mult=3-mult;
}
if(checksum%10!=0){
return false;
}
for(i=0;i<=cards.length;i++){
var LengthValid = false;
var PrefixValid = false;
var prefix = new Array();
var lengths = new Array();
if(cards[i]==undefined){
return false;
}
prefix = cards[i].prefixes.split(",");
for (j=0; j