var componentVerifyCycle = 0; var bottom_of_window = jQuery(window).scrollTop() + jQuery(window).height(); var siteApp = { params: { homepage: { images: [ ], images_mobile: [ ] }, }, init: function () { if (siteApp.allComponentIsLoaded()) { siteApp.startApplication(); } else { componentVerifyCycle++; if (componentVerifyCycle < 200) { setTimeout(function () { siteApp.init(); }, 100); } else { console.warn('Init Application Error! waiting for: ' + siteApp.params.tmp); return false; } } }, allComponentIsLoaded: function () { var loaded = true; var msg = ''; if (typeof jQuery == 'undefined') { loaded = false; msg += '-jQuery'; } if (typeof hs == 'undefined') { loaded = false; msg += '-hs'; } if (typeof jQuery().slick == 'undefined') { loaded = false; msg += '-slick'; } if (typeof jQuery().imageLightbox == 'undefined') { loaded = false; msg += '-imagelightbox'; } if (typeof cms == 'undefined') { loaded = false; msg += 'cms'; } if (!loaded) { //console.info('waiting for: '+msg); siteApp.params.tmp = msg; return false; } else { return true; } }, startApplication: function () { console.info('startApplication...'); siteApp.fadeInHeader(jQuery('#contenuto_361885')); siteApp.openMenuMobile(); siteApp.openLanguage(); siteApp.scrollAnimation(); siteApp.accordionTab(); siteApp.openSubMenu(); startImageLightBox(); /* -------------- */ jQuery('.centrato').wrapInner( "
" ); // Initialize Background Stretcher for homepage if (cmsPageParams.type == 3) { //controllo di essere solo in homepage } //var days = ['SUN','MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']; //var mese = ['','JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC']; // console.log(data.Tdata.dayTextShort); cms.onEvent('DatePickerSelected', function(data){ console.log(data.Tdata.date.getDay()); console.log(data.Tdata); //alert(data.Tdata.monthNumber+' '+data.Tdata.monthText); var id =data.Tdata.element[0].id; switch (id) { case 'data_arrivo': console.log("arrivo "+data.Tdata); //console.log(data.Tdata.dayTextShort); var data_arrivo = jQuery('#booking #data_arrivo').val(); createCookie('data_arrivo', data_arrivo, 1); jQuery('.day_formatted').html(data.Tdata.day); jQuery('.ArriveMonth').html(data.Tdata.monthText.substring(0,3)+' '+data.Tdata.year); /* jQuery('.day_text_arr').html(days[data.Tdata.date.getDay()]); */ jQuery('.day_text_arr').html(data.Tdata.dayTextShort); break; case 'data_partenza': // console.log(data.Tdata); var data_partenza = jQuery('#booking #data_partenza').val(); createCookie('data_partenza', data_partenza, 1); jQuery('.departday_formatted').html(data.Tdata.day); jQuery('.DepartMonth').html(data.Tdata.monthText.substring(0,3)+' '+data.Tdata.year); // jQuery('.day_text_dep').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_dep').html(data.Tdata.dayTextShort); break; } }) cms.onEvent('DatePickerStarted', function(data){ var id =data.Tdata.element[0].id; //alert(data.Tdata.dayText); //console.log(data) //alert(data.Tdata.monthNumber+' '+data.Tdata.monthText); if((cmsPageParams.relation_code == 1515494617 )){ var data_arrivo = getUrlVars()["data_arrivo"]; console.log('data_arrivo= '+data_arrivo); if(typeof(data_arrivo) === 'undefined'){ switch (id) { case 'data_arrivo': console.log("data arrivo start"); console.log(data.Tdata.dayText); jQuery('.day_formatted').html(data.Tdata.day); jQuery('.ArriveMonth').html(data.Tdata.monthText.substring(0,3)+' '+data.Tdata.year); // jQuery('.day_text_arr').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_arr').html(data.Tdata.dayTextShort); break; case 'data_partenza': // console.log(data.Tdata); jQuery('.departday_formatted').html(data.Tdata.day); jQuery('.DepartMonth').html(data.Tdata.monthText.substring(0,3)+' '+data.Tdata.year); //jQuery('.day_text_dep').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_dep').html(data.Tdata.dayTextShort); break; } } else{ data_arrivo = data_arrivo.replace("%2F", "-"); data_arrivo = data_arrivo.replace("%2F", "-"); var gg = getUrlVars()["gg"]; var mm = getUrlVars()["mm"]; var aa = getUrlVars()["aa"]; var data_partenza = getUrlVars()["data_partenza"]; var data_partenza2 = data_partenza; var data_arrivo2 = data_arrivo; data_partenza = data_partenza.replace("%2F", "-"); data_partenza = data_partenza.replace("%2F", "-"); var ggf = getUrlVars()["ggf"]; var mmf = getUrlVars()["mmf"]; var aaf = getUrlVars()["aaf"]; console.log(data_arrivo); console.log(data_partenza); jQuery('.day_formatted').html(gg); jQuery('.ArriveMonth').html(data.Tdata.monthText.substring(0,3)+' '+aa); // jQuery('.ArriveMonth').html( mese[parseInt(mm)]+' '+aa); jQuery('.day_text_arr').html(); jQuery('#data_arrivo').val(data_arrivo); jQuery('#arrivo').val(data_arrivo); jQuery('.departday_formatted').html(ggf); // jQuery('.DepartMonth').html( mese[parseInt(mmf)]+' '+aaf); jQuery('.DepartMonth').html(data.Tdata.monthText.substring(0,3)+' '+aa); jQuery('.day_text_dep').html(); jQuery('#data_partenza').val(data_partenza); jQuery('#partenza').val(data_partenza); } } else{ switch (id) { case 'data_arrivo': console.log("data arrivo start"); console.log(data.Tdata.dayText); jQuery('.day_formatted').html(data.Tdata.day); jQuery('.ArriveMonth').html(data.Tdata.monthText.substring(0,3)+' '+data.Tdata.year); //jQuery('.day_text_arr').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_arr').html(data.Tdata.dayTextShort); break; case 'data_partenza': // console.log(data.Tdata); jQuery('.departday_formatted').html(data.Tdata.day); jQuery('.DepartMonth').html(data.Tdata.monthText.substring(0,3)+' '+data.Tdata.year); // jQuery('.day_text_dep').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_dep').html(data.Tdata.dayTextShort); break; } } }) cms.onEvent('DatePickerAutoSelectedDeparture', function(data){ var id =data.Tdata.element[0].id; // console.log(data.Tdata); jQuery('.departday_formatted').html(data.Tdata.day); jQuery('.DepartMonth').html(data.Tdata.monthText.substring(0,3)+' '+data.Tdata.year); // jQuery('.day_text_dep').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_dep').html(data.Tdata.dayTextShort); }) //aggiungo una freccia a qualunque voce abbia un sottomenu jQuery(".level1 > li:has('.level2')").addClass('submenu'); // apertura sottomenu mobile di prova // if (window.innerWidth < 992) { siteApp.openSecondLevel(); } //jQuery('#button_email_min').val(''); //jQuery('.bottone_alt').val(''); var pathname = window.location.href; var pathname = pathname.split('?id='); var parametro = pathname[1]; if (parametro) { //console.log('passo') goToByScroll('#' + parametro); } /*****************************************************/ /* slider home uno */ if (cmsPageParams.relation_code == '1515509432' || cmsPageParams.relation_code == '1515514315' || cmsPageParams.relation_code == '1515515579' || cmsPageParams.relation_code == '1515571665' || cmsPageParams.relation_code == '1515572293'){ jQuery('.voce_menu_29474').addClass('cmsCurrentPage'); } jQuery('.slider-offerte').slick({ dots: false, infinite: true, speed: 800, arrows: true, slidesToShow: 2, slidesToScroll: 1, autoplay: true, autoplaySpeed: 4000, responsive: [ { breakpoint: 992, settings: { slidesToShow: 1, } }, { breakpoint: 767, settings: { slidesToShow: 1, arrows: false, } } ] }); jQuery('.slider-commenti').slick({ dots: false, infinite: true, speed: 800, arrows: true, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 4000, fade: true, cssEase: 'linear', accessibility:false, slide:'.block-commenti', responsive: [ { breakpoint: 767, settings: { arrows: false, } } ] }); jQuery('.slider-alloggi').slick({ dots: false, infinite: false, speed: 800, arrows: false, slidesToShow: 1, slidesToScroll: 1, autoplay: false, autoplaySpeed: 4000, fade: true, cssEase: 'linear', accessibility:false, pauseOnHover:false, }); jQuery('.slider-homepage').slick({ dots: false, infinite: false, speed: 800, arrows: true, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 4000, fade: true, cssEase: 'linear', accessibility:false, pauseOnHover:false, }); /* gestione tab */ jQuery('.cont-tabs input').click(function () { jQuery('.tab-content').hide(); var element = jQuery(this).attr('id'); console.log(element); jQuery(this).parent('.cont-tabs').siblings(jQuery('.' + element + '').show()); // jQuery('.slider-img').resize(); }) /************************/ jQuery(window).on('scroll load', function(){ siteApp.viewCheck(); }) console.info('startApplication started!'); }, openMenuMobile: function(){ var $id_menu = '#menu_2567'; $menu = jQuery($id_menu); $btn = jQuery('.op_block'); jQuery($btn).click(function() { $btn.find('.click').toggleClass('open'); jQuery('.vedi-menu').toggleClass('slide-menu'); $btn.toggleClass('open'); }); /* jquery per chiudere la tendina del menu al click esterno alla tendina */ jQuery(document).bind("click touchstart", function (event) { if (jQuery(event.target).parents('.op_block').size() | (jQuery(event.target).hasClass('open')) | (jQuery(event.target).parents('ul#root_2567 li').size())) return; jQuery(".op_block").removeClass('open'); $btn.find('.click').removeClass('open'); if (jQuery('.vedi-menu').hasClass('slide-menu')) jQuery('.vedi-menu').removeClass('slide-menu'); }); }, openSecondLevel: function(){ jQuery('.submenu > a').click(function(e){ e.preventDefault(); /* disaable click 'a' event */ jQuery(this).parents('li').children('.level2').addClass('slide-menu') /* rendo visibile il level2 */ }) jQuery('.level2 li:first-child a').click(function(e){ e.preventDefault(); jQuery(this).parents('li').parents('.level2').removeClass('slide-menu') /* nascondo il level2 */ }) }, accordionTab: function (param) { jQuery('.slider-titolo').click(function () { if (!jQuery(this).hasClass('opened')) { jQuery('.slider-titolo.opened').removeClass('opened'); jQuery(this).addClass('opened'); jQuery('.slider-corpo.opened').slideUp('slow', function () { jQuery(this).removeClass('opened'); }) jQuery(this).next().slideDown('slow', function () { jQuery(this).addClass('opened'); }); } else { jQuery(this).removeClass('opened'); jQuery('.slider-corpo.opened').slideUp('slow', function () { jQuery(this).removeClass('opened'); }); } }); }, /**************** tendina lingue ********************/ openLanguage: function () { //APRO MENU LINGUE jQuery('.tendina-lingue').click(function () { var lingua = jQuery(this).next(); if (lingua.is(':hidden')) { lingua.slideDown(); } else { lingua.slideUp(); } }); jQuery("#select_lingue").click(function () { jQuery(this).slideUp(); }); /* jquery per chiudere la tendina delle lingue al click esterno alla tendina */ jQuery(document).click(function (event) { if (jQuery(event.target).parents('.tendina-lingue').size() | (jQuery(event.target).hasClass('tendina-lingue'))) { return; } if (!jQuery("#select_lingue").is(':hidden')) { jQuery("#select_lingue").fadeOut(250); } }); }, showMe: function (elem) { anim = jQuery(elem).attr('data-anim'); jQuery(elem).addClass('animated ' + anim); jQuery(elem).animate({ opacity: 1 }, 700, function () {}) }, scrollAnimation: function(){ jQuery(window).on('scroll load', function(){ setTimeout(function() { if(window.innerWidth > 991){ jQuery('.hideme.visible').each( function(i){ siteApp.showMe(this); }); } }, 100); }); }, fadeInHeader: function (element) { if (window.innerWidth > 991) { jQuery(window).scroll(function () { var scrollpos = (document.documentElement.scrollTop || document.body.scrollTop); if (scrollpos > 300) { element.show().addClass('view-menu'); } else { element.hide().removeClass('view-menu'); } }); } }, viewCheck:function(){ if (window.innerWidth > 991) { //console.log('ok') jQuery('.moveUp,.moveRight,.moveDown, .moveLeft,.hideme').viewportChecker({ classToAdd: 'visible', // Class to add to the elements when they are visible, classToAddForFullView: 'full-visible', // Class to add when an item is completely visible in the viewport repeat: false // Add the possibility to remove the class if the elements are not visible }); } }, // Effetto Superfish // openSubMenu: function () { jQuery('#root_2567 ul.level2').css('margin-top', '4px'); // setta la posizione verticale dei sottomenu rispetto alle voci principali jQuery('#root_2567 ul.level2').css('margin-left', '0px'); // setta la posizione orizzontale dei sottomenu rispetto alle voci principali jQuery('#root_2567, #root_2567').superfish({ delay: 800, // the delay in milliseconds that the mouse can remain outside a submenu without it closing speed: 'normal' // fast, normal }); }, // fine effetto // /* ***************gestione tab a fisarmonica*********** */ adatta: function (elem) { var win_h = window.innerHeight; jQuery(elem).css('height', win_h); } } window.addEventListener("load", function () { siteApp.init(); }); jQuery(window).on('load resize', function () { if (window.innerWidth > 767) { jQuery('.adattHeight').each(function () { $height = jQuery(this).prev().height(); console.log($height) if ($height) { jQuery(this).height($height); } else if (!$height) { $height = jQuery(this).next().height(); jQuery(this).height($height); } }); } }) /*gestione di funzioni es. onclick="gotobyscroll('.classe')"*/ function add_slide_menu(item) { jQuery('li' + item + ' .level2').toggleClass('slide-menu'); //console.log(item) } function back_menu(item) { jQuery('li' + item + ' .level2').toggleClass('slide-menu'); //console.log('vado') } function getUrlVars() { //console.log('getUrlVars'); var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } function goToByScroll(param) { jQuery('html, body').animate({ scrollTop: jQuery(param).offset().top - 80 }, 2000, "easeInOutQuad"); } function frmcheck(frm) { jQuery('#booking_gg').val(jQuery('#data_arrivo').val().substring(0, 2)); jQuery('#booking_mm').val(jQuery('#data_arrivo').val().substring(3, 5)); jQuery('#booking_aa').val(jQuery('#data_arrivo').val().substring(6, 10)); jQuery('#booking_ggf').val(jQuery('#data_partenza').val().substring(0, 2)); jQuery('#booking_mmf').val(jQuery('#data_partenza').val().substring(3, 5)); jQuery('#booking_aaf').val(jQuery('#data_partenza').val().substring(6, 10)); } /* funzioni dei cookie */ function createCookie(name, value, days) { console.log('createCookie'); if (days) { var date = new Date(); // Now get the current Time (in milliseconds) and add the required number of days (in milliseconds). Set the Time of the date to this new value, so that it now contains the date in milliseconds that the cookie should expire. date.setTime(date.getTime()+(days*24*60*60*1000)); // Set the variable expires to this date in the UTC/GMT format required by cookies. var expires = "; expires=" + date.toGMTString(); } else { // If 0 is passed to the function, expires is not set and the cookie expires when the user closes his browser.. var expires = ""; } // Finally write the new cookie into document.cookie in the correct syntax. document.cookie = name + "=" + value + expires + "; path=/"; } function readCookie(name) { console.log('readCookie'); var nameEQ = name + "="; // Then split document.cookie on semicolons. ca becomes an array containing all cookies that are set for this domain and path. var ca = document.cookie.split(';'); // Then we go through the array (so through all cookies): for(var i=0;i < ca.length;i++) { // Set c to the cookie to be checked. var c = ca[i]; // If the first character is a space, remove it by using the substring() method. Continue doing this until the first character is not a space. while (c.charAt(0)==' ') c = c.substring(1, c.length); // Now string c begins with the name of the current cookie. If this is the name of the desired cookie // we've found what we were looking for. We now only need to return the value of the cookie, which is the part of c that comes after nameEQ. By returning this value we also end the function: mission accomplished. if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } // If, after having gone through all cookies, we haven't found the name we're looking for, the cookie is not present. We return null. return null; } function eraseCookie(name) { createCookie(name,'',-1); }