var dispStructures = new Array(); var totalMk = new Array(); var mapPoiGeo = ''; activeSimulate = false; var loadFirstTime = true; var myImg = new Array(); var myImgSel = 0; var isMobile = { Android: function() { return navigator.userAgent.match(/Android/i); }, BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); }, iOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); }, Opera: function() { return navigator.userAgent.match(/Opera Mini/i); }, Windows: function() { return navigator.userAgent.match(/IEMobile/i); }, any: function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); } }; /** * SEARCH PAGE FUNCTIONS WRAP */ var absSearch = { init:function(){ // Setto il cookie per il sistema di "cronologia di ricerca" // $.cookie('ABS_MINISITE_BACK_URL',jbase64.encode(window.location.href)); // console.log($.cookie()); // $.ajax({ // type: 'GET', // url: trad['APP_WEB_ROOT']+'v2/assets/cookieManager.php', // cache: false, // crossDomain: true, // xhrFields: { // thCredentials: true // }, // data: { // url : jbase64.encode(window.location.href), // action: 'save-minisite-back-url' // }, // success:function(res){ // // $elForm.submit(); // } // }); // Salvo in sessione l'url della pagina di ricerca per il pulsante di "back" del minisite // if( // typeof window.location.href != 'undefined' && // typeof Storage != 'undefined' && // window.location.href!='' // ) // { // sessionStorage.setItem("minisite_backurl", window.location.href); // } // Pulsante toggle mappa mobile $('#mobile-aside-btn-map').click(function(){ $('.boxMapAside').toggleClass('hidden-xs'); setTimeout(function(){ loadGeneralMap(); },150); }); // Pulsante toggle filtri mobile $('#mobile-aside-btn-filters').click(function(){ $('.boxOptionAside').toggleClass('hidden-xs'); }); // Inizializzazione slider prezzi if($("#prc").length>0){ if(typeof searchMaxPrice != 'undefined' && typeof searchMinPrice != 'undefined'){ searchMinPrice = parseInt(searchMinPrice)-1; searchMaxPrice = parseInt(searchMaxPrice)+1; $("#prc").val(searchMinPrice+';'+searchMaxPrice); $("#prc-slider-legend .minLab").html(searchMinPrice); $("#prc-slider-legend .maxLab").html(searchMaxPrice); $( "#prc-slider" ).slider({ range: true, step: 0.5, animate: "fast", min: searchMinPrice, max: searchMaxPrice, values: [ searchMinPrice, searchMaxPrice ], slide: function( event, ui ) { $("#prc").val(ui.values[0]+';'+ui.values[1]); $("#prc-slider-legend .minLab").html(ui.values[0]); $("#prc-slider-legend .maxLab").html(ui.values[1]); }, stop: function(){ formSubmit(); } }); } } // Pulsante ricerca per nome $('#aside-search-by-name').click(function(){ formSubmit(); }); // Invio sul campo ricerca per nome $('#aside-search-by-name-input').keydown(function(event){ if (event.keyCode == 13) { formSubmit(); } }); // $( '.liComf > small img' ).each( function( nch ) { // var that = $( this ); // if ( ! that.hasClass( 'lods' ) ) { // that.addClass( 'lods' ); // myId = that.parent( 'label' ).attr( 'for' ); // var urlImg = that.attr( 'src' ).replace( "_A.png", ".png" ); // var urlActiveImg = urlImg.replace( ".png", "_A.png" ); // if ( ! $( '#' + myId ).is( ':checked' ) ) { // this.src = urlImg; // } // else { // this.src = urlActiveImg; // } // $( '#' + myId ).change({ thisImg: this }, function( e ) { // if ( ! $( this ).is( ':checked' ) ) { // $( "img", $( this ).parent() ).attr( "src", urlImg ); // } // else { // $( "img", $( this ).parent() ).attr( "src", urlActiveImg ); // } // }); // } // }); $( '.boxPOI > ul > li > article > ul' ).each( function() { if ( $( this ).parents( 'li' ).hasClass( 'sel' ) ) { $( 'li > ul', this ).slideUp( 0 ); $( 'li li > a.sel', this ).parent( 'li' ).parent( 'ul' ).slideDown( 0 ); $( 'li li > a.sel', this ).children( "span" ).removeClass( "poi_marker" ).addClass( "poi_marker_selected" ); $( 'li li > a.sel', this ).parent( 'li' ).parent( 'ul' ).parent( 'li' ).addClass( 'opened' ); $( 'li li > a.sel', this ).parent( 'li' ).parent( 'ul' ).parent( 'li' ).siblings().children( 'ul' ).slideUp( 0 ); if ( typeof( window['bform'] ) != "undefined" && typeof( bform['mode'] ) != "undefined" && bform['mode'] != "undefined" && bform["mode"] == "search" ) { $( 'li li > a', this ).each( function() { $( this ).attr( "href", $( this ).attr( "href" ) + "?bform[mode]=search" ); }); } } else { $( 'li > ul', this ).slideUp( 0 ); if ( $( 'li li > a.sel', this ).length == 0 ) { $( this ).slideUp( 0 ); } else { $( 'li > ul', this ).slideDown( 0 ); $( 'li li > a.sel', this ).parent( 'li' ).siblings( 'li' ).slideUp( 0 ); $( 'li li > a.sel', this ).parent( 'li' ).parent( 'ul' ).parent( 'li' ).addClass( 'opened' ); $( 'li li > a.sel', this ).parent( 'li' ).parent( 'ul' ).parent( 'li' ).siblings().children( 'ul' ).slideUp( 0 ); } } }); $( '.boxPOI > ul > li > article h3 a' ).each( function() { if ( typeof( window['bform'] ) != "undefined" ) { if ( typeof( bform['mode'] ) != "undefined" && bform['mode'] != "undefined" && bform["mode"] == "search" ) { $( this ).attr( "href", $( this ).attr( "href" ) + "?bform[mode]=search" ); } } if ( $( this ).parents( 'article' ).children( 'ul' ).is( ':visible' ) ) { $( 'ul > li > a', $( this ).parents( 'article' ) ).bind( 'click', function() { if( $( this ).siblings( 'ul' ).is( ':visible' ) ) { $( this ).siblings( 'ul' ).slideUp( 300 ); $( this ).parent().removeClass( 'opened' ); } else { $( this ).siblings( 'ul' ).slideDown( 300 ); $( this ).parent().addClass( 'opened' ); } }); } }); $( '#addOptions, #addOptions2' ).attr( 'action', 'javascript:;' ); $( '.boxOptionAside form input[type="checkbox"]' ).bind( 'change', function() { // Gestione change checkbox con icona con selezione eventuale altro check ripetuto sotto (Es. Comfort Ag. Serena) var $label = $(this).parents('label'); var thisName = $(this).attr('name'); if($label.hasClass('icon-label')){ $label.toggleClass('active'); $('[name="'+ thisName +'"]').prop('checked',$label.hasClass('active')); } startBlockUI( msg1, msg2 ); formSubmit(); }); $( '#addOptions input.inputS' ).bind( 'click', function() { startBlockUI( msg1, msg2 ); formSubmit(); }); setSearch( true ); // Informazioni struttura con popOver setInfoHide(); if ( $( '.boxMapAside' ).length == 1 ) { $( '.boxMapAside .wrapper-map-small-search > a' ).click( function() { activeShadBox.init({urlP:'/assets/'+ iso2ForAll +'/mapBig.html'}); }); } else if ( $( '#mapBigZoneS' ).length == 1 ) { loadGeneralMap( "", zone_id ); $( '.oMa' ).fadeOut( 0 ); $( '.cMa, .oMa' ).bind( 'click', function() { $( this ).fadeOut( 150, function() { $( this ).siblings( 'a' ).fadeIn( 150 ); }); if ( $( this ).hasClass( 'oMa' ) ) { $( '.mapBigZone > div' ).slideDown( 300 ); } else { $( '.mapBigZone > div' ).slideUp( 300 ); } }); } setTimeout(closeAllFilters, 250); }, load:function(){}, resize:function(){ loadGeneralMap(); }, /** * SCROLL PAGINA */ goToPos: function(ref,offset){ // Offset Default (sostituire con altezza se presenti barre in posizione fixed top) defaultOffset = 0; if(typeof siteGlobal.defaultScrollOffset != 'undefined') defaultOffset = siteGlobal.defaultScrollOffset; if($(ref).length==0) ref = 'body'; if(typeof offset == 'undefined') var offset = defaultOffset; myPos = $(ref).offset().top-offset; $('html, body').animate({ scrollTop: myPos}, { duration: 600, easing: 'easeInOutExpo'} ); }, /** * SIMULATE BOOKING * Sostituisce la chiamata precedente fatta con load di una gif in hotel_tpl * @return {[type]} [description] */ doSimulateBooking: function(){ if(typeof hotelCalls !=='undefined'){ var simStructures = hotelCalls; var count = 0; var myInterval = setInterval( function(){ if(typeof simStructures[count]=='undefined'){ clearInterval(myInterval); hotelCalls = []; return; } includeSB(simStructures[count],trad['iso2']); count+=1; }, 250); } } } /** * MINISITE PAGE FUNCTIONS WRAP */ var absMinisite = { init:function(){ // Setto il pulsante di back se presente la variabile in sessionStorage // if(typeof sessionStorage != 'undefined' && typeof sessionStorage.minisite_backurl != 'undefined'){ // $('#minisite-back-button').prop('href',sessionStorage.minisite_backurl).removeClass('hidden'); // } // $.ajax({ // type: 'GET', // url: trad['APP_WEB_ROOT']+'v2/assets/cookieManager.php', // cache: false, // crossDomain: true, // xhrFields: { // withCredentials: true // }, // data: { // action: 'get-minisite-back-url' // }, // success:function(res){ // // $elForm.submit(); // } // }); // console.log($.cookie()); // // Setto il pulsante di back se presente la variabile in sessione // if(typeof $.cookie('ABS_MINISITE_BACK_URL') !== 'undefined'){ // $('#minisite-back-button').prop('href',sessionStorage.minisite_backurl).removeClass('hidden'); // } // Informazioni struttura con popOver setInfoHide('#minisite-address'); this.createIframeUrlAddPostMessage(); this.createTabsUrl(); if(typeof window.minisiteAsideScroll === 'undefined'){ this.scrollAsideForm(); } setTimeout(function(){absMinisite.modyfyBaseSearch();}, 100); }, initLoad:function(){ this.mainGalleryInit(); this.mapInit(); // Registro la grandezza della finestra iniziale this.windowInitialWidth = $(window).width(); // Toggle label recensioni $('#minisite-box-review-details').on('hidden.bs.collapse', function () { $('.closeRwTxt','#minisite-box-review').text(trad['rew_box_open']); }); $('#minisite-box-review-details').on('shown.bs.collapse', function () { $('.closeRwTxt','#minisite-box-review').text(trad['rew_box_close']); }); // Toggle label mostra/nascondi info struttura $('#minisite-structure-info-wrap').on('hidden.bs.collapse', function () { $('#minisite-structure-info-btn').html(' ' + trad['minisite_info_open']); absSearch.goToPos('#minisiteWrap'); }); $('#minisite-structure-info-wrap').on('shown.bs.collapse', function () { $('#minisite-structure-info-btn').html(' ' + trad['minisite_info_close']); absSearch.goToPos('#minisiteWrap'); setTimeout(function(){ absMinisite.mapInit(); absMinisite.mainGalleryInit(); },150); }); // // Chiamata tracciamento iframe booking // BookingOne.addIframe('bookingframe'); this.activateCalendar(); // Scrolla la pagina all'iframe Booking if ( typeof( window[ 'bform' ] ) != "undefined" ) { if(location.href.search('/booking.html') != -1 ){ setTimeout(function(){ absSearch.goToPos('#bookingframe'); },2000); } } }, initResizeStop:function(){ this.updateIframeUrlAddPostMessage(); }, /** * Gestione scroll form aside minisite allo scroll della pagina */ scrollAsideForm:function(){ asidePos = $('#minisite-aside').offset(); asideMarg = parseInt($('#minisite-aside').css('marginTop')); $(window).scroll(function(){ iFramePos = $('#bookingframe').offset(); if($(this).scrollTop() <= iFramePos.top){ val = $(this).scrollTop(); addSc = 0; if (val > asidePos.top) addSc = val+asideMarg; $('#minisite-aside').css({'top':addSc}); } }); }, /** * Main gallery minisite */ mainGalleryInit: function(){ if($('#minisite-gallery').length > 0){ if($('#minisite-gallery .flexslider').is(':visible')){ $('#minisite-gallery .flexslider').flexslider({animation: "slide"}); } } }, /** * Mappa struttura minisite */ mapInit: function(){ if($('#minisite-map').length>0){ if( $('#minisite-map').data('lat') != undefined && $('#minisite-map').data('lon') != undefined && $('#minisite-map').data('lat') != '' && $('#minisite-map').data('lon') != '' ){ absSimpleMap.set( 'minisite-map', { lat: $('#minisite-map').data('lat'), lon: $('#minisite-map').data('lon'), icon: '/images/staticv2/minisiteMapMarker.png' }, 15, 'ROADMAP', false ); } } }, /** * Toggle reviews minisite per tipologia */ showReviews: function(rtype){ var $revBoxes = $('.revBoxBig','#minisite-box-review'); var revBoxesLg = $revBoxes.length; // Mostra tutti if(rtype==0) { $revBoxes.show(); return; } // Filtra i=0; for (i; i<=revBoxesLg-1; i++) { var $el = $($revBoxes[i]); var revType = $el.data('rev-type'); $el.toggle(revType==rtype); } }, /** * Set url tabs (dettagli struttura,prezzi,ecc.) */ createTabsUrl:function(){ $('#minisite-tabs a').each(function(){ myUrl = $(this).attr('href') + location.search; $(this).attr('href', myUrl); }); }, /** * Creazione iframe minisite con gestione PostMessagge resize e tracciamento */ createIframeUrlAddPostMessage:function(){ if(typeof absMinisiteIframeSrcWithParams == 'undefined' && typeof absMinisiteIframeSrc == 'undefined') return; // var if_height; var src = absMinisiteIframeSrcWithParams; if ($(window).width() < 980){ newSrc = src.substring(0, (src.length)-4); src += newSrc+'_mobile.css'; //if(!(/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))) src += '&booking_type=FM'; // else { // } } var iframe = $( '