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-prop",
		"dojo/dom-construct",
		"dojo/dom-geometry",
		"dojox/fx/scroll",
		"dojo/window",
		"dojo/query",
		"dojo/request",
		"dojo/on",
		"dojo/topic",
		"dijit/registry",
        "dojo/dom-attr",
        "dojo/io-query"],
		function(ready,
			lang,
			arrayUtil,
			dom,
			domStyle,
			domProp,
			domConstruct,
			domGeometry,
			scroll,
			win,
			query,
			request,
			on,
			topic,
			registry,
            domAttr,
            ioQuery) {
			ready(function() {
              
              
              var testoHairMakeup = '<div  class="itemForm text" style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); margin-top: 10px; font-weight: lighter; text-align: justify; display: block;">If you and/or your guest are interested in having your hair and makeup done for the event – we’ve got you covered! If you would like to make an appointment, please sign up for your preferred time below and we will email you if we can confirm your request.<BR/><b>Make Up is $45 per person.</b> Eyelashes are an additional $20.<BR/> <b>Hair is $50 per person</b> (style only, no wash). Hair Extensions, provided by you, can be installed for an additional $25.<BR/>Payment options are cash, Venmo, Zelle or PayPal.</div>';
              
              var idsessioniHair = ['338941','338942','338943','338944','338947','338946','338945'];
              var idsessioniMake = ['338955','338956','338957','338958','338959','338960','338961'];
              var idsessioniHead = ['338982','338979','338978','338977','338976','338975','338974','338973','338972','338980','338981','338969','338970','338971','338983'];
              var maxUTCHr=0;
              var maxUTCMa=0;
              var maxUTCHrMa=0;
              var maxUTCHe=0;
              
              var leftProgress = "337px;"
              
              function limitaDate(){
                //limita i calendar a Novembre 2025
                
                //Arrival Date
                var w = registry.byId("customfield17_box_anagrafica");
                if (!!w) {
                  w.set("constraints", {min: "2025-11-01", max: "2025-11-30"});
                  w.set("dropDownDefaultValue", new Date(2025, 11, 0, 0, 0, 0, 0));
                }
                //Departure Date
                w = registry.byId("customfield21_box_anagrafica");
                if (!!w) {
                  w.set("constraints", {min: "2025-11-01", max: "2025-11-30"});
                  w.set("dropDownDefaultValue", new Date(2025, 11, 0, 0, 0, 0, 0));
                }
                
              }
              
              function checkSessionHairMakeupHeadshot(){
                console.log("");
                console.log("checkSessionHairMakeupHeadshot");
                
                var trovatoMa = false;
                var trovatoHr = false;
                var trovatoHe = false;
                arrayUtil.forEach(iscrizione.dateEvento,function(datEvent){
                	//console.log("DEBUG datEvent", datEvent);
                    arrayUtil.forEach(datEvent.fasce,function(datFasc){
                    	console.log("DEBUG datFasc", datFasc);
                        console.log("DEBUG datFasc.idFasciaOraria:"+datFasc.idFasciaOraria);
                      	
                      	arrayUtil.forEach(idsessioniHair,function(sessioneHr){
                            console.log("DEBUG sessionsHair", sessioneHr);
                          	if(datFasc.idFasciaOraria==sessioneHr){
                            	console.log("DEBUG datFasc.idFasciaOraria:"+datFasc.idFasciaOraria);
                              	var radioHr = query("input[data-eb-idfascia='"+datFasc.idFasciaOraria+"']")[0]
                                if(!!radioHr){
                                	if(radioHr.checked){
                                      	trovatoHr=true;
                                  		console.log("CHECKED");
                                      	/*if(maxUTCHr<datFasc.oraInizioUTC){
                                          maxUTCHr=datFasc.oraInizioUTC;
                                        }*/
                                      	//if(maxUTCHr<datFasc.oraFineUTC){
                                          maxUTCHr=datFasc.oraFineUTC;
                                        //}
                                	}  
                                }
                            }


                        });
                      	
                      	arrayUtil.forEach(idsessioniMake,function(sessioneMa){
                            console.log("DEBUG sessionsMake", sessioneMa);
                          	if(datFasc.idFasciaOraria==sessioneMa){
                            	console.log("DEBUG datFasc.idFasciaOraria:"+datFasc.idFasciaOraria);
                              	var radioMa = query("input[data-eb-idfascia='"+datFasc.idFasciaOraria+"']")[0]
                                if(!!radioMa){
                                	if(radioMa.checked){
                                      	trovatoMa=true;
                                  		console.log("CHECKED");
                                      	/*if(maxUTCMa<datFasc.oraInizioUTC){
                                          maxUTCMa=datFasc.oraInizioUTC;
                                        }*/
                                      	//if(maxUTCMa<datFasc.oraFineUTC){
                                          maxUTCMa=datFasc.oraFineUTC;
                                        //}
                                	}  
                                }
                            }
                        });
                      
                      	arrayUtil.forEach(idsessioniHead,function(sessioneHe){
                            console.log("DEBUG sessionsHe", sessioneHe);
                          	if(datFasc.idFasciaOraria==sessioneHe){
                            	console.log("DEBUG datFasc.idFasciaOraria:"+datFasc.idFasciaOraria);
                              	var radioHe = query("input[data-eb-idfascia='"+datFasc.idFasciaOraria+"']")[0]
                                if(!!radioHe){
                                	if(radioHe.checked){
                                      	trovatoHe=true;
                                  		console.log("CHECKED");
                                      	//if(maxUTCHe<datFasc.oraInizioUTC){
                                          maxUTCHe=datFasc.oraInizioUTC;
                                        //}
                                	}  
                                }
                            }
                        });
                      
                      	
                       
                    });
                });
                
                if(trovatoMa==false){
                	maxUTCMa = 0;
                }
                
                if(trovatoHr==false){
                	maxUTCHr = 0;
                }
                
                if(trovatoHe==false){
                	maxUTCHe = 0;
                }
                
                console.log("maxUTCHr:"+maxUTCHr);
                console.log("maxUTCMa:"+maxUTCMa);
                console.log("maxUTCHe:"+maxUTCHe);
                
                if((maxUTCHr>0)&&(maxUTCMa>0)){                	
                    if(maxUTCMa>maxUTCHr){
                        maxUTCHrMa = maxUTCMa;
                    }else{
                        maxUTCHrMa = maxUTCHr;
                    }                	
                }else if(maxUTCHr>0){                	                    
                    maxUTCHrMa = maxUTCHr;                                    	
                }else if(maxUTCMa>0){                	                    
                    maxUTCHrMa = maxUTCMa;                                    	
                }else{
                	maxUTCHrMa = 0;
                }
                console.log("maxUTCHrMa:"+maxUTCHrMa);
                if((maxUTCHrMa>0)&&(maxUTCHe>0)){
                  console.log("maxUTCHrMa settato");
                  
                  if(maxUTCHrMa<=maxUTCHe){
                    //ok
                  }else{
                    //non puoi selezionarne una sessione headshot prima della fine dell'Hair Makeup
                    console.log("ERRORE HEADSHOT PRIMA DI HAIRMAKEUP");
                  }
                }
                                
              }
              
              
              
              function attivaTriggerCheckSessioni(){
              	//controllo statico al caricamento della pagina
                checkSessionHairMakeupHeadshot();
                arrayUtil.forEach(idsessioniHair,function(sessioneHr){
                    console.log("DEBUG sessioneHr:"+sessioneHr);
                    var radioHr = query("input[data-eb-idfascia='"+sessioneHr+"']")[0]
                    if(!!radioHr){
                      on(radioHr,'click',function(e){
                        console.log("clicked session");
                        checkSessionHairMakeupHeadshot();
                      });
                    }
                });
                arrayUtil.forEach(idsessioniMake,function(sessioneMa){
                    console.log("DEBUG sessioneMa:"+sessioneMa);
                    var radioMa = query("input[data-eb-idfascia='"+sessioneMa+"']")[0]
                    if(!!radioMa){
                      on(radioMa,'click',function(e){
                        console.log("clicked session");
                        checkSessionHairMakeupHeadshot();
                      });
                    }
                });
                
                arrayUtil.forEach(idsessioniHead,function(sessioneHe){
                    console.log("DEBUG sessioneHe:"+sessioneHe);
                    var radioHe = query("input[data-eb-idfascia='"+sessioneHe+"']")[0]
                    if(!!radioHe){
                      on(radioHe,'click',function(e){
                        console.log("clicked session");
                        checkSessionHairMakeupHeadshot();
                      });
                    }
                });
                
                
              }
              
              function trasformaDate(nomeBlocco){
                  var fasceData3 = query("#"+nomeBlocco)[0];
                  console.log("fasceData3:",fasceData3);
                  if(!!fasceData3){
                    domStyle.set(fasceData3, "display", "block");
                    query("input[type=radio]",fasceData3).forEach(function(item){
                      console.log("DEBUG item:", item);
                      item.type="checkbox";
                    });

                  }
                }
              
              /*  inizio piccole personalizzazioni */
              
              var testObbligatorio = query("p[data-ebplatform-template-elementid='personalDetailsFieldsWarningNode']")[0];
              
              if(!!testObbligatorio){
              		domConstruct.place("<p><span data-ebplatform-template-elementid='personalDetailsAdditionalTextNode' class='warningMsg personalDetailsAdditionalText'><strong>Congratulations, Honoree!<br><br>It is now time to register for the Gala. Please have you and your Guest Preferred Travel information on-hand. Your guest must be 21 years of age at the time of event.<BR/><BR/>Please check your personal details accurately and update them if necessary. Fields marked with an asterisk (*) are required and must be completed.<BR/><BR/>The deadline to register is Friday, October 17th.<BR/>Thank you!</strong></span></p>", testObbligatorio, 'before');     
              }

              
              /*  fine piccole personalizzazioni */

              	/*
                Per rimappare le id eseguire queste select:
                
                select 's/' || idcopyfrom  || '/' || idcustomfield || '/' from customfieldseventi where idevento=IDEVENTO
                select 's/' || idcopyfrom  || '/' || idcustomfield || '/' from fasceorarie where idevento=IDEVENTO
                SELECT 's/' || idcopyfrom  || '/' || idvalore || '/g' FROM valoriliste where idlista in ( select idlista from listevalori where idevento= IDEVENTO )
                SELECT 's/' || idcopyfrom  || '/' || idtesto || '/g' FROM public.testipagineiscrizione  
                      where idpaginaiscrizione in (select idpaginaiscrizione from pagineiscrizione where idevento=IDEVENTO)
                      ORDER BY idtesto

                
                mettere i risultati in un file testo file.sed
                
                poi lanciare la command line 
                
                sed -f file.sed questojs.js > out.js 
                
                prendere out.js e sostituirlo a questo file                                
                
                */
              
				
				console.log("**** CF ***",cf);
				/*
				
				657954;"Email"
				657953;"PPR Number (Nine Digits)"
				657955;"Start Now"

				1. Honoree Information
				657952;"Preferred First Name (this will appear on all printed materials)"
				657951;"Preferred Last Name (this will appear on all printed materials)"
				657964;"Honoree Date of Birth"
                658033;" PPR Number (Nine digits)"
				658030;"Job Title"
				658032;"Department Number (i.e 901)"
				658023;"Station Code (i.e ATG)"
				657965;"Preferred Email"
				657966;" Phone Number"
				657967;"Best way to reach you"
				658014;"Chairman’s Club Business Unit"
				657969;"Dietary Restrictions (1)"
				658019;"Do you have mobility issues?"
				378108;"How do you want to display your Chairman’s Club Pride?"
				657971;"Emergency Contact First Name"
				658027;"Emergency Contact Last Name"
				658026;"Emergency Contact Phone Number"
				658025;"Emergency Contact Email"
				658024;"Emergency Contact Relationship"

				2. Honoree Meal Preference and Dietary Restrictions
                658003;"Honoree Meal option"
				657997;"Honoree Please list Dietary Restrictions"

				3. Honoree Travel
				657950;"Do you Require Travel to Atlanta?"
				657994;"Arrival Flight Number"
				657996;"Arrival Date"
				657995;"Arrival Time"
				657993;"Origin City (1)"
				658006;"Departure Flight Number"
				658007;"Departure Date"
				658008;"Departure Time"
				657962;"Return City (1)"
				657999;"Record Locator Number"
				657963;"Do you require transportation from the airport"
				657959;" Known Traveler Number (TSA Pre-Check / Global Entry #)"

				4. Honoree Fun Facts
				658005;"Tell us about your Delta Work History"
				658013;"Do you have Military Experience?"
				658039;"What branch of Military did you serve?"
				658022;"Do you have family members in the military?"
				658038;"Tell us about your familys military service"
				658031;"Are you involved with any volunteer outr programs?"
				658037;"Tell us about the volunteer outreach programs"
				658017;"What are some of your hobbies?"
				658018;"What is your favorite song?"
				658016;"Tell us what you are most proud of"
				658004;"what is your most memorable moment at Delta?"
				658015;"What does being selected mean to you?"

				5. Guest Information
				657968;"First Name (As it appears on government issued ID)"
				658028;"Last Name (As it appears on government issued ID)"
				658029;"Gender"
				657972;"Date of Birth"
				657960;"Dietary Restrictions (2)"
				657970;"Guest relationship to the honoree"
				657974;"Does your guest have mobility issues?"
				657992;"Does your guest’s mobility issues require a wheelchair?"
				658036;"If your guest is flying, will your guest be with their own wheelchair?"
				658040;"What type of wheelchair does your guest have?"
				658041;"What type of battery does your guest’s wheelchair use? "
				657998;"Does your guest require travel to Atlanta?"
				657991;"Origin City (2)"
				657989;"Desired  Arrival Date"
				657988;"Desired  Arrival Time"
				657987;"Desired Arrival Flight Number"
				657984;"Is this the same flight that you booked for yourself?"
				657986;"Return City (2)"
				657985;"Desired Departure Date (use calendar tool)"
				657981;"Back-up return flight time preference"
				657983;"Desired Departure Time"
				657982;"Desired Departure Flight Number"
				657990;"Does your guest require transportation from the airport?"
                
                6. Guest Meal Preference and Dietary Restrictions
				657975;"Guest Meal option"
				657958;"Guest  Please list Dietary Restrictions"

				7. Accommodations
				658011;"Hotel Room Preference"
				658009;"Do you plan on having an extended stay?"
                
                8. Appointment
                
                9. Headshots

				//6. Atlanta Excursions
				//378103;"Select your 1st preference"
				//378104;"Select your 2nd preference"
				//378105;"Select your 3rd preference"
				*/
				
              
				var descrittoreSteps = {
					"HonoreeInformation" : {campi:[	{id:657952},
													{id:657951},
                                                   	{id:657976},//new pronoun
                                                   	{id:657964},//Honoree Date of Birth	
													{id:658033},
													{id:658030},
													{id:658032},
													{id:658023},
													{id:657965},
													{id:657966},
                                                   {id:658020}, // new 
													{id:657967},
													{id:658014},
													{id:657969},
													{id:658019},
													{id:378108},
													{id:657971},
													{id:658027},
													{id:658026},
													{id:658025},                                                    
													{id:658024},
                                                    {id:391719} // new 2
                                                     
                                                  ]},
                  	"HonoreeMealPreferenceAndDietaryRestrictions" : { campi:[ {id:658003},
                    							{id:657997} ]},
					"HonoreeTravel" : {	campi:[	{id:657950},
												{id:657994},
												{id:657996},
												{id:657995},
												{id:657993},
												{id:658006},
												{id:658007},
												{id:658008},
												{id:657962},
												{id:657999},
												{id:657963},
												{id:657959}]},
					"HonoreeFunFacts" : { campi: [ 	{id:658005},
													{id:658013},
													{id:658039},
													{id:658022},
													{id:658038},
													{id:658031},
													{id:658037},
													{id:658017},
													{id:658018},
													{id:658016},
													{id:658004},
													{id:658015}]},
					"GuestInformation" : { campi: [	{id:657968},
													{id:658028},
													{id:658029},//Guest gender
													{id:657972},
													{id:657960},
													{id:657970},
													{id:657974},
													{id:657992},
													{id:658036},
													{id:658040},
													{id:658041},
													{id:657998},
													{id:657991},
													{id:657989},
													{id:657988},
													{id:657987},
													{id:657984},
													{id:657986},
													{id:657985},
													{id:657981},
													{id:657983},
													{id:657982},
                                                    {id:658012}, // new
                                                   	{id:657977}, // Guest phone number
                                                   	{id:658010}, // Guest Know Traveler Number
													{id:657990}]},
					"GuestMealPreferenceAndDietaryRestrictions": { campi: [
                      									{id:657975},
                      									{id:657958}
                    								]},
					"Accommodations" : { campi: [	{id:658011},
													{id:658009}]}//,
					/*"AtlantaExcursions" : { campi: [{id:378103},
													{id:378104},
													{id:378105}]}*/

				};
				var campiSteps = {};

				var mappaStepCbxSelector = {
					"HonoreeInformation" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(1)",
                    "HonoreeMealPreferenceAndDietaryRestrictions" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(2)",
					"HonoreeTravel" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(3)",
					"HonoreeFunFacts" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(4)",
					"GuestInformation" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(5)",
                  	"GuestMealPreferenceAndDietaryRestrictions" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(6)",
					"Accommodations" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(7)",
                  	"Appointment" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(8)",
                  	"Headshots" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(9)"
					//"AtlantaExcursions" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(6)"
				}
                
                var mappaStepCbxSelectorOptionals = {
					"Appointment" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(8)"//,
					//"Headshots" : ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(9)"			 
				}
                
				var labelStatoStep = {};

				function init(){
                  	console.log("INIT");
					/*
					1208399;"1. Honoree Information"
					1208400;"2. Honoree Travel"			idTesto44058
					1208401;"3. Honoree Fun Facts"		idTesto48813
					1208402;"4. Guest Information"		idTesto44061					
					1208407;"5. Accommodations"			idTesto44063
                    1208405;"6. Appointment"
                    1208406;"7. Headshots"
                    
					//775663;"6. Atlanta Excursions"		idTesto44059

					92413;"Honoree Travel"
					92414;"Honoree Fun Facts"
					92429;"Guest Information"
					92411;"Accommodations"
					62221;"Atlanta Excursions"
                    92408;Appointment
                    92407;headshot

					*/
                  
                    // sposta fasce appuntamenti sotto il testo "Appuntamenti"
                  /*  
                  domConstruct.place(query(".fasceDataEvento.fasciaId90575")[0], query(".idTesto92408")[0], 'after');
                    domConstruct.place(query(".fasceDataEvento.fasciaId90576")[0], query(".idTesto92408")[0], 'after'); 
                    domConstruct.place(query(".fasceDataEvento.fasciaId90577")[0], query(".idTesto92408")[0], 'after');
                  	domConstruct.place(query(".fasceDataEvento.fasciaId90574")[0], query(".idTesto92408")[0], 'after');                                    			
                    */
                    // sposta date-fasce sotto appoinment
                  	// idTesto92408 == "Hair and Make Up"
                    domConstruct.place(query("#boxDateEvento")[0], query(".idTesto92408")[0], 'after');     
                  
                   	// sposta appointment prima della prima data appointment:                    
                    domConstruct.place(query(".idTesto92408")[0], query(".fasceDataEvento.fasciaId90574")[0], 'before');      
                  	
                   	// sposta headshot prima delle sue sessioni
                   	domConstruct.place(query(".idTesto92407")[0], query(".fasceDataEvento.fasciaId90578")[0], 'before'); 
                   	// rinasconde headshot dopo lo spostamento (?)
                   	domStyle.set(query(".idTesto92407")[0], "display", "none"); 
                  
                  	// nasconde l'ultimo next
                  	domStyle.set( query(".itemForm.idTesto92410")[0], "display", "none");
                  
                  	//Tell us what you are most proud of, either professionally or personally
                  	var campo1 = query("#customfield42_box_anagrafica")[0];                  	
                    if(!!campo1){
                      	console.log("DEBUG campo1:",campo1);
                      	if(!!document.getElementById("customfield42_box_anagrafica")){
                      		document.getElementById("customfield42_box_anagrafica").placeholder = "Tell us in min 140 characters.";
                        }
                    	//limitaTesto(campo1,140);
                    }
                  	//Other than being selection a Chairman’s Club Honoree, what is your most memorable moment at Delta?
                  	var campo2 = query("#customfield43_box_anagrafica")[0];
                    if(!!campo2){
                      	console.log("DEBUG campo2:",campo2);
                      	if(!!document.getElementById("customfield43_box_anagrafica")){
                      		document.getElementById("customfield43_box_anagrafica").placeholder = "Tell us in min 140 characters.";
                        }
                    	//limitaTesto(campo2,140);
                    }
                  	//What does being selected a Chairman’s Club Honoree mean to you?
                  	var campo3 = query("#customfield44_box_anagrafica")[0];
                    if(!!campo3){
                      	console.log("DEBUG campo3:",campo3);
                      	if(!!document.getElementById("customfield44_box_anagrafica")){
                      		document.getElementById("customfield44_box_anagrafica").placeholder = "Tell us in min 140 characters.";
                        }
                    	//limitaTesto(campo3,140);
                    }
                  	
                  	//Tell us about your Delta Work History
                  	var campo4 = query("#customfield45_box_anagrafica")[0];                  	
                    if(!!campo4){
                      	console.log("DEBUG campo4:",campo4);
                      	if(!!document.getElementById("customfield45_box_anagrafica")){
                      		document.getElementById("customfield45_box_anagrafica").placeholder = "Tell us in min 140 characters.";
                        }
                    	//limitaTesto(campo4,140);
                    }
                  
                  
					var mappaCbxIdTesto = {
						"1208400":"idTesto92413",
						"1208402":"idTesto92414",
						"1208401":"idTesto92429",
						"1208407":"idTesto92411",
                        //"1208405":"idTesto92408",  boxDateEvento
                        "1208405":"idCustomfield657957",
                      	//"1208405":"idTesto92408",
                        "1208406":"idTesto92407",
                      	"1208403" : "idTesto92422",
                      	"1208404" : "idTesto92431"
                         //,
						//"775663":"idTesto62221"
					};
					try {
                      
                      	// mette Optional ad Appointment  
                        for (const opt in mappaStepCbxSelectorOptionals) {
                          var ref = query(mappaStepCbxSelectorOptionals[opt])[0];
                          if (!!ref){
                              var lbl = domConstruct.create("span",{},ref);	
                              lbl.innerHTML = '<span style="color:green;font-weight:bold;position:relative;top:2px;position:absolute;left:'+leftProgress+';">OPTIONAL</span>';
                          }
                        }	  
                      
                        //---- headshots completed/progress label
                        if (!("Headshots" in labelStatoStep)) {
                          var ref = query(".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955 > div > div:nth-child(9)")[0];
                          if (!!ref){
                              var lbl = domConstruct.create("span",{},ref);	
                              lbl.innerHTML = '<span style="color:orange;font-weight:bold;position:relative;top:2px;position:absolute;left:'+leftProgress+';">IN PROGRESS</span>';
                              labelStatoStep["Headshots"] = lbl;
                          }
                        }
                  	    // check se completed headshot al load
                        if (query("#fasceData4 input[type=radio][checked]").length > 0){
                            labelStatoStep["Headshots"].innerHTML = '<span style="color:green;font-weight:bold;position:relative;top:2px;position:absolute;left:'+leftProgress+';">COMPLETED</span>';
                        }
                      
                        // se seleziono una sessione headshot allora headshot completed
                      	query("#fasceData4 input[type=radio]").forEach(function(item){
                          		on(item,'click',function(e){
                                     console.log("clicked session");
                                     labelStatoStep["Headshots"].innerHTML  = '<span style="color:green;font-weight:bold;position:relative;top:2px;position:absolute;left:'+leftProgress+';">COMPLETED</span>';
                                });
                        });
                      
                      	/*----INIZIO per rendere funzionante anche da fromBE=true-----------*/
                      	// check se completed headshot al load
                        if (query("#fasceData4 input[type=checkbox][checked]").length > 0){
                            labelStatoStep["Headshots"].innerHTML = '<span style="color:green;font-weight:bold;position:relative;top:2px;position:absolute;left:'+leftProgress+';">COMPLETED</span>';
                        }
                      
                        // se seleziono una sessione headshot allora headshot completed
                      	query("#fasceData4 input[type=checkbox]").forEach(function(item){
                          		on(item,'click',function(e){
                                     console.log("clicked session");
                                     labelStatoStep["Headshots"].innerHTML  = '<span style="color:green;font-weight:bold;position:relative;top:2px;position:absolute;left:'+leftProgress+';">COMPLETED</span>';
                                });
                        });
                      	/*----FINE per rendere funzionante anche da fromBE=true-----------*/

						/* Blocco i checkbox degli step */
						var stepCbxsContainer = query(".tundra.pagIscrizione .boxDatiIscrizione .itemForm.idCustomfield657955")[0];
						if (!!stepCbxsContainer){
							var mask;
							query("input[type=checkbox]",stepCbxsContainer).forEach(function(item){
								//console.log(item);
								if (item.checked){
									mascheraCbx(item);
								}
								
								domStyle.set(item.parentNode,{"position":"relative"});

								on(item,'click',function(e){
									console.log("click: " + e.target.value);

									if (e.target.checked){
										mascheraCbx(e.target);
										
                                      	//	1208405 idValore "Appointment"
                                      	//	1208406 idValore "Headshots"
                                      
										if (e.target.value != 1208405 && e.target.value != 1208406)	{
												console.log("CERCO:" + ".tundra.pagIscrizione .boxDatiIscrizione .itemForm.text."+mappaCbxIdTesto[""+e.target.value]);
												// scroll
                                          		//Fra
                                          		var btnNextUltimo = query(".idTesto92410")[0];
                                          		console.log("Ultimo BTN:",btnNextUltimo);
                                          		if(!!btnNextUltimo){
                                          			domStyle.set(btnNextUltimo, "display", "none"); 
                                                }
                                        } else if (e.target.value == 1208405) { // checkbox appointment
											console.log ("1208405");
                                            
                                            // mostra blocco date
                                            domStyle.set(query("#boxDateEvento")[0], "display", "block");
                                            // mostra appointment
                                            domStyle.set(query(".idTesto92408")[0], "display", "block");	// "Hair and Make Up"
                                          
                                          	
                                          
                                            // mostra date appointment                                          
                                            domStyle.set( query(".fasceDataEvento.fasciaId90575")[0], "display", "block");
                                            domStyle.set( query(".fasceDataEvento.fasciaId90576")[0], "display", "block");
                                            domStyle.set( query(".fasceDataEvento.fasciaId90577")[0], "display", "block");
                                            domStyle.set( query(".fasceDataEvento.fasciaId90574")[0], "display", "block");
                    

                          					//domConstruct.place(query(".idTesto92408")[0], query(".fasceDataEvento.fasciaId90574")[0] , 'before');
                                          	// posiziono "Hair and Make Up" all'inizio del box date
  					                        domConstruct.place(query(".idTesto92408")[0], query("#boxDateEvento")[0] , 'first');                           
                                          
                                          	//domConstruct.place('<div  class="itemForm text" style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); margin-top: 10px; font-weight: lighter; text-align: justify; display: block;">If you and/or your guest are interested in having your hair and makeup done for the event – we’ve got you covered! If you would like to make an appointment, please sign up for your preferred time below and we will email you if we can confirm your request.<BR/><b>Make Up is $45 per person.</b> Eyelashes are an additional $20.<BR/> <b>Hair is $50 per person</b> (style only, no wash). Hair Extensions, provided by you, can be installed for an additional $25.<BR/>Payment options are cash, Venmo, Zelle or PayPal.</div>', query(".idTesto92408")[0], 'after'); 
                                          	domConstruct.place(testoHairMakeup, query(".idTesto92408")[0], 'after'); 
                                          
                                          
                                          
                                          	//Fra provo a mettere questo per togliere la barra headshot
                                          	//domStyle.set(query(".idTesto92407")[0], "display", "none"); 
                                        
                                        	// l'ultimo next 
                                            domStyle.set( query(".itemForm.idTesto92410")[0], "display", "block");
                                          	// posiziono l'ultimo next prima del blocco del testo "Honoree headshots"
                                            //domConstruct.place (query(".itemForm.idTesto92410")[0]  , query(".fasceDataEvento.fasciaId90577")[0] , 'after');
                                          	domConstruct.place (query(".itemForm.idTesto92410")[0]  , query(".idTesto92407")[0] , 'before');
                                          	ebPlatform.iscrizione.allineaAltezzaBoxSxDx();
                                            
                                        
                                          	//query(".id338940 input[type=checkbox]").forEach(function(node){node.checked=true;});
                                          
                                        } else if (e.target.value == 1208406) {  // checkbox headshot
                                             console.log ("1208406");
                                             // mostra blocco date
                                             domStyle.set(query("#boxDateEvento")[0], "display", "block");
                                             // mostra date headshot 
                                             domStyle.set( query(".fasceDataEvento.fasciaId90578")[0] , "display", "block");
                                             // mostra headshot
                                             domStyle.set(query(".idTesto92407")[0], "display", "block"); 
                                          
                                             domConstruct.place('<div  class="itemForm text" style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); margin-top: 10px; font-weight: lighter; text-align: justify; display: block;"> Now that you are an Honoree you must be added to our Honoree Hall of Fame! In order to make sure you don’t miss the opportunity to take your headshot, you will need to sign up for your preferred time.</div>', query(".idTesto92407")[0], 'after');
                                          	 ebPlatform.iscrizione.allineaAltezzaBoxSxDx();
                                        }	
										// scroll
                                      
                                      
                                      
                                        try {
                                      
                                          if (e.target.value != 1208405) {
                                               var node = query(".tundra.pagIscrizione .boxDatiIscrizione .itemForm.text."+mappaCbxIdTesto[""+e.target.value])[0];
                                               var pos = domGeometry.position(findFirstVisibleDivPrevSibling(node));
                                               scroll({
                                                  target: {y: pos.y - 30, x:0},
                                                  win: window
                                               }).play();	    
                                          } else {
                                                console.log ("ecci !");

                                                var node = query("#boxDateEvento")[0];
                                                var pos = domGeometry.position(node);
                                                scroll({
                                                   target: {y: pos.y - 30, x:0},
                                                   win: window
                                                }).play();	
                                          }
                                      
                                      
                                        } catch (e) {
                                        
                                        }
                                      
                                      
									}


								});
							});
						}

						/* Avvio il controllo di completezza */						
						avviaControlloCompletezza();
						controllaCompletezza();
                      
                      
                        // se appointment ceccato apre la sezione appointment
                      	// idTesto92408 == "Hair and Make Up"
                      
                      	//Fra 
                      	//adesso valoriLista20.idValoreLista_box_anagrafica6 è
                      	//6. Guest Meal Preference and Dietary Restrictions
                      	//andrebbe messo valoriLista20.idValoreLista_box_anagrafica8
                        if (document.getElementById("valoriLista20.idValoreLista_box_anagrafica8").checked) {
                          	console.log("valoriLista20.idValoreLista_box_anagrafica8 checked");
                           // mostra blocco date
                          domStyle.set(query("#boxDateEvento")[0], "display", "block");
                          // mostra appointment
                          domStyle.set(query(".idTesto92408")[0], "display", "block");	// "Hair and Make Up"
                          
                          // mostra date appointment                                          
                          domStyle.set( query(".fasceDataEvento.fasciaId90575")[0], "display", "block");
                          domStyle.set( query(".fasceDataEvento.fasciaId90576")[0], "display", "block");
                          domStyle.set( query(".fasceDataEvento.fasciaId90577")[0], "display", "block");
                          domStyle.set( query(".fasceDataEvento.fasciaId90574")[0], "display", "block");
                          
                          // posiziono "Hair and Make Up" all'inizio del box date
                          //domConstruct.place(query(".idTesto92408")[0], query(".fasceDataEvento.fasciaId90577")[0] , 'before'); 
                          domConstruct.place(query(".idTesto92408")[0], query("#boxDateEvento")[0] , 'first');                           
                          
                          //domConstruct.place('<div  class="itemForm text" style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); margin-top: 10px; font-weight: lighter; text-align: justify; display: block;">If you and/or your guest are interested in having your hair and makeup done for the event – we’ve got you covered! If you would like to make an appointment, please sign up for your preferred time below and we will email you if we can confirm your request.</div>', query(".idTesto92408")[0], 'after'); 
                          domConstruct.place(testoHairMakeup, query(".idTesto92408")[0], 'after');
                          
                          // l'ultimo next 
                          domStyle.set( query(".itemForm.idTesto92410")[0], "display", "block");
                          
                          //Fra provo a mettere questo per togliere la barra headshot
                          //domStyle.set(query(".idTesto92407")[0], "display", "none"); 
                          
                          // posiziono l'ultimo next prima del testo "Honoree headshots"                                          	
                          //domConstruct.place (query(".itemForm.idTesto92410")[0]  , query(".fasceDataEvento.fasciaId90574")[0] , 'after');
                          domConstruct.place (query(".itemForm.idTesto92410")[0]  , query(".idTesto92407")[0] , 'before');
                          
                          ebPlatform.iscrizione.allineaAltezzaBoxSxDx();
                        } 
  
                      	//Fra 
                      	//adesso valoriLista20.idValoreLista_box_anagrafica7 è
                      	//7. Hotel Rooming Preference
                      	//andrebbe messo valoriLista20.idValoreLista_box_anagrafica9
                        // se headshot ceccato apre la sezione headshot
                        if (document.getElementById("valoriLista20.idValoreLista_box_anagrafica9").checked) {
                          console.log("valoriLista20.idValoreLista_box_anagrafica9 checked");
                         // mostra blocco date
                          domStyle.set(query("#boxDateEvento")[0], "display", "block");
                          // mostra date headshot 
                          domStyle.set( query(".fasceDataEvento.fasciaId90578")[0] , "display", "block");
                          // mostra headshot
                          domStyle.set(query(".idTesto92407")[0], "display", "block"); 
                          
                          domConstruct.place('<div  class="itemForm text" style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); margin-top: 10px; font-weight: lighter; text-align: justify; display: block;"> Now that you are an Honoree you must be added to our Honoree Hall of Fame! In order to make sure you don’t miss the opportunity to take your headshot, you will need to sign up for your preferred time.</div>', query(".idTesto92407")[0], 'after');
                          ebPlatform.iscrizione.allineaAltezzaBoxSxDx();
                        }
                      
                        // preseleziona la sessione "Gala" - sembra non vada più questa
                        query(".id338940 input[type=checkbox]").forEach(function(node){node.checked=true;});
                        // preseleziona la sessione "Gala"
                        document.querySelector("#fascia_5_0").checked= true;
                      
						//on(document.getElementById("iscrizioneForm"),"mouseup",function(){
						/*query("#iscrizioneForm input, #iscrizioneForm select").forEach(function(n){						
							on(n,"click",function(){
								console.log("CLICK");
								controllaCompletezza()
							});
						});*/
                      
                      
						
						

					} catch (err) {
						console.log("MYERROR:" + err)
					}      
                  
                  	
                  	
				}
              
              //attivaTriggerCheckSessioni();
              limitaDate();
              /*--------------------------------------------------*/
              /*  questo serve per poter modificare gli appuntamenti nel caso fromBE*/
              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;
                  }
                }
              }
              var iscrittoAlmenoUnaFascia = query(".iscrittoAlmenoUnaFascia")[0];
              
              console.log("fromBE:"+fromBE);
              console.log("iscrittoAlmenoUnaFascia:"+iscrittoAlmenoUnaFascia);
              if(fromBE && !!iscrittoAlmenoUnaFascia){
                console.log("FROMBE");
                trasformaDate("fasceData0");
                trasformaDate("fasceData1");
                trasformaDate("fasceData2");
                trasformaDate("fasceData3");
                trasformaDate("fasceData4");
                trasformaDate("fasceData5");
                
                //customfield106Row
                
                query(".titoloFascia").forEach(function(item){
                  console.log("DEBUG item:", item);
                  if(!!item){
                    domStyle.set(item, "display", "block");
                  }
                });
                
                var boxDateEvento = query("#boxDateEvento")[0];
                console.log("boxDateEvento:",boxDateEvento);
                if(!!boxDateEvento){
                  domStyle.set(boxDateEvento, "display", "block");
                }
                
                var customfield106Row = query("#customfield106Row")[0];
                console.log("customfield106Row:",customfield106Row);
                if(!!customfield106Row){
                  console.log("IMPOSTO DISPLAY customfield106Row");
                  domStyle.set(customfield106Row, "display", "block");
                }
                
                var idTesto92407 = query(".idTesto92407")[0];
                console.log("idTesto92407:",idTesto92407);
                if(!!idTesto92407){
                  console.log("IMPOSTO DISPLAY idTesto92407");
                  domStyle.set(idTesto92407, "display", "block");
                }
                
                
                ebPlatform.iscrizione.allineaAltezzaBoxSxDx();
              }
              
              	/*-----fine blocco fromBE modifica sessioni--------------------------------------------*/

				if (lang.exists("ebPlatform.iscrizione.boxAnagraficaEndSetUp")) {
					if (!!ebPlatform.iscrizione.boxAnagraficaEndSetUp){
						init();
					}
				}
				topic.subscribe("BoxAnagrafica.EndSetUp", lang.hitch(this, function() {				
					init();
				}));
              
              	

				function findFirstVisibleDivPrevSibling(node){
					var ret = node.previousElementSibling;
					if (ret.tagName.toUpperCase()!="DIV" || domStyle.get(ret,"display")=="none"){
						return findFirstVisibleDivPrevSibling(ret);
					}
					return ret;
				}

				function mascheraCbx(item){
					var mask;
					//domStyle.set(item.parentNode,{"position":"relative"});
					mask = domConstruct.create("div",{},item.parentNode);
					domStyle.set(mask,{
						"width":"100%",
						"height":"30px",
						"position":"absolute",
						"z-index":10,
						"top":"-3px",
						"background-color":"#fff",
						"opacity":0.17});
				}

				function avviaControlloCompletezza(){
					for(step in descrittoreSteps){
						//console.log(step,descrittoreSteps[step].campi);
						avviaControlloCompletezzaStep(step,descrittoreSteps[step].campi,!!descrittoreSteps[step].capo?descrittoreSteps[step].capo:null);
					}
                  
                    
				}
				
				function onValuaChange(){
					//console.log("CLICK");
					controllaCompletezza()
				}
				
				function avviaControlloCompletezzaStep(nomeStep,campi){
                  	console.log("DEBUG avviaControlloCompletezzaStep nomeStep:",nomeStep);
					var campiStep = [];
					arrayUtil.forEach(campi,function(campo){
						var idc = campo.id;
						if (!!cf[""+idc]){
							var currCf = cf[""+idc];
							var campo = {
								idCf: currCf.idCf,
								desc: currCf.desc,
								idLista: currCf.idLista,
								indiceIdValore: currCf.indiceIdValore,
								indiceCustomField: currCf.indiceCustomField,
								file: currCf.file,
								radio: currCf.radio,
								multi: currCf.multi
							};
							campiStep.push(campo);
							addOnChange(campo,onValuaChange);
						}
					});					
					//console.log(nomeStep,campiStep);
					campiSteps[nomeStep] = campiStep;					

					var ref = query(mappaStepCbxSelector[nomeStep])[0];
					if (!!ref){
						labelStatoStep[nomeStep] = domConstruct.create("span",{},ref);	
					}
					
				}
              
             
				function controllaCompletezza(){
					var tuttoCompleto = true;                  	
					var stepCompleto;
					for(step in campiSteps){
						stepCompleto = controllaCompletezzaStep(step,campiSteps[step]);
						tuttoCompleto = tuttoCompleto && stepCompleto;						
					}
					console.log("______tuttoCompleto: " + tuttoCompleto);

                    // se headshot non fatto allora non è tutto completo.
                  	if ((query("#fasceData4 input[type=radio][checked]").length == 0) && (query("#fasceData4 input[type=checkbox][checked]").length == 0)) {
						tuttoCompleto = false;
                    }                  
                  
					/*
					1208359;"No"
					1208358;"Yes"
					*/
					var completedWidget = registry.byId("customFieldSelect_657957");
					if (!!completedWidget){
						//console.log("completedWidget",completedWidget);
						completedWidget.set("value",(tuttoCompleto?1208358:1208359))
					} else {
						var completedSelect = document.getElementById("valoreLista22.idValoreLista_box_anagrafica");
						//console.log("completedSelect",completedSelect);
						domProp.set(completedSelect,"value",(tuttoCompleto?1208358:1208359));
					}
				}

				function controllaCompletezzaStep(nomeStep,campiStep){
                  	console.log("DEBUG nomeStep:"+nomeStep+",campiStep:",campiStep);
					var numCampiCompilati = 0;
					var numCampiNecessari = 0;

					arrayUtil.forEach(campiStep,function(cs){						
						//console.log(cs.desc + ": [" + val + "] | VISIBLE:" + (domStyle.get(query(".idCustomfield"+cs.idCf)[0],"display")!='none'));
                      	var ele = query(".idCustomfield"+cs.idCf)[0];
                      	if(!!ele){
                          if (domStyle.get(ele,"display")!='none'){
                              numCampiNecessari++;
                              var val = getValue(cs);
                              if(!!val){
                                  numCampiCompilati++;
                              }
                          }
                        }
					});	
					
					console.log(nomeStep + ": " + numCampiCompilati + "/" + numCampiNecessari);
					var ret = (numCampiCompilati == numCampiNecessari) && numCampiNecessari>0;
					mostraRisultatoControllo(nomeStep,ret);
					return ret;
				}

				function mostraRisultatoControllo(nomeStep,ret){
					labelStatoStep[nomeStep].innerHTML = ret ? '<span style="color:green;font-weight:bold;position:relative;top:2px;position:absolute;left:'+leftProgress+';">COMPLETED</span>' : '<span style="color:orange;font-weight:bold;position:relative;top:2px;position:absolute;left:'+leftProgress+';">IN PROGRESS</span>';
				}
				

				function getElName(campo) {
					var ret;
					if (!!campo.idLista) {
						if (campo.multi) {
							ret = "valoriCustomField[" + campo.idCf + "]";
						} else {
							ret = "valoreLista" + campo.indiceIdValore + ".idValoreLista";
						}
					} else if (!!campo.file){
						ret = "customfiles[" + campo.indiceCustomField + "]";
					} else {
						ret = "customfield" + campo.indiceCustomField;
					}
					return ret;
				}

				function getElId(campo) {
					var ret;
					if (!!campo.idLista) {
						ret = "valoreLista" + campo.indiceIdValore + ".idValoreLista_box_anagrafica";
					} else if (campo.type=="numero accompagnatori") {
						ret = "customfield" + campo.indiceCustomField;
					} else {
						ret = "customfield" + campo.indiceCustomField + "_box_anagrafica";
					}
					return ret;
				}

				function getWidgetId(campo) {
					var ret;
					if (!!campo.idLista) {
						ret = "customFieldSelect_" + campo.idCf;
					} else if (campo.type=="numero accompagnatori") {
						ret = "customField_" + campo.indiceCustomField;
					}else {
						ret = "customfield" + campo.indiceCustomField + "_box_anagrafica";;
					}
					return ret;
				}
              
              	function limitaTesto(f,num){
                    console.log("Debug limitaTesto f:", f);
                  	if(!!f){
                      domAttr.set(f,'maxlength',num);
                      on(f,'keydown',function(e){
                          console.log("DEBUG e:",e);
                          console.log("DEBUG f:",f);                      	

                          if ((e.keyCode>0) && !deleteOrFrecce(e.keyCode)){
                              if(f.value.length<num){
                                f.value += e.key;
                              }
                              e.preventDefault();
                          }
                      });
                    }
				}
              	function controllaLunghezza(f,num){
                    console.log("Debug controllaLunghezza f:", f);
                  	if(!!f){
                      	console.log("f.value.length:"+f.value.length);
                      	if(f.value.length>0){
                          if(f.value.length>num){
                          	return true;
                          }
                        }
                    }
                  	return false;
				}
              
              	function deleteOrFrecce(keyCode){
					return (keyCode==8 || keyCode==46 || keyCode==37 || keyCode==39);
				}

				function getValue(campo) {
					var value = null;
					var _widget = registry.byId(getWidgetId(campo));
					if (!!_widget) {
						value = _widget.get("value");
					} else if (campo.radio || campo.multi) {
						var els = dom.byId("iscrizioneForm")[getElName(campo)];
						var elsAnd = '';
						value = '';
						for (var idx = 0; idx < els.length; idx++) {
							if (els[idx].checked) {
								value += elsAnd + els[idx].value;
								elsAnd = ',';
							}
						}
					} else {
						var el = dom.byId(getElId(campo));						
						if (el.selectedIndex > 0) {
							value = el.options[el.selectedIndex].value;
						} else {
							value = el.value;
						}
					}
					return value;
				}

				function getLabelValue(campo) {
					var value = null;
					var _widget = registry.byId(getWidgetId(campo));
					if (!!_widget) {
						value = _widget.get("displayedValue");
					} else if (campo.radio || campo.multi) {
						var els = dom.byId("iscrizioneForm")[getElName(campo)];
						var elsAnd = '';
						value = '';
						for (var idx = 0; idx < els.length; idx++) {
							if (els[idx].checked) {
								value += elsAnd + els[idx].label;
								elsAnd = ',';
							}
						}
					} else {
						var el = dom.byId(getElId(campo));						
						if (el.selectedIndex > 0) {
							value = el.options[el.selectedIndex].label;
						} else {
							value = el.label;
						}
					}
					return value;
				}
				
				function addOnChange(campo,f){
                  	console.log("DEBUG addOnChange campo:", campo);
					var _widget = registry.byId(getWidgetId(campo));
					if (!!_widget) {
						_widget.on("change", f);
					} else if (campo.radio || campo.multi) {
						var els = dom.byId("iscrizioneForm")[getElName(campo)];
						if (!!els.length){
							for (var idx = 0; idx < els.length; idx++) {
                              	if(!!els[idx]){
									on(els[idx], "change", f);
                                }
							}
						} else {
                          	if(!!els){
								on(els, "change", f);
                            }
						}
						
					} else {
                      	console.log("DEBUG campo33:",campo);
                      	console.log("DEBUG getElId(campo):"+getElId(campo));
                      	var campid = dom.byId(getElId(campo));
                      	console.log("DEBUG campid:",campid);
                      	if(!!campid){
							on(dom.byId(getElId(campo)), "change", f);
                        }
					}
				}

			});
		});
}); // outer require

function ebPlatformCustomCheckAndSubmit(){
	console.log("ebPlatformCustomCheckAndSubmit");
  
  	var returnValue = 'ok';
  	//return returnValue;
  
  
  
  	var tuttoCompleto = true;
  	var controllo1 = true;
  	var controllo2 = true;
  	var controllo3 = true;
  	var controllo4 = true;
    //Tell us what you are most proud of, either professionally or personally
  	var campo1 = document.getElementById("customfield42_box_anagrafica");                  	
    if(!!campo1){
      console.log("DEBUG campo1:",campo1);
      console.log("DEBUG campo1.value:"+campo1.value);
      console.log("DEBUG campo1.value.length:"+campo1.value.length);
     
      if(campo1.value.length>0){
         if(campo1.value.length<140){
           controllo1=false;
      	}
      }
      
      console.log("controllo1:"+controllo1);
      if(!controllo1){
      	returnValue = '"Tell us what you are most proud of, either professionally or personally" Min 140chars';
        campo1.focus();
        console.log("focus1");
        return returnValue;
      }
    }
  
  	var campo2 = document.getElementById("customfield43_box_anagrafica");                  	
    if(!!campo2){
      console.log("DEBUG campo2:",campo2);
      console.log("DEBUG campo2.value:"+campo2.value);
      console.log("DEBUG campo2.value.length:"+campo2.value.length);
      
      if(campo2.value.length>0){
         if(campo2.value.length<140){
           controllo2=false;
      	}
      }
      
      console.log("controllo2:"+controllo2);
      if(!controllo2){
      	returnValue = '"Other than being selection a Chairman’s Club Honoree, what is your most memorable moment at Delta?" Min 140chars';
        campo2.focus();
        return returnValue;
      }
    }
  
  var campo3 = document.getElementById("customfield44_box_anagrafica");                  	
    if(!!campo3){
      console.log("DEBUG campo3:",campo3);
      console.log("DEBUG campo3.value:"+campo3.value);
      console.log("DEBUG campo3.value.length:"+campo3.value.length);
      
      if(campo3.value.length>0){
         if(campo3.value.length<140){
           controllo3=false;
      	}
      }
      
      console.log("controllo3:"+controllo3);
      if(!controllo3){
      	returnValue = '"What does being selected a Chairman’s Club Honoree mean to you?" Min 140chars';
        campo3.focus();
        return returnValue;
      }
    }
  var campo4 = document.getElementById("customfield45_box_anagrafica");                  	
    if(!!campo4){
      console.log("DEBUG campo4:",campo4);
      console.log("DEBUG campo4.value:"+campo4.value);
      console.log("DEBUG campo4.value.length:"+campo4.value.length);
      
      if(campo4.value.length>0){
         if(campo4.value.length<140){
           controllo4=false;
      	}
      }
      
      console.log("controllo4:"+controllo4);
      if(!controllo4){
      	returnValue = '"Tell us about your Delta Work History" Min 140chars';
        campo4.focus();
        return returnValue;
      }
    }
  

	
	return returnValue;
}