/* JavaScript Document
 piccoli script caricati in defer
 quando si usa il jquery $(document).ready() si usa il defer */


	
/* INIZIO REFRESH CAPTCHA */		
$JQCaptcha = jQuery.noConflict();

$JQCaptcha(document).ready(function () {	
	Inizializzazione();	
});

function Inizializzazione() {	
	$JQCaptcha("span[id^='refreshCaptcha_']").click(function() {
		
		var identificatore=$JQCaptcha(this).attr("id");
		var arrayIdentificatore=identificatore.split("_");
			
		var par_fcpt=arrayIdentificatore[1];
		
		RefreshCaptcha(par_fcpt);					
	});	
}

function RefreshCaptcha(par_fcpt) {	
	var tabindex=$JQCaptcha("#fcpt"+par_fcpt).prop("tabindex");
					
	$JQCaptcha.ajax({
		url: "captcha_gestione.php",
		type: "POST",
		data: "azione=rigeneraCaptcha&tabindex="+tabindex+"&par_fcpt="+par_fcpt,
		success: function(data) {
			$JQCaptcha("#formcaptchaContenitore_"+par_fcpt).html(data);
			
			Inizializzazione();
		}
	});	
}
/* FINE REFRESH CAPTCHA */



/* INIZIO CHECK FORM */
var $jQCheckForm = jQuery.noConflict();

$jQCheckForm(document).ready(function () {
	
	InizializzazioneCheckForm();
	
});
	
function InizializzazioneCheckForm()
    {	
    $jQCheckForm("form.checkJq").submit(function() {
       
        var modulo=$jQCheckForm(this).attr("id");
       
		if(!checkModulo("#"+modulo))
			{
			console.log("errori");
			return false;
			}
	});
    }
	
	
	
function checkModulo(modulo)
    {
    var erroriTOT=0;
		
    $jQCheckForm(modulo+" .obbligatorio, "+modulo+" input[class*='formato_']").each(function() {
    	var errori=0;			
		
		if($jQCheckForm(this).is(":disabled")==false)
			{			
	        var valore=$jQCheckForm.trim($jQCheckForm(this).val());
			var identificatore=$jQCheckForm(this).attr("id"); 
			 
			var classe=$jQCheckForm.trim($jQCheckForm(this).attr("class"));
			var arrayClasse=classe.split(" ");
					
						
			$jQCheckForm.each(arrayClasse, function(kClass, vClass) {
	
				if(vClass=="obbligatorio")
					{
					if(valore=="")
			         	{
			         	errori++;
			            }
					}	

				if(vClass=="formato_cap")
					{					
					if(valore!="")
						{					
						var dtRegex = new RegExp(/^[0-9]{5}$/);			
			   	        
			            if(!dtRegex.test(valore))
			               	{ 
		                    errori++;
		                    }
		                }	
					}

				if(vClass=="formato_piva")
					{					
					if(valore!="")
						{					
						var dtRegex = new RegExp(/^[0-9]{11}$/);			
			   	        
			            if(!dtRegex.test(valore))
			               	{ 
		                    errori++;
		                    }
		                }	
					}

				if(vClass=="formato_cf")
					{					
					if(valore!="")
						{									
						var dtRegex = new RegExp(/^[0-9]{11}$/);	
						var dtRegex2 = new RegExp(/^[a-zA-Z]{6}[0-9]{2}[a-zA-Z]{1}[0-9]{2}[a-zA-Z]{1}[0-9]{3}[a-zA-Z]{1}$/);		
			   	        				   	        
			            if(!dtRegex.test(valore) && !dtRegex2.test(valore))
			               	{ 
		                    errori++;
		                    }
		                }	
					}

				if(vClass=="formato_int")
					{					
					if(valore!="")
						{									
						var dtRegex = new RegExp(/^\d*$/);		
			   	        				   	        
			            if(!dtRegex.test(valore))
			               	{ 
		                    errori++;
		                    }
		                }	
					}

				if(vClass=="formato_telefono")
					{					
					if(valore!="")
						{									
						var dtRegex = new RegExp(/^[+./0123 456789-]+$/);		
			   	        				   	        
			            if(!dtRegex.test(valore))
			               	{ 
		                    errori++;
		                    }
		                }	
					}

				if(vClass=="formato_email")
					{					
					if(valore!="")
						{									
						var dtRegex = new RegExp(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,6})?$/);		
			   	        				   	        
			            if(!dtRegex.test(valore))
			               	{ 
		                    errori++;
		                    }
						}
					}			

				if(vClass=="formato_email")
					{					
					if(valore!="")
						{									
						var dtRegex = new RegExp(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,6})?$/);		
			   	        				   	        
			            if(!dtRegex.test(valore))
			               	{ 
		                    errori++;
		                    }
						}
					}		

				if(vClass.indexOf("formato_obb_se_not_")>=0)
					{				
					if(valore=="")
						{
						var altroCampo=vClass.replace("formato_obb_se_not_","");	
						var valoreAltroCampo=$jQCheckForm.trim($jQCheckForm(modulo+" #"+altroCampo).val());	
							   	        
			            if(valoreAltroCampo=="")
			               	{ 
		                    errori++;
		                    }
						}
					}
					
					
				if(errori>0)
	               	{			
	                $jQCheckForm(modulo+" #"+identificatore).addClass("field-errore");
                
					if($jQCheckForm(modulo+" label[for='"+identificatore+"']").length>0)
						{						
						$jQCheckForm(modulo+" label[for='"+identificatore+"']").addClass("label-errore");	
						}
                    }
                else
                    {     
	                $jQCheckForm(modulo+" #"+identificatore).removeClass("field-errore");
					    
					if($jQCheckForm(modulo+" label[for='"+identificatore+"']").length>0)
						{						
						$jQCheckForm(modulo+" label[for='"+identificatore+"']").removeClass("label-errore");	
						} 
                    }
			
			});
			
			}			
				
		erroriTOT=parseInt(erroriTOT)+parseInt(errori);
	});
	    
    
	if(erroriTOT==0)
		{
    	return true;
		}
	else
		{
    	return false;
		}
    }
/* FINE CHECK FORM */



/* INIZIO SCROLL CON ANCORA */
var $jQScrollOnElement = jQuery.noConflict();

$jQScrollOnElement(document).ready(function () {

	/*se nell'url c'è un ancora mi sposto sull'elemento */
	if (location.href.indexOf("#") != -1) 
		{
		var hash=location.hash.replace("#","");
		
		/*se è un form devo cercare l'elemento form perché l'ancora <a name="..."> è nascosta 
		e con gli elementi nascosti non funziona perché non li jquery ovviamente non li vede */
		var elemento="a[name='"+hash+"']";
		if(hash.indexOf("Formrichiesteinfo") != -1)
			{				
			elemento="#modulo"+hash;
			}
			
		if($jQScrollOnElement(elemento).length>0)
			{
			ScrollOnElement(elemento, 150)
			}
		}
	});
	
	
function ScrollOnElement(element, riduci=0)
	{
	var top=($jQScrollOnElement(element).offset().top)-riduci;
	
	if($jQScrollOnElement(".box-barra-alta").length)
		{
		top= top - $jQScrollOnElement(".box-barra-alta").outerHeight(true);
		}
	
	$jQScrollOnElement(".menu-orizzontale-con-blocco").each(function(){		
		
		top= top - ($jQOrizzontaleMenu(this).outerHeight(true)*2)
		
	}); 

	$jQScrollOnElement("html,body").animate({scrollTop:top}, 2000);	  
	} 
/* FINE SCROLL CON ANCORA */



/* INIZIO SORTBY PER LE PAGINE DI ELENCO */
var $JQsortBy= jQuery.noConflict();

$JQsortBy(document).ready(function (){

	let phpSelfDoveSono=$JQMenuTastiAttivi("input[id='phpSelfDoveSono']").val();
	let phpSelfDoveSono2=$JQMenuTastiAttivi("input[id='phpSelfDoveSono2']").val();
	
	if(phpSelfDoveSono=="categorie.php" || phpSelfDoveSono2=="categorie.php")
		{
		if($JQsortBy("#sortBy").length ) {
						
			$JQsortBy("#sortBy").change(function() {
				
				$JQsortBy("form[id='paginazione'] #ordinaPer").val($JQsortBy( "#sortBy option:selected" ).val());
				$JQsortBy("form[id='paginazione'] #pagina").val(""); /*annullo la pagina altrimenti non funziona più il lazy loading */
				$JQsortBy("form[id='paginazione']").submit();			
			});		
		}
 	}
	
});
/* FINE SORTBY PER LE PAGINE DI ELENCO */		
		


/* INIZIO FILTRI PER LE PAGINE DI ELENCO */
var $JQfiltri= jQuery.noConflict();

$JQfiltri(document).ready(function (){
		
	let phpSelfDoveSono=$JQMenuTastiAttivi("input[id='phpSelfDoveSono']").val();
	let phpSelfDoveSono2=$JQMenuTastiAttivi("input[id='phpSelfDoveSono2']").val();
	
	if(phpSelfDoveSono=="categorie.php" || phpSelfDoveSono2=="categorie.php")
		{
		$JQfiltri("a[name='area-filtri']").click(function(e, first){			
				e.preventDefault();	 			  
		
				var display=$JQfiltri("+ div.area-filtri", $JQfiltri(this)).css("display");
				$JQfiltri("+ div.area-filtri", $JQfiltri(this)).slideToggle(first ? 0 : 400);
			
				return false;
		});
	
	
		if($JQfiltri("div[id^='filtroElenco']").length ) 
			{  		
			$JQfiltri("div[id^='filtroElenco']").click(function() {
				 
				var arrayFiltri=new Array(); 
				
				if($JQfiltri("form[id='paginazione'] #filtri").val()!="")
					{
					arrayFiltri=$JQfiltri("form[id='paginazione'] #filtri").val().split(",");
					}
					
				var nArray=count(arrayFiltri);
			
				var arrayIdentificatoreFiltro=$JQfiltri(this).attr("id").split("filtroElenco");
	
				if($JQfiltri.inArray(arrayIdentificatoreFiltro[1], arrayFiltri)<0)
					{
					arrayFiltri[nArray]=arrayIdentificatoreFiltro[1];
					}
				
				$JQfiltri("form[id='paginazione'] #filtri").val(implode(",",arrayFiltri));
				$JQfiltri("form[id='paginazione'] #azione").val("cercaspec");
				$JQfiltri("form[id='paginazione'] #pagina").val(""); /*annullo la pagina altrimenti non funziona più il lazy loading */
				$JQfiltri("form[id='paginazione']").submit();
			});
			}

		if($JQfiltri("select[id^='filtroSelect']").length ) 
			{  		
			$JQfiltri("select[id^='filtroSelect']").change(function() {
				 
				var arrayFiltri=new Array(); 
				
				$JQfiltri("select[id^='filtroSelect']").each(function() {
					
					var valore=$JQfiltri(this).val();
					
					if(valore!="")
						{
						var nArray=count(arrayFiltri);
										
						if($JQfiltri.inArray(valore, arrayFiltri)<0)
							{
							arrayFiltri[nArray]=valore;
							}	
						}
				});
				
				$JQfiltri("form[id='paginazione'] #filtri").val(implode(",",arrayFiltri));
				$JQfiltri("form[id='paginazione'] #azione").val("cercaspec");
				$JQfiltri("form[id='paginazione'] #pagina").val(""); /*annullo la pagina altrimenti non funziona più il lazy loading */
				$JQfiltri("form[id='paginazione']").submit();
			});
			}
	
			
		if( $JQfiltri("div[id^='filtroElenco']").length || $JQfiltri("select[id^='filtroSelect']").length || $JQfiltri("img[id^='filtroElimina']").length )
			{		 		
			$JQfiltri("#filtroEliminaTutti").click(function() {
			
				$JQfiltri("form[id='paginazione'] #filtri").val("");
				$JQfiltri("form[id='paginazione'] #azione").val("cercaspec");
				$JQfiltri("form[id='paginazione'] #pagina").val(""); /*annullo la pagina altrimenti non funziona più il lazy loading */
				$JQfiltri("form[id='paginazione']").submit();			
			});	
				 		
			$JQfiltri("img[id^='filtroElimina'], #filtroEliminaTutti").click(function() {
			
				var arrayFiltri=new Array(); 
				
				if($JQfiltri("form[id='paginazione'] #filtri").val()!="")
					{
					arrayFiltri=$JQfiltri("form[id='paginazione'] #filtri").val().split(",");
					}
					
				var nArray=count(arrayFiltri);
			
				var arrayIdentificatoreFiltro=$JQfiltri(this).attr("id").split("filtroElimina");
				
				arrayFiltri.splice($JQfiltri.inArray(arrayIdentificatoreFiltro[1], arrayFiltri),1);
				
				$JQfiltri("form[id='paginazione'] #filtri").val(implode(",",arrayFiltri));
				$JQfiltri("form[id='paginazione'] #azione").val("cercaspec");
				$JQfiltri("form[id='paginazione'] #pagina").val(""); /*annullo la pagina altrimenti non funziona più il lazy loading */
				$JQfiltri("form[id='paginazione']").submit();
			});
			}
		}
});
/* FINE FILTRI PER LE PAGINE DI ELENCO */



/* INZIO CAMBIO VALUTA */
var $jQValuta = jQuery.noConflict();

$jQValuta(document).ready(function (){
	
	if($jQValuta("#idvalutaopzionale").length )
		{
		$jQValuta("#idvalutaopzionale").change(function() {
			CambiaValuta($jQValuta(this).val());			
		});
		}
});

function CambiaValuta(value)
	{
	$jQValuta.ajax({
		url: 'box/box_cambiavaluta.php',
		type: 'POST',
		data: 'azione=cambiavaluta&valutascelta=' + value,
		success: function() {
			location.reload();		
		}
	});	
	}
/* FINE CAMBIO VALUTA */



/* INIZIO TORNA IN CIMA ALLE PAGINE */
var $JQscrolltop = jQuery.noConflict(); 

function tornaSu()
	{
	$JQscrolltop('html,body').animate({scrollTop:0}, 'slow');
	}	
	
$JQscrolltop(document).ready(function (){
	
	$JQscrolltop("#tornasu").click(function(){
		tornaSu();
	});
});

$JQscrolltop(window).scroll(function(e){
	
	var mioscroll = $JQscrolltop(window).scrollTop();
	
	if(mioscroll >= 300)
		{
		$JQscrolltop("#tornasu").fadeIn();
		}
	else
		{
		$JQscrolltop("#tornasu").fadeOut();
		}
});
/* FINE TORNA IN CIMA ALLE PAGINE */



/* INIZIO RESIZE FORM */
var $jQresizeFormBox = jQuery.noConflict();

$jQresizeFormBox(document).ready(function () {
	
		resizeFormBox();
	});
	
function resizeFormBox()
	{
	if($jQresizeFormBox(window).width() > 1000)
		{
		$jQresizeFormBox(".boxcerca form, .box-generico form[id^='moduloFormrichiesteinfo']").each(function (e){
			
			var w=$jQresizeFormBox(this).outerWidth();
			
			if(w<260)
				{
				$jQresizeFormBox(this).find(".formcontattiriga").each(function (e1){
					$jQresizeFormBox(this).css({"display": "block"});
				});
				
				$jQresizeFormBox(this).find(".formcontattirigacampo").each(function (e2){
					$jQresizeFormBox(this).css({"width": "100%", "padding-right": "0"});
				});
				}
		});
		}
	}
/* FINE RESIZE FORM */



/* INIZIO ADATTAMENTO SWF ALLA LARGHEZZA DEL CONTENITORE */
var $jQEmbed = jQuery.noConflict();

$jQEmbed(document).ready(function (){
	$jQEmbed(".embedcontainer").each(function(){
	 
	var w=$jQEmbed(this).find("input[name='larghezzaswf']").val();
	var h=$jQEmbed(this).find("input[name='altezzaswf']").val();	
	var wContainer=$jQEmbed(this).width();
	
	var from_w=w;
	var from_h=h;
	
	var to_w = wContainer;
	
	if(from_w<to_w)
		{
		to_w=w;
		to_h = h;
		}
	else
		{
		var percent = (to_w/from_w); 
		var to_h=(from_h*percent);
		}
	
	$jQEmbed(this).find("embed").width(to_w);
	$jQEmbed(this).find("embed").height(to_h);
	});
});
/* FINE ADATTAMENTO SWF ALLA LARGHEZZA DEL CONTENITORE */



/* INIZIO PREFERITI E DESIDERI */
var $JQPreferitiDesideri = jQuery.noConflict();

$JQPreferitiDesideri(document).ready(function (index) {
	InitPreferitiDesideri();
});    		
	
function InitPreferitiDesideri()
	{
	$JQPreferitiDesideri("div[id^='preferitiaggiungi']").unbind("click");
	$JQPreferitiDesideri("div[id^='desideriaggiungi']").unbind("click");
	
    $JQPreferitiDesideri("div[id^='preferitiaggiungi']").click(function(e) {
    	
	    var identificatore=$JQPreferitiDesideri(this).attr("id");
		var arrayIdentificatore=identificatore.split("-");
		
		
		$JQWinAutenticazione.post( "https://www.dibrizzi.eu/autenticazione.php", { azione: "checkautenticato" } , function( data ) {
	 	
		 	if(data==1)
		 		{
				AggiungiPreferiti(arrayIdentificatore[1]);	
	        	}
	        else
	        	{
				ShowWinAutenticazione();
				
			    $JQPreferitiDesideri("#formWinAutenticazione #campiWinAutenticazione").html('<input type="hidden" id="azione2" name="azione2" value="aggiungipreferiti"><input type="hidden" id="idspecifica" name="idspecifica" value="'+arrayIdentificatore[1]+'">');
				
			    var href=$JQPreferitiDesideri("#hrefWinAutenticazione").attr("href");
			    var quesrystring="code=preferiti&idpd="+arrayIdentificatore[1];
			    if(strpos(href,"?")===false)
			    	{
			    	quesrystring=href+"?"+quesrystring;	
			    	}
			    else
			    	{
			    	quesrystring=href+"&"+quesrystring;	
			    	}
			    $JQPreferitiDesideri("#hrefWinAutenticazione").attr("href", quesrystring);
			    
				$JQPreferitiDesideri(".windows_Autenticazione_sfondo").click(function (e)
					{
					HideWinAutenticazione();
					});	
					
				$JQPreferitiDesideri(".windows_small_chiudi").click(function (e)
					{
					HideWinAutenticazione();
					});	
	        	}      
	    });
 
 	InitPreferitiDesideri();
    }); 


	$JQPreferitiDesideri("div[id^='desideriaggiungi']").click(function(e) {
		
		
	    var identificatore=$JQPreferitiDesideri(this).attr("id");
		var arrayIdentificatore=identificatore.split("-");
		
		
		$JQWinAutenticazione.post( "https://www.dibrizzi.eu/autenticazione.php", { azione: "checkautenticato" } , function( data ) {
	 	
		 	if(data==1)
		 		{
				AggiungiDesideri(arrayIdentificatore[1]);	
	        	}
	        else
	        	{
				ShowWinAutenticazione();
				
			    $JQPreferitiDesideri("#formWinAutenticazione #campiWinAutenticazione").html('<input type="hidden" id="azione2" name="azione2" value="aggiungidesideri"><input type="hidden" id="idspecifica" name="idspecifica" value="'+arrayIdentificatore[1]+'">');
			    
			    var href=$JQPreferitiDesideri("#hrefWinAutenticazione").attr("href");
			    var quesrystring="code=desideri&idpd="+arrayIdentificatore[1];
			   	if(strpos(href,"?")===false)
			    	{
			    	quesrystring=href+"?"+quesrystring;	
			    	}
			    else
			    	{
			    	quesrystring=href+"&"+quesrystring;	
			    	}
			    $JQPreferitiDesideri("#hrefWinAutenticazione").attr("href", quesrystring);
			    
				$JQPreferitiDesideri(".windows_Autenticazione_sfondo").click(function (e)
					{
					HideWinAutenticazione();
					});	
					
				$JQPreferitiDesideri(".windows_small_chiudi").click(function (e)
					{
					HideWinAutenticazione();
					});	
	        	}      
	    });
	    
	 
	InitPreferitiDesideri();
	}); 
    
    }
    
    
function AggiungiPreferiti(identificatore)
	{ 	
    $JQPreferitiDesideri.post( "https://www.dibrizzi.eu/catalogo_scheda.php", { azione: "aggiungipreferiti", idspecifica: identificatore } , function( data ) {
        $JQPreferitiDesideri( ".box-barra-alta-preferiti-numero" ).html( data );
          
        $JQPreferitiDesideri("div[id^='preferitiaggiungi-"+identificatore+"']").addClass("bottone-preferiti-in-preferiti");
        $JQPreferitiDesideri("div[id^='preferitiaggiungi-"+identificatore+"']").removeClass("bottone-preferiti-aggiungi");
        $JQPreferitiDesideri("div[id^='preferitiaggiungi-"+identificatore+"']").html("star_border");
        $JQPreferitiDesideri("div[id^='preferitiaggiungi-"+identificatore+"']").attr("title","già nella lista dei preferiti");
    });
	}
    
    
function AggiungiDesideri(identificatore)
	{ 	
    $JQPreferitiDesideri.post( "https://www.dibrizzi.eu/catalogo_scheda.php", { azione: "aggiungidesideri", idspecifica: identificatore } , function( data ) {
        $JQPreferitiDesideri( ".box-barra-alta-desideri-numero" ).html( data );
          
        $JQPreferitiDesideri("div[id^='desideriaggiungi-"+identificatore+"']").addClass("bottone-desideri-in-desideri");
        $JQPreferitiDesideri("div[id^='desideriaggiungi-"+identificatore+"']").removeClass("bottone-desideri-aggiungi");
        $JQPreferitiDesideri("div[id^='desideriaggiungi-"+identificatore+"']").html("favorite_border");
        $JQPreferitiDesideri("div[id^='desideriaggiungi-"+identificatore+"']").attr("title","già nella lista dei desideri");
   	});
	}



function ReloadPreferitiDesideri()
	{ 	
	var numDesideri=$JQPreferitiDesideri("div[id^='desideriaggiungi']").length;
	var numPreferiti=$JQPreferitiDesideri("div[id^='preferitiaggiungi']").length;
	
	if(numDesideri>0)
		{	
	    $JQPreferitiDesideri.post( "https://www.dibrizzi.eu/catalogo_scheda.php", { azione: "checkdesideri" } , function( data ) {

			var i, arrayLength, arrayIdentificatore;
			
			arrayIdentificatore=data.split("-");
			
			arrayLength = arrayIdentificatore.length;
			
			for (i = 0; i < arrayLength; i++) 
				{				
		        $JQPreferitiDesideri("div[id^='desideriaggiungi-"+arrayIdentificatore[i]+"']").addClass("bottone-desideri-in-desideri");
		        $JQPreferitiDesideri("div[id^='desideriaggiungi-"+arrayIdentificatore[i]+"']").removeClass("bottone-desideri-aggiungi");
		        $JQPreferitiDesideri("div[id^='desideriaggiungi-"+arrayIdentificatore[i]+"']").html("favorite_border");
		        $JQPreferitiDesideri("div[id^='desideriaggiungi-"+arrayIdentificatore[i]+"']").attr("title","già nella lista dei desideri");
		       }
	   	});	
		}
	
	if(numPreferiti>0)
		{	
	    $JQPreferitiDesideri.post( "https://www.dibrizzi.eu/catalogo_scheda.php", { azione: "checkpreferiti" } , function( data ) {

			var i, arrayLength, arrayIdentificatore;
			
			arrayIdentificatore=data.split("-");
			
			arrayLength = arrayIdentificatore.length;
			
			for (i = 0; i < arrayLength; i++) 
				{				
		        $JQPreferitiDesideri("div[id^='preferitiaggiungi-"+arrayIdentificatore[i]+"']").addClass("bottone-preferiti-in-preferiti");
		        $JQPreferitiDesideri("div[id^='preferitiaggiungi-"+arrayIdentificatore[i]+"']").removeClass("bottone-preferiti-aggiungi");
		        $JQPreferitiDesideri("div[id^='preferitiaggiungi-"+arrayIdentificatore[i]+"']").html("star_border");
		        $JQPreferitiDesideri("div[id^='preferitiaggiungi-"+arrayIdentificatore[i]+"']").attr("title","già nella lista dei preferiti");
		       }
	   	});	
		}
	}
/* FINE FINE PREFERITI E DESIDERI */


/* INIZIO WIN AUTENTICAZIONE */
var $JQWinAutenticazione = jQuery.noConflict();		
	
$JQWinAutenticazione(document).ready(function (){
			
	$JQWinAutenticazione("#formWinAutenticazione").submit(function(e) {
		
		e.preventDefault();	
		
		var azione2=$JQWinAutenticazione("#formWinAutenticazione #azione2").val();
		var idspecifica=$JQWinAutenticazione("#formWinAutenticazione #idspecifica").val();
		
		var form = $JQWinAutenticazione(this);
		var post_url = form.attr("action");
		var post_data = converti_ajax(form.serialize());
		
		$JQWinAutenticazione.ajax({
			type: "POST",
			url: post_url, 
			data: post_data,
			success: function(response) {	
			
				if(response!="OK")
					{
					$JQWinAutenticazione("#formWinAutenticazione .errore").html(response);	
					}	
				else
					{
					if(azione2=="aggiungipreferiti")
						{
						AggiungiPreferiti(idspecifica);
						}
						
					if(azione2=="aggiungidesideri")
						{
						AggiungiDesideri(idspecifica);
						}
						
					ReloadAreaPrivataAlta();
					ReloadPreferitiDesideri();
						
					HideWinAutenticazione();
					}					
			}
		});
		
	});	
});	
	

function ShowWinAutenticazione()
	{
    $JQWinAutenticazione("#formWinAutenticazione #username_log").val("");
    $JQWinAutenticazione("#formWinAutenticazione #password_log").val("");
    $JQWinAutenticazione("#formWinAutenticazione .errore").html("");
    $JQWinAutenticazione("#formWinAutenticazione #campiWinAutenticazione").html("");
    	
	$JQWinAutenticazione(".windows_Autenticazione_sfondo").show();	
	$JQWinAutenticazione(".windows_Autenticazione").show();
	}
	

function HideWinAutenticazione()
	{
	$JQWinAutenticazione(".windows_Autenticazione_sfondo").fadeOut(1000);			
	$JQWinAutenticazione(".windows_Autenticazione").fadeOut(1000);
	}	
	
	
function ReloadAreaPrivataAlta()
	{
	if($JQWinAutenticazione( ".box-barra-alta" ).length>0)
		{
	    $JQWinAutenticazione.post( "https://www.dibrizzi.eu/box/box_area_privata_alto.php", { azione: "reloadarea" } , function( data ) {
	    	
	    	$JQWinAutenticazione( "#box-barra-alta-mobile").remove();
	        $JQWinAutenticazione( ".box-barra-alta" ).replaceWith( data );
	   	});	
	   	}
	}
/* FINE WIN AUTENTICAZIONE */


/* INIZIO JQUERY GENERICO */
var $jQGenerico = jQuery.noConflict();

$jQGenerico(document).ready(function () {
	
	resizeScreen();
		
	var idResize;
	$jQGenerico(window).resize(function() {
	    clearTimeout(idResize);
	    idResize = setTimeout(doneResizing, 500);		    
	});
		
	// inizio spostamento contenuto sito e altro secondo altezza barra alta
	if($jQGenerico(".box-barra-alta").length>0 || $jQGenerico("#box-barra-alta-mobile").length>0 || $jQGenerico("#banner-avviso-modello").length>0)	
		{
		var height=0;
		
		if($jQGenerico(".box-barra-alta").length>0)
			{
			height=$jQGenerico(".box-barra-alta").height();
			}	
		if($jQGenerico("#box-barra-alta-mobile").length>0)
			{
			height=$jQGenerico("#box-barra-alta-mobile").height();
			}	
		if($jQGenerico("#banner-avviso-modello").length>0)
			{
			var height2=$jQGenerico("#banner-avviso-modello").outerHeight(true);
			
			height=parseFloat(height)+parseFloat(height2);
			
			$jQGenerico(".box-barra-alta").css({"top":height2+"px"});
			
			
			if($jQGenerico("#box-barra-alta-mobile").length)
				{
				$jQGenerico("#box-barra-alta-mobile").css({"top":height2+"px"});
				$jQGenerico("#menu-burger-nav-mobile").css({"top":height2+"px"});
				}
			}	
		
		$jQGenerico("#sfondo-sito-home, #sfondo-sito").css({"padding-top":height+"px", "-webkit-transition":"padding-top .5s linear", "-moz-transition":"padding-top .5s linear", "-ms-transition":"padding-top .5s linear", "-o-transition":"padding-top .5s linear", "transition":"padding-top .5s linear"});
		$jQGenerico(".menu-burger-nav").css({"top":(height+1)+"px"});
		}
	// fine spostamento contenuto sito e altro secondo altezza barra alta
		
	
		
	// inizio lingua browser per successivo popup siti collegati 
	const getLanguage = () => navigator.userLanguage || (navigator.languages && navigator.languages.length && navigator.languages[0]) || navigator.language || navigator.browserLanguage || navigator.systemLanguage || "it";

	var linguaBrowser=getLanguage();
	linguaBrowser1=linguaBrowser.toLowerCase();		
	linguaBrowser2=linguaBrowser1.split("-");
	linguaBrowser2=linguaBrowser2[0];
	
	
	array_lingue = new Array();

	$jQGenerico("#linguabrowser").html("lingua browser: "+linguaBrowser+" | lingua browser 1: "+linguaBrowser1+" | lingua browser 2: "+linguaBrowser2);
	$jQGenerico("#linguasitoweb").html("it");
	
	if($jQGenerico(".windows_SitiWebLingua").length>0)
		{		
		if(linguaBrowser1!="it")
			{	
			if(
				linguaBrowser2!="it" ||
				
				(
					linguaBrowser2=="it" &&
					in_array (linguaBrowser1, array_lingue)
				)
			)
				{
				// mostro popup siti in lingua
				$jQGenerico(".windows_SitiWebLingua_sfondo").show();	
				$jQGenerico(".windows_SitiWebLingua").css({"display":"flex"});
				}
			}
		
		$jQGenerico(".windows_SitiWebLingua .winsitiweblingua-boxscelta").click(function (e)
			{				
			var url=$jQGenerico(this).attr("data-url");
			
			window.location = url;
			});
			
		$jQGenerico(".windows_SitiWebLingua .winsitiweblingua-boxattuale").click(function (e)
			{				
			$jQGenerico(".windows_SitiWebLingua .windows_small_chiudi").trigger("click");
			});

		$jQGenerico(".windows_SitiWebLingua .windows_small_chiudi").click(function (e)
			{				
			$jQGenerico.post("https://www.dibrizzi.eu/piede.php", {"azione": "setwinlinguasitoweb"});
			});			
		}
	// fine lingua browser per successivo popup siti collegati 
	
	
	$jQGenerico(".windows_small_chiudi").click(function (e)
		{
		$jQGenerico(".windowsSfondo").fadeOut(1000);			
		$jQGenerico(".windows").fadeOut(1000);
		});
	
	
	$jQGenerico(".calDateEvento div[data-navlink]").click(function() {
				
		var url=$jQGenerico(this).attr("data-urllink");	
		var opzioni=$jQGenerico(this).attr("data-navlink");		
		var obj = jQuery.parseJSON(opzioni);		
		var querystring = $jQGenerico.param(obj);
		
		var redirect=window.location.protocol+"//"+window.location.hostname+"/"+url+"?"+querystring;
		
		$jQGenerico(location).attr("href",redirect);
	});
});

	
	
function doneResizing()
	{		
  	if(typeof PiedeFisso == "function")
		{
		PiedeFisso();
		}
	if(typeof resizeFormBox == "function")
		{
		resizeFormBox();
		}
	if(typeof resizeScreen == "function")
		{	
		resizeScreen();
		}
	}
	
	
function resizeScreen()
	{			
	var risoluzionedimensione_prima=$jQGenerico("#risoluzioneschermo #risoluzionedimensione").html().split(" × ");
	var detectmobile_prima=$jQGenerico("#risoluzioneschermo #detectmobile").html();
	
	$jQGenerico.post("https://www.dibrizzi.eu/intestazione_css.php", { azione: "resizescreen", windowwidth: $jQGenerico(window).width(), windowheight: $jQGenerico(window).height() }, function(response) {
		
		$jQGenerico("#risoluzioneschermo #risoluzionedimensione").html($jQGenerico(window).width()+" × "+$jQGenerico(window).height());
		$jQGenerico("#risoluzioneschermo #detectmobile").html(response);
		
		var risoluzionedimensione_dopo=$jQGenerico("#risoluzioneschermo #risoluzionedimensione").html().split(" × ");
		var detectmobile_dopo=$jQGenerico("#risoluzioneschermo #detectmobile").html();
		
		if(detectmobile_prima!="" && detectmobile_prima!=detectmobile_dopo)
			{
			location.reload();			
			}
	});		    
	}
	
	
function ShowWindow(win)
	{
	$jQGenerico(win+"_sfondo").fadeIn(1000);
	$jQGenerico(win).fadeIn(1000);	
	}
	

function HideWindow(win)
	{
	$jQGenerico(win+"_sfondo").fadeOut(1000);			
	$jQGenerico(win).fadeOut(1000);
	} 


function shareFacebook(url,titolo) 
	{
	window.open("http://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(url),"sharer","toolbar=0,status=0,width=626,height=436");
	}	


function shareTwitter(url,titolo) 
	{
	window.open("https://twitter.com/intent/tweet?url="+encodeURIComponent(url),"sharer","toolbar=0,status=0,width=626,height=436");
	}	
	

function shareWhatsapp(url,titolo) 
	{
	window.open("https://api.whatsapp.com/send?phone=&text="+encodeURIComponent(url)+"%0A%0A"+titolo,"sharer","toolbar=0,status=0,width=650,height=660");
	}
	
	
function shareMessenger(url) 
	{			
	window.open("https://www.facebook.com/dialog/send?app_id=767547120467610&link="+encodeURIComponent(url)+"&redirect_uri="+encodeURIComponent(url)+"&display=popup","sharer","toolbar=0,status=0,width=626,height=436");
	}


function shareTelegram(url,titolo) 
	{
	window.open("https://t.me/share?url="+encodeURIComponent(url)+"&text="+titolo,"sharer","toolbar=0,status=0,width=626,height=436");
	}		


function copyUrl(url,questo)
	{			
	var sampleTextarea = document.createElement("textarea");
	
	document.body.appendChild(sampleTextarea);
	sampleTextarea.value = url; //save main text in it
	sampleTextarea.select(); //select textarea contenrs
	document.execCommand("copy");
	document.body.removeChild(sampleTextarea);
	
	
	questo.after("<div class=\"confermacopyurl\">Link copiato negli appunti</div>");
	setTimeout(function(){
	  		$jQGenerico(".confermacopyurl").remove();
	  	},3000);
	}

/* FINE JQUERY GENERICO */



/* INIZIO GENERA PASSWORD CASUALE */
/* num lowercase, num uppercase, num number, num special char */
function PasswordGenerate(numLc, numUc, numDigits, numSpecial) 
	{
	numLc = numLc || 2;
	numUc = numUc || 2;
	numDigits = numDigits || 2;
	numSpecial = numSpecial || 2;
	
	var lcLetters = "abcdefghjkmnpqrstuvwxyz";  /* eliminati: i l o */
	var ucLetters = lcLetters.toUpperCase();
	var numbers = "123456789"; /* eliminati: 0 */
	var special = "!£$%()?^*§°ç@#[]{}+-_=";
	
	var getRand = function(values) 
		{
		return values.charAt(Math.floor(Math.random() * values.length));
		}
	
	/* Jonas Raoni Soares Silva jsfromhell.com/array/shuffle v1.0 */
	function shuffle(o)
		{
		for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
		return o;
		};
		
	var pass = [];
	for(var i = 0; i < numLc; ++i) { pass.push(getRand(lcLetters)); }
	for(var i = 0; i < numUc; ++i) { pass.push(getRand(ucLetters)); }
	for(var i = 0; i < numDigits; ++i) { pass.push(getRand(numbers)); }
	for(var i = 0; i < numSpecial; ++i) { pass.push(getRand(special)); }
	
	return shuffle(pass).join("");
	}
/* FINE GENERA PASSWORD CASUALE */