require( ebplatform.config.enableLoadBuilt ? ["built/dojo", "built/ebCommon", "built/iscrizione"] : [], function() { //.js.uncompressed
	require(["dojo/ready",
	 	"dojo/_base/lang",
	 	"dojo/_base/array",
		"dojo/dom",
		"dojo/dom-style",
		"dojo/dom-attr",
		"dojo/dom-prop",
		"dojo/dom-construct",
		"dojo/query",
		"dojo/request",
		"dojo/html",
		"dojo/io-query",
		"dojo/on",
		"dojo/topic",
		"dijit/registry"],
		function(ready,
			lang,
			arrayUtil,
			dom,
			domStyle,
			domAttr,
			domProp,
			domConstruct,
			query,
			request,
			html2,
			ioQuery,
			on,
			topic,
			registry) {
			ready(function() {

				function init(){
					try {

						rendiEsclusivoGruppo(['fascia_0_4','fascia_0_5','fascia_0_6']);
						rendiEsclusivoGruppo(['fascia_0_7','fascia_0_8','fascia_0_9','fascia_0_10']);
						rendiEsclusivoGruppo(['fascia_2_0','fascia_2_1','fascia_2_2','fascia_2_3','fascia_2_4']);
						rendiEsclusivoGruppo(['fascia_3_0','fascia_3_1','fascia_3_2','fascia_3_3','fascia_3_4']);

						 
						// STRUCTURE htmlFasce
var htmlFasce = {
  "fasce": { 
    
"206986" : "Post-COVID-19 Policy Responses to Support Recovery (ADB)<br/> <a href='https://eventboost.s3.amazonaws.com/assets/customHtmlEmail/seas-adb/ID%20206986%20-%20Post-COVID-19%20Policy%20Responses%20to%20Support%20Recovery%20Session%20Info%20Sheet%20%28ADB%29.pdf' style='color:red' target='_new'>- Click here for the Agenda -</a>",
"206987" : "The Role of Taxation in the Crisis Response and Recovery (ADB and OECD)<br/> <a href='https://eventboost.s3.amazonaws.com/assets/customHtmlEmail/seas-adb/ID%20206987%20-%20The%20Role%20of%20Taxation%20in%20the%20Crisis%20Response%20and%20Recovery%20Session%20Info%20Sheet%20%28ADB%20and%20OECD%29.pdf' style='color:red' target='_new'>- Click here for the Agenda -</a>",
"206988" : "Reinventing Smart Cities after COVID-19 (ADB)<br/> <a href='https://eventboost.s3.amazonaws.com/assets/customHtmlEmail/seas-adb/ID%20206988%20-%20Reinventing%20Smart%20Cities%20after%20COVID-19%20Session%20Info%20Sheet%20%28ADB%29.pdf' style='color:red' target='_new'>- Click here for the Agenda -</a>",
"206989" : "Leave No One Behind: Harnessing Technology for Post-Pandemic Recovery and Resilience (ADB & UNESCAP)<br/> <a href='https://eventboost.s3.amazonaws.com/assets/customHtmlEmail/seas-adb/ID%20206989%20-%20Leave%20No%20One%20Behind%20Harnessing%20Technology%20for%20Post-Pandemic%20Recovery%20and%20Resilience%20Session%20Info%20Sheet%20%28ADB%20and%20UNESCAP%29.pdf' style='color:red' target='_new'>- Click here for the Agenda -</a>",
"206990" : "Road to Recovery with Tech: Building the Foundation for Resilient Growth (Grab)<br/> <a href='https://eventboost.s3.amazonaws.com/assets/customHtmlEmail/seas-adb/ID%20206990%20-%20Road%20to%20Recovery%20with%20Tech%20Info%20Sheet%20%28Grab%29.pdf' style='color:red' target='_new'>- Click here for the Agenda -</a>",
"206991" : "Financing Post-Pandemic Green Growth and Green Recovery Session (ADB, OECD, EU SWITCH-Asia Programme) <br/> <a href='https://eventboost.s3.amazonaws.com/assets/customHtmlEmail/seas-adb/ID%20206991%20-%20Financing%20Post-Pandemic%20Green%20Growth%20and%20Green%20Recovery%20Session%20Info%20Sheet%20%28ADB%2C%20OECD%2C%20EU%20SWITCH-Asia%20Programme%29.pdf' style='color:red' target='_new'>- Click here for the Agenda -</a>",
"206992" : "An Ecosystem Approach for Economic Recovery in Southeast Asia Session (Google)<br/> <a href='https://eventboost.s3.amazonaws.com/assets/customHtmlEmail/seas-adb/ID%20206992%20-%20An%20Ecosystem%20Approach%20for%20Economic%20Recovery%20in%20Southeast%20Asia%20Session%20%20Info%20Sheet%20%28Google%29.pdf' style='color:red' target='_new'>- Click here for the Agenda -</a>",
"207008" : "Clean Energy Transition as an Engine for Green Recovery (ADB)<br/> <a href='https://eventboost.s3.amazonaws.com/assets/customHtmlEmail/seas-adb/ID%20207008%20-%20Clean%20Energy%20Transition%20as%20an%20Engine%20for%20Green%20Recovery%20DDW%20Info%20Sheet%20%28ADB%29.pdf' style='color:red' target='_new'>- Click here for the Agenda -</a>",
"207010" : "Scaling up SMEs Sustainable Consumption and Production (SCP) Actions (EU SWITCH-Asia)<br/> <a href='https://eventboost.s3.amazonaws.com/assets/customHtmlEmail/seas-adb/ID%20207010%20-%20Scaling%20up%20SMEs%20Sustainable%20Consumption%20and%20Production%20%28SCP%29%20Actions%20DDW%20Info%20Sheet%20%28EU%20SWITCH-Asia%20Programme%29.pdf' style='color:red' target='_new'>- Click here for the Agenda -</a>",
"207011" : "Open Source and Government Digital Transformation – Perfect Storm of Opportunity (Amazon Web Services Institute)<br/> <a href='https://eventboost.s3.amazonaws.com/assets/customHtmlEmail/seas-adb/ID%20207011%20-%20Open%20Source%20and%20Government%20Digital%20Transformation%20%20DDW%20Info%20Sheet%20%28AWSI%29.pdf' style='color:red' target='_new'>- Click here for the Agenda -</a>"



  }
}
// END STRUCTURE htmlFasce





 
	 					try {	 						 
							for (const [key, value] of Object.entries(htmlFasce.fasce)) {
								console.log ("key set html:" , key, value, query(".tundra.pagIscrizione .boxDateEvento .fasceDataEvento .idFascia" + key+ " span.titoloFascia"));
							    
							    if (value != "")
							       html2.set(query(".tundra.pagIscrizione .boxDateEvento .fasceDataEvento .idFascia" + key+ " span.titoloFascia")[0], value);

							}								 
					 	} catch (err) {
							console.log("htmlFasce: ", err);
						}	
 
						query(".id204377 input[type=checkbox]").forEach(function(node){node.checked=true;});	
						query(".id207003 input[type=checkbox]").forEach(function(node){node.checked=true;});	

						/* BEGIN_BLOCK: popupDescriptions
						// STRUCTURE popupDescriptions
						var popupDescriptions = {
						  "template": "%titolo%",
						  "editables": "%titolo%,%bio%",
						  "fasce": {     
						    }
						}
						
						// END STRUCTURE popupDescriptions

						function ifNotEmpty (v) {
						    if (v != ""){
						     	return "<br/><br/>" + v 
						    } 
							return "" ;
						}
						try {
							for (const idFascia in popupDescriptions.fasce) {
								console.log("idFascia", idFascia);
								var ref0 = query('.idFascia' + idFascia)[0];
								var ref1 = query('.titoloFascia', ref0)[0];

								if (!!ref1 && popupDescriptions[idFascia] != "") {
									// sostituisce lo span con titolo fascia mettendo il bottone	
									var html1 = "<span class='titoloFascia'>" + ref1.innerHTML + " <button type='button' id='ButIdFascia" + idFascia + "'>Details</button></span>";	
									domConstruct.place(html1, ref1, 'replace');
																					
									// apre popup quando clicco bottone
									var btn1 = query('#ButIdFascia' + idFascia)[0];
									on (btn1,'click',function(){
										//**** TODO ****: Aggiungere elementi di popupDescriptions.fasce o usare il template 
										var myContent = popupDescriptions.fasce[idFascia].descrizione + 
												ifNotEmpty(popupDescriptions.fasce[idFascia].teacher1);
												
										myDialog = new Dialog({
									        //title: "Details",
									        title: popupDescriptions.fasce[idFascia].titolo,
									        content: myContent,
									        style: "width: 800px"
									    });
									    myDialog.show();

									});
								}
							}	
						} catch (err) {
							console.log("popupDescriptions: ", err);
						}		
						END_BLOCK: popupDescriptions */

						/*
						if (!!dom.byId("intMaxAccompagnatori") && dom.byId("intMaxAccompagnatori").innerHTML == "0") {
							domStyle.set(dom.byId("boxAcc"), "display", "none");
							ebPlatform.iscrizione.allineaAltezzaBoxSxDx();
						}
						*/

						/*  // cecca una sessione:
							query(".id201509 input[type=checkbox]").forEach(function(node){node.checked=true;});
						*/

						/* aggiungo un link */
						/*var lab=query(".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield197656 label")[0];
						if (!!lab){
							lab.innerHTML = 'PRESA VISIONE DELL\'<a href="#" class="informativaPrivacy">INFORMATIVA PRIVACY</a><span class="mandatory">*</span>';
							var link = query(".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield197656 label a.informativaPrivacy")[0];
							on(link,'click',function(){
								window.open('https://s3-eu-west-1.amazonaws.com/eventboost/assets/customcss/sacbo/Informativa01.html','informativa','width=800,height=600');
							})							
						}*/

						/* modifico frase pagina declinazione per il Lei */
						/* var target = query(".tundra.pagIscrizione .boxModule .boxModuleInner .system")[0];
						if (!!target && target.innerHTML.indexOf("Se hai declinato")>-1){
							target.innerHTML = target.innerHTML.replace('Se hai declinato','Se ha declinato').replace('ricarica la pagina','ricarichi la pagina').replace('conferma la tua','confermi la Sua');
						} */

						/* se devo leggere/agire da/su un campo lista */
						/*
						var widget = registry.byId("customFieldSelect_307042");
						var accompagnatori = "";
						*/
						/* 	663363;"SI"
							663364;"NO"
						*/
						/*
						if (!!widget){
							accompagnatori = widget.get("value");
							console.log("... da widget");

							widget.on('change',function(newVal){
								console.log("newVal:",newVal);
							});

						} else {
							var el = dom.byId("valoreLista3.idValoreLista_box_anagrafica");
							if (el.selectedIndex > 0) {
								accompagnatori = el.options[el.selectedIndex].value;
							}
							on(el,'change',function(e){
								console.log("newVal:",el.options[el.selectedIndex].value);
							});
							console.log("... da select");
						}
						*/

						/* consensi privacy: rimuoviamo default no */
						/* var c1 = document.getElementById('consensoTrattamentoDati.consensoServizioIscrizione2');
						if (!!c1){
							domProp.set(c1,'checked',false);
						}
						var c2 = document.getElementById('consensoTrattamentoDati.consensoPubblicitaIscrizione2');
						if (!!c2){
							domProp.set(c2,'checked',false);
						}	
						*/

						/* sostituisce from at nelle ore fasce */	
						/*				 		
						query(".date.time").forEach(function(dateTime) {
							console.log (".date.time n " , dateTime);
					        dateTime.innerHTML = dateTime.innerHTML.replace("from", "at").replace("dalle", "alle");		
					    });	
						*/

						/* BEGIN_BLOCK: addBottoneDopoBottoneIscrizione
						var ref1 = query('.iscrizione')[0];
						var html1 = '<br/><span class="inputSubmit maggioriinfo" style="margin-top: 0px;">' + 									
									'<a href="https://www.axpo.com/it/it/axpo_green_energy_solutions_talks.html" class="submitIscrizione" style="vertical-align:middle;border: 0px none;    border-radius: 4px;    cursor: pointer;    display: inline-block;    font-size: 100%;    font-weight: 600;    height: 50px;    line-height: 38px;    padding: 5px 15px;    -webkit-appearance: none;font-family: \'Montserrat\';color:white;BACKGROUND-COLOR:#FF0000" target="_new">MAGGIORI INFO</a>' + 	
									'</span>';

						domConstruct.place(html1, ref1, 'after');
						END_BLOCK: addBottoneDopoBottoneIscrizione */


						/* BEGIN_BLOCK: messaggioSeGiaIscrittoENonDaBE
						var idPersona = document.getElementsByName("idPersona");
						//console.log("ep-25659.js idPersona.value:"+idPersona[0].value);

						var giaPresente = !!query(".giaRegistratoNoUpdate.giaRegistratoNoDelete")[0];
						console.log("giaPresente",giaPresente);
						var qs = document.location.search;
						var fromBE = false;
						if (!!qs) {
							qs = ioQuery.queryToObject(qs.substring(1, qs.length));
							if (!!qs.fromBE) {
								 console.log ("from BE:" + qs.fromBE);
								 if (qs.fromBE == "true") {
								 	fromBE = true;
								 }
							}
						}	
						//if(idPersona[0].value>0){
						if (giaPresente && fromBE == false){
							//c'e' un iscrizione
							domStyle.set("boxDxContent", "display", "none");
							var boxesPrivacyWrap = query(".boxesPrivacyWrap ")[0];
							if (!!boxesPrivacyWrap ){
								domStyle.set(boxesPrivacyWrap, "display", "none");
							}
							document.getElementById("boxDx").innerHTML = "<div id=\"boxAvvertimento\">La tua registrazione &egrave; gi&agrave; stata effettuata;<BR/>Qualora avessi bisogno di modificare la tua iscrizione, contatta la <b>Segreteria Organizzativa Amundi Digital Roadshow</b><BR/><b>Email:</b>amundidigitalroadshow@aesteam.it<BR/><b>Telefono:</b>338 4642173<BR/><i>(orario segreteria organizzativa: dal luned&igrave; al venerd&igrave; dalle 10.00 alle 16.00)</i></div>";

							var buttons = document.getElementsByClassName("boxRegistrationButtons");
							//console.log("ep-25659.js buttons.style.display:"+buttons[0].style.display);
							var i;
							for (i = 0; i < buttons.length; i++) {
								buttons[i].style.display = "none";
								//console.log("ep-25659.js buttons.style.display none");
							}
							var boxDx = document.getElementById("boxDx");
							boxDx.style.marginTop="30px";

						}else{
							//nessuna iscrizione quindi non faccio niente
						}
						END_BLOCK: messaggioSeGiaIscrittoENonDaBE */



					} catch (err) {
						console.log(err)
					}
				}

				if (lang.exists("ebPlatform.iscrizione.boxAnagraficaEndSetUp")) {
					if (!!ebPlatform.iscrizione.boxAnagraficaEndSetUp){
						init();
					}
				}
				topic.subscribe("BoxAnagrafica.EndSetUp", lang.hitch(this, function() {				
					init();
				}));

				/* Per rendere un gruppo di checkbox a scelta esclusiva */
				function rendiEsclusivoGruppo(idArr){
					arrayUtil.forEach(idArr,function(itemId){
						if (!!document.getElementById(itemId)){
							on(document.getElementById(itemId),'click',function(e){
								console.log("this",this,"e",e);
								if (e.target.checked){
									resetChecked(idArr,itemId);
								}
							});
						}
					});
				};

				function resetChecked(idArr,escludiId){
					arrayUtil.forEach(idArr,function(itemId){
						if (itemId != escludiId){
							var el = document.getElementById(itemId);
							if (!!el){
								el.checked = false;
							}
						}
					});
				}

				/* Per controllare la lunghezza dei campi testo */
				function deleteOrFrecce(keyCode){
					return (keyCode==8 || keyCode==46 || keyCode==37 || keyCode==39);
				}

				function limitaCifre(f,num){
					domAttr.set(f,'maxlength',num);
					on(f,'keydown',function(e){
						console.log(e.keyCode);
						if ((e.keyCode<48 || e.keyCode>57) && !deleteOrFrecce(e.keyCode)){
							e.preventDefault();
						}
					});
				}

				/* Per limitare le date disponibili sui calendari */
				function limitaDate() {
					try {
						var w = registry.byId("customfield5_box_anagrafica");
						if (!!w) {						
							w.set("dropDownDefaultValue", new Date(2018, 0, 1, 0, 0, 0, 0));
							w.set("constraints", {min: "2019-02-01", max:"2019-02-28"});
						}
						
					} catch(err) {
						console.log(err);
					}
				}

				/* Per limitare le date disponibili su tutti i calendari */
				function limitaTutteLeDate() {
					try {
						query(".ebTimeZoneAwareDateTextBox").forEach(function(node){
							var widgetId = domAttr.get(node,'widgetid');
							console.log(widgetId);

							var w = registry.byId(widgetId);
							if (!!w) {						
								w.set("dropDownDefaultValue", new Date(2020, 0, 1, 0, 0, 0, 0));
								w.set("constraints", {min: "2020-01-01"});
							}
						});
					} catch(err) {
						console.log(err);
					}
				}

				/* Apre E Seleziona Tutte Le Fasce */
				function ApreESelezionaTutteLeFasce() {
					domConstruct.place("<button type='button' id='allFascia'>Subscribe to all events</button><br><br>", query("[data-ebplatform-template-elementid='registrationBoxTitleNode']")[0], 'after');
					var btnAll = query('#allFascia' )[0];
					on (btnAll,'click',function(){
					
					query(".boxDateEvento input[type=checkbox]").forEach(function(node){node.checked=true;});

					arrayUtil.forEach(
					    query(".iconText"),
					    function(selectTag){					         
							selectTag.click(); 
							
					    }
					  );		 
					});
				}

			});
		});
}); // outer require

/* BEGIN_BLOCK: allowedDomains 
function ebPlatformCustomCheckAndSubmit(){
	console.log("ebPlatformCustomCheckAndSubmit");


	// controlla che domini della email ospite ed accompagnatore siano in un certo set:
	// METTERE "," iniziale e "," finale
	var email0AllowedDomains = ",@gmail.com,@hotmail.com,@eventboost.com,";
	var emailAccompagnatoreAllowedDomains = ",@gmail.com,@hotmail.com,@eventboost.com,";
	var idCampoEmailAccompagnatore= "customfield1_box_anagrafica"

	var returnValue = 'ok';
	// classe managingFiglio
	if (ebManagingFiglio == false){
	    var email0 = document.getElementById("customfield0_box_anagrafica").value;
		var domain0 = email0.substring(email0.indexOf("@"), email0.length);
	    if (email0AllowedDomains.toLowerCase().indexOf(domain0.toLowerCase()) < 0) {
	        console.log ("Dominio email ospite non permesso.");
	        returnValue = 'Dominio email ospite non permesso.';
	    }
	} else {
	    // accompagnatore cambiare id a seconda del caso
	    var emailAcc = document.getElementById(idCampoEmailAccompagnatore).value;
		var domainAccompagnatore = emailAcc.substring(emailAcc.indexOf("@"), emailAcc.length);
	    if (emailAccompagnatoreAllowedDomains.toLowerCase().indexOf(domainAccompagnatore.toLowerCase()) < 0) {
	        console.log ("Dominio email accompagnatore non permesso."); 
	        returnValue = 'Dominio email accompagnatore non permesso.';
	    }
	}   
	return returnValue;

	return 'ko'
}
END_BLOCK: allowedDomains */