var checkin = '';
var checkout = '';
var checkinProg = 0;
var bookingStep = 1;
var loader = '
';
var maxStay = 21;
var firstBook = true;
var calendarPos = 0;
var nexiStarted = false;
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function cardName(n) {
$('#cardname').val('');
if (!n) {
return false;
}
var cards = new Array();
cards.push({
name : "Visa",
length : "13,16",
prefixes : "4",
checkdigit : true,
className : "visa"
});
cards.push({
name : "MasterCard",
length : "16",
prefixes : "51,52,53,54,55,56,57,58",
checkdigit : true
});
cards.push({
name : "AmEx",
length : "15",
prefixes : "34,37",
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 < prefix.length; j ++) {
var exp = new RegExp ("^" + prefix[j]);
if (exp.test(n)) {
PrefixValid = true;
}
}
if (PrefixValid) {
lengths = cards[i].length.split(",");
for (j = 0; j < lengths.length; j ++) {
if (n.length == lengths[j]) {
LengthValid = true;
}
}
if (LengthValid) {
$('#cardname').val(cards[i].name);
return cards[i].name;
}
}
}
return false;
}
function sendReservation(formData) {
$.ajax({
url : 'ajax/ajax_send_reservation.php',
type : 'post',
data : 'hotel=marin&' + formData,
success : function(data) {
$('#main').html(data);
window.setTimeout(function() {
var ga4tot = $('#ga4tot').val();
var ga4id = $('#ga4id').val();
var items = parseInt($('#gadata').data('items'));
var ids = $('#gadata').data('ids').split(';');
var nms = $('#gadata').data('nms').split(';');
var prz = $('#gadata').data('prz').split(';');
var google_items = [];
for (x = 0; x < items; x ++) {
google_items.push({
item_id : ids[x],
item_name : nms[x],
price : prz[x],
quantity : 1
})
}
//console.log(items, ids, nms, prz, google_items);
// MODIFICA DI MARCO
// Inserire totale e id prenotazione
if (typeof be_ga4_event == "function") {
be_ga4_event("purchase", {
"transaction_id" : ga4id,
"value" : ga4tot,
"currency" : "EUR",
"items" : google_items
});
}
// FINE MODIFICA DI MARCO
}, 250);
}
})
}
function drawStay(from, to) {
$('.day').removeClass('stay');
if (Math.abs(from - to) <= maxStay) {
if (from > to + 1) {
for (i = to + 1; i < from; i ++) {
$('#day_' + i).addClass('stay');
}
}
if (from < to - 1) {
for (i = to - 1; i > from; i --) {
$('#day_' + i).addClass('stay');
}
}
return true
}
return false;
}
function checkForm() {
var corretto = true;
var scrollX = 0;
if ($('#invoicecheck').is(':checked')) {
if ($('#f_intestazione').val().length < 3) {
$('#formintestazioneerrorf').show();
corretto = false;
scrollX = $('#f_intestazione').offset().top;
}
if ($('#f_indirizzo').val().length < 5) {
$('#formaddresserrorf').show();
corretto = false;
scrollX = $('#f_indirizzo').offset().top;
}
if ($('#f_citta').val().length < 3) {
$('#formcittaerrorf').show();
corretto = false;
scrollX = $('#f_citta').offset().top;
}
if ($('#f_piva').val().length < 5) {
$('#formpivaerrorf').show();
corretto = false;
scrollX = $('#f_piva').offset().top;
}
if ($('#f_codicefiscale').val().length < 5) {
$('#formcodicefiscaleerrorf').show();
corretto = false;
scrollX = $('#f_codicefiscale').offset().top;
}
if ($('#f_pec').val().length < 5) {
$('#formpecerrorf').show();
corretto = false;
scrollX = $('#f_pec').offset().top;
}
}
if ($('#formname').val().length < 3) {
$('#formnameerror').show();
corretto = false;
scrollX = $('#formname').offset().top;
}
if ($('#formname').val().length < 3) {
$('#formsurnameerror').show();
corretto = false;
scrollX = $('#formsurnameerror').offset().top;
}
re = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm
if ($('#formemail').val() == '' || !re.test($('#formverify').val())) {
$('#formemailerror').show();
corretto = false;
scrollX = $('#formemailerror').offset().top;
}
if ($('#formmobile').val().length < 3) {
$('#formmobileerror').show();
scrollX = $('#formmobileerror').offset().top;
corretto = false;
}
if (!$('#cancellationcheck').is(':checked')) {
$('#formcancellationerror').show();
corretto = false;
}
if (!$('#gdprcheck').is(':checked')) {
$('#formgdprerror').show();
corretto = false;
}
if (!corretto) {
var content = $('#triqui').serialize() + '&hotel=marin'
$([document.documentElement, document.body]).animate({
scrollTop : scrollX - 500
}, 1);
$.ajax({
url : 'ajax/ajax_notify_error.php',
type : 'post',
data : content,
success : function(data) {
if (data) {
alert(data);
}
}
});
}
return corretto;
}
function checkCreditCard() {
var corretto = true;
if ($('#cardholder').val().length < 5) {
$('#formcardnameerror').show();
corretto = false;
}
var cleanCard = $('#cardnumber').val().replace(/\D/g,'')
if (!cardName(cleanCard)) {
$('#formcardnumbererror').show();
corretto = false;
}
var pezzi = $('#formexpiry').val().split('/');
if (pezzi.length != 2 || pezzi[0] < 1 || pezzi[0] > 12 || pezzi[1] < 23) {
$('#formcardexpiryerror').show();
corretto = false;
}
return corretto;
}
function drawCheckinCheckout(checkin, checkout) {
if (checkin && checkout && checkin > checkout) {
var temp = checkin;
checkin = checkout;
checkout = temp;
}
$('.inoutbadge').removeClass('checkinbadge').removeClass('checkoutbadge').hide();
if (checkin == checkout) {
return;
}
if (checkin) {
//$('#badge_' + checkin).show().html('').addClass('checkinbadge');
}
if (checkout) {
//$('#badge_' + checkout).show().html('').addClass('checkoutbadge');
}
if (checkin && checkout && Math.abs(checkout - checkin) > maxStay) {
$('#badge_' + checkin).hide();
$('#badge_' + checkout).hide();
}
}
function showTooltips(element) {
if (element == undefined) {
element = '[data-bs-toggle="tooltip"]';
}
var tooltipTriggerList = [].slice.call(document.querySelectorAll(element))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})
}
function drawCart(data) {
var parts = data.split('%split%');
$('.cartcontent').html(parts[0]);
$('.carttotal').html(parts[1]); ;
}
function shortenPolicy(element) {
var height = $(element).height();
while ($(element).height() > 60) {
var lastIndex = $(element).html().lastIndexOf(' ');
$(element).html($(element).html().substring(0, lastIndex))
}
if (height > $(element).height()) {
for (x = 1; x <= 4; x ++) {
var lastIndex = $(element).html().lastIndexOf(' ');
$(element).html($(element).html().substring(0, lastIndex))
}
$(element).html($(element).html() + '... Ver más')
}
}
function sortResults() {
$('.roomcontainer').each(function() {
var element = $(this).find('.offerrates');
var divList = $(element).children('.offer');
divList.sort(function(a, b){
return $(a).data('offerprice')-$(b).data('offerprice')
});
$(element).html(divList);
$(element).children(':first').addClass('bestoffer').removeClass('offer');
$(element).children(':first').find('.bestbadge').show();
})
}
function setupCart() {
$.ajax({
url : 'ajax/ajax_draw_cart.php',
type : 'post',
data : 'hotel=marin&lan=4',
success : function(data) {
drawCart(data);
$('.removecart').each(function(){
var master = $(this).data('master');
$('.master' + master).each(function() {
$(this).data('pool', $(this).data('pool') - 1);
if ($(this).data('pool') == 0) {
$(this).removeClass('btn-primary').addClass('btn-secondary');
$('.soldout' + master).show();
}
if ($(this).data('pool') == 1) {
$('.lastroom' + master).show();
}
else {
$('.lastroom' + master).hide();
}
})
})
}
})
}
$(document).ready(function() {
showTooltips('.mytooltips');
sortResults();
setupCart();
var reservationModal = new bootstrap.Modal(document.getElementById('resmodal'), {});
var roomModal = new bootstrap.Modal(document.getElementById('roommodal'), {});
/*var cartLength = 0;
var stessoCarrello = window.setInterval(function() {
$.ajax({
url : 'ajax/ajax_control_cart.php',
type : 'post',
data : 'hotel=marin',
success : function(data) {
if (cartLength != data.length) {
cartLength = data.length
setupCart();
}
}
});
}, 2000); */
$(document).on('click', '#notifybutton', function() {
var data = $('#notif').serialize();
$.ajax({
url : 'ajax/ajax_notify.php',
type : 'post',
data : data,
success : function(data) {
if (data) {
$('#notifyid').html(data);
}
}
})
})
$(document).on('click', '#booknowbutton', function() {
var method = $(this).data('payment');
$.ajax({
url : 'ajax/ajax_last_check.php',
type : 'post',
data : 'hotel=marin',
success : function(data) {
if (data) {
$('#siteoverlay').show();
$('#siteoverlay').html(data);
}
else {
$('.formerror').hide();
var formChecked = checkForm();
var cardChecked = (method == 1 || method == 2) ? true : checkCreditCard();
if (formChecked && cardChecked) {
if (method == 0) {
var content = $('#triqui').serialize();
$('#main').html(loader);
sendReservation(content);
}
if (method == 1) {
var content = $('#triqui').serialize();
$('#siteoverlay').show();
$('#siteoverlay').html(loader);
$.ajax({
url : 'ajax/ajax_generate_axerve_link.php',
type : 'post',
data : 'hotel=marin&' + content,
success : function(data) {
var pezzi = data.split('|');
$('#siteoverlay').html(pezzi[0]);
window.open(pezzi[1]);
var controllo = window.setInterval(function() {
$.ajax({
url : 'ajax/ajax_check_axerve_payment.php',
type : 'post',
data : 'hotel=marin&token=' + pezzi[2],
success : function(data) {
if (data == pezzi[2]) {
$('#siteoverlay').hide();
clearInterval(controllo);
var content = $('#triqui').serialize();
content += '&axerve=' + pezzi[2];
$('#main').html(loader);
sendReservation(content);
}
}
})
}, 2000)
}
});
}
if (method == 2) {
if (!nexiStarted) {
nexiStarted = true;
var content = $('#triqui').serialize();
$.ajax({
url : 'ajax/ajax_generate_nexi_content.php',
type : 'post',
data : 'hotel=marin&' + content,
success : function(data) {
$('#newnexi').append(data)
$('#newnexi').submit();
}
});
}
}
}
else {
// ci penso
}
}
}
})
})
$(document).on('click', '.paxrange', function() {
var pax = $(this).data('pax')
var room = $(this).data('room');
$('.paxrange' + room).hide();
$('.r' + room + 'p' + pax).show();
$('.squarepaxcheck' + room).hide();
$('.squarepaxcheck' + room + '_' + pax).show();
$('.squarepax' + room).show();
$('.squarepax' + room + '_' + pax).hide();
})
$(document).on('click', '.reservationinfo', function() {
reservationModal.show();
$.ajax({
url : 'ajax/ajax_draw_cart_big.php',
type : 'post',
data : 'hotel=marin&lan=4',
success : function(data) {
var pezzi = data.split('%edopo%');
$('#modalbody').html(pezzi[0]);
$('#reservationtotal').html(pezzi[1]);
}
})
});
$(document).on('click', '.suggest', function() {
var newcheckin = $(this).data('checkin');
var newcheckout = $(this).data('checkout');
checkin = newcheckin;
checkout = newcheckout;
$('.day').removeClass('checkin').removeClass('checkout');
$('.day[data-day="' + newcheckin + '"]').addClass('checkin');
$('.day[data-day="' + newcheckout + '"]').addClass('checkout');
drawStay($('.day[data-day="' + newcheckin + '"]').data('prog'), $('.day[data-day="' + newcheckout + '"]').data('prog'));
var pageToShow = $('.checkin').data('page');
if (pageToShow != undefined) {
calendarPos = pageToShow
$('#calcontent').css('left', - 378 * calendarPos);
}
$('#overlay').show();
$('#calcontainer').show();
})
$(document).on('click', '.bookexpand', function() {
var room = $(this).data('room');
$(this).parentsUntil('.roomcontainer').find('.offerrates').toggle();
$(".cancellationp").each(function() {
shortenPolicy(this)
});
});
$(document).on('keyup keydown', '#cardnumber', function() {
var clean = $(this).val().replace(/\D/g,'');
if (clean.length > 0) {
clean = clean.match(new RegExp('.{1,4}', 'g')).join(' ');
}
$(this).val(clean);
});
$(document).on('keyup', '#formexpiry', function() {
var clean = $(this).val().replace(/\D/g,'');
if (clean.length > 0) {
clean = clean.match(new RegExp('.{1,2}', 'g')).join('/');
}
$(this).val(clean);
});
$(document).on('click', '.prevpic', function() {
var room = $(this).data('room');
var current = $(this).data('current');
var max = $(this).data('max');
current --;
if (current < 0) {
current = max;
}
$(this).data('current', current);
$('#nextpic_' + room).data('current', current);
$('.photoroom' + room).hide();
$('.photoroom' + room + '_' + current).fadeTo(200, 1);
});
$(document).on('click', '#invoicecheck', function() {
if ($(this).is(':checked')) {
$('#invoicediv').show();
}
else {
$('#invoicediv').hide();
}
})
$(document).on('click', '.nextpic', function() {
var room = $(this).data('room');
var current = $(this).data('current');
var max = $(this).data('max');
current ++;
if (current > max) {
current = 0;
}
$(this).data('current', current)
$('#prevpic_' + room).data('current', current);
$('.photoroom' + room).hide();
$('.photoroom' + room + '_' + current).fadeTo(200, 1);
});
$('#calendario').click(function() {
var pageToShow = $('.checkin').data('page');
if (pageToShow != undefined) {
calendarPos = pageToShow
$('#calcontent').css('left', - 378 * calendarPos);
}
$('#overlay').show();
$('#calcontainer').show();
});
$(document).on('click', '#newsearch', function() {
var pageToShow = $('.checkin').data('page');
if (pageToShow != undefined) {
calendarPos = pageToShow
$('#calcontent').css('left', - 378 * calendarPos);
}
$('#overlay').show();
$('#calcontainer').show();
});
$('.day').hover(function() {
if (checkin != '' && checkout == '') {
$('.day').removeClass('checkout');
$('.day').removeClass('simplehover');
$('.day').removeClass('stay');
$(this).addClass('checkout');
var prog = $(this).data('prog');
drawStay(prog, checkinProg);
drawCheckinCheckout(checkinProg, prog);
// $('#badge_' + prog).show().html('Check in').addClass('checkinbadge');
}
else {
$('.day').removeClass('simplehover');
$(this).addClass('simplehover');
}
}, function() {
$('.day').removeClass('simplehover');
});
$('.day').click(function() {
var giorno = $(this).data('day');
if (checkin == '') {
$(this).addClass('checkin');
checkin = giorno;
checkinProg = $(this).data('prog');
drawCheckinCheckout(checkinProg, null)
}
else {
if (checkout == '') {
if (giorno > checkin) {
$(this).addClass('checkout');
checkout = giorno
if (!drawStay($('.checkin').data('prog'), $('.checkout').data('prog'))) {
$('.checkin').removeClass('checkin');
checkin = giorno
checkinProg = $(this).data('prog');
checkout = '';
$(this).removeClass('checkout').addClass('checkin');
drawCheckinCheckout(checkinProg, null);
}
}
else {
if (giorno < checkin) {
checkout = checkin;
checkin = giorno;
$('.checkin').addClass('checkout').removeClass('checkin');
$(this).removeClass('checkout').addClass('checkin');
if (!drawStay($('.checkin').data('prog'), $('.checkout').data('prog'))) {
$('.checkin').removeClass('checkin');
$('.checkout').removeClass('checkout');
checkin = giorno
checkinProg = $(this).data('prog');
checkout = '';
$(this).removeClass('checkout').addClass('checkin');
drawCheckinCheckout(checkinProg, null);
}
}
else {
checkin = '';
checkout = '';
$('.day').removeClass('checkin').removeClass('checkout')
drawCheckinCheckout(null, null);
}
}
}
else {
checkout = '';
checkin = '';
$('.day').removeClass('checkin').removeClass('checkout').removeClass('stay');
drawCheckinCheckout(null, null);
$(this).click();
return;
if (giorno < checkin) {
checkout = '';
checkin = '';
$('.day').removeClass('checkout');
$('.day').removeClass('checkin');
$('.day').removeClass('stay');
drawCheckinCheckout(null, null);
}
else {
if (giorno > checkin) {
checkout = giorno;
$('.day').removeClass('checkout').removeClass('stay');
$(this).addClass('checkout');
if (!drawStay($('.checkin').data('prog'), $('.checkout').data('prog'))) {
$('.checkin').removeClass('checkin');
checkin = giorno
checkinProg = $(this).data('prog');
checkout = '';
$(this).removeClass('checkout').addClass('checkin');
drawCheckinCheckout(null, null);
}
else {
drawCheckinCheckout($('.checkin').data('prog'), $('.checkout').data('prog'));
}
}
}
}
}
})
$('#search').click(function() {
var prevXML = '';
$.ajax({
url : 'ajax/ajax_get_cart.php',
type : 'post',
data : 'hotel=marin',
success : function(data) {
prevXML = data;
}
})
bookingStep = 1;
$('#needmorerooms').hide();
$('#needmoreextras').hide();
if (checkin != '' && checkout != '') {
$('#overlay').hide();
$('#calcontainer').hide();
$('#main').html(loader);
var dataString = 'checkin=' + checkin + "&checkout=" + checkout + "&nights=" + (parseInt($('.checkout').data('prog')) - parseInt($('.checkin').data('prog'))) + '&promo=' + $('#hiddenpromo').val() + '&lan=4' + '&hotel=marin';
$.ajax({
url : 'ajax/ajax_write_checkin.php',
type : 'post',
data : dataString ,
success : function(data) {
$('#calendario').html(data);
$.ajax({
url : 'ajax/ajax_show_results.php',
type : 'post',
data : dataString,
success : function(data) {
$.ajax({
url : 'ajax/ajax_get_cart.php',
type : 'post',
data : 'hotel=marin',
success : function(data) {
if (prevXML != data) {
setupCart();
}
}
})
$('#main').html(data);
sortResults();
showTooltips('.mytooltips');
$('.removecart').each(function() {
return
var master = $(this).data('master');
$('.master' + master).each(function() {
$(this).data('pool', $(this).data('pool') - 1);
if ($(this).data('pool') == 0) {
$(this).hide();
$('.soldout' + master).show();
}
if ($(this).data('pool') == 1) {
$('.lastroom' + master).show();
}
else {
$('.lastroom' + master).hide();
}
})
})
}
});
}
})
}
$('#proceedbutton').show();
});
$(document).on('click', '#needmorerooms', function() {
$('#search').click();
})
$(document).on('click', '#needmoreextras', function() {
$('#main').html(loader);
$.ajax({
url : 'ajax/ajax_show_extra.php',
data : '&lan=4&hotel=marin',
type : 'post',
success : function(data) {
if (data.length < 200) {
$('#proceedbutton').click();
}
else {
$('#main').html(data);
}
}
});
bookingStep = 2;
$('#needmoreextras').hide();
$('#needmorerooms').show();
$('#proceedbutton').show();
})
$(document).on('click', '.multibook', function() {
$('.dropdown-menu').removeClass('show');
var rooms = $(this).data('rooms');
var room = $(this).data('room');
$(this).parentsUntil('.book').find('.bookbutton').removeClass('hasdropdown');
for (var i = 1; i <= rooms; i ++) {
$(this).parentsUntil('.book').find('.bookbutton').click();
}
$(this).parentsUntil('.book').find('.bookbutton').addClass('hasdropdown');
$('.dropdown-menu').removeClass('show');
})
$(document).on('click', '.bookbutton', function() {
var room = $(this).data('room');
var checkin = $(this).data('checkin');
var checkout = $(this).data('checkout');
var nights = $(this).data('nights');
var pax = $(this).data('pax')
var pool = $(this).data('pool');
if ($(this).hasClass('hasdropdown')) {
$('.multi' + room).addClass('disabled');
for (var i = 1; i <= pool; i ++) {
$('#p' + pax + 'r' + room + 'n' + i).removeClass('disabled');
}
return;
}
if (pool <= 0) {
return;
}
if (firstBook) {
firstBook = false;
}
$('.cartcontent').html('');
var master = $(this).data('master');
for (i = 1; i <= 12; i ++) {
if ($(this).hasClass('lock' + i)) {
$('.master' + master).each(function() {
$(this).data('pool', $(this).data('pool') + 1);
})
$('.lock' + i).each(function() {
$(this).data('pool', $(this).data('pool') - 1);
if ($(this).data('pool') == 0) {
$(this).removeClass('btn-primary').addClass('btn-secondary');
$('.soldout' + $(this).data('master')).show();
}
if ($(this).data('pool') == 1) {
$('.lastroom' + $(this).data('master')).show();
}
else {
$('.lastroom' + $(this).data('master')).hide();
}
})
}
}
$('.master' + master).each(function() {
$(this).data('pool', $(this).data('pool') - 1);
if ($(this).data('pool') == 0) {
$(this).removeClass('btn-primary').addClass('btn-secondary');
$('.soldout' + master).show();
}
if ($(this).data('pool') == 1) {
$('.lastroom' + master).show();
}
else {
$('.lastroom' + master).hide();
}
})
$.ajax({
url : 'ajax/ajax_add_to_cart.php',
type : 'post',
data : 'hotel=marin&checkin=' + checkin + '&checkout=' + checkout + '&nights=' + nights + '&room=' + room + '&pax=' + pax + '&lan=4' + '&promo=' + $('#hiddenpromo').val(),
success : function(data) {
drawCart(data);
}
})
})
$(document).on('click', '.removecart', function() {
var prog = $(this).data('prog');
var master = $(this).data('master');
$('.master' + master).each(function() {
$(this).data('pool', $(this).data('pool') + 1);
if ($(this).data('pool') > 0) {
if (!$(this).hasClass('paxrange')) {
$(this).removeClass('btn-secondary').addClass('btn-primary');
}
else {
$('.squarepaxcheck' + master + ':visible').click();
}
$('.soldout' + master).hide();
}
if ($(this).data('pool') == 1) {
$('.lastroom' + master).show();
}
else {
$('.lastroom' + master).hide();
}
})
//
for (i = 1; i <= 12; i ++) {
if ($('#bookbutton_' + master).hasClass('lock' + i)) {
$('.master' + master).each(function() {
$(this).data('pool', $(this).data('pool') - 1);
})
//$('#bookbutton_' + master).data('pool', $('#bookbutton_' + master).data('pool') - 1);
$('.lock' + i).each(function() {
$(this).data('pool', $(this).data('pool') + 1);
if ($(this).data('pool') > 0) {
$(this).removeClass('btn-secondary').addClass('btn-primary');
$('.soldout' + $(this).data('master')).hide();
}
if ($(this).data('pool') == 1) {
$('.lastroom' + $(this).data('master')).show();
}
else {
$('.lastroom' + $(this).data('master')).hide();
}
})
}
}
$('.bookbutton').each(function() {
var pool = $(this).data('pool');
if (pool > 0) {
$(this).removeClass('btn-secondary').addClass('btn-primary');
}
})
//
$('.cartcontent').html('');
$.ajax({
url : 'ajax/ajax_remove_from_cart.php',
type : 'post',
data : 'hotel=marin&prog=' + prog + '&lan=4',
success : function(data) {
drawCart(data);
}
})
if (bookingStep != 1) {
$('#search').click();
}
})
$(document).on('click', '.removecartextra', function() {
var prog = $(this).data('prog');
var extra = $(this).data('extra');
var extraid = $(this).data('extraid');
$('#extra_' + prog + '_' + extraid).data('pool', $('#extra_' + prog + '_' + extraid).data('pool') + 1);
if ($('#extra_' + prog + '_' + extraid).data('pool') > 0) {
$('#extra_' + prog + '_' + extraid).removeClass('grey').addClass('blue');
}
$('.cartcontent').html('');
$.ajax({
url : 'ajax/ajax_remove_from_cart_extra.php',
type : 'post',
data : 'hotel=marin&prog=' + prog + '&extra=' + extra + '&lan=4',
success : function(data) {
drawCart(data);
}
});
if (bookingStep > 2) {
$('#main').html(loader);
$.ajax({
url : 'ajax/ajax_show_extra.php',
type : 'post',
data : 'lan=4&hotel=marin',
success : function(data) {
$('#main').html(data);
}
});
bookingStep = 2;
$('#proceedbutton').show();
$('#needmoreextras').hide();
$('#needmorerooms').show();
}
});
$(document).on('click', '#proceedbutton', function() {
$('#main').html(loader);
switch (bookingStep) {
case 1 :
$.ajax({
url : 'ajax/ajax_show_extra.php',
type : 'post',
data : 'lan=4&hotel=marin',
success : function(data) {
//console.log(data);
if (data.length < 200) {
$('#proceedbutton').click();
}
else {
$('#main').html(data);
}
}
});
bookingStep = 2;
$('#needmorerooms').show();
break;
case 2 :
case 3 :
$.ajax({
url : 'ajax/ajax_show_form.php',
type : 'post',
data : 'lan=4&hotel=marin' + '&promo=' + $('#hiddenpromo').val() + '&googlelink=' + $('#googlelink').val(),
success : function(data) {
$('#main').html(data);
$('#proceedbutton').hide();
}
});
bookingStep = 3;
$('#needmorerooms').show();
$('#needmoreextras').show();
break;
}
})
$(document).on('change', '.bedselect', function() {
var prog = $(this).data('prog');
var value = $(this).val();
$.ajax({
url : 'ajax/ajax_change_bed.php',
type : 'post',
data : 'hotel=marin&prog=' + prog + '&val=' + value,
success : function(data) {
if (data) {
alert(data);
}
}
});
});
$(document).on('change', '.adultselect', function() {
var prog = $(this).data('prog');
var value = $(this).val();
$.ajax({
url : 'ajax/ajax_change_adult.php',
type : 'post',
data : 'hotel=marin&prog=' + prog + '&val=' + value,
success : function(data) {
if (data) {
alert(data);
}
}
});
});
$(document).on('change', '.childselect', function() {
var prog = $(this).data('prog');
var value = $(this).val();
$.ajax({
url : 'ajax/ajax_change_children.php',
type : 'post',
data : 'hotel=marin&prog=' + prog + '&val=' + value,
success : function(data) {
if (data) {
alert(data);
}
}
});
});
$('#closecal').click(function() {
$('#overlay').hide();
$('#calcontainer').hide();
})
$(document).on('click', '.addex', function() {
if ($(this).data('pool') > 0) {
$(this).data('pool', $(this).data('pool') - 1);
if ($(this).data('pool') < 1) {
$(this).removeClass('blue').addClass('grey')
}
var room = $(this).data('room');
var extra = $(this).data('extra');
$('.cartcontent').html('');
$.ajax({
url : 'ajax/ajax_add_extra_to_cart.php',
type : 'post',
data : 'hotel=marin&room=' + room + '&extra=' + extra + '&lan=4',
success : function(data) {
drawCart(data);
}
})
}
});
$(document).on('click', '.expand', function(){
$(this).parent().parent().find('.fullcancellationp').show()
$(this).parent().parent().find('.cancellationp').hide()
});
$(document).on('click', '.contract', function(){
$(this).parent().parent().find('.fullcancellationp').hide()
$(this).parent().parent().find('.cancellationp').show()
});
$('.more').click(function(){
$(this).hide();
var room = $(this).data('room');
$('#room_' + room).find('.wouldbebest').addClass('bestoffer').removeClass('wouldbebest');
$('#room_' + room).find('.offer').show()
})
$('.calmove').click(function(){
var direction = $(this).data('dir');
calendarPos += parseInt(direction);
calendarPos = Math.min(34, calendarPos);
calendarPos = Math.max(0, calendarPos);
$('#calcontent').animate({
left : - 378 * calendarPos
}, 100 );
})
})