/* Jquery */

jQuery(window).ready(function() {

var altezza_dello_schermo = jQuery(window).height();
var larghezza_dello_schermo_stage = jQuery(window).width();





if ($(window).width() > 768) {
    var clbnavElement = $('.clb-share-bar');
    var nonscrollamititoloElement = $('.nonscrollamititolo');

    var height = nonscrollamititoloElement.height();
    clbnavElement.css('margin-top', -height);
  }



$("#switchgraph").click(function(){
console.log("rcccc");
$("#switchgraph img").toggleClass( "gira" );
  $("#calendari, #cubotti").fadeToggle();
}); 





/* TAKE OVER */
if ($(".page-template-takeover")[0]){
    
$('.ilticker').simplemarquee({
	speed: 100,
	cycles: Infinity,
	space: 10,
	delayBetweenCycles: 0,
	handleHover: false,
	handleResize: true
});


$(".ilbtn").click(function() {

    $(this).html(
    $(this).html() == 
     '<i class="fa fa-pause-circle-o" aria-hidden="true"></i>' ? 
     '<i class="fa fa-play-circle-o" aria-hidden="true"></i>' : 
     '<i class="fa fa-pause-circle-o" aria-hidden="true"></i>');



    $(this).next(".ilticker").simplemarquee('toggle');
});


}
/* FINE TAKE OVER */







var colorestag = jQuery('#colorestagione').val();
var nopictas = jQuery('#nopicta').val();


/* Cookie Wishlist */
console.log('Inizializza_Wishlist!');

function scriviCookie(nomeCookie, valoreCookie, durataCookie) {
  var scadenza = new Date();
  var adesso = new Date();
  scadenza.setTime(adesso.getTime() + (parseInt(durataCookie) * 60000));
  document.cookie = nomeCookie + '=' + escape(valoreCookie) + '; expires=' + scadenza.toGMTString() + '; path = /';
}

function leggiCookie(nomeCookie) {
  if (document.cookie.length > 0) {
    var inizio = document.cookie.indexOf(nomeCookie + "=");
    if (inizio != -1) {
      inizio = inizio + nomeCookie.length + 1;
      var fine = document.cookie.indexOf(";", inizio);
      if (fine == -1) fine = document.cookie.length;
      return unescape(document.cookie.substring(inizio, fine));
    } else {
      return "";
    }
  }
  return "";
}

// Funzione per generare un numero casuale a 6 cifre
function generaNumeroCasuale() {
  return Math.floor(100000 + Math.random() * 900000); // Genera un numero tra 100000 e 999999
}

console.log('leggo cookie');

function rearrange() {
  jQuery("#lawishlist .listainwishlist").removeClass("odd even");
  jQuery("#lawishlist .listainwishlist:visible:odd").addClass("odd");
  jQuery("#lawishlist .listainwishlist:visible:even").addClass("even");
}

var lettura = leggiCookie('lamiawishlist');

var urlaWish = "https://romaeuropa.net/wishlist/";
var langAttribute = jQuery('html').attr('lang');
if (langAttribute === 'en-US') {
  urlaWish = "https://romaeuropa.net/en/wishlist/";
}

// Aggiungi la variabile casuale alla URL
var numeroCasuale = generaNumeroCasuale();
urlaWish = urlaWish + "?var=" + numeroCasuale; // Concatenare la variabile casuale alla URL

jQuery("#mailidc").text(lettura);

var ListaPref = "";
if (lettura) {
  ListaPref = lettura.split(',');
  console.log('Quanti --> ' + ListaPref.length);

  // Usa template literals per concatenare correttamente
  jQuery("#menu-superiore").prepend(`<li id='nav-menu-item-wishlist' class='mega-menu-item nav-item menu-item-depth-0'><a href='${urlaWish}' title='Wishlist ${ListaPref.length}'><i class='fa fa-heart' aria-hidden='true'></i> WISHLIST (${ListaPref.length})</a></li>`);
  jQuery("#mcompat").prepend(`<span class='wisha'><a href='${urlaWish}' title='Wishlist ${ListaPref.length}'><i class='fa fa-heart' aria-hidden='true'></i> (${ListaPref.length})</a></span>`);
} else {
  console.log('Lista vuota');
  jQuery("#menu-superiore").prepend(`<li id='nav-menu-item-wishlist' class='mega-menu-item nav-item menu-item-depth-0'><a href='${urlaWish}' title='Wishlist'><i class='fa fa-heart-o' aria-hidden='true'></i> WISHLIST</a></li>`);
  jQuery("#mcompat").prepend(`<span class='wisha'><a href='${urlaWish}' title='Wishlist'><i class='fa fa-heart-o' aria-hidden='true'></i></a></span>`);
}

jQuery(".btnwishlist").each(function(index) {
  console.log(index + ": " + jQuery(this).attr("id"));
  var preferito = jQuery(this).attr("id");

  if (ListaPref.includes(preferito)) {
    console.log(preferito + ' presente');
    jQuery(this).append(`<a class="wbtn wishrem" id="${preferito}" href="#" title="Wishlist"><i class="fa fa-heart" aria-hidden="true"></i> <span class="nocubo">Wishlist</span></a>`);
    jQuery(`.picm${preferito}`).append(`<a class="wbtn wishrem" id="${preferito}" href="#" title="Wishlist"><i class="fa fa-heart" aria-hidden="true"></i></a>`);
  } else {
    console.log(preferito + ' assente');
    jQuery(this).append(`<a class="wbtn wishadd" id="${preferito}" href="#" title="Wishlist"><i class="fa fa-heart-o" aria-hidden="true"></i> <span class="nocubo">Wishlist</span></a>`);
    jQuery(`.picm${preferito}`).append(`<a class="wbtn wishadd" id="${preferito}" href="#" title="Wishlist"><i class="fa fa-heart-o" aria-hidden="true"></i></a>`);
  }

  if (jQuery(this).hasClass('solocancella')) {
    jQuery(".wbtn", this).addClass('solocancella');
  }

  var etichettarimuove = jQuery('.labelrem').text();
  jQuery('.wbtn.wishrem.solocancella').empty().append(`<i class="fa fa-times" aria-hidden="true"></i> ${etichettarimuove}`);
});

jQuery("#rearrange").click(function() {
  rearrange();
});

console.log('attivo bottoni');

jQuery(".wbtn").click(function() {
  var leggo = leggiCookie('lamiawishlist');
  var listaletti = "";
  var preferito = jQuery(this).attr("id");

  if (jQuery(this).hasClass('wishrem')) {
    if (leggo) {
      listaletti = leggo.split(',');
      var indice = listaletti.indexOf(preferito);
      listaletti.splice(indice, 1);
      scriviCookie('lamiawishlist', listaletti, 60);

      jQuery("#nav-menu-item-wishlist").empty();

      if (listaletti.length != 0) {
        jQuery("#nav-menu-item-wishlist").prepend(`<a href='${urlaWish}' title='Wishlist ${listaletti.length}'><i class='fa fa-heart' aria-hidden='true'></i> WISHLIST (${listaletti.length})</a>`);
        jQuery(".wisha").empty().prepend(`<a href='${urlaWish}' title='Wishlist ${listaletti.length}'><i class='fa fa-heart' aria-hidden='true'></i> (${listaletti.length})</a>`);
      } else {
        jQuery("#nav-menu-item-wishlist").prepend(`<a href='${urlaWish}' title='Wishlist'><i class='fa fa-heart-o' aria-hidden='true'></i></a>`);
        jQuery(".wisha").empty().prepend(`<a href='${urlaWish}' title='Wishlist'><i class='fa fa-heart-o' aria-hidden='true'></i></a>`);
      }

      jQuery(this).removeClass("wishrem").addClass("wishadd");
      jQuery(".fa", this).removeClass("fa-heart").addClass("fa-heart-o");

      if (jQuery(this).hasClass('solocancella')) {
        var rimuove = '.p' + preferito;
        jQuery(rimuove).fadeOut("slow", function() {
          rearrange();
        });

        var rileggo = leggiCookie('lamiawishlist');
        if (!rileggo) location.reload();
      }
    }
  } else {
    if (leggo) {
      listaletti = leggo.split(',');
      listaletti.push(preferito);
      scriviCookie('lamiawishlist', listaletti, 60);
      jQuery("#nav-menu-item-wishlist").empty();
      jQuery("#nav-menu-item-wishlist").prepend(`<a href='${urlaWish}' title='Wishlist ${listaletti.length}'><i class='fa fa-heart' aria-hidden='true'></i> WISHLIST (${listaletti.length})</a>`);
      jQuery(".wisha").empty().prepend(`<a href='${urlaWish}' title='Wishlist ${listaletti.length}'><i class='fa fa-heart' aria-hidden='true'></i> (${listaletti.length})</a>`);
    } else {
      scriviCookie('lamiawishlist', preferito, 60);
      jQuery("#nav-menu-item-wishlist").empty();
      jQuery("#nav-menu-item-wishlist").prepend(`<a href='${urlaWish}' title='Wishlist 1'><i class='fa fa-heart' aria-hidden='true'></i> WISHLIST (1)</a>`);
      jQuery(".wisha").empty().prepend(`<a href='${urlaWish}' title='Wishlist 1'><i class='fa fa-heart' aria-hidden='true'></i> (1)</a>`);
    }

    jQuery(this).removeClass("wishadd").addClass("wishrem");
    jQuery(".fa", this).removeClass("fa-heart-o").addClass("fa-heart");
  }

  var cosapermail = leggiCookie('lamiawishlist');
  jQuery("#mailidc").text(cosapermail);
  return false;
});

jQuery("#stampawishlist").click(function() {
  jQuery("#lawishlist").printElement({
    printMode: 'popup'
  });
});

jQuery("#cancellalawishlist").click(function() {
  scriviCookie('lamiawishlist', '', -1);
  location.reload();
});




/* CoverFlow */


if (jQuery("body").hasClass("page-template-cronoprogramma")) {

function getIndex(el) {
  return Array.from(el.parentNode.children).indexOf(el)
}

var coverflow = $("#coverflow").flipster({
        style: 'coverflow',
        spacing: -0.6,
		nav: false,
		keyboard: true,
        buttons:   true,

start: 0,
onItemSwitch: (current,prev) => {
    console.log('switched from ',getIndex(prev),' to ',getIndex(current));
	/* alert( getIndex(current)); */

var stringatarget = ".flipster__container li:eq("+getIndex(current)+") a";
var titolodaqui = $(stringatarget).attr('title');
var compagniadaqui = $(stringatarget).data('compagnia');
console.log(titolodaqui);
	if(compagniadaqui){
		jQuery('#outputxt').html(compagniadaqui+'<br><b>'+titolodaqui +'</b>');
	} else {
		jQuery('#outputxt').html('<b>'+titolodaqui +'</b>');
	}
  }
    });
    var wheel = $("#wheel").flipster({
        style: 'wheel',
        spacing: 0
    });
    var flat = $("#flat").flipster({
        style: 'flat',
        spacing: -0.25
    });

/* Check oggi */

var numeroparte = parseInt( jQuery('#numeroparte').val() );

console.log(" - -- - -- -- -- - - -- -- coverflow ------> "+numeroparte);

coverflow.flipster('jump', numeroparte); 



/* CoveFlow Desktop */
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {



var sliderSelector = '.swiper-container',
    isMove = false,
    options = {
      init: false,
      loop: false,
disableOnInteraction: false,
      speed:800,
      effect: 'cube', // 'cube', 'fade', 'coverflow',
      cubeEffect: {
        shadow: true,
        slideShadows: true,
        shadowOffset: 40,
        shadowScale: 0.94,
      },
      grabCursor: true,
      pagination: {
        el: '.swiper-pagination',
        clickable: true
      },
      navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev'
      },
      // Events
      on: {
        init: function(){
          this.autoplay.stop();
        },
        imagesReady: function(){
          this.el.classList.remove('loading');
          this.autoplay.start();
        },
        touchMove: function(event){
          if (!isMove) {
            this.el.classList.remove('scale-in');
            this.el.classList.add('scale-out');
            isMove = true;
          }
        },
        touchEnd: function(event){
          this.el.classList.remove('scale-out');
          this.el.classList.add('scale-in');
          setTimeout(function(){
            isMove = false;
          }, 300);
        },
        slideChangeTransitionStart: function(){
          console.log('slideChangeTransitionStart '+this.activeIndex);
          if (!isMove) {
            this.el.classList.remove('scale-in');
            this.el.classList.add('scale-out');
          }
        },
        slideChangeTransitionEnd: function(){
          console.log('slideChangeTransitionEnd '+this.activeIndex);
          if (!isMove) {
            this.el.classList.remove('scale-out');
            this.el.classList.add('scale-in');
          }
        },
        transitionStart: function(){
          console.log('transitionStart '+this.activeIndex);
        },
        transitionEnd: function(){
          console.log('transitionEnd '+this.activeIndex);
        },
        slideChange:function(){
          console.log('slideChange '+this.activeIndex);
          console.log(this);
        }
      }
    },
    mySwiper = new Swiper(sliderSelector, options);

// Initialize slider
mySwiper.init();

function goToPage(numberPage){
  mySwiper.slideTo(numberPage,1000,false)
}

function getSlideIndexByClass(className) {
  var index = 0;
  $.each($('.swiper-wrapper').children(), function(i, item) {
    if ($(item).hasClass(className)) {
      index = i;
      return false;
    }
  });
  return index;
}


jQuery( ".storybtn" ).click(function() {
  var contentPanelId = 'picm'+jQuery(this).attr("id");
	/* alert(contentPanelId); */
	mySwiper.slideTo(getSlideIndexByClass(contentPanelId));
	/* alert(contentPanelId); */
	jQuery('.swiper-container').fadeIn();
	jQuery( "body" ).addClass( 'fullsa' );
	window.scrollTo(0, 0);
window.dispatchEvent(new Event('resize'));
});



var numeroparte_swi = parseInt( jQuery('#numeroparte').val() );
console.log(" - -- - -- -- -- - - -- -- swiper cube ------> "+numeroparte_swi);



mySwiper.slideTo(numeroparte_swi); 






 
} else {


var titoloiniziale = $(".flipster__item--current a").attr('title');
var compagniainiziale= $(".flipster__item--current a").data('compagnia');

	if(compagniainiziale){
		jQuery('#outputxt').html(compagniainiziale+'<br><b>'+titoloiniziale +'</b>');
	} else {
		jQuery('#outputxt').html('<b>'+titoloiniziale +'</b>');
	}

}
/* CoveFlow Desktop */

}



/* alert(jQuery('.flipster__item--current').index()); */ 

/* menu-superiore */

jQuery('.clb-hamburger').click(function() {


var tassello = jQuery("#secondary-menu").outerHeight();
tassello =tassello/3;
console.log("tassello "+tassello);
var quanto_su = (tassello*1);
jQuery(".clb-hamburger-nav-holder .vaisu .sub-nav").css("margin-top", "-"+quanto_su+"px"); 
});

jQuery("#js-wrapper section").delay(200).fadeIn();


function Sistema_la_fascia_titolo(){

var larghezza_dello_schermo = jQuery(window).width();
var largezza_della_foto = jQuery('.toright .imma').width();

var larghezza_colonna = jQuery('.page-container').width();

console.log('Fascia Titolo/foto '+larghezza_dello_schermo+' '+largezza_della_foto+' '+larghezza_colonna);

var datogliere = (larghezza_dello_schermo - larghezza_colonna)/2;
var copertura = largezza_della_foto - datogliere;

var altezza_blocco_titolo =  jQuery('.vc_col-lg-12.animated-holder').height();
var altezza_della_foto =  jQuery('.toright .imma').height();

if (altezza_blocco_titolo > altezza_della_foto ){
	jQuery('.clb-page-headline-holder').height(altezza_blocco_titolo+30);
} else {
	jQuery('.clb-page-headline-holder').height(altezza_della_foto+20);
}

var nuovamisura = (larghezza_colonna - copertura);

jQuery('.vc_col-lg-12.animated-holder').width(nuovamisura);

}

if (larghezza_dello_schermo_stage > altezza_dello_schermo){
console.log("desktop");

jQuery(window).resize(function(){
  Sistema_la_fascia_titolo();
});

Sistema_la_fascia_titolo();


setTimeout(function () {
	Sistema_la_fascia_titolo();
}, 700);

}

jQuery("#rifiltra").change(function(){
	var nuovo_filtro = jQuery(this).children("option:selected").val();
	jQuery('.filtri input').remove();

	if (nuovo_filtro == "artisti"){
		jQuery('.filtri').html('<input type="hidden" value="285" name="cat" id="artisti" />');
	}
	if (nuovo_filtro == "archivio"){
		jQuery('.filtri').html('<input type="hidden" value="284" name="cat" id="archivio" />');
	}
	if (nuovo_filtro == "escludi"){
		jQuery('.filtri').html('<input type="hidden" value="284" name="escludi" id="escludi">');
	}
});




jQuery('.page-template-archivio-base h3 a').mouseover(function(){
	jQuery("#areafooter").addClass("roller");
	if ( jQuery(this).hasClass("artisti") ) {
	var immagine_di_sfondo = jQuery('#artisti_bg').val(); 
		jQuery('#sfondodinamico').css("background-image", "url("+immagine_di_sfondo+")");
	}
	if ( jQuery(this).hasClass("festival") ) {
	var immagine_di_sfondo = jQuery('#festival_bg').val(); 
		jQuery('#sfondodinamico').css("background-image", "url("+immagine_di_sfondo+")");
	}
	if ( jQuery(this).hasClass("coproduzioni") ) {
	var immagine_di_sfondo = jQuery('#coproduzioni_bg').val(); 
		jQuery('#sfondodinamico').css("background-image", "url("+immagine_di_sfondo+")");
	}
	if ( jQuery(this).hasClass("digitalife") ) {
	var immagine_di_sfondo = jQuery('#digitalife_bg').val(); 
		jQuery('#sfondodinamico').css("background-image", "url("+immagine_di_sfondo+")");
	}
	if ( jQuery(this).hasClass("palladium") ) {
	var immagine_di_sfondo = jQuery('#palladium_bg').val(); 
		jQuery('#sfondodinamico').css("background-image", "url("+immagine_di_sfondo+")");
	}
	if ( jQuery(this).hasClass("promozione") ) {
	var immagine_di_sfondo = jQuery('#promozione_bg').val(); 
		jQuery('#sfondodinamico').css("background-image", "url("+immagine_di_sfondo+")");
	}
	if ( jQuery(this).hasClass("altri") ) {
	var immagine_di_sfondo = jQuery('#altri_bg').val(); 
		jQuery('#sfondodinamico').css("background-image", "url("+immagine_di_sfondo+")");
	}

});


jQuery('.page-template-archivio-base h3 a').mouseout(function(){
	jQuery("#areafooter").removeClass("roller");
     jQuery('#sfondodinamico').css("background","none");

});







jQuery('.filtra-ricerca #ovunque').click(function() {
			jQuery('.filtra-ricerca #escludi').removeClass("attivato");
			jQuery('.filtra-ricerca #solo').removeClass("attivato");
			jQuery('.search-form #archivio').remove();
			jQuery('.search-form #escludi').remove();
			jQuery('.filtra-ricerca #ovunque').addClass("attivato");
});


jQuery('.filtra-ricerca #solo').click(function() {

	if ( jQuery(this).hasClass("attivato") ) {
		jQuery(this).removeClass("attivato");
		jQuery('.filtra-ricerca #ovunque').addClass("attivato");
		jQuery('.search-form #archivio').remove();
	} else {
		jQuery(this).addClass("attivato");
			jQuery('.filtra-ricerca #escludi').removeClass("attivato");
			jQuery('.filtra-ricerca #ovunque').removeClass("attivato");
			jQuery('.search-form #escludi').remove();
		jQuery('.search-field').prepend('<input type="hidden" value="284" name="cat" id="archivio">');
	}
});

jQuery('.filtra-ricerca #escludi').click(function() {

	if ( jQuery(this).hasClass("attivato") ) {
		jQuery(this).removeClass("attivato");
		jQuery('.filtra-ricerca #ovunque').addClass("attivato");
		jQuery('.search-form #archivio').remove();
	} else {
		jQuery(this).addClass("attivato");
			jQuery('.filtra-ricerca #solo').removeClass("attivato");
			jQuery('.filtra-ricerca #ovunque').removeClass("attivato");
			jQuery('.search-form #archivio').remove();
		jQuery('.search-field').prepend('<input type="hidden" value="284" name="escludi" id="escludi">');
	}
});




(function () {
            if (window.addtocalendar)if(typeof window.addtocalendar.start == "function")return;
            if (window.ifaddtocalendar == undefined) { window.ifaddtocalendar = 1;
                var d = document, s = d.createElement('script'), g = 'getElementsByTagName';
                s.type = 'text/javascript';s.charset = 'UTF-8';s.async = true;
                s.src = ('https:' == window.location.protocol ? 'https' : 'http')+'://addtocalendar.com/atc/1.5/atc.min.js';
                var h = d[g]('body')[0];h.appendChild(s); }})();

function leggiCookie(nomeCookie){
  if (document.cookie.length > 0){
    var inizio = document.cookie.indexOf(nomeCookie + "=");
    if (inizio != -1){
      inizio = inizio + nomeCookie.length + 1;
      var fine = document.cookie.indexOf(";",inizio);
      if (fine == -1) fine = document.cookie.length;
      return unescape(document.cookie.substring(inizio,fine));
    } else {
       return "";
    }
  }
  return "";
}


function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    });
    return vars;
}


function isInArray(value, array) {
  return array.indexOf(value) > -1;
}



var $calendario = jQuery('#calendari');

	if ( $calendario.length){

jQuery('.sincal .prossimese').click(function() {
	jQuery('.cencal').delay(500).fadeIn();
	jQuery('.sincal').fadeOut();
})

jQuery('.cencal .precemese').click(function() {
	jQuery('.sincal').delay(500).fadeIn();
	jQuery('.cencal').fadeOut();
})

jQuery('.cencal .prossimese').click(function() {
	jQuery('.descal').delay(500).fadeIn();
	jQuery('.cencal').fadeOut();
})

jQuery('.descal .precemese').click(function() {
	jQuery('.cencal').delay(500).fadeIn();
	jQuery('.descal').fadeOut();
})

	}




if (larghezza_dello_schermo_stage < altezza_dello_schermo){


jQuery('.clb-hamburger').click(function() {
	jQuery('body').addClass('menuaperto');
	jQuery('html .search-global').fadeIn();
	jQuery('html .clb-mode-switcher').css('z-index','9999999999999999999');
	console.log('apre');
});


jQuery('.clb-close, .mbl-overlay-bg').click(function() {
	jQuery('body').removeClass('menuaperto');
	jQuery('html .search-global').fadeOut();
	jQuery('html .clb-mode-switcher').css('z-index','-1');
	console.log('chiude');
});


console.log(larghezza_dello_schermo_stage +' < '+ altezza_dello_schermo);

jQuery(".header-wrap").append('<div id="percscrolmob"></div>');
jQuery(window).scroll(function(e){
	var scrollTop = jQuery(window).scrollTop();
	var docHeight = jQuery(document).height();
	var winHeight = jQuery(window).height();
	var scrollPercent = (scrollTop) / (docHeight - winHeight);
	var scrollPercentRounded = Math.round(scrollPercent*100);
		console.log(scrollPercentRounded);
	jQuery("#percscrolmob").width(scrollPercentRounded+"%");
});
	   
}


	var lingua_corrente = jQuery('#linguacorrente').val();
console.log(lingua_corrente);

var $testohpfonda = jQuery('.page-template-homefondazione .text-regular');

if ( $testohpfonda.length){
	var lingua_corrente = jQuery('#linguacorrente').val();
console.log(lingua_corrente);
	if (lingua_corrente == "en"){

		jQuery('.page-template-homefondazione .text-regular').html('Romaeuropa is one of the most prestigious institutions in Italy and Europe, <br>for the diffusion of contemporary art, theater, dance and music.')
	}

}



var $rulloanni = jQuery('#js-slideContainer');

	if ( $rulloanni.length){



var $wrapper = jQuery('.section');

/*
$wrapper.find('.singolo_anno').sort(function (a, b) {
    return +a.dataset.name - +b.dataset.name;
}).appendTo( $wrapper );*/

var scatola_largh = jQuery('#js-wrapper').width();
var anno_largh = 245;

var quanti = scatola_largh/anno_largh;
quanti = Math.floor(quanti);

var quanti_anni = jQuery('.singolo_anno').length;

var contenitore_anni = (anno_largh*quanti_anni);

var margine = scatola_largh-(anno_largh*quanti);



jQuery('#js-slideContainer').width(contenitore_anni);




  
  var controller = new ScrollMagic.Controller();

  var horizontalSlide = new TimelineMax()
  // animate panels
  .to("#js-slideContainer", 1,   {x: "-5%" ,  margin:"0 0 0 5%"})
  .to("#js-slideContainer", 1,   {x: "-20%",  margin:"0 0 0 20%"})
  .to("#js-slideContainer", 1,   {x: "-40%",  margin:"0 0 0 40%"})
  .to("#js-slideContainer", 1,   {x: "-60%",  margin:"0 0 0 60%"})
  .to("#js-slideContainer", 1,   {x: "-80%",  margin:"0 0 0 80%"})
  .to("#js-slideContainer", 1,   {x: "-100%", margin:"0 0 0 100%"})

  // create scene to pin and link animation
  new ScrollMagic.Scene({
    triggerElement: "#js-wrapper",
    triggerHook: 0.4,
    duration: 600,
	offset: 1 // move trigger to center of element
  })
    .setPin("#js-wrapper")
    .setTween(horizontalSlide)
    /* .addIndicators() // add indicators (requires plugin) */
    .addTo(controller);
  

}


















var $filtreria = jQuery('.filtreria');

	if ( $filtreria.length){

	var filtra = getUrlVars()["filtra"];

	var ord = getUrlVars()["ord"];

	if (filtra){
	var listalettere = filtra.split(',');
		jQuery( ".tastiera a" ).each(function() {
			var nomec = jQuery(this).text();
			if(isInArray(nomec, listalettere)){
				jQuery( this ).addClass( 'spegni' );
			}
		});
	}

jQuery(".rimuovi").click(function(){
		window.location = 'https://romaeuropa.net/archivio/artisti/';
}); 


jQuery(".filtreria .az").click(function(){

	if (filtra){
		window.location = 'https://romaeuropa.net/archivio/artisti/?filtra='+filtra+'&ord=ASC';
	} else {
		window.location = 'https://romaeuropa.net/archivio/artisti/?ord=ASC';
	}
}); 

jQuery(".filtreria .za").click(function(){

	if (filtra){
		window.location = 'https://romaeuropa.net/archivio/artisti/?filtra='+filtra+'&ord=DESC';
	} else {
		window.location = 'https://romaeuropa.net/archivio/artisti/?ord=DESC';
	}
}); 

jQuery(".filtreria .tastiera a").not('.spegni').click(function(){
  		var lettera = jQuery(this).text();

	if (filtra){
			if (ord){
	window.location = 'https://romaeuropa.net/archivio/artisti/?filtra='+filtra+','+lettera+'&ord='+ord;
			}else{
	window.location = 'https://romaeuropa.net/archivio/artisti/?filtra='+filtra+','+lettera
			}
		}else{
			if (ord){
	window.location = 'https://romaeuropa.net/archivio/artisti/?filtra='+lettera+'&ord='+ord;
			}else{
	window.location = 'https://romaeuropa.net/archivio/artisti/?filtra='+lettera;
			}
	}
}); 


jQuery(".filtreria .tastiera .spegni").click(function(){
var letterata = jQuery(this).text();

var xfiltra =[];


if (filtra){
	var arr_filtra = filtra.split(',');



	/* arr_filtra = arr_filtra.filter(item => item !== letterata);
	var xfiltra = arr_filtra.toString(); Vecchi Js */

var i;
for (i = 0; i < arr_filtra.length; i++) {
  if(arr_filtra[i] != letterata){ xfiltra.push(arr_filtra[i]); }
} 


	xfiltra = xfiltra.toString();

	if(xfiltra) {
		if (ord){
			window.location = 'https://romaeuropa.net/archivio/artisti/?filtra='+xfiltra+'&ord='+ord;
		}else{
			window.location = 'https://romaeuropa.net/archivio/artisti/?filtra='+xfiltra;
		}
	}else{
		if (ord){
			window.location = 'https://romaeuropa.net/archivio/artisti/?ord='+ord;
		}else{
			window.location = 'https://romaeuropa.net/archivio/artisti/';
		}
	}
	}else{
		if (ord){
			window.location = 'https://romaeuropa.net/archivio/artisti/?ord='+ord;
		}else{
			window.location = 'https://romaeuropa.net/archivio/artisti/';
		}
	}

}); 


	

	}


/* Social */

var $socialbar_flat = jQuery('.socialbar.flat');

	if ( $socialbar_flat.length){

	document.querySelectorAll('.socialbar.flat a')
	.forEach(function(elem) {
		elem.setAttribute('target', '_blank');
	}) 

	var w_link = "whatsapp://send?text="+window.location.href;
	jQuery('.socialbar.flat').append('<a title="Whatsapp" target="_blank" href="'+w_link+'" data-action="share/whatsapp/share" class="whatsapp"><i class="fa fa-whatsapp"></i></a>');
	jQuery('.socmob').append('<li><a title="Whatsapp" target="_blank" href="'+w_link+'" data-action="share/whatsapp/share" class="whatsapp"><i class="fa fa-whatsapp"></i></a</li>');


	jQuery('.socialbar.flat .twitter span').removeClass();
	jQuery('.socialbar.flat .twitter span').addClass('fa-brands fa-x-twitter');


	} 



jQuery('.gallery-interna').slick({
 autoplay: true,
  centerMode: false,
  centerPadding: '40px',
  slidesToShow: 5,
  responsive: [
    {
      breakpoint: 768,
      settings: {
        arrows: false,
        centerMode: true,
        centerPadding: '40px',
        slidesToShow: 3
      }
    },
    {
      breakpoint: 480,
      settings: {
        arrows: false,
        centerMode: true,
        centerPadding: '40px',
        slidesToShow: 2
      }
    }
  ]
});

var $btn_slick_exist = jQuery('.slick-prev');

	if ( $btn_slick_exist.length){
		jQuery('.slick-prev').html('<i class="fa fa-chevron-left" aria-hidden="true"></i>');
		jQuery('.slick-next').html('<i class="fa fa-chevron-right" aria-hidden="true""></i>');
	}



function scriviCookie(nomeCookie,valoreCookie,durataCookie){
console.log("scrivo e coloro")





  var scadenza = new Date();
  var adesso = new Date();
  scadenza.setTime(adesso.getTime() + (parseInt(durataCookie) * 60000));
  document.cookie = nomeCookie + '=' + escape(valoreCookie) + '; expires=' + scadenza.toGMTString() + '; path=/';
}

function cancellaCookie(nomeCookie){
  scriviCookie(nomeCookie,'',-1);
}

var colore_pagina = leggiCookie('colore_pagina');


if(colore_pagina == "dark") {
	jQuery('body' ).addClass( "dark-scheme" );
 	jQuery('.clb-mode-switcher' ).addClass( "dark" );
	console.log("dark");
		jQuery( ".sololight" ).css({'filter':'alpha(opacity=0)', 'zoom':'1', 'opacity':'0.0'});
		console.log("nascondibianco");
} else {
		jQuery( ".soloeco" ).css({'filter':'alpha(opacity=0)', 'zoom':'1', 'opacity':'0.0', 'pointer-events' : 'none'});
		console.log("mostrabianco");
}




/* jQuery http://romaeuropa.net/wp-content/uploads/2020/03/Fondazione_black.png*/

jQuery('.clb-mode-switcher' ).click(function() {
  	if ( jQuery('.clb-mode-switcher' ).hasClass( "dark" ) ) {
			cancellaCookie('colore_pagina');

jQuery( ".soloeco" ).css({'filter':'alpha(opacity=0)', 'zoom':'1', 'opacity':'0.0' , 'pointer-events' : 'none'});
jQuery( "html .sololight" ).css({'filter':'alpha(opacity=1)', 'zoom':'1', 'opacity':'1.0'});
console.log("mostrabianco");

		} else {
			scriviCookie('colore_pagina','dark',60); 
jQuery( ".sololight" ).css({'filter':'alpha(opacity=0)', 'zoom':'1', 'opacity':'0.0'});
jQuery( "html .soloeco" ).css({'filter':'alpha(opacity=1)', 'zoom':'1', 'opacity':'1.0', 'pointer-events' : 'all'});
console.log("nascondibianco");

	}
});


/* Mouse FX */
jQuery('.demo-image').mouseover(function(){
     jQuery('.circle-cursor').addClass("tonda");

});
jQuery('.demo-image').mouseout(function(){

    jQuery('.circle-cursor').removeClass("tonda");

});

jQuery('.active .ciao').mouseover(function(){
     jQuery('.circle-cursor').addClass("calla");

});
jQuery('.active .ciao').mouseout(function(){

   jQuery('.circle-cursor').removeClass("calla");

});


jQuery('.slick-prev, .sxart').mouseover(function(){
     jQuery('.circle-cursor').addClass("lafrecciasx");

});
jQuery('.slick-prev, .sxart').mouseout(function(){
   jQuery('.circle-cursor').removeClass("lafrecciasx");

});


jQuery('.dxart, .slick-next').mouseover(function(){
     jQuery('.circle-cursor').addClass("lafrecciadx");

});
jQuery('.dxart, .slick-next').mouseout(function(){
   jQuery('.circle-cursor').removeClass("lafrecciadx");

});


jQuery(".acc_fascia").click(function() {
    var PanelId = jQuery(this).attr("id");
    var mostraId = '.fasce.nasc.'+PanelId;
	var BtId = '#'+PanelId;
	jQuery(BtId).remove();

var delay = 0;
   jQuery(mostraId).each(function(){ 
     jQuery(this).delay(delay).animate({
         left:100, opacity:"show"
     },1500);
     delay += 500;
   });

});


jQuery('.ante_prev').mouseover(function(){
     jQuery('.circle-cursor').addClass("anteprima_p");
		var immagine_p = jQuery('.ante_p').attr('src');
	 jQuery('html .circle-cursor.circle-cursor--outer.anteprima_p').css("background", "url("+immagine_p+")");
});
jQuery('.ante_prev').mouseout(function(){
	jQuery('.circle-cursor').removeClass("anteprima_p"); 
		 jQuery('html .circle-cursor.circle-cursor--outer').css("background", "none");

});

jQuery('.ante_next').mouseover(function(){
     jQuery('.circle-cursor').addClass("anteprima_p");
		var immagine_n = jQuery('.ante_n').attr('src');
	 jQuery('html .circle-cursor.circle-cursor--outer.anteprima_p').css("background", "url("+immagine_n+")");
});
jQuery('.ante_next').mouseout(function(){
	jQuery('.circle-cursor').removeClass("anteprima_p"); 
		 jQuery('html .circle-cursor.circle-cursor--outer').css("background", "none");

});



$('.scrollamititolo.artisti').simplemarquee({
	speed: 90,
	cycles: Infinity,
	space: 10,
	delayBetweenCycles: 0,
	handleHover: false,
	handleResize: true
}); 

$('.scrollamititolo.artisti').animate({
    opacity: 1,
  }, 6000, function() {
    // Animation complete.
  });


/* Mod chatgpt 
if ($.fn.simplemarquee) {
    $('.scrollamititolo').simplemarquee({
        speed: 90,
        cycles: Infinity,
        space: 10,
        delayBetweenCycles: 0,
        handleHover: false,
        handleResize: true
    });
} else {
    console.error('simplemarquee plugin is not loaded.');
}
*/






});