// Avoid `console` errors in browsers that lack a console. (function() { var method; var noop = function noop() {}; var methods = [ 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn' ]; var length = methods.length; var console = (window.console = window.console || {}); while (length--) { method = methods[length]; // Only stub undefined methods. if (!console[method]) { console[method] = noop; } } }()); function updateCheckOutDate(checkinInput, checkoutInput, nightsInput, numberNights ){ if(!checkinInput){ checkinInput = 'CheckInDate'; } if(!checkoutInput){ checkoutInput = 'CheckOutDate'; } if(!numberNights){ numberNights = 1; } if(!nightsInput){ nightsInput = 'Nights'; numberNights = parseInt($('.'+nightsInput).val()); } else{ if(parseInt($('.'+nightsInput).val()) < numberNights) $('.'+nightsInput).val(numberNights); } utcCheckInDateTab = $('.'+checkinInput).val().split("/"); utcCheckOutDateTab = $('.'+checkoutInput).val().split("/"); utcCheckInDate = utcCheckInDateTab[1] + "/" + utcCheckInDateTab[0] + "/" + utcCheckInDateTab[2]; utcCheckOutDate = utcCheckOutDateTab[1] + "/" + utcCheckOutDateTab[0] + "/" + utcCheckOutDateTab[2]; utcDateDiff = dateDiff("d", utcCheckInDate, utcCheckOutDate, 2); if (utcDateDiff > 0 && nightsInput) { utcNewCheckOutDate = dateAdd("d", parseInt($('.'+nightsInput).val()), utcCheckInDate); if (parseInt(utcNewCheckOutDate.getDate()) < 10 ) utcNewCheckOutDay = "0" + parseInt(utcNewCheckOutDate.getDate()); else utcNewCheckOutDay = parseInt(utcNewCheckOutDate.getDate()); if (parseInt(utcNewCheckOutDate.getMonth() + 1) < 10 ) utcNewCheckOutMonth = "0" + parseInt(utcNewCheckOutDate.getMonth() + 1); else utcNewCheckOutMonth = parseInt(utcNewCheckOutDate.getMonth() + 1); $('#'+checkoutInput).val( utcNewCheckOutDay + "/" + utcNewCheckOutMonth + "/" + utcNewCheckOutDate.getFullYear()); $('#'+checkoutInput).datepicker( "option", "minDate", dateAdd("d", 1, utcCheckInDate) ); } else { utcNewCheckOutDate = dateAdd("d", numberNights, utcCheckInDate); if (parseInt(utcNewCheckOutDate.getDate()) < 10 ) utcNewCheckOutDay = "0" + parseInt(utcNewCheckOutDate.getDate()); else utcNewCheckOutDay = parseInt(utcNewCheckOutDate.getDate()); if (parseInt(utcNewCheckOutDate.getMonth() + 1) < 10 ) utcNewCheckOutMonth = "0" + parseInt(utcNewCheckOutDate.getMonth() + 1); else utcNewCheckOutMonth = parseInt(utcNewCheckOutDate.getMonth() + 1); $('.'+checkoutInput).val( utcNewCheckOutDay + "/" + utcNewCheckOutMonth + "/" + utcNewCheckOutDate.getFullYear()); $('.'+checkoutInput).datepicker( "option", "minDate", dateAdd("d", 1, utcCheckInDate) ); if(nightsInput){ $('.'+nightsInput).val(numberNights); } } } function updateNights(checkinInput, checkoutInput, nightsInput ){ if(!checkinInput){ checkinInput = 'CheckInDate'; } if(!checkoutInput){ checkoutInput = 'CheckOutDate'; } if(!nightsInput){ nightsInput = 'Nights'; } utcCheckInDateTab = $('.'+checkinInput).val().split("/"); utcCheckOutDateTab = $('.'+checkoutInput).val().split("/"); utcCheckInDate = utcCheckInDateTab[1] + "/" + utcCheckInDateTab[0] + "/" + utcCheckInDateTab[2]; utcCheckOutDate = utcCheckOutDateTab[1] + "/" + utcCheckOutDateTab[0] + "/" + utcCheckOutDateTab[2]; utcDateDiff = dateDiff("d", utcCheckInDate, utcCheckOutDate, 2); if (utcDateDiff > 0) { $('.'+nightsInput).val(utcDateDiff); } else { $('.'+nightsInput).val('1'); utcNewCheckOutDate = dateAdd("d", 1, utcCheckInDate); if (parseInt(utcNewCheckOutDate.getDate()) < 10 ) utcNewCheckOutDay = "0" + parseInt(utcNewCheckOutDate.getDate()); else utcNewCheckOutDay = parseInt(utcNewCheckOutDate.getDate()); if (parseInt(utcNewCheckOutDate.getMonth() + 1) < 10 ) utcNewCheckOutMonth = "0" + parseInt(utcNewCheckOutDate.getMonth() + 1); else utcNewCheckOutMonth = parseInt(utcNewCheckOutDate.getMonth() + 1); $('.'+checkoutInput).val(utcNewCheckOutDay + "/" + utcNewCheckOutMonth + "/" + utcNewCheckOutDate.getFullYear()); } } function jPost(cData, divResult){ $.ajax({ type: 'POST', url: '/includes/process', data: cData, async: false }).done(function( msg ) { if (divResult != '') $(divResult).html(msg); }); } $(function() { // DATEPICKER $('.datepicker').each(function(){ $(this).datepicker( { minDate: 27/04/2024, numberOfMonths: 1}, $.datepicker.regional[LC]); }); /* $('#CheckInDate').change(function(){ updateCheckOutDate() }); $('#CheckOutDate').change(function(){ updateNights() }); $('#Nights').change(function(){ updateCheckOutDate() }); $('#Adults').change(function(){ if($(this).val() == 0){ $('#sltRooms').show(); $('#sltAdults').hide(); } }); $('#RoomNumber').change(function(){ $('.sltPeople').hide(); for(i=1;i<=this.value;i++) $('#sltPeople'+i).show(); }); $('#ApartNumber').change(function(){ $('.sltPeopleApart').hide(); for(i=1;i<=this.value;i++) $('#sltPeople'+i+'Apart').show(); }); */ // CYCLE $('.descSlider').cycle({ fx: 'fade', speed: 'fast', width: 'auto', timeout: 0, pager: '#navSlider', pagerAnchorBuilder: function(idx, slide) { // return sel string for existing anchor return '#navSlider li:eq(' + (idx) + ') a'; } }); // POSHYTIP $('.poshytip').poshytip({ className: 'tip-twitter', showTimeout: 1, alignTo: 'target', alignX: 'center', offsetY: 5, allowTipHover: false }); $('.help').poshytip({ className: 'tip-twitter', alignTo: 'target', alignX: 'right', alignY: 'center', offsetX: 5, allowTipHover: false }); // FANCYBOX $('.desc, .descapart').fancybox({ helpers : { overlay : { css : { 'background' : 'rgba(255,255,255, 0.5)' } } }, preload : true, autoSize : true, //width: '400', openEffect : 'elastic', closeEffect : 'elastic', afterLoad: function() { $('.fancybox-wrap').css('position','absolute !important'); $('.fancybox-wrap').css('top','50% !important'); $('.fancybox-wrap').css('bottom','auto'); } }); $('.fancybox').fancybox({ helpers : { overlay : { css : { 'background' : 'rgba(255,255,255, 0.5)' } } }, openEffect : 'elastic', closeEffect : 'elastic' }); // SORT RATES /* $('.orderRates > li').sort(function(a, b){ return parseFloat($(a).attr('class')) > parseFloat($(b).attr('class')) ? 1 : -1; }); */ $('.orderRates').each(function(){ $(this).find('li:visible').sortElements(function(a, b){ return parseFloat($(a).attr('class')) > parseFloat($(b).attr('class')) ? 1 : -1; }); }); // RATES $('.rate').click(function(){ var jTotalRate = 0; if( $('#IdOffer'+$(this).attr('roomnum')).val() != $(this).attr('idoffer') ){ $('.extras').hide().find('.extra').each( function(){ if($(this).attr('type') != 'checkbox') $(this).val('0'); $(this).attr('checked', false); }); } $('#Extras'+ $(this).attr('roomnum') + $(this).attr('idoffer') +', #Extras'+ $(this).attr('roomnum') + $(this).attr('idroom') + $(this).attr('idoffer')).show(); $('input[name="IdRoom'+$(this).attr('roomnum')+'"]').val($(this).attr('idroom')); $('input[name="IdBoard'+$(this).attr('roomnum')+'"]').val($(this).attr('idboard')); $('input[name="IdOffer'+$(this).attr('roomnum')+'"]').val($(this).attr('idoffer')); var strPeople = '('; strPeople += $(this).attr('adults'); if($(this).attr('teenagers')) strPeople += ' / ' + $(this).attr('teenagers'); if($(this).attr('children')) strPeople += ' / ' + $(this).attr('children'); if($(this).attr('babies')) strPeople += ' / ' + $(this).attr('babies'); strPeople += ')'; $('#SummaryRoom'+$(this).attr('roomnum')).html($(this).attr('room') +' '+ strPeople); $('#SummaryBoard'+$(this).attr('roomnum')).html($(this).attr('board')); $('#SummaryOffer'+$(this).attr('roomnum')).html($(this).attr('offer')); $('#SummaryExtra'+$(this).attr('roomnum')).html(''); $('#SummaryRate'+$(this).attr('roomnum')).html(parseFloat($(this).val().replace(',','.')).formatPrice() + ' €'); $('.extra').each( function(){ if($(this).is(':checkbox')) { if($(this).is(':checked')) { jTotalRate += parseFloat($(this).attr('extrarate').replace(',','.')); $('#SummaryExtra'+$(this).attr('roomnum')).append($(this).attr('extraname')+'
'); } } else { jTotalRate += parseFloat($(this).attr('extrarate').replace(',','.')) * parseFloat($(this).val().replace(',','.')); if(parseFloat('0' + $(this).val()) > 0) $('#SummaryExtra'+$(this).attr('roomnum')).append('
' + $(this).attr('extraname')+' (x '+ parseFloat('0' + $(this).val().replace(',','.')) +')
'+ (parseFloat($(this).attr('extrarate').replace(',','.')) * parseFloat($(this).val().replace(',','.'))).formatPrice() + ' €
'); } }); $('.rate:checked').each( function(){ jTotalRate += parseFloat($(this).val().replace(',','.')); }); $('#TotalRate').html(jTotalRate.formatPrice() + ' €'); var strDiaryRates = $(this).attr('diaryrates'); var tabDiaryRates = strDiaryRates.split('#'); $('#SummaryDetails'+$(this).attr('roomnum')).html('
'); for( i = 0; i < tabDiaryRates.length-1; i++){ var tabDatesAndRates = tabDiaryRates[i].split('-'); $('#SummaryDetails'+$(this).attr('roomnum')).append(''); } $('#SummaryDetails').append('
'); }); $('.extra').change(function(){ var jTotalRate = 0; $('#SummaryExtra'+$(this).attr('roomnum')).html(''); $('.extra').each( function(){ if($(this).is(':checkbox')) { if($(this).is(':checked')) { jTotalRate += parseFloat($(this).attr('extrarate').replace(',','.')); $('#SummaryExtra'+$(this).attr('roomnum')).append($(this).attr('extraname')+'
'); } } else { jTotalRate += parseFloat($(this).attr('extrarate').replace(',','.')) * parseFloat('0' + $(this).val().replace(',','.')); if(parseFloat('0' + $(this).val()) > 0) $('#SummaryExtra'+$(this).attr('roomnum')).append('
' + $(this).attr('extraname')+' (x '+ parseFloat('0' + $(this).val().replace(',','.')) +')
'+ (parseFloat($(this).attr('extrarate').replace(',','.')) * parseFloat($(this).val().replace(',','.'))).formatPrice() + ' €
'); } }); $('.rate:checked').each( function(){ jTotalRate += parseFloat($(this).val().replace(',','.')); }); $('#TotalRate').html(jTotalRate.formatPrice() + ' €'); }); // PICTS NO EXISTE $('img').each(function(){ //if($(this).length < 10) $(this).parent('a').parent('div.pic, div.descSlider').remove(); }); // VALIDATION function BuenMail (string) { var at="@"; var dot="."; var lat=string.indexOf(at); var lstr=string.length; var ldot=string.indexOf(dot); if (string.indexOf(at)==-1){ return false; } if (string.indexOf(at)==-1 || string.indexOf(at)==0 || string.indexOf(at)==lstr){ return false; } if (string.indexOf(dot)==-1 || string.indexOf(dot)==0 || string.indexOf(dot)==lstr){ return false; } if (string.indexOf(at,(lat+1))!=-1){ return false; } if (string.substring(lat-1,lat)==dot || string.substring(lat+1,lat+2)==dot){ return false; } if (string.indexOf(dot,(lat+2))==-1){ return false; } if (string.indexOf(" ")!=-1){ return false; } return true; } $('#ConfirmBookingBtn, #ConfirmBookingBtn2').click(function(){ var button = $(this); button.attr('disabled', true).text('Cargando...'); if($('#BookingPolitic').is(':checked')){ var strAlert = ''; $('#ConfirmBooking input:visible').each(function(){ if($(this).attr('required') == 'required' && $(this).val() == '' && $(this).val().length < 3){ if(strAlert == ''){ $(this).focus(); $('html, body').animate({ scrollTop: $(this).offset().top }, 2000); } $(this).addClass('warning').blur(function(){ if($(this).val() != '' && $(this).val().length >= 3) $(this).removeClass('warning'); }); strAlert += $(this).attr('help') + '\n'; } else if($(this).attr('required') == 'required' && $(this).attr('type') == 'email' && !BuenMail ($(this).val())){ if(strAlert == ''){ $(this).focus(); $('html, body').animate({ scrollTop: $(this).offset().top }, 2000); } $(this).addClass('warning').blur(function(){ if($(this).val() != '' && $(this).val().length >= 3) $(this).removeClass('warning'); }); strAlert += $(this).attr('help') + '\n'; } }); if(strAlert == '') $('#ConfirmBooking').submit(); else alert(strAlert); } else { $('html, body').animate({ scrollTop: $("#HaveToAccept").offset().top }, 2000); $('#HaveToAccept').show(); for(i=0;i<3;i++) { $('#HaveToAccept').fadeTo('slow', 0.5).fadeTo('slow', 1.0); } alert($('#BookingPolitic').attr('help')); } button.attr('disabled', false).text('CONFIRMAR'); }); $('#loginBtn').click(function(){ var strAlert = ''; $('#loginFrm input:visible').each(function(){ if($(this).attr('required') == 'required' && $(this).val() == '' && $(this).length < 3){ if(strAlert == '') $(this).focus(); strAlert += $(this).attr('help') + '\n'; $(this).addClass('warning').click(function(){ $(this).removeClass('warning'); }); } }); if(strAlert == '') $('#loginFrm').submit(); else alert(strAlert); }); function codificarFuncion(funcio, param){ return encodeURI(funcio.toString().replace('param', param)); } function SendFramePost(funcio, param){ window.parent.postMessage(codificarFuncion(funcio, param),'*'); } function SetiFrame(){ document.getElementById("iRolineSystem").style.height = param+"px"; } function SetHeight(){ var iframeHeight; var bodyheight = $('#bookingEngine').height(); if(bodyheight <= 600) iframeHeight = 600; else iframeHeight = bodyheight+60; return iframeHeight; } setTimeout(function(){ SendFramePost(SetiFrame, SetHeight() + 250); }, 1000); $('#bookingEngine').scroll(function (){ SendFramePost(SetiFrame, SetHeight()); }); $('#ShoppingCart').click( function() { SendFramePost(SetiFrame, SetHeight() + 250); }); });