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: [
]
},
xlFilters: true
},
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;
}
},
selectOfferta: function(id){
if(jQuery('.offerta').length > 0){
jQuery('.richiedi-preventivo a').on("click", function() {
let id = jQuery(this).data('id');
let nomeOfferta = jQuery('h3 #offerta-'+id).html();
jQuery('.form-dettaglio-struttura [name="note"]').val(dictionaryTranslate("[DIZIONARIO:richiedi_info_offerta] "+nomeOfferta, cmsPageParams.lang));
if(jQuery( window ).width() < 992){
goToByScroll('.form-dettaglio-struttura');
}
});
}
},
startApplication: function () {
siteApp.loadGoogleFont("https://fonts.googleapis.com/css?family=Montserrat:300,400,500,700&display=swap");
siteApp.selectBambiniForm();
siteApp.actionSchedaStruttura();
siteApp.selectOfferta();
siteApp.changeFiltriListaStrutture();
siteApp.changeFiltriListaOfferte();
siteApp.changeOrdinamentoListaStrutture();
siteApp.menuMobile();
siteApp.initBarraBloccata();
siteApp.initDateForm();
siteApp.toggleFiltriRicercaListaStrutture();
jQuery(window).resize(function(){
siteApp.toggleFiltriRicercaListaStrutture();
});
jQuery('div.cb').remove();
// Aggiungi ai preferiti e mostra quantità preferiti selezionati
PtPreferiti.init('.add-preferiti', jQuery('.header-top .qta-wishlist'));
// Azioni relative al form di preventivo multiplo
PtPreferiti.initFormPreventivo(jQuery('.form-preventivo-multiplo'), jQuery('.container-form-preventivo form'), jQuery('.header-top .qta-wishlist'));
siteApp.initFormRichiestaPreventivo();
/*********************************************************************/
//homepage
if((cmsPageParams.relation_code == 1581668430)&&(cmsPageParams.lang=='it')){
//console.log("homepage");
if (jQuery("#popupModalLong")){
jQuery("#popupModalLong").modal('show');
}
}
jQuery('.homepage-slider').slick({
dots: false,
arrows: false,
infinite: true,
speed: 2000,
fade: true,
slidesToShow: 1,
autoplay: true,
autoplaySpeed: 2000,
});
if(jQuery('.slick-scheda-struttura').length > 0){
jQuery('.slick-scheda-struttura').slick({
dots: false,
arrows: true,
infinite: false,
speed: 300,
slidesToShow: 6,
autoplay: false,
autoplaySpeed: 2000,
prevArrow: '',
nextArrow: '',
responsive: [
{
breakpoint: 1400,
settings: {
slidesToShow: 4
}
},
{
breakpoint: 1024,
settings: {
slidesToShow: 3
}
},
{
breakpoint: 768,
settings: {
slidesToShow: 2
}
}
]
});
jQuery('a.scheda-struttura').fancybox({
padding: 0
});
}
if(jQuery('.slick-pagina').length > 0){
jQuery('.slick-pagina').slick({
dots: false,
arrows: false,
infinite: false,
speed: 300,
slidesToShow: 1,
autoplay: true,
autoplaySpeed: 2000,
prevArrow: '',
nextArrow: ''
});
}
if(jQuery('.slick-evento').length > 0){
jQuery('.slick-evento').slick({
dots: false,
arrows: false,
infinite: false,
speed: 300,
slidesToShow: 3,
autoplay: true,
autoplaySpeed: 2000,
prevArrow: '',
nextArrow: '',
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 1
}
}
]
});
}
},
// Imposto i campi data dei form in sola lettura
initDateForm: function(){
// Form scheda struttura
if(jQuery('.container-form-struttura form').length > 0){
var today = new Date();
var nextDay = new Date(today);
nextDay.setDate(today.getDate() + 1);
jQuery('.container-form-struttura form [name="data_arrivo"]').pickadate({
min: today,
format: 'dd/mm/yyyy',
formatSubmit: 'yyyy_mm_dd',
onSet: function(context) {
var nextDay = new Date(context.select);
nextDay.setDate(nextDay.getDate() + 1);
var picker = jQuery('.container-form-struttura form [name="data_partenza"]').pickadate('picker');
//picker.set('select', nextDay);
picker.set('min', nextDay);
}
});
jQuery('.container-form-struttura form [name="data_partenza"]').pickadate({
min: nextDay,
format: 'dd/mm/yyyy',
formatSubmit: 'yyyy_mm_dd'
});
}
// Form richiesta preventivo multiplo
if(jQuery('.container-form-preventivo form').length > 0){
var today = new Date();
var nextDay = new Date(today);
nextDay.setDate(today.getDate() + 1);
jQuery('.container-form-preventivo form [name="data_arrivo"]').pickadate({
min: today,
format: 'dd/mm/yyyy',
formatSubmit: 'yyyy_mm_dd',
onSet: function(context) {
var nextDay = new Date(context.select);
nextDay.setDate(nextDay.getDate() + 1);
var picker = jQuery('.container-form-preventivo form [name="data_partenza"]').pickadate('picker');
picker.set('select', nextDay);
picker.set('min', nextDay);
}
});
jQuery('.container-form-preventivo form [name="data_partenza"]').pickadate({
min: nextDay,
format: 'dd/mm/yyyy',
formatSubmit: 'yyyy_mm_dd'
});
}
// Form contatti
if(jQuery('.container-form-contatti form').length > 0){
var today = new Date();
var nextDay = new Date(today);
nextDay.setDate(today.getDate() + 1);
jQuery('.container-form-contatti form [name="data_arrivo"]').pickadate({
min: today,
format: 'dd/mm/yyyy',
formatSubmit: 'yyyy_mm_dd',
onSet: function(context) {
var nextDay = new Date(context.select);
nextDay.setDate(nextDay.getDate() + 1);
var picker = jQuery('.container-form-contatti form [name="data_partenza"]').pickadate('picker');
picker.set('select', nextDay);
picker.set('min', nextDay);
}
});
jQuery('.container-form-contatti form [name="data_partenza"]').pickadate({
min: nextDay,
format: 'dd/mm/yyyy',
formatSubmit: 'yyyy_mm_dd'
});
}
},
changeFiltriListaStrutture: function(){
if(jQuery('.cont-form-ricerca form').length > 0){
jQuery('.cont-form-ricerca form input').change(function(){
let params = jQuery('.cont-form-ricerca form').serialize();
jQuery.ajax({
url: '/ws.php',
data: params,
success: function(strutture){
let html = jQuery('.cont-template-row-struttura').html();
jQuery('.lista-strutture').html('');
jQuery('.numero-strutture span').html(strutture.length);
for(let i = 0; i < strutture.length; i++){
let template = html;
template = template.replace(/\[PT_APERTURA\]/g, strutture[i].pt_apertura);
template = template.replace(/\[PT_IMG\]/g, strutture[i].pt_img);
template = template.replace(/\[PT_INDIRIZZO\]/g, strutture[i].pt_indirizzo);
template = template.replace(/\[PT_LINK_STRUTTURA\]/g, strutture[i].pt_link_struttura);
template = template.replace(/\[PT_ID_STRUTTURA\]/g, strutture[i].pt_id_struttura);
template = template.replace(/\[PT_NOME_STRUTTURA\]/g, strutture[i].pt_nome_struttura);
template = template.replace(/\[PT_STELLE_STRUTTURA\]/g, strutture[i].pt_stelle_struttura);
template = template.replace(/\[PT_OFFERTE\]/g, strutture[i].pt_offerte);
template = template.replace(/\[PT_SERVIZI\]/g, strutture[i].pt_servizi);
template = template.replace(/\[PT_TIPOLOGIE_TEMATICHE\]/g, strutture[i].pt_tipologie_tematiche);
jQuery('.lista-strutture').append(dictionaryTranslate(template,lang_page));
}
jQuery('.lista-strutture a').each(function(){
if(jQuery(this).attr('content') == 'noindex'){
jQuery(this).removeAttr('content');
}
});
PtPreferiti.drawStatus();
}
});
});
}
},
changeFiltriListaOfferte: function(){
if(jQuery('.cont-form-ricerca-offerte form').length > 0){
jQuery('.cont-form-ricerca-offerte form input').change(function(){
let params = jQuery('.cont-form-ricerca-offerte form').serialize();
jQuery.ajax({
url: '/ws.php',
data: params,
success: function(offerte){
let html = jQuery('.cont-template-row-offerta').html();
jQuery('.lista-offerte .strutture-offerta').html('');
jQuery('.numero-offerte span').html(offerte.length);
for(let i = 0; i < offerte.length; i++){
let template = html;
template = template.replace(/\[PT_URL_OFFERTA\]/g, offerte[i].pt_url_offerta);
template = template.replace(/\[PT_NOME_STRUTTURA\]/g, offerte[i].pt_nome_struttura);
template = template.replace(/\[PT_IMG_OFFERTA\]/g, offerte[i].pt_img_offerta);
template = template.replace(/\[PT_STELLE\]/g, offerte[i].pt_stelle);
template = template.replace(/\[PT_NOME_STRUTTURA\]/g, offerte[i].pt_nome_struttura);
template = template.replace(/\[PT_NOME_OFFERTA\]/g, offerte[i].pt_nome_offerta);
template = template.replace(/\[PT_PREZZO_OFFERTA\]/g, offerte[i].pt_prezzo_offerta);
template = template.replace(/\[PT_DESCRIZIONE_PREZZO_OFFERTA\]/g, offerte[i].pt_descrizione_prezzo_offerta);
jQuery('.lista-offerte .strutture-offerta').append(dictionaryTranslate(template,lang_page));
}
jQuery('.lista-offerte .strutture-offerta a').each(function(){
if(jQuery(this).attr('content') == 'noindex'){
jQuery(this).removeAttr('content');
}
});
}
});
});
}
},
toggleFiltriRicercaListaStrutture: function(){
if(jQuery('.title-form-ricerca').length < 1) return;
if(jQuery( window ).width() < 1200 && siteApp.params.xlFilters){
// Se sono nel responsive sposto i filtri dalla sidebar al wrapper della lista strutture
// Inserisco un segnaposto per sapere dov'erano posizionati nella versione desktop, in base alla pagina potrebbe cambiare la posizione dei filtri nella sidebar
if(jQuery('.segnaposto-filtri').length < 1){
jQuery("").insertAfter( "#form-ricerca" );
}
jQuery('.cont-top-lista').parent().prepend(jQuery('#form-ricerca'));
jQuery('.cont-top-lista').parent().prepend(jQuery('.title-form-ricerca'));
jQuery('.title-form-ricerca').removeClass("opened");
// Bindo il click sul titolo per mostrare o nascondere i filtri di ricerca
jQuery('#form-ricerca').css("display", "none");
jQuery('.title-form-ricerca').off("click");
jQuery('.title-form-ricerca').on("click", function(){
jQuery('#form-ricerca').toggle();
if(jQuery('#form-ricerca').css("display") != "none"){
jQuery(this).addClass("opened");
}else{
jQuery(this).removeClass("opened");
}
});
siteApp.params.xlFilters = false;
}else if(jQuery( window ).width() >= 1200 && !siteApp.params.xlFilters){
// Nelle versioni desktop mi assicuro che i filtri siano visibili
jQuery('#form-ricerca').css("display", "block");
if(jQuery('.segnaposto-filtri').length > 0){
//jQuery("").insertAfter( "#form-ricerca" );
jQuery('.segnaposto-filtri').parent().prepend(jQuery('#form-ricerca'));
jQuery('.segnaposto-filtri').parent().prepend(jQuery('.title-form-ricerca'));
jQuery('.title-form-ricerca').off("click");
jQuery('.segnaposto-filtri').remove();
}
siteApp.params.xlFilters = true;
}
},
changeOrdinamentoListaStrutture: function(){
if(jQuery('.ordinamento select').length > 0){
jQuery('.ordinamento select').change(function(){
jQuery('.cont-form-ricerca form input[name="ordinamento"]').val(jQuery(this).val());
jQuery('.cont-form-ricerca form input[name="ordinamento"]').trigger("change");
});
}
},
actionSchedaStruttura: function(){
if(jQuery('.btn-offerte').length > 0){
jQuery('.btn-offerte').on("click", function(event){
event.preventDefault();
goToByScroll('.cont-offerte');
});
}
var idStruttura = jQuery('.scheda-struttura').data('id');
jQuery('.container-form-struttura form input[name="id_struttura"]').val(idStruttura);
},
selectBambiniForm: function(){
let selectBambini = jQuery('form select[name="bambini"]');
if(selectBambini.length > 0){
// Imposto il valore delle select eta con il carattere "-"
// In questo modo i campi nascosti sono obbligatori ma hanno un valore accettabile
jQuery('form select[name="eta_bambino_1"] option:eq(0)').val('-');
jQuery('form select[name="eta_bambino_2"] option:eq(0)').val('-');
jQuery('form select[name="eta_bambino_3"] option:eq(0)').val('-');
jQuery('form select[name="eta_bambino_4"] option:eq(0)').val('-');
selectBambini.change(function(){
jQuery('form .eta_bambino').addClass("eta_bambino_hidden");
jQuery('form .eta_bambino select').each(
function(){
jQuery(this).val("");
// Quando la select bambini cambia valore mi assicuro di selezionare il valore "-" per tutte le età
jQuery(this).find('option:eq(0)').val('-');
jQuery(this).find('option:eq(0)').attr("selected", true);
}
);
// Recupero le select età bambino da mostrare e gli tolgo il valore di default "-" così da scatenare l'alert di campo obbligatorio
let val = jQuery(this).val();
for (i = 1; i <= val; i++) {
jQuery('form .eta_bambino_'+i).removeClass("eta_bambino_hidden");
jQuery('form select[name="eta_bambino_'+i+'"] option:eq(0)').val('');
}
});
}
},
menuMobile: function(){
jQuery(document).ready(function() {
jQuery('#toogle-menu').sidr({
source: '#menu_3379',
renaming: false
});
});
},
// Create the element
openMenuMobile: function () {
/* variabili menu */
var $id_menu = '#menu_3319';
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 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_3319 li').size()) | jQuery(event.target).is('.tendina-lingue') | jQuery(event.target).parents(".blocco-lingue").size()) {
return;
}
// if(window.innerWidth > 991){
// jQuery('.menu-fix').fadeOut();
//}
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(); /* 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 */
})
},
// Effetto Superfish //
openSubMenu: function () {
jQuery('.menu-fix #root_3319, #root_3319').superfish({
delay: 0, // 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*********** */
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');
});
}
});
},
hresize: function (param, padding) {
/* FUNZIONE PER CALCOLARE L'ALTEZZA MAX TRA DIV AFFIANCATI */
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);
})
//console.log(arrH)
maxh = Math.max.apply(Math, arrH);
//console.log(maxh)
jQuery(param).height(maxh)
},
/**************** tendina lingue ********************/
openLanguage: function () {
//APRO MENU LINGUE
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 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").slideUp();
jQuery('.tendina-lingue').removeClass('open')
}
});
},
initFormRichiestaPreventivo: function(){
jQuery('[name="hidden_adulti"]').val(jQuery('[name="adulti"]').val());
jQuery('[name="hidden_bambini"]').val(jQuery('[name="bambini"]').val());
jQuery('[name="hidden_eta_bambini_1"]').val(jQuery('[name="eta_bambino_1"]').val());
jQuery('[name="hidden_eta_bambini_2"]').val(jQuery('[name="eta_bambino_2"]').val());
jQuery('[name="hidden_eta_bambini_3"]').val(jQuery('[name="eta_bambino_3"]').val());
jQuery('[name="hidden_eta_bambini_4"]').val(jQuery('[name="eta_bambino_4"]').val());
if(jQuery('.titanka_form > form').length > 0){
jQuery('[name="adulti"]').on("change", function(){
jQuery('[name="hidden_adulti"]').val(jQuery(this).val());
});
}
if(jQuery('.titanka_form > form').length > 0){
jQuery('[name="bambini"]').on("change", function(){
jQuery('[name="hidden_bambini"]').val(jQuery(this).val());
});
}
if(jQuery('.titanka_form > form').length > 0){
jQuery('[name="eta_bambino_1"]').on("change", function(){
jQuery('[name="hidden_eta_bambini_1"]').val(jQuery(this).val());
});
}
if(jQuery('.titanka_form > form').length > 0){
jQuery('[name="eta_bambino_2"]').on("change", function(){
jQuery('[name="hidden_eta_bambini_2"]').val(jQuery(this).val());
});
}
if(jQuery('.titanka_form > form').length > 0){
jQuery('[name="eta_bambino_3"]').on("change", function(){
jQuery('[name="hidden_eta_bambini_3"]').val(jQuery(this).val());
});
}
if(jQuery('.titanka_form > form').length > 0){
jQuery('[name="eta_bambino_4"]').on("change", function(){
jQuery('[name="hidden_eta_bambini_4"]').val(jQuery(this).val());
});
}
/*
jQuery('[name="hidden_adulti"]').val(jQuery('[name="adulti"]').val());
if(jQuery('.titanka_form > form').length > 0){
jQuery('[name="adulti"]').on("change", function(){
jQuery('[name="hidden_adulti"]').val(jQuery(this).val());
});
}
jQuery('[name="hidden_adulti"]').val(jQuery('[name="adulti"]').val());
if(jQuery('.titanka_form > form').length > 0){
jQuery('[name="adulti"]').on("change", function(){
jQuery('[name="hidden_adulti"]').val(jQuery(this).val());
});
}
jQuery('[name="hidden_adulti"]').val(jQuery('[name="adulti"]').val());
if(jQuery('.titanka_form > form').length > 0){
jQuery('[name="adulti"]').on("change", function(){
jQuery('[name="hidden_adulti"]').val(jQuery(this).val());
});
}
jQuery('[name="hidden_adulti"]').val(jQuery('[name="adulti"]').val());
if(jQuery('.titanka_form > form').length > 0){
jQuery('[name="adulti"]').on("change", function(){
jQuery('[name="hidden_adulti"]').val(jQuery(this).val());
});
}*/
},
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) {
//console.log('ok')
jQuery('.moveUp,.moveRight,.moveDown, .moveLeft, .moveLine, .hideme, .image-container, .video-box').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('.video-box').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);
// console.log('vado');
});
}
}, 150);
},
adatta: function (elem) {
var win_h = window.innerHeight;
jQuery(elem).css('height', win_h);
},
loadGoogleFont: function (url) {
// the 'fetch' equivalent has caching issues
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();
},
initBarraBloccata: function(){
var barra = jQuery('.header-top');
if(barra.length>0){
siteApp.refreshBarraBloccata(barra);
jQuery(window).scroll(function(){
siteApp.refreshBarraBloccata(barra);
});
}
},
refreshBarraBloccata: function(barra){
var scrollpos = (document.documentElement.scrollTop || document.body.scrollTop);
barra.addClass('fixed');
if(scrollpos > 63){
barra.addClass('fixed');
}
else {
barra.removeClass('fixed');
}
}
}
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) {
jQuery("html, body").animate({ scrollTop: jQuery(param).offset().top - 100 }, 600);
}
function goToByScrollParametro(param) {
setTimeout(function () {
try {
jQuery('html, body').animate({
scrollTop: jQuery(param).offset().top - 100
}, 2000, "easeInOutQuad");
} catch (err) {}
}, 800);
}
/* 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);
}