function inviaFormRicercaCatalogo(ref_from){
	if(ref_from!=null){
		try{ref_from.idParent0.value=ref_from.categoriaRicerca.value;}catch(err){}
		try{ref_from.categoria.value=ref_from.categoriaRicerca.value;}catch(err){}
// Se il valore nel campo ricerca � diverso da "Cerca Prodotto" allora passa effettivamente la parola da cercare inserita dall'utente
// Controlla anche che esista nomeRicerca
		try{
			if(ref_from.nomeRicerca!=null&ref_from.nomeRicerca.value!="Cerca Prodotto")
				ref_from.nome.value=ref_from.nomeRicerca.value;
		}catch(err){}
		
		try{ref_from.dittaProduttrice.value=ref_from.dittaProduttriceSelect.value;}catch(err){}
	}
}
function inviaFormRicercaCatalogoRewrite(ref_from){
	if(ref_from!=null){
		var url = '/catalogo';
		if(ref_from.categoriaRicerca.value!=''){
			var idCat = ref_from.categoriaRicerca.value;
			url+='/c/'+idCat+'/csrc/'+idCat+'/'+ref_from.categoriaRicerca[ref_from.categoriaRicerca.selectedIndex].text;
			
		}
		if(ref_from.dittaProduttriceSelect.value!='')
			url+='/dit/'+ref_from.dittaProduttriceSelect.value;
		if(ref_from.nomeRicerca.value!='')
			url+='/no/'+ref_from.nomeRicerca.value;
		url+='.html';
	//	alert(url);
		ref_from.idParent0.disabled=true;
		ref_from.categoriaRicerca.disabled=true;;
		ref_from.categoria.disabled=true;
		ref_from.categoriaRicerca.disabled=true;;
		ref_from.nome.disabled=true;
		ref_from.nomeRicerca.disabled=true;;
		ref_from.dittaProduttrice.disabled=true;
		ref_from.dittaProduttriceSelect.disabled=true;;
		ref_from.action=url;
	}
}
function cambiaOrdinamento(selectSorgente){
	 tendino = selectSorgente;
	 valore = "";
	 
	if(tendino!=null){
		valore =tendino.value;
	}
	
	 urlToGo = '/ChangeOrdinamentoCatalogo.do?'+document.getElementById('requestParams').value+'&ordinamentoProdottiSelect='+valore;
	document.location=urlToGo;
	
	
}
function cambiaNumeroProdotti(selectSorgente){
	 tendino = selectSorgente;
	 valore = "";
	 
	if(tendino!=null){
		valore =tendino.value;
	}
	
	 urlToGo = '/UpdateNumeroProdottiCatalogo.do?'+document.getElementById('numProd-requestParams').value+'&numeroProdottiSelect='+valore;
	document.location=urlToGo;
	
	
}
function inoltraOrdine(msg){
	return inoltraOrdine(msg,true);
}
function inoltraOrdine(msg,mostroConfirm){
	return inoltraOrdine(msg,mostroConfirm,false);
}
function inoltraOrdine(msg,mostroConfirm,mostraWaitMask, areServletPagamentoSecondarie){
	var formInoltro = document.getElementById('InoltraOrdine');
	
	var accettoCondizioniVendita = document.getElementById('accettoCondizioniVendita');
	var accettoCondizioniPrivacy = document.getElementById('accettoCondizioniPrivacy');
	
	var continua = true;
	
	
	
	realjq=recuperaJquery($);
	if(realjq==null)
		realjq=recuperaJquery(Jq);
	
	
	
	var msgErrore = 'Attenzione!\nPer procedere con l\'ordine occorre accettare le condizioni di vendita e dare il consenso al trattamento dei dati.'; 
	
	if(accettoCondizioniVendita!=null){
		if(accettoCondizioniVendita.checked==false){
			continua = false;
			accettoCondizioniVendita.style.borderStyle = 'solid';
			accettoCondizioniVendita.style.borderWidth = '3px';
			accettoCondizioniVendita.style.borderColor = '#cc0000';
			alert(msgErrore);
		}else{
			accettoCondizioniVendita.style.borderWidth = '0';
		}
	}
	if(continua&&accettoCondizioniPrivacy!=null){
		if(accettoCondizioniPrivacy.checked==false){
			continua = false;
			accettoCondizioniPrivacy.style.borderStyle = 'solid';
			accettoCondizioniPrivacy.style.borderWidth = '3px';
			accettoCondizioniPrivacy.style.borderColor = '#cc0000';
			alert(msgErrore);
		}else{
			accettoCondizioniPrivacy.style.borderWidth = '0';
		}
		
	}
	
	if(continua){
		var tastoInoltroOrdine = document.getElementById('tastoInoltroOrdine');
		var tastoInoltroOrdine2 = document.getElementById('tastoInoltroOrdine2');
		var tastoCaricamentoOrdine = document.getElementById('tastoCaricamentoOrdine');
		var immagineCaricamentoOrdine = document.getElementById('immagineCaricamentoOrdine');
		
		var maskLoading = document.getElementById('dialog-mask-ordine');
		var msgLoading = document.getElementById('loading-ordine');
		
		if(formInoltro!=null){
			continuo = false;
			if(mostroConfirm!=null&&mostroConfirm==false){
				continuo = true;
			}else{
				continuo = confirm(msg);
			}
			
			if(continuo){
				if(mostraWaitMask){
					if(maskLoading!=null&&msgLoading!=null){
						maskLoading.style.display='block';
						msgLoading.style.display='block';
					}
				}
				
				
				
				if(tastoInoltroOrdine!=null){
					realjq('#'+tastoInoltroOrdine.id).addClass("disabled");
					realjq('#'+tastoInoltroOrdine.id).prop('disabled', true);
					realjq('#'+tastoInoltroOrdine.id).attr('disabled', true);
				}
				if(tastoInoltroOrdine2!=null)
					tastoInoltroOrdine2.style.display='none';
				if(tastoCaricamentoOrdine!=null)
					tastoCaricamentoOrdine.style.display='';
				if(immagineCaricamentoOrdine!=null)
					immagineCaricamentoOrdine.style.display='';
					
				// note ordine
				var testo = document.getElementById("notaOrdine");
			    if(testo!=null){
				    var valoreTesto=testo.value;
				    if(valoreTesto!=null&&(valoreTesto.replace(/\s/g,"") != "")){
				    	var nof = document.getElementById("notaOrdineForm");
				    	if(nof!=null){
				    		nof.value=(valoreTesto);
				    	}
				    }
			    }
			    
			    // note spedizione
			    var testo = document.getElementById("notaSpedizione");
			    if(testo!=null){
				    var valoreTesto=testo.value;
				    if(valoreTesto!=null&&(valoreTesto.replace(/\s/g,"") != "")){
				    	var nsf = document.getElementById("notaSpedizioneForm");
				    	if(nsf!=null){
				    		nsf.value=(valoreTesto);
				    	}
				    }
			    }
			    
			    // flag per il consenso al salvataggio dei dati della carta di credito
				var valoreFlag = document.getElementById("flagSalvaDatiCarta");
			    if(valoreFlag!=null){
				    var valorePerForm=valoreFlag.value;
				    if(valorePerForm!=null){
				    	var flagForm = document.getElementById("flagSalvaDatiCartaForm");
				    	if(flagForm!=null){
				    		flagForm.value=(valorePerForm);
				    	}
				    }
			    }
			    
			    var valoreFlag2 = document.getElementById("flagSalvaDatiCartaSoloCliente");
			    if(valoreFlag2!=null){
				    var valorePerForm=valoreFlag2.value;
				    if(valorePerForm!=null){
				    	var flagForm = document.getElementById("flagSalvaDatiCartaSoloClienteForm");
				    	if(flagForm!=null){
				    		flagForm.value=(valorePerForm);
				    	}
				    }
			    }
			    
			    
			/*	
			vecchia gestione newsletter
			var newsletterAttivaForm = document.getElementById("newsletterAttivaForm");
				var newsletterAttiva = document.getElementById("newsletterAttiva");
				if(newsletterAttiva!=null&&newsletterAttivaForm!=null){
				newsletterAttivaForm.checked =newsletterAttiva.checked; 
				}*/
				
				var partecipaValutazioneForm = document.getElementById("partecipaValutazioneForm");
				var partecipaValutazione = document.getElementById("partecipaValutazione");
				if(partecipaValutazione != null && partecipaValutazioneForm != null){
					partecipaValutazioneForm.checked = partecipaValutazione.checked;
				}
				
				var areServletPagamentoSecondarieInput = document.getElementById("areServletPagamentoSecondarie");
				
				if (areServletPagamentoSecondarie != undefined && areServletPagamentoSecondarie == true && areServletPagamentoSecondarieInput != null && areServletPagamentoSecondarieInput != undefined){
					
					document.getElementById("areServletPagamentoSecondarie").value = 'true';
				}
								
				realjq(".btn.btn-procedi.btn-acquista").addClass("disabled");
				realjq(".btn.btn-procedi.btn-acquista").prop('disabled', true);
				realjq(".btn.btn-procedi.btn-acquista").attr('disabled', true);
				
				formInoltro.submit();
			}
				
		}
	}
	return false;
}
function copyCheck(targetId,check){
	var elC = document.getElementById(targetId);
	if(elC!=null){
		elC.checked = check;
	}
}
function scopriDiv(idElemento){
	var idElemento = document.getElementById(idElemento);
	if(idElemento!=null){
		if(idElemento.style.display=='none')
			idElemento.style.display = '';
		else
			idElemento.style.display = 'none';
	}
}
function inviaForm(idForm,msg){
	var formInoltro = document.getElementById(idForm);
	if(formInoltro!=null){
		if(confirm(msg))
			formInoltro.submit();
	}
}
function nascondi(id){
	var elemento=document.getElementById(id);
	 if(elemento!=null){
		 elemento.style.display='none';
		 elemento.style.visibility='hidden';
	 }
}
function mostra(id){
	var elemento=document.getElementById(id);
	 if(elemento!=null){
		 elemento.style.display='';
		 elemento.style.visibility='';
	 }
}
function mostraNota(){
	mostra('nota');
	nascondi('tastoMostraNota');
	mostra('tastoChiudiNota');
	nascondi('TestoScritto');
}
function chiudiNota(){
	nascondi('nota');
	mostra('tastoMostraNota');
	var testo = document.getElementById("nota");
	    if(testo!=null){
	    var valoreTesto=testo.value;
	    if(valoreTesto!=null&&(valoreTesto.replace(/\s/g,"") != "")){
	    	var x=document.getElementById("TestoScritto");
	    	if(x!=null){
	    		x.innerHTML=encodeMyHtml(valoreTesto);
	    		mostra('TestoScritto');
	    	}
	    }
	    }
	nascondi('tastoChiudiNota');
}
function encodeMyHtml(stringa) {
	if(stringa==null)
		return "";
    encodedHtml = stringa;
     encodedHtml= encodedHtml.replace(/&/g, "&");
     encodedHtml= encodedHtml.replace(//g, ">");
    return encodedHtml;
  } 
function PopupCentrata(nomeFile,nomefinestra,wid,heigh,resiz,scroll) {
	   var w = wid;
	   var h = heigh;
	   var l = Math.floor((screen.width-w)/2);
	   var t = Math.floor((screen.height-h)/2);
	   if(nomefinestra!=null)
		   nomefinestra=nomefinestra.replace(/ /g, "");
	     pop =  window.open(nomeFile,nomefinestra,"width=" + w + ",height=" + h + ",top=" + t + ",left=" + l+",resizable="+resiz+",scrollbars="+scroll);
	     pop.focus();
	}
function recuperaJquery(o) {
    if (o.fn) {
       return o;
    }
    return null;
}
function caricaDisponibilita(dataIniziale,dataFinale){
	divContenutoDisponibilita = 'disponibilita_contenuto';
	divCaricamento = 'disponibilita_loading';
	divErrore = 'disponibilita_errore';
	realjq=recuperaJquery($);
	if(realjq==null)
		realjq=recuperaJquery(Jq);
	
	realjq('#'+divErrore).hide();
	realjq('#'+divContenutoDisponibilita).hide();
	realjq('#'+divCaricamento).show();
	
	var qs='dataIniziale='+dataIniziale+'&dataFinale='+dataFinale; 
	realjq.ajax  
	   ({  
	   type: "POST",  
	   url: "/include/responsive/disponibilita/logicaDisponibilita.jsp",  
	   data: qs,  
	   dataType: "html",
	   cache: false,  
	   success: function(htmlContent)  
	   {  
			if(htmlContent!=null){
				realjq('#'+divContenutoDisponibilita).html(htmlContent);
				realjq('#'+divCaricamento).hide();
				realjq('#'+divContenutoDisponibilita).show();
			}else{
				realjq('#'+divContenutoDisponibilita).html('');
				realjq('#'+divCaricamento).hide();
				realjq('#'+divContenutoDisponibilita).hide();
				realjq('#'+divErrore).show();
			}
	   },
	   error: function(htmlContent)  
	   {  
		    realjq('#'+divContenutoDisponibilita).html('');
			realjq('#'+divCaricamento).hide();
			realjq('#'+divContenutoDisponibilita).hide();
			realjq('#'+divErrore).show();
	   }
	   }); //FINE CHIAMATA AJAX  
}
function setSceltaDisponibilita(prefisso,id_div,data,ora,risorsa,servizio){
	divErrore = 'disponibilita_radio_errore';
	divOk = 'disponibilita_radio_errore';
	divCaricamento = 'disponibilita_radio_loading_'+id_div;
	classeCssFasciaSelezionata='spedSelezionata';
	prosegui='bottone_prosegui';
	realjq=recuperaJquery($);
	if(realjq==null)
		realjq=recuperaJquery(Jq);
	//nascondo il tasto prosegui
	realjq('#'+prosegui).hide();
	//rimuovo tutte le classi di selezione
	realjq('tr[id^="'+prefisso+'"]').removeClass(classeCssFasciaSelezionata);
	//nascondo l'eventuale errore
	realjq('#'+divErrore).hide();
	//nascondo l'eventuale OK
	realjq('#'+divOk).hide();
	//mostro il loader
	realjq('#'+divCaricamento).show();
	
	var qs='data='+data+'&ora='+ora+'&risorsa='+risorsa+'&servizio='+servizio; 
	realjq.ajax  
	   ({  
	   type: "POST",  
	   url: "/UpdateDatiPrenotazioneRisorsa.do",
	   data: qs,  
	   dataType: "xml",
	   cache: false,  
	   success: function(xml)  
	   {  
			if(xml!=null){
				try{
				 realjqxml = realjq( xml );
				 esito = realjqxml.find( "esito" );
				 esito = realjq( esito ).text();
				 
				//nascondo il loader
				realjq('#'+divCaricamento).hide();
				if(esito=='1'){
				//mostro l'eventuale OK
				realjq('#'+divOk).show();
				//mostro il tasto prosegui
				realjq('#'+prosegui).show();
				//metto la classe css
				realjq('#'+prefisso+id_div).addClass(classeCssFasciaSelezionata);
				}else{
					realjq('#'+divErrore).show();
					realjq('#'+prosegui).hide();
				}
				}catch(err){
					//nascondo il loader
					realjq('#'+divCaricamento).hide();
					realjq('#'+prosegui).hide();
					//mostro l'eventuale errore
					realjq('#'+divErrore).show();
				}
			}else{
				//nascondo il loader
				realjq('#'+divCaricamento).hide();
				//mostro l'eventuale errore
				realjq('#'+divErrore).show();
				realjq('#'+prosegui).hide();
			}
	   },
	   error: function(xml)  
	   {  
		 //nascondo il loader
			realjq('#'+divCaricamento).hide();
			//mostro l'eventuale OK
			realjq('#'+divErrore).show();
			realjq('#'+prosegui).hide();
	   }
	   }); //FINE CHIAMATA AJAX  
}
function caricaPuntiVendita(stepDistanza){
	divContenutoPuntiVendita = 'punti_vendita_contenuto';
	divPuntiVendita = 'punti_vendita_loading';
	divErrore = 'punti_vendita_errore';
	realjq=recuperaJquery($);
	if(realjq==null)
		realjq=recuperaJquery(Jq);
	
	realjq('#'+divErrore).hide();
	realjq('#'+divContenutoPuntiVendita).hide();
	realjq('#'+divPuntiVendita).show();
	
	var qs='stepDistanza='+stepDistanza; 
	realjq.ajax  
	   ({  
	   type: "POST",  
	   url: "/include/responsive/puntiVendita/logicaPuntoVendita.jsp",  
	   data: qs,  
	   dataType: "html",
	   cache: false,  
	   success: function(htmlContent)  
	   {  
			if(htmlContent!=null){
				realjq('#'+divContenutoPuntiVendita).html(htmlContent);
				realjq('#'+divPuntiVendita).hide();
				realjq('#'+divContenutoPuntiVendita).show();
			}else{
				realjq('#'+divContenutoPuntiVendita).html('');
				realjq('#'+divPuntiVendita).hide();
				realjq('#'+divContenutoPuntiVendita).hide();
				realjq('#'+divErrore).show();
			}
	   },
	   error: function(htmlContent)  
	   {  
		    realjq('#'+divContenutoPuntiVendita).html('');
			realjq('#'+divPuntiVendita).hide();
			realjq('#'+divContenutoPuntiVendita).hide();
			realjq('#'+divErrore).show();
			
	   }
	   }); //FINE CHIAMATA AJAX  
}
function setSceltaPuntoVenditaVoid(prefisso,id_div,id_pdv,iniziale){
	realjq=recuperaJquery($);
	if(realjq==null)
		realjq=recuperaJquery(Jq);
	prosegui='bottone_prosegui';
	var qs="id="+id_pdv+"&soloSet=true"; 
	realjq.ajax  
	   ({  
	   type: "POST",  
	   url: "/UpdateDatiRitiroPuntoVendita.do",
	   data: qs,  
	   dataType: "xml",
	   cache: false,  
	   success: function(xml){
		   realjq('#'+prosegui).show();
	   },
	   error: function(xml)  
	   {  
		   realjq('#'+prosegui).show();
	   }
	   }); //FINE CHIAMATA AJAX  
}
		
function setSceltaPuntoVendita(prefisso,id_div,id_pdv,iniziale){
	
	var funzioneDopoSuccesso = function(datiExtra) {
	    return function(xml) {
	    	if(xml!=null){
				try{
				 realjqxml = realjq( xml );
				 esito = realjqxml.find( "esito" );
				 descrizione = realjqxml.find( "descrizione" );
				 esito = realjq( esito ).text();
				 if(datiExtra.iniziale){
						//nascondo il tasto prosegui
						realjq('#'+datiExtra.inputRadio).show();
					}
				//nascondo il loader
				realjq('#'+datiExtra.divCaricamento).hide();
				if(esito=='1'){
				//mostro l'eventuale OK
				realjq('#'+datiExtra.divOk).show();
				//mostro il tasto prosegui
				 if(!datiExtra.iniziale){
					 realjq('#'+datiExtra.prosegui).show();
				 }
				//metto la classe css
				realjq('#'+datiExtra.prefisso+datiExtra.id_div).addClass(datiExtra.classeCssFasciaSelezionata);
				
				//modifico l'onclick
				 try{
				 te = realjq('#'+datiExtra.inputRadio).attr('onclick');
				 te = te.replace('setSceltaPuntoVendita(','setSceltaPuntoVenditaVoid(');
				 realjq('#'+datiExtra.inputRadio).attr('onclick',te);
				 te = realjq('#'+datiExtra.inputRadio).attr('onclick');
				 }catch(err){}
				
				}else{
					title = realjq(descrizione).html().replace("", "");
					//controllo se ci sono mancanti
					tot='';
					mancanti = realjqxml.find( "prodotto" );
						 realjq.each(mancanti , function() {
							 tot+=formattaProdottoMancante(realjq,this);
				
						});
					if(tot!=null&&tot!=''){
						title+="
 ")
								 te=realjq(te).prev();
								 te =realjq(te).find('input[id^="punto_vendita_radio_"]')
								 te = realjq(te).attr('onclick');
								 eval(te);
							 }
						}else{
							realjq('#li_'+idProdotto).html('Impossibile eliminare il prodotto');
						}
				   }catch(err){
					   realjq('#li_'+idProdotto).html('Impossibile eliminare il prodotto');
				   }
			   }else{
				   realjq('#li_'+idProdotto).html('Impossibile eliminare il prodotto');
			   }
		   },
		   error: function(xml)  
		   {  
			 //nascondo il loader
			   realjq('#li_'+idProdotto).html('Impossibile eliminare il prodotto');
		   }
		   });
	}
}
function scegliSpedizione(nome,perRitiro){
	if(perRitiro==null||(perRitiro!=true&&perRitiro!='true')){
		document.getElementById('stepDistanza').value='0';
	}
	document.getElementById(nome).submit();
}
function goToPaginaPagamento(nomeForm){
	var formSpediziome = document.getElementById(nomeForm);
	if(formSpediziome!=null){
		formSpediziome.action='/GoToModalitaPagamentoCarrello.do';
		formSpediziome.submit();
	}
}
//(titolo,testo,tipoPopup,classePopup, idOrdine)
function inoltraOrdineMobileWithSwal(titolo,testo,tipoPopup,classePopup, idOrdine,mostroConfirm,mostraWaitMask, areServletPagamentoSecondarie){
	realjq=recuperaJquery($);
	if(realjq==null)
		realjq=recuperaJquery(Jq);
	var formInoltro = document.getElementById('InoltraOrdine');
	
	var accettoCondizioniVendita = document.getElementById('accettoCondizioniVendita');
	var accettoCondizioniPrivacy = document.getElementById('accettoCondizioniPrivacy');
	var continua = true;
	
	
	
	var msgErrore = 'Per procedere con l\'ordine occorre accettare le condizioni di vendita e dare il consenso al trattamento dei dati.'; 
	
	if(accettoCondizioniVendita!=null){
		if(accettoCondizioniVendita.checked==false){
			continua = false;
			accettoCondizioniVendita.style.borderStyle = 'solid';
			accettoCondizioniVendita.style.borderWidth = '3px';
			accettoCondizioniVendita.style.borderColor = '#cc0000';
			msgErrore = 'Per procedere con l\'ordine occorre accettare le condizioni di vendita.'; 
			Swal.fire({  title: 'Attenzione', text: msgErrore, type: 'error',  confirmButtonText: 'Ok',buttonsStyling: false,	customClass: classePopup,focusConfirm:false,onBeforeOpen: () => {Jq(".swal2-confirm").blur()},onOpen: () => {Jq(".swal2-confirm").blur()},onClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();},onAfterClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();}	}).then((result) => {Jq("#tastoInoltroOrdine").children("button").blur();});
		}else{
			accettoCondizioniVendita.style.borderWidth = '0';
		}
	}
	if(continua&&accettoCondizioniPrivacy!=null){
		if(accettoCondizioniPrivacy.checked==false){
			continua = false;
			accettoCondizioniPrivacy.style.borderStyle = 'solid';
			accettoCondizioniPrivacy.style.borderWidth = '3px';
			accettoCondizioniPrivacy.style.borderColor = '#cc0000';
			msgErrore = 'Per procedere con l\'ordine occorre accettare prestare il consenso al trattamento dei dati.'; 
			Swal.fire({  title: 'Attenzione', text: msgErrore, type: 'error',  confirmButtonText: 'Ok',buttonsStyling: false,	customClass: classePopup,focusConfirm:false,onBeforeOpen: () => {Jq(".swal2-confirm").blur()},onOpen: () => {Jq(".swal2-confirm").blur()},onClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();},onAfterClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();}	}).then((result) => {Jq("#tastoInoltroOrdine").children("button").blur();});
		}else{
			accettoCondizioniPrivacy.style.borderWidth = '0';
		}
		
	}
	
	if(continua){
		var tastoInoltroOrdine = document.getElementById('tastoInoltroOrdine');
		var tastoInoltroOrdine2 = document.getElementById('tastoInoltroOrdine2');
		var tastoCaricamentoOrdine = document.getElementById('tastoCaricamentoOrdine');
		var immagineCaricamentoOrdine = document.getElementById('immagineCaricamentoOrdine');
		
		var maskLoading = document.getElementById('dialog-mask-ordine');
		var msgLoading = document.getElementById('loading-ordine');
		
		if(formInoltro!=null){
			continuo = false;
			if(mostroConfirm!=null&&mostroConfirm==false){
				if(mostraWaitMask){
								if(maskLoading!=null&&msgLoading!=null){
									maskLoading.style.display='block';
									msgLoading.style.display='block';
								}
							}
							
							if(tastoInoltroOrdine!=null)
								tastoInoltroOrdine.style.display='none';
							if(tastoInoltroOrdine2!=null)
								tastoInoltroOrdine2.style.display='none';
							if(tastoCaricamentoOrdine!=null)
								tastoCaricamentoOrdine.style.display='';
							if(immagineCaricamentoOrdine!=null)
								immagineCaricamentoOrdine.style.display='';
								
							// note ordine
							var testo = document.getElementById("notaOrdine");
						    if(testo!=null){
							    var valoreTesto=testo.value;
							    if(valoreTesto!=null&&(valoreTesto.replace(/\s/g,"") != "")){
							    	var nof = document.getElementById("notaOrdineForm");
							    	if(nof!=null){
							    		nof.value=(valoreTesto);
							    	}
							    }
						    }
						    
						    // note spedizione
						    var testo = document.getElementById("notaSpedizione");
						    if(testo!=null){
							    var valoreTesto=testo.value;
							    if(valoreTesto!=null&&(valoreTesto.replace(/\s/g,"") != "")){
							    	var nsf = document.getElementById("notaSpedizioneForm");
							    	if(nsf!=null){
							    		nsf.value=(valoreTesto);
							    	}
							    }
						    }
						    
						     // flag per il consenso al salvataggio dei dati della carta di credito
							var valoreFlag = document.getElementById("flagSalvaDatiCarta");
						    if(valoreFlag!=null){
							    var valorePerForm=valoreFlag.value;
							    if(valorePerForm!=null){
							    	var flagForm = document.getElementById("flagSalvaDatiCartaForm");
							    	if(flagForm!=null){
							    		flagForm.value=(valorePerForm);
							    	}
							    }
						    }
						    
						    var valoreFlag2 = document.getElementById("flagSalvaDatiCartaSoloCliente");
			   				if(valoreFlag2!=null){
				    			var valorePerForm=valoreFlag2.value;
				    			if(valorePerForm!=null){
				    				var flagForm = document.getElementById("flagSalvaDatiCartaSoloClienteForm");
				    				if(flagForm!=null){
				    					flagForm.value=(valorePerForm);
				    				}
				    			}
			    			}
									    
							
							var partecipaValutazioneForm = document.getElementById("partecipaValutazioneForm");
							var partecipaValutazione = document.getElementById("partecipaValutazione");
							if(partecipaValutazione != null && partecipaValutazioneForm != null){
								partecipaValutazioneForm.checked = partecipaValutazione.checked;
							}
							
							formInoltro.submit();
						
			}else{
				Swal.fire({
				  title: titolo,
				  text: testo,
				   type: tipoPopup,
				   	reverseButtons: true,
			  		focusConfirm: false,
			  		showCancelButton: true,
			  		cancelButtonText: 'Annulla',
			  		buttonsStyling: false,
			  		customClass: classePopup,
			  		focusConfirm:false,
			  		onBeforeOpen: () => {Jq(".swal2-confirm").blur(); Jq(".swal2-cancel").blur()},
			  		onOpen: () => {Jq(".swal2-confirm").blur(); Jq(".swal2-cancel").blur()},
			  		onClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();},
			  		onAfterClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();}
				}).then((result) => {
				document.activeElement.blur();
				  if (result.value) {
				  
							if(mostraWaitMask){
								Swal.fire({
								  html:
								    'Stiamo elaborando il tuo ordine',
								  timer: 10000,
								  onBeforeOpen: () => {
								    Swal.showLoading()
								
								  }
								})
							}
							
							if(tastoInoltroOrdine!=null){
								realjq('#'+tastoInoltroOrdine.id).addClass("disabled");
								realjq('#'+tastoInoltroOrdine.id).prop('disabled', true);
								realjq('#'+tastoInoltroOrdine.id).attr('disabled', true);
							}
							if(tastoInoltroOrdine2!=null)
								tastoInoltroOrdine2.style.display='none';
							if(tastoCaricamentoOrdine!=null)
								tastoCaricamentoOrdine.style.display='';
							if(immagineCaricamentoOrdine!=null)
								immagineCaricamentoOrdine.style.display='';
								
							// note ordine
							var testo = document.getElementById("notaOrdine");
						    if(testo!=null){
							    var valoreTesto=testo.value;
							    if(valoreTesto!=null&&(valoreTesto.replace(/\s/g,"") != "")){
							    	var nof = document.getElementById("notaOrdineForm");
							    	if(nof!=null){
							    		nof.value=(valoreTesto);
							    	}
							    }
						    }
						    
						    // note spedizione
						    var testo = document.getElementById("notaSpedizione");
						    if(testo!=null){
							    var valoreTesto=testo.value;
							    if(valoreTesto!=null&&(valoreTesto.replace(/\s/g,"") != "")){
							    	var nsf = document.getElementById("notaSpedizioneForm");
							    	if(nsf!=null){
							    		nsf.value=(valoreTesto);
							    	}
							    }
						    }
						    
						    // flag per il consenso al salvataggio dei dati della carta di credito
							var valoreFlag = document.getElementById("flagSalvaDatiCarta");
						    if(valoreFlag!=null){
							    var valorePerForm=valoreFlag.value;
							    if(valorePerForm!=null){
							    	var flagForm = document.getElementById("flagSalvaDatiCartaForm");
							    	if(flagForm!=null){
							    		flagForm.value=(valorePerForm);
							    	}
							    }
						    }
						    
						    var valoreFlag2 = document.getElementById("flagSalvaDatiCartaSoloCliente");
			    			if(valoreFlag2!=null){
				 				var valorePerForm=valoreFlag2.value;
				   				if(valorePerForm!=null){
				    				var flagForm = document.getElementById("flagSalvaDatiCartaSoloClienteForm");
				    				if(flagForm!=null){
				    					flagForm.value=(valorePerForm);
				    				}
				   				}
			   				}
						    
							
							var partecipaValutazioneForm = document.getElementById("partecipaValutazioneForm");
							var partecipaValutazione = document.getElementById("partecipaValutazione");
							if(partecipaValutazione != null && partecipaValutazioneForm != null){
								partecipaValutazioneForm.checked = partecipaValutazione.checked;
							}
							
							var areServletPagamentoSecondarieInput = document.getElementById("areServletPagamentoSecondarie");
				
							if (areServletPagamentoSecondarie != undefined && areServletPagamentoSecondarie == true && areServletPagamentoSecondarieInput != null && areServletPagamentoSecondarieInput != undefined){
					
								document.getElementById("areServletPagamentoSecondarie").value = 'true';
							}
							
								
							realjq(".btn.btn-procedi.btn-acquista").addClass("disabled");
							realjq(".btn.btn-procedi.btn-acquista").prop('disabled', true);
							realjq(".btn.btn-procedi.btn-acquista").attr('disabled', true);
							
							formInoltro.submit();
							
					  }
				})
				
			}
			
			
				
		}
	}
	return false;
}
function vaiAUrl(url){
	try{
		if(url){
			document.location.href=(url);
		}
	}catch(e){
		console.log("URL errato")
	}
}
")
								 te=realjq(te).prev();
								 te =realjq(te).find('input[id^="punto_vendita_radio_"]')
								 te = realjq(te).attr('onclick');
								 eval(te);
							 }
						}else{
							realjq('#li_'+idProdotto).html('Impossibile eliminare il prodotto');
						}
				   }catch(err){
					   realjq('#li_'+idProdotto).html('Impossibile eliminare il prodotto');
				   }
			   }else{
				   realjq('#li_'+idProdotto).html('Impossibile eliminare il prodotto');
			   }
		   },
		   error: function(xml)  
		   {  
			 //nascondo il loader
			   realjq('#li_'+idProdotto).html('Impossibile eliminare il prodotto');
		   }
		   });
	}
}
function scegliSpedizione(nome,perRitiro){
	if(perRitiro==null||(perRitiro!=true&&perRitiro!='true')){
		document.getElementById('stepDistanza').value='0';
	}
	document.getElementById(nome).submit();
}
function goToPaginaPagamento(nomeForm){
	var formSpediziome = document.getElementById(nomeForm);
	if(formSpediziome!=null){
		formSpediziome.action='/GoToModalitaPagamentoCarrello.do';
		formSpediziome.submit();
	}
}
//(titolo,testo,tipoPopup,classePopup, idOrdine)
function inoltraOrdineMobileWithSwal(titolo,testo,tipoPopup,classePopup, idOrdine,mostroConfirm,mostraWaitMask, areServletPagamentoSecondarie){
	realjq=recuperaJquery($);
	if(realjq==null)
		realjq=recuperaJquery(Jq);
	var formInoltro = document.getElementById('InoltraOrdine');
	
	var accettoCondizioniVendita = document.getElementById('accettoCondizioniVendita');
	var accettoCondizioniPrivacy = document.getElementById('accettoCondizioniPrivacy');
	var continua = true;
	
	
	
	var msgErrore = 'Per procedere con l\'ordine occorre accettare le condizioni di vendita e dare il consenso al trattamento dei dati.'; 
	
	if(accettoCondizioniVendita!=null){
		if(accettoCondizioniVendita.checked==false){
			continua = false;
			accettoCondizioniVendita.style.borderStyle = 'solid';
			accettoCondizioniVendita.style.borderWidth = '3px';
			accettoCondizioniVendita.style.borderColor = '#cc0000';
			msgErrore = 'Per procedere con l\'ordine occorre accettare le condizioni di vendita.'; 
			Swal.fire({  title: 'Attenzione', text: msgErrore, type: 'error',  confirmButtonText: 'Ok',buttonsStyling: false,	customClass: classePopup,focusConfirm:false,onBeforeOpen: () => {Jq(".swal2-confirm").blur()},onOpen: () => {Jq(".swal2-confirm").blur()},onClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();},onAfterClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();}	}).then((result) => {Jq("#tastoInoltroOrdine").children("button").blur();});
		}else{
			accettoCondizioniVendita.style.borderWidth = '0';
		}
	}
	if(continua&&accettoCondizioniPrivacy!=null){
		if(accettoCondizioniPrivacy.checked==false){
			continua = false;
			accettoCondizioniPrivacy.style.borderStyle = 'solid';
			accettoCondizioniPrivacy.style.borderWidth = '3px';
			accettoCondizioniPrivacy.style.borderColor = '#cc0000';
			msgErrore = 'Per procedere con l\'ordine occorre accettare prestare il consenso al trattamento dei dati.'; 
			Swal.fire({  title: 'Attenzione', text: msgErrore, type: 'error',  confirmButtonText: 'Ok',buttonsStyling: false,	customClass: classePopup,focusConfirm:false,onBeforeOpen: () => {Jq(".swal2-confirm").blur()},onOpen: () => {Jq(".swal2-confirm").blur()},onClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();},onAfterClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();}	}).then((result) => {Jq("#tastoInoltroOrdine").children("button").blur();});
		}else{
			accettoCondizioniPrivacy.style.borderWidth = '0';
		}
		
	}
	
	if(continua){
		var tastoInoltroOrdine = document.getElementById('tastoInoltroOrdine');
		var tastoInoltroOrdine2 = document.getElementById('tastoInoltroOrdine2');
		var tastoCaricamentoOrdine = document.getElementById('tastoCaricamentoOrdine');
		var immagineCaricamentoOrdine = document.getElementById('immagineCaricamentoOrdine');
		
		var maskLoading = document.getElementById('dialog-mask-ordine');
		var msgLoading = document.getElementById('loading-ordine');
		
		if(formInoltro!=null){
			continuo = false;
			if(mostroConfirm!=null&&mostroConfirm==false){
				if(mostraWaitMask){
								if(maskLoading!=null&&msgLoading!=null){
									maskLoading.style.display='block';
									msgLoading.style.display='block';
								}
							}
							
							if(tastoInoltroOrdine!=null)
								tastoInoltroOrdine.style.display='none';
							if(tastoInoltroOrdine2!=null)
								tastoInoltroOrdine2.style.display='none';
							if(tastoCaricamentoOrdine!=null)
								tastoCaricamentoOrdine.style.display='';
							if(immagineCaricamentoOrdine!=null)
								immagineCaricamentoOrdine.style.display='';
								
							// note ordine
							var testo = document.getElementById("notaOrdine");
						    if(testo!=null){
							    var valoreTesto=testo.value;
							    if(valoreTesto!=null&&(valoreTesto.replace(/\s/g,"") != "")){
							    	var nof = document.getElementById("notaOrdineForm");
							    	if(nof!=null){
							    		nof.value=(valoreTesto);
							    	}
							    }
						    }
						    
						    // note spedizione
						    var testo = document.getElementById("notaSpedizione");
						    if(testo!=null){
							    var valoreTesto=testo.value;
							    if(valoreTesto!=null&&(valoreTesto.replace(/\s/g,"") != "")){
							    	var nsf = document.getElementById("notaSpedizioneForm");
							    	if(nsf!=null){
							    		nsf.value=(valoreTesto);
							    	}
							    }
						    }
						    
						     // flag per il consenso al salvataggio dei dati della carta di credito
							var valoreFlag = document.getElementById("flagSalvaDatiCarta");
						    if(valoreFlag!=null){
							    var valorePerForm=valoreFlag.value;
							    if(valorePerForm!=null){
							    	var flagForm = document.getElementById("flagSalvaDatiCartaForm");
							    	if(flagForm!=null){
							    		flagForm.value=(valorePerForm);
							    	}
							    }
						    }
						    
						    var valoreFlag2 = document.getElementById("flagSalvaDatiCartaSoloCliente");
			   				if(valoreFlag2!=null){
				    			var valorePerForm=valoreFlag2.value;
				    			if(valorePerForm!=null){
				    				var flagForm = document.getElementById("flagSalvaDatiCartaSoloClienteForm");
				    				if(flagForm!=null){
				    					flagForm.value=(valorePerForm);
				    				}
				    			}
			    			}
									    
							
							var partecipaValutazioneForm = document.getElementById("partecipaValutazioneForm");
							var partecipaValutazione = document.getElementById("partecipaValutazione");
							if(partecipaValutazione != null && partecipaValutazioneForm != null){
								partecipaValutazioneForm.checked = partecipaValutazione.checked;
							}
							
							formInoltro.submit();
						
			}else{
				Swal.fire({
				  title: titolo,
				  text: testo,
				   type: tipoPopup,
				   	reverseButtons: true,
			  		focusConfirm: false,
			  		showCancelButton: true,
			  		cancelButtonText: 'Annulla',
			  		buttonsStyling: false,
			  		customClass: classePopup,
			  		focusConfirm:false,
			  		onBeforeOpen: () => {Jq(".swal2-confirm").blur(); Jq(".swal2-cancel").blur()},
			  		onOpen: () => {Jq(".swal2-confirm").blur(); Jq(".swal2-cancel").blur()},
			  		onClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();},
			  		onAfterClose: () => {Jq("#tastoInoltroOrdine").children("button").blur();}
				}).then((result) => {
				document.activeElement.blur();
				  if (result.value) {
				  
							if(mostraWaitMask){
								Swal.fire({
								  html:
								    'Stiamo elaborando il tuo ordine',
								  timer: 10000,
								  onBeforeOpen: () => {
								    Swal.showLoading()
								
								  }
								})
							}
							
							if(tastoInoltroOrdine!=null){
								realjq('#'+tastoInoltroOrdine.id).addClass("disabled");
								realjq('#'+tastoInoltroOrdine.id).prop('disabled', true);
								realjq('#'+tastoInoltroOrdine.id).attr('disabled', true);
							}
							if(tastoInoltroOrdine2!=null)
								tastoInoltroOrdine2.style.display='none';
							if(tastoCaricamentoOrdine!=null)
								tastoCaricamentoOrdine.style.display='';
							if(immagineCaricamentoOrdine!=null)
								immagineCaricamentoOrdine.style.display='';
								
							// note ordine
							var testo = document.getElementById("notaOrdine");
						    if(testo!=null){
							    var valoreTesto=testo.value;
							    if(valoreTesto!=null&&(valoreTesto.replace(/\s/g,"") != "")){
							    	var nof = document.getElementById("notaOrdineForm");
							    	if(nof!=null){
							    		nof.value=(valoreTesto);
							    	}
							    }
						    }
						    
						    // note spedizione
						    var testo = document.getElementById("notaSpedizione");
						    if(testo!=null){
							    var valoreTesto=testo.value;
							    if(valoreTesto!=null&&(valoreTesto.replace(/\s/g,"") != "")){
							    	var nsf = document.getElementById("notaSpedizioneForm");
							    	if(nsf!=null){
							    		nsf.value=(valoreTesto);
							    	}
							    }
						    }
						    
						    // flag per il consenso al salvataggio dei dati della carta di credito
							var valoreFlag = document.getElementById("flagSalvaDatiCarta");
						    if(valoreFlag!=null){
							    var valorePerForm=valoreFlag.value;
							    if(valorePerForm!=null){
							    	var flagForm = document.getElementById("flagSalvaDatiCartaForm");
							    	if(flagForm!=null){
							    		flagForm.value=(valorePerForm);
							    	}
							    }
						    }
						    
						    var valoreFlag2 = document.getElementById("flagSalvaDatiCartaSoloCliente");
			    			if(valoreFlag2!=null){
				 				var valorePerForm=valoreFlag2.value;
				   				if(valorePerForm!=null){
				    				var flagForm = document.getElementById("flagSalvaDatiCartaSoloClienteForm");
				    				if(flagForm!=null){
				    					flagForm.value=(valorePerForm);
				    				}
				   				}
			   				}
						    
							
							var partecipaValutazioneForm = document.getElementById("partecipaValutazioneForm");
							var partecipaValutazione = document.getElementById("partecipaValutazione");
							if(partecipaValutazione != null && partecipaValutazioneForm != null){
								partecipaValutazioneForm.checked = partecipaValutazione.checked;
							}
							
							var areServletPagamentoSecondarieInput = document.getElementById("areServletPagamentoSecondarie");
				
							if (areServletPagamentoSecondarie != undefined && areServletPagamentoSecondarie == true && areServletPagamentoSecondarieInput != null && areServletPagamentoSecondarieInput != undefined){
					
								document.getElementById("areServletPagamentoSecondarie").value = 'true';
							}
							
								
							realjq(".btn.btn-procedi.btn-acquista").addClass("disabled");
							realjq(".btn.btn-procedi.btn-acquista").prop('disabled', true);
							realjq(".btn.btn-procedi.btn-acquista").attr('disabled', true);
							
							formInoltro.submit();
							
					  }
				})
				
			}
			
			
				
		}
	}
	return false;
}
function vaiAUrl(url){
	try{
		if(url){
			document.location.href=(url);
		}
	}catch(e){
		console.log("URL errato")
	}
}