var componentVerifyCycle = 0; var bottom_of_window = jQuery(window).scrollTop() + jQuery(window).height(); var lang_page = cmsPageParams.lang; var bLazy; 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) { siteApp.params.tmp = msg; return false; } else { return true; } }, startApplication: function () { siteApp.loadGoogleFont("https://fonts.googleapis.com/css?family=Palanquin:400,600,700&display=swap"); siteApp.openMenuMobile(); siteApp.openLanguage(); if(window.innerWidth > 991){ siteApp.fadeInHeader(jQuery('.barra-desktop')); } siteApp.accordionTxtHome(); siteApp.scrollAnimation(); //siteApp.accordionTab(); //siteApp.openSubMenu(); jQuery(".comments_clear").remove(); jQuery('.testo.table-box').wrapInner("
"); jQuery(".level1 > li:has('.level2')").addClass('submenu'); jQuery("li.submenu > a").removeAttr("href"); siteApp.openSecondLevel(); siteApp.accordionMesi(); switch (lang_page) { case "it": break; default: } switch (cmsPageParams.relation_code) { case "1582042607": /* animazione */ var galleries = ['.foto-1 a.image_lightbox', '.foto-2 a.image_lightbox', '.foto-3 a.image_lightbox', '.foto-4 a.image_lightbox', '.foto-5 a.image_lightbox', '.foto-6 a.image_lightbox', '.foto-7 a.image_lightbox', '.foto-8 a.image_lightbox', '.foto-9 a.image_lightbox','.foto-10 a.image_lightbox','.foto-11 a.image_lightbox','.foto-12 a.image_lightbox','.foto-13 a.image_lightbox','.foto-14 a.image_lightbox']; var instance = []; jQuery.each(galleries, function (i) { var selector = galleries[i]; instance[i] = jQuery(selector).imageLightbox({ onStart: function () { overlayOn(); arrowsOn(instance[i], selector); closeButtonOn(instance[i]); }, onEnd: function () { overlayOff(); closeButtonOff(); arrowsOff(); activityIndicatorOff(); }, onLoadStart: function () { activityIndicatorOn(); }, onLoadEnd: function () { jQuery('.imagelightbox-arrow').css('display', 'block'); activityIndicatorOff(); } }); }); break; default: startImageLightBox(); } switch (cmsPageParams.relation_code) { case "1582109166": jQuery('.slider-home').slick({ arrows:false, dots: true, speed: 600, slidesToShow: 1, autoplay: true, autoplaySpeed: 6000, accessibility:false, infinite:true, slide:'img', fade: true, cssEase: 'linear', pauseOnHover:false }); jQuery('.slider-home').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); jQuery('.slider-hotel-home').slick({ arrows:false, dots: true, speed: 600, slidesToShow: 1, autoplay: true, autoplaySpeed: 6000, accessibility:false, infinite:true, slide:'img', fade: true, cssEase: 'linear', pauseOnHover:false, responsive: [{ breakpoint: 768, settings: { dots:false } }] }); jQuery('.slider-hotel-home').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); jQuery('.slider-home-icons').slick({ arrows:false, dots: false, infinite: false, speed: 800, slidesToShow: 4, autoplay: true, autoplaySpeed: 3500, slide:'.cont-item', responsive: [{ breakpoint: 992, settings: { slidesToShow: 3 } }, { breakpoint: 768, settings: { slidesToShow: 2 } }, { breakpoint: 580, settings: { slidesToShow: 1 } }] }); jQuery('.arrows-icons .next').click(function () { jQuery('.slider-home-icons').slick('slickNext'); }); jQuery('.arrows-icons .prev').click(function () { jQuery('.slider-home-icons').slick('slickPrev'); }); if (window.innerWidth<768) { jQuery('.slider-com').slick({ arrows:false, dots: true, infinite: false, speed: 800, slidesToShow: 1, autoplay: true, autoplaySpeed: 3500, slide:'.item-slide-com' }); } break; case "1584952026": jQuery( ".period_body" ).click(); break; } //jQuery('.bottone_email_min').attr('value', dictionaryTranslate('[DIZIONARIO:voglio_guida]', cmsPageParams.lang)); if (cmsPageParams.relation_code == 1583414831) { var news_opt = readCookie("newsletter_optin"); console.log('news_opt = ' + news_opt); if (news_opt == 1) { console.log('news_opt checkata'); } else { console.log('news_opt NON checkata'); jQuery('.blocco-txt-guida, .txt-grazie-top, #contenuto_509133, .blocco-due-guida, #blk_82323').css('display', 'none'); jQuery('.testo-grazie').html(dictionaryTranslate('[DIZIONARIO:grazie_no_guida]', cmsPageParams.lang)); } } /* slider offerte */ jQuery('.offerte-scorrevoli > div').slick({ arrows: false, dots: true, speed: 600, slidesToShow: 3, autoplay: true, autoplaySpeed: 6000, accessibility: false, infinite: true, responsive: [ { breakpoint: 992, settings: { slidesToShow: 2 } }, { breakpoint: 768, settings: { slidesToShow: 1 } } ] }); jQuery('.offerte-scorrevoli > div').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }) jQuery('.arrows-offerte .next').click(function () { jQuery('.offerte-scorrevoli > div').slick('slickNext'); }) jQuery('.arrows-offerte .prev').click(function () { jQuery('.offerte-scorrevoli > div').slick('slickPrev'); }) if (window.innerWidth > 991) { if (jQuery('.offerte-scorrevoli > div .slick-slide').length <= 2) { jQuery('.arrows-offerte').hide(); } } jQuery('.slider-commenti').slick({ dots: false, infinite: true, speed: 900, arrows: false, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 5000, accessibility:false, slide:'.slide-commenti' }); jQuery('.arrows-commenti .next').click(function () { jQuery('.slider-commenti').slick('slickNext'); }) jQuery('.arrows-commenti .prev').click(function () { jQuery('.slider-commenti').slick('slickPrev'); }) if (window.innerWidth > 991) { if (jQuery('.slider-commenti .slick-slide').length <= 1) { jQuery('.arrows-commenti').hide(); } } jQuery('.slider-camere').slick({ arrows: false, dots: false, speed: 600, slidesToShow: 3, autoplay: true, autoplaySpeed: 5000, accessibility: false, infinite: false, responsive: [ { breakpoint: 992, settings: { slidesToShow: 2 } }, { breakpoint: 768, settings: { slidesToShow: 1 } } ] }); jQuery('.slider-camere').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); jQuery('.slider-img-dw').slick({ arrows:false, dots: true, infinite: false, speed: 800, slidesToShow: 1, autoplay: true, autoplaySpeed: 3500, slide:'.cont-img', }); jQuery('.slider-inclusive').slick({ arrows:true, dots: false, infinite: false, speed: 800, slidesToShow: 5, autoplay: true, autoplaySpeed: 3500, slide:'.cont-item', responsive: [{ breakpoint: 1200, settings: { slidesToShow: 4, arrows:false, dots:true } }, { breakpoint: 992, settings: { slidesToShow: 3, arrows:false, dots:true } }, { breakpoint: 768, settings: { slidesToShow: 2, arrows:true } }, { breakpoint: 580, settings: { slidesToShow: 1, arrows:true } }] }); jQuery('.arrows-icons .next').click(function () { jQuery('.slider-inclusive').slick('slickNext'); }); jQuery('.arrows-icons .prev').click(function () { jQuery('.slider-inclusive').slick('slickPrev'); }); jQuery('.slider-mima').slick({ arrows:true, dots: false, infinite: false, speed: 800, slidesToShow: 3, autoplay: true, autoplaySpeed: 3500, slide:'.cont-item', responsive: [{ breakpoint: 1200, settings: { slidesToShow: 2, arrows:false, dots:true } }, { breakpoint: 768, settings: { slidesToShow: 1 } }] }); jQuery('.arrows-icons .next').click(function () { jQuery('.slider-mima').slick('slickNext'); }); jQuery('.arrows-icons .prev').click(function () { jQuery('.slider-mima').slick('slickPrev'); }); jQuery('.slider-mima2').slick({ arrows:true, dots: false, infinite: false, speed: 800, slidesToShow: 3, autoplay: true, autoplaySpeed: 3500, slide:'.cont-item', responsive: [{ breakpoint: 1200, settings: { slidesToShow: 2, arrows:false, dots:true } }, { breakpoint: 768, settings: { slidesToShow: 1 } }] }); jQuery('.arrows-icons2 .next').click(function () { jQuery('.slider-mima2').slick('slickNext'); }); jQuery('.arrows-icons2 .prev').click(function () { jQuery('.slider-mima2').slick('slickPrev'); }); jQuery('.slider-img').slick({ arrows:true, dots: false, infinite: false, speed: 800, slidesToShow: 3, autoplay: true, autoplaySpeed: 3500, slide:'.cont-img', responsive: [{ breakpoint: 768, settings: { slidesToShow: 1 } }] }); jQuery('.slider-img').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); if (jQuery('.slider-img .slick-slide').length <= 3) { jQuery('.slider-img .slick-dots').hide(); jQuery('.arrows-slider-img').hide(); } if (jQuery('.slider-img .slick-active').attr('data-slick-index') == '0') { jQuery('.slider-img').find('.slick-prev').addClass('freccia-none'); } else { jQuery('.slider-img').find('.slick-next').removeClass('freccia-none'); } jQuery('.slider-img').on('afterChange', function (event, slick, currentSlide, nextSlide) { bLazy.revalidate(); if (jQuery(this).find('.slick-slide:last-child').hasClass('slick-active')) { jQuery(this).find('.slick-next').addClass('freccia-none'); } else { jQuery(this).find('.slick-next').removeClass('freccia-none'); } if (jQuery(this).find('.slick-active').attr('data-slick-index') == '0') { jQuery(this).find('.slick-prev').addClass('freccia-none'); } else { jQuery(this).find('.slick-prev').removeClass('freccia-none'); } }); if (window.innerWidth < 768) { jQuery('#contenuto_517197').slick({ arrows:true, dots: false, infinite: false, speed: 800, slidesToShow: 1, autoplay: true, autoplaySpeed: 3500, slide:'.col-sm-4' }) jQuery('#contenuto_517197').on('afterChange', function (event, slick, currentSlide, nextSlide) { bLazy.revalidate(); }) } var pathname = window.location.href; var pathname = pathname.split('?id='); var parametro = pathname[1]; var focusnewsletter = 'newsletter_anchor'; if (parametro) { setTimeout(function() { goToByScroll('#' + parametro); }, 1500); if(parametro == focusnewsletter) { setTimeout(function() { jQuery("#email_min").focus(); }, 2000); } } var periodID = window.location.href; var periodID = periodID.split('?dataid='); var dataID = periodID[1]; if (dataID) { setTimeout(function() { goToByScroll(".period[data-id='" + dataID + "']"); }, 1500); } jQuery('.cont-tabs input').click(function () { jQuery('.tab-content').hide(); var element = jQuery(this).attr('id'); jQuery(this).parent('.cont-tabs').siblings(jQuery('.' + element + '').show()); }); jQuery(window).on('scroll', function () { siteApp.viewCheck(); siteApp.scrollAnimation(); }); jQuery('.image-container').each(function () { var h_image = jQuery(this).find('img.foto').height(); jQuery(this).height(h_image); }); jQuery(window).on('resize', function () { if (window.innerWidth > 991) { jQuery('.image-container').each(function () { var h_image = jQuery(this).find('img.foto').height(); jQuery(this).height(h_image); }); } }); /*calendari*/ 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(data.Tdata.dayTextShort); jQuery('.day_formatted').html(data.Tdata.day); jQuery('.ArriveMonth').html(data.Tdata.monthText.substring(0,3)); /* jQuery('.day_text_arr').html(days[data.Tdata.date.getDay()]); */ jQuery('.day_text_arr').html(data.Tdata.dayTextShort); var data_arrivo = jQuery('.booking #data_arrivo').val(); createCookie('data_arrivo', data_arrivo, 1); console.log("arrivo data sel "+data_arrivo); break; case 'data_partenza': // console.log(data.Tdata); jQuery('.departday_formatted').html(data.Tdata.day); jQuery('.DepartMonth').html(data.Tdata.monthText.substring(0,3)); // jQuery('.day_text_dep').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_dep').html(data.Tdata.dayTextShort); var data_partenza = jQuery('.booking #data_partenza').val(); createCookie('data_partenza', data_partenza, 1); console.log("partenza data sel "+data_partenza); 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); 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)); //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)); // 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)); // jQuery('.day_text_dep').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_dep').html(data.Tdata.dayTextShort); }) bLazy = new Blazy({ offset: 8000, loadInvisible: false, selector: '.b-lazy', // all images breakpoints: [{ width: 767 // max-width , src: 'data-src-small' }, { width: 2000 // max-width , src: 'data-src' }] }); }, openMenuMobile: function () { var $id_menu = '#menu_3381'; var $menu = jQuery($id_menu); var $btn = jQuery('.op_block'); jQuery($btn).click(function () { jQuery('.vedi-menu').toggleClass('slide-menu'); $btn.find('.click').toggleClass('open'); $btn.toggleClass('open'); if (jQuery($id_menu + ' .level2').hasClass('slide-menu')) { jQuery($id_menu + ' .level2').removeClass('slide-menu') } }); 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_3381 li').size()) | jQuery(event.target).is('.tendina-lingue') | jQuery(event.target).parents(".blocco-lingue").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'); } if (jQuery(".level2").hasClass('slide-menu')) { jQuery(".level2").removeClass('slide-menu'); } }); }, openBook: function (param) { jQuery(param).toggleClass('open'); jQuery(param + ' .chiudi').click(function(){ jQuery(param).removeClass('open'); }); }, openSecondLevel: function () { jQuery('.submenu > a').click(function (e) { e.preventDefault(); jQuery(this).parents('li').children('.level2').addClass('slide-menu'); }) jQuery('.level2 li:first-child a').click(function (e) { e.preventDefault(); jQuery(this).parents('li').parents('.level2').removeClass('slide-menu'); }) }, openSubMenu: function () { jQuery('.menu-fix #root_3381, #root_3381').superfish({ delay: 0, speed: 'normal' }); }, 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('fast', function () { jQuery(this).removeClass('opened'); }) jQuery(this).next().slideDown('fast', function () { jQuery(this).addClass('opened'); }); } else { jQuery(this).removeClass('opened'); jQuery('.slider-corpo.opened').slideUp('fast', function () { jQuery(this).removeClass('opened'); }); } }); }, accordionTxtHome: function (param) { jQuery('.leggi-piu').click(function () { if (!jQuery(this).hasClass('opened')) { jQuery('.leggi-piu.opened').removeClass('opened'); jQuery(this).addClass('opened'); jQuery('.leggi-piu-corpo.opened').slideUp('fast', function () { jQuery(this).removeClass('opened'); }) jQuery(this).next().slideDown('fast', function () { jQuery(this).addClass('opened'); }); } else { jQuery(this).removeClass('opened'); jQuery('.leggi-piu-corpo.opened').slideUp('fast', function () { jQuery(this).removeClass('opened'); }); } }); }, accordionMesi: function(param) { jQuery('.select_mesi').click(function() { if (!jQuery(this).hasClass('opened')) { jQuery('.select_mesi.opened').removeClass('opened'); jQuery(this).addClass('opened'); jQuery('.cont_mesi.opened').slideUp('fast', function() { jQuery(this).removeClass('opened'); }) jQuery(this).next().slideDown('fast', function() { jQuery(this).addClass('opened'); }); } else { jQuery(this).removeClass('opened'); jQuery('.cont_mesi.opened').slideUp('fast', function() { jQuery(this).removeClass('opened'); }); } }); }, hresize: function (param, padding) { var hm = ''; var maxh = ''; var arrH = []; var sost = 0; if (padding) { sost = padding; } jQuery(param).each(function () { hm = jQuery(this).height() + sost; arrH.push(hm); }); maxh = Math.max.apply(Math, arrH); jQuery(param).height(maxh) }, openLanguage: function () { jQuery('.tendina-lingue').click(function () { var lingua = jQuery(this).children('#select_lingue'); if (lingua.is(':hidden')) { lingua.slideDown(); jQuery(this).addClass('open'); } else { lingua.slideUp(); jQuery(this).removeClass('open'); } }); jQuery("#select_lingue").click(function () { jQuery(this).slideUp(); jQuery('.tendina-lingue').children('.click').removeClass('open') }); 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").slideUp(); jQuery('.tendina-lingue').removeClass('open') } }); }, fadeInHeader: function(element){ jQuery(window).scroll(function(){ var scrollpos = (document.documentElement.scrollTop || document.body.scrollTop); var h_w = jQuery(window).height(); if(scrollpos > 250){ element.fadeIn(); } else { element.fadeOut(); } }); }, viewCheck: function () { if (window.innerWidth > 991) { jQuery('.moveUp,.moveRight,.moveDown, .moveLeft, .moveLine, .hideme, .image-container, .highlight').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 }); } else { jQuery('.highlight').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 }); } }, showMe: function (elem) { anim = jQuery(elem).attr('data-anim'); jQuery(elem).addClass('animated ' + anim); jQuery(elem).animate({ opacity: 1 }, 300, function () {}) }, scrollAnimation: function () { setTimeout(function () { if (window.innerWidth > 991) { jQuery('.hideme.visible').each(function (i) { siteApp.showMe(this); }); } }, 150); }, adatta: function (elem) { var win_h = window.innerHeight; jQuery(elem).css('height', win_h); }, loadGoogleFont: function (url) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var css = xhr.responseText; css = css.replace(/}/g, 'font-display: swap; }'); var head = document.getElementsByTagName('head')[0]; var style = document.createElement('style'); style.appendChild(document.createTextNode(css)); head.appendChild(style); } }; xhr.send(); }, } window.addEventListener("load", function () { siteApp.init(); siteApp.viewCheck(); siteApp.scrollAnimation(); }); jQuery(window).on('load resize', function () { if (window.innerWidth > 991) { jQuery('.adattHeight').each(function () { $height = jQuery(this).next().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 goToByScroll(param) { bLazy.revalidate(); //console.log("goToByScroll"); try { jQuery('html, body').animate({ scrollTop: jQuery(param).offset().top - 270 //scrollTop: jQuery(param).offset().top }, 2000, "easeInOutQuad"); //bLazy.destroy(); } catch (err) {} } /* 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); } function myReplyOnPostRender(options) { var lbl1 = dictionaryTranslate('[DIZIONARIO:testo_check_newsletter_form]', lang_page); // jQuery('.newsletter_optin_text_wrapper').html(lbl1); jQuery('button.alpaca-form-button').click(function(event) { event.preventDefault(); if (jQuery('input[name="newsletter_optin"]').is(':checked')) { jQuery('input[name="newsletter_optin"]').val(1); } else { jQuery('input[name="newsletter_optin"]').val(0); } var newsletter_optin = jQuery('input[name="newsletter_optin"]').val(); createCookie('newsletter_optin', newsletter_optin, 1); }); }