// JavaScript Document

//---------------------------------------------
// Variabili di errore da mostrare a video

if (jslang == "it") {
	// variabili per la pagina "invicurrstep1.php"
	var errNaturaDati = "Non hai letto interamente la sezione relativa a \"Natura dei dati e Finalita' del trattamento\"";
	var errModalitaTrattamento = "Non hai letto interamente la sezione relativa a \"Modalita' di trattamento\"";	
	var errAmbito = "Non hai letto interamente la sezione relativa a \"Ambito di comunicazione e di diffusione\"";
	var errDirittiPrevisti = "Non hai letto interamente la sezione relativa a \"Diritti previsti dall'art. 7 del d. lgs. 196/03\"";
	// variabili per la pagina "invicurrstep2.php"
	var errAccetta3punti = "ATTENZIONE.\nPer proseguire con la compilazione del curriculum e' necessario accettare\n i 3 consensi al trattamento dei dati personali.";
	// variabili per la pagina "invicurrstep3.php"
	var errInvalidEmail = "Indirizzo E-mail non valido! Controllalo e reinseriscilo.";
	var errFormatoData = "Il formato della data dovrebbe essere : gg/mm/aaaa";
	var errMeseValido = "Per favore, inserire un mese valido";
	var errGiornoValido = "Per favore, inserire un giorno valido";
	var errAnnoCompresoFra= "Per favore, inserire un anno di 4 cifre compreso fra";
	var errAnnoCompresoE= "e";	
	var errFormatoDataValido = "Per favore, inserire la data in un formato valido";
	var errNome = "Il campo NOME e' obbligatorio";
	var errCognome = "Il campo COGNOME e' obbligatorio";
	var errSesso = "Il campo SESSO e' obbligatorio";
	var errLuogoNascita = "Il campo LUOGO DI NASCITA e' obbligatorio";
	var errPaeseOrigine = "Il campo PAESE DI ORIGINE e' obbligatorio";
	var errCittadinanza = "Il campo CITTADINANZA e' obbligatorio";
	var errPatente = "Il campo PATENTE e' obbligatorio";
	var errIndirizzo = "Il campo INDIRIZZO e' obbligatorio";
	var errCap = "Il campo CAP e' obbligatorio";
	var errComune = "Il campo COMUNE e' obbligatorio";
	var errProvincia = "Il campo PROVINCIA e' obbligatorio";
	var errNazione = "Il campo NAZIONE e' obbligatorio";
	var errSituazione = "Il campo SITUAZIONE LAVORATIVA ATTUALE e' obbligatorio";
	var errInvalidita= "Indicare la tipologia di invalidita'";
	var errPercDisabilita = "Il campo PERCENTUALE di DISABILITA' e' obbligatorio.";
	var errPercDisabilitaCorretto = "Inserire un valore corretto nelle PERCENTUALE di DISABILITA'";
	var errEspProfessionali= "ATTENZIONE\nSe il campo \"Periodo dal\" viene compilato \n e' necessario compilare anche il resto dei campi.\n\n\n Verifica le informazioni di [ Esperienze Professionali]";
	var errFormazione = "ATTENZIONE\nSe il campo \"Periodo dal\" viene compilato \n e' necessario compilare anche il resto dei campi.\n\n\n Verifica le informazioni di [ Formazione ]";
	var errConoInfo= "ATTENZIONE\nSe il campo \"Software / area di competenza \" viene compilato \n e' necessario compilare anche il resto dei campi.\n\n\n Verifica le informazioni di [ Conoscenze Informatiche ]";
	var errConoLing = "ATTENZIONE\nSe il campo \"Lingua\" viene compilato \n e' necessario compilare anche il resto dei campi.\n\n\n Verifica le informazioni di [ Conoscenze Linguistiche ]";
	var msgCongratulazioni = "CONGRATULAZIONI.\n Il modulo e' compilato in maniera corretta e verra' inviato al nostro ufficio competente.\n";
}	
if (jslang == "en") {
	// variabili per la pagina "invicurrstep1.php"
	var errNaturaDati = 'Please, be sure to have read the "Types of data and purposes of handling" section';
	var errModalitaTrattamento = 'Please, be sure to have read the "Handling procedures" section';	
	var errAmbito = 'Please, be sure to have read the "Extent of release and dissemination" section';
	var errDirittiPrevisti = 'Please, be sure to have read the  "Rights as per art. 7 of Leg. Decree n° 196/03" section';
	// variabili per la pagina "invicurrstep2.php"
	var errAccetta3punti = 'ATTENTION.\nTo proceed with the form submitting, you must agree with the \n informative report.';
	// variabili per la pagina "invicurrstep3.php"
	var errInvalidEmail = 'Invalid E-mail address. Check and submit it again.';
	var errFormatoData = 'Invalid date format (dd/mm/yyyy)';
	var errMeseValido = 'Please, insert a valid month';
	var errGiornoValido = 'Please, insert a valid day';
	var errAnnoCompresoFra= 'Please, insert a year (4 figures) between';
	var errAnnoCompresoE= 'and';	
	var errFormatoDataValido = 'Please, insert the date in a valid format';
	var errNome = 'The field NAME is a mandatory field';
	var errCognome = 'The field LAST NAME is a mandatory field';
	var errSesso = 'The field SEX is a mandatory field';
	var errLuogoNascita = 'The field PLACE OF BIRTH is a mandatory field';
	var errPaeseOrigine = 'The field COUNTRY OF ORIGIN is a mandatory field';
	var errCittadinanza = 'The field NATIONALITY is a mandatory field';
	var errPatente = 'The field DRIVING LICENSE is a mandatory field';
	var errIndirizzo = 'The field ADDRESS is a mandatory field';
	var errCap = 'The field POSTCODE is a mandatory field';
	var errComune = 'The field PLACE is a mandatory field';
	var errProvincia = 'The field PROVINCE is a mandatory field';
	var errNazione = 'The field COUNTRY is a mandatory field';
	var errSituazione = 'The field PRESENT WORK SITUATION is a mandatory field';
	var errInvalidita= 'Indicare la tipologia di invalidit&agrave;';
	var errPercDisabilita = "Il campo PERCENTUALE di DISABILITA\' &agrave; obbligatorio.";
	var errPercDisabilitaCorretto = "Inserire un valore corretto nelle PERCENTUALE di DISABILITA";
	var errEspProfessionali= 'ATTENTION\nIf \"Period:from\" is filled in \n all the remaining fields are mandatory.\n\n\n Please check the [ Work experience ] section';
	var errFormazione = 'ATTENTION\nIf \"Period:from\" is filled in \n all the remaining fields are mandatory.\n\n\n Please check the [ Schooling ] section';
	var errConoInfo= 'ATTENTION\nIf \"Software type / abilities \" is filled in \n all the remaining fields are mandatory.\n\n\n Please check the [ Computer knowledge ] section';
	var errConoLing = 'ATTENTION\nIf \"Language\" is filled in \n all the remaining fields are mandatory.\n\n\n Please check the [ Languages ] section';
	var msgCongratulazioni = 'CONGRATULATIONS.\n The form has been submitted in a right way.\n Our office will contact you as soon as possibile.\n\n Thank you.\n';
}

//---------------------------------------------

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function displayHideLayers() { //v6.0
  var i,p,v,obj,args=displayHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

function espandiNascondiArea(immagine, idArea){
    
     if (immagine.src.indexOf("ico_piu")!= -1){
      // devo espandere
      immagine.src = immagine.src.replace("ico_piu","ico_meno");
      displayHideLayers(idArea,"","show");
     } else {
      // devo nascondere
      immagine.src = immagine.src.replace("ico_meno","ico_piu");
      displayHideLayers(idArea,"","hide");
     }
}

//###############################################
//----------------------------------------------
var visibile = false;

function ShowHideLayer(idArea) {
	if (visibile) {
		displayHideLayers(idArea,"","hide");
		visibile = false;
	} else {
		displayHideLayers(idArea,"","show");
		visibile = true;	
	}
}
//----------------------------------------------
//###############################################

//###############################################
// Per controllo lettura pagina STEP 1
function scrollingDetectorStep1(){
//Verifico che l'utente legga l'informativa andando a vedere se l'altezza dello scroll totale è maggiore
//dell'altezza della textarea più l'altezza dello scroll fatto
	//if (navigator.appName == "Microsoft Internet Explorer") {
	//	alert("You're at " + document.body.scrollTop + " pixels.");
	//} else { 
	//	alert("You're at " + window.pageYOffset + " pixels.");
	//}

	var NaturaDati_scrollheight = window.document.InviaCurrStep1.NaturaDati.scrollHeight; //altezza dello scroll
	var NaturaDati_scroll = window.document.InviaCurrStep1.NaturaDati.scrollTop;	// distanza dal top dello scroll
	var NaturaDati_height = window.document.InviaCurrStep1.NaturaDati.clientHeight;	// altezza dell'oggetto senza barre		

	var ModalitaTrattamento_scrollheight = window.document.InviaCurrStep1.ModalitaTrattamento.scrollHeight; //altezza dello scroll
	var ModalitaTrattamento_scroll = window.document.InviaCurrStep1.ModalitaTrattamento.scrollTop;	// distanza dal top dello scroll
	var ModalitaTrattamento_height = window.document.InviaCurrStep1.ModalitaTrattamento.clientHeight;	// altezza dell'oggetto senza barre		

	var ComunicazioneDiffusione_scrollheight = window.document.InviaCurrStep1.ComunicazioneDiffusione.scrollHeight; //altezza dello scroll
	var ComunicazioneDiffusione_scroll = window.document.InviaCurrStep1.ComunicazioneDiffusione.scrollTop;	// distanza dal top dello scroll
	var ComunicazioneDiffusione_height = window.document.InviaCurrStep1.ComunicazioneDiffusione.clientHeight;	// altezza dell'oggetto senza barre		

	var DirittiPrevisti_scrollheight = window.document.InviaCurrStep1.DirittiPrevisti.scrollHeight; //altezza dello scroll
	var DirittiPrevisti_scroll = window.document.InviaCurrStep1.DirittiPrevisti.scrollTop;	// distanza dal top dello scroll
	var DirittiPrevisti_height = window.document.InviaCurrStep1.DirittiPrevisti.clientHeight;	// altezza dell'oggetto senza barre		
			
	if 	(NaturaDati_scrollheight > (NaturaDati_scroll + NaturaDati_height)) {
		alert(errNaturaDati);
		window.document.InviaCurrStep1.Informativa.checked = false;
		return false;
	}
	if 	(ModalitaTrattamento_scrollheight > (ModalitaTrattamento_scroll + ModalitaTrattamento_height)) {
		alert(errModalitaTrattamento);
		window.document.InviaCurrStep1.Informativa.checked = false;
		return false;
	}
	if 	(ComunicazioneDiffusione_scrollheight > (ComunicazioneDiffusione_scroll + ComunicazioneDiffusione_height)) {
		alert(errAmbito);
		window.document.InviaCurrStep1.Informativa.checked = false;
		return false;
	}
	if 	(DirittiPrevisti_scrollheight > (DirittiPrevisti_scroll + DirittiPrevisti_height)) {
		alert(errDirittiPrevisti);
		window.document.InviaCurrStep1.Informativa.checked = false;
		return false;
	}						
	//Abilito il check a "Ho letto l'informativa"
	window.document.InviaCurrStep1.Informativa.checked = true;
	return true;
}

// Per invio FORM pagina STEP 1
function checkAndSubmitStep1 () {
	if (scrollingDetectorStep1()) {
		window.document.InviaCurrStep1.Informativa.checked = true;	
		window.document.InviaCurrStep1.submit();
	} else {
		//alert('ATTENZIONE.\nLeggi per intero ogni singola sezione dell\'informativa.\nGrazie')
		window.document.InviaCurrStep1.Informativa.checked = false;		
		return false;
	}
}
//###############################################

//###############################################
// Per invio FORM pagina STEP 2
function checkAndSubmitStep2 () {
	var InfoDatiComuni = window.document.InviaCurrStep2.TrattDatiComuni.checked;
	var InfoDatiSensibili = window.document.InviaCurrStep2.TrattDatiSensibili.checked;
	var InfoDatiAltreSedi = window.document.InviaCurrStep2.TrattDatiAltreSedi.checked;
	
	if (InfoDatiComuni && InfoDatiSensibili && InfoDatiAltreSedi) {
		window.document.InviaCurrStep2.submit();
	} else {
		//alert('ATTENZIONE.\nLeggi per intero ogni singola sezione dell\'informativa.\nGrazie')
		alert(errAccetta3punti);
		window.document.InviaCurrStep2.TrattDatiComuni.checked = true;	
		window.document.InviaCurrStep2.TrattDatiSensibili.checked = true;	
		window.document.InviaCurrStep2.TrattDatiAltreSedi.checked = true;			
		return false;
	}
}

function EliminaLivello (IdLayer) {
	// la funzione viene utilizzata per eliminare tutti i DIV che vengono creati tramite 
	// l'utility ADD / REMOVE div
	var mydiv=document.getElementById(IdLayer);		//leggo il valore del campo NOME
	pnode=mydiv.parentNode;
	pnode.removeChild(mydiv);
} 
//###############################################


// ###################################################################################
// Controllo dei campi di testo per evitare l'inserimento di 2 spazi vuoti consecutivi
//----------------------------------CheckTitle---------------------------------
// function that checks void field
//-----------------------------------------------------------------------------
function CheckTitle(valore){
	if (valore == "" || valore == " "){
		return false;
	}
	for (var i=0; i < valore.length-1; i++) {
		if (valore.substring(i,i+2) == "  "){
			return false;	
		}
	}
}
// ###################################################################################

// #############################################################################
// EMAIL VALIDATION
// #############################################################################
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function checkEmail(myForm) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.value)){
	return (true);
	}
	alert(errInvalidEmail)
	return (false);
}

// #############################################################################
// Numeric validation function
//#############################################################################
function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-,";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
// #############################################################################
/**
 * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var dataoggi = new Date();
var maxYear=dataoggi.getFullYear();

function isInteger(s){
	var i;
	for (i = 0; i < s.length; i++){   
		// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	// All characters are numbers.
	return true;
}

function stripCharsInBag(s, bag){
	var i;
	var returnString = "";
	// Search through string's characters one by one.
	// If character is not in bag, append to returnString.
	for (i = 0; i < s.length; i++){   
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
	// EXCEPT for centurial years which are not also divisible by 400.
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)

	if (pos1==-1 || pos2==-1){
		alert(errFormatoData)
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert(errMeseValido)
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert(errGiornoValido)
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert(errAnnoCompresoFra + minYear + errAnnoCompresoE +maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert(errFormatoDataValido)
		return false
	}
return true
}
// #############################################################################


// #############################################################################
// VALIDAZIONE DELLO STEP 3 di iscrizione
// -----------------------------------------------------------------------------
// DATI ANAGRAFICI VALIDATION
// Validazione della sezione 
// -----------------------------------------------------------------------------
function checkDatiAnagrafici(myForm) {
	var nome = document.getElementById('nome').value;
	var cognome = document.getElementById('cognome').value;	
	//ottengo i valori del radio button "Sesso"
	j=myForm.sesso.length; //alert(j)
	for (i=0; i<j; i++){
		if(myForm.sesso[i].checked) var sesso = myForm.sesso[i].value;
	}	
	//---------------------------------
	//var sesso = document.getElementById('sesso').value;		
	var datanascita = document.getElementById('datanascita').value;		
	//var luogonascita = document.getElementById('luogonascita').options[document.getElementById('luogonascita').selectedIndex].value;
	var luogonascita = document.getElementById('luogonascita').value;
	var paeseorigine = document.getElementById('paeseorigine').options[document.getElementById('paeseorigine').selectedIndex].value;
	var cittadinanza = document.getElementById('cittadinanza').options[document.getElementById('cittadinanza').selectedIndex].value;
	var figli = document.getElementById('figli').value;	
	var patente = document.getElementById('patente').options[document.getElementById('patente').selectedIndex].value;
	var indirizzo = document.getElementById('indirizzo').value;
	var cap = document.getElementById('cap').value;	
	var citta = document.getElementById('citta').value;
	//var provincia = document.getElementById('provincia').options[document.getElementById('provincia').selectedIndex].value;
	var provincia = document.getElementById('provincia').value;
	var nazione = document.getElementById('nazione').options[document.getElementById('nazione').selectedIndex].value;	
	//--------
	if (CheckTitle(nome) == false) {
		alert(errNome);
		myForm.nome.focus();
		return false;
	}	
	//--------	
	if (CheckTitle(cognome) == false) {
		alert(errCognome);
		myForm.cognome.focus();
		return false;
	}
	//--------	
	if (!sesso) {
		alert(errSesso);
		myForm.sesso[0].focus();
		return false;
	}
	//--------	
	if (isDate(datanascita)==false){
		myForm.datanascita.focus();
		return false;
	}
	//--------	
	if (luogonascita=="") {
		alert(errLuogoNascita);
		myForm.luogonascita.focus();
		return false;
	}
	//--------	
	if (paeseorigine=="") {
		alert(errPaeseOrigine);
		myForm.paeseorigine.focus();
		return false;
	}
	//--------	
	if (cittadinanza=="") {
		alert(errCittadinanza);
		myForm.cittadinanza.focus();
		return false;
	}
	//--------	
	// Non obbligatorio su richiesta di Melissa Rib (09/02/2006)
//	if (figli=="") {
/*		alert("Il campo FIGLI è obbligatorio");
		myForm.figli.focus();
		return false;
	}else {
		if (!isInteger(figli)) {
			alert("Il campo FIGLI deve essere un numero intero");
			myForm.figli.focus();
			return false;
		}
	}
*/
	//--------
	if (patente=="") {
		alert(errPatente);
		myForm.patente.focus();
		return false;
	}
	//--------
	if (CheckTitle(indirizzo) == false) {
		alert(errIndirizzo);
		myForm.indirizzo.focus();
		return false;
	}	
	//--------
	if (CheckTitle(cap) == false) {
		alert(errCap);
		myForm.cap.focus();
		return false;
	}
	//--------
	if (CheckTitle(citta) == false) {
		alert(errComune);
		myForm.citta.focus();
		return false;
	}	
	//--------
	if (provincia=="") {
		alert(errProvincia);
		myForm.provincia.focus();
		return false;
	}
	//--------
	if (nazione=="") {
		alert(errNazione);
		myForm.nazione.focus();
		return false;
	}

	//Ok, non ci sono errori
	return true;
}
// -----------------------------------------------------------------------------
// SITUAZIONE ATTUALE VALIDATION
// Validazione della sezione 
// -----------------------------------------------------------------------------
function checkSituazioneAttuale(myForm) {
	var situazione = document.getElementById('situazioneattuale').value;

	//--------
	if (situazione=="") {
		alert(errSituazione);
		myForm.situazioneattuale.focus();
		return false;
	}

	//verifico l'eventuale iscrizione alle Liste speciali
	if (myForm.listespeciali) {
		if (myForm.listespeciali.checked) {
	
			var iscrittolistespeciali = myForm.listespeciali.checked;
	
			if (iscrittolistespeciali) {
				//ottengo i valori del radio button "tipologia di quale lista speciale"
				j=myForm.listespeciali_tipo.length; //alert(j)
				for (i=0; i<j; i++){
					//tipo di invalidità
					if(myForm.listespeciali_tipo[i].checked) var listespeciali_tipo = myForm.listespeciali_tipo[i].value;
				}	
			
				if (!listespeciali_tipo) { 
					alert(errInvalidita);
					myForm.listespeciali_tipo[0].focus();
					return false;
				} else {
					var percdisabile = document.getElementById('perc_invalidita').value; // perc di invalidità
			
					if (listespeciali_tipo=="disabile") {
						//la percentuale è obbligatoria solo se il campo "disabile" è flaggato
						if (percdisabile.length == 0) {
							alert(errPercDisabilita);
							myForm.perc_invalidita.focus();
							return false;
						} else if (IsNumeric(percdisabile) == false) {
							alert(errPercDisabilitaCorretto);
							myForm.perc_invalidita.focus();
							return false;				
						}
					}
				}
			}
		}
	}	

	//Ok, non ci sono errori
	return true;
	//---------------------------------
}

// -----------------------------------------------------------------------------
// SITUAZIONE ATTUALE VALIDATION
// Validazione della sezione 
// -----------------------------------------------------------------------------
function checkEspProfessionale(myForm) {

	numEspLav = 0;
	idFormField = 0;	//ID numerico del campo della form
	
	for (var e = 0; e < myForm.elements.length; e++) {
		var el = new String(myForm.elements[e].name);
		//controllo presenza di "periodo dal"
		if (el.indexOf('EspPeriododal_') != -1) {
			numEspLav = numEspLav + 1;  //numero delle esperienze lavorative
			//controllo solo se inserisco il valore nel campo "periodo dal"
			if (myForm.elements[e].value !="") { 
				boolErrore = false;
				//Se il campo "Periodo dal" verifico che anche il resto dei campi sia compilato
				myStr = myForm.elements[e].name;
				strContatore 	= new String(myStr);			//ottengo ID numerico del campo
				splitContatore 	= strContatore.split("_");		//ottengo ID numerico del campo
				idFormField 	= splitContatore[1];			//ottengo ID numerico del campo

				//ottengo il campo Periodo dal
				EspPeriododalId = "EspPeriododal_"+idFormField;
				EspPeriododalValue = document.getElementById(EspPeriododalId).value;
				if (CheckTitle(EspPeriododalValue) == false) boolErrore = true;
				//ottengo il campo Periodo al
				EspPeriodoalId = "EspPeriodoal_"+idFormField;
				EspPeriodoalValue = document.getElementById(EspPeriodoalId).value;
				if (CheckTitle(EspPeriodoalValue) == false) boolErrore = true;
				//ottengo il campo Azienda
				EspAziendaId = "EspAzienda_"+idFormField;
				EspAziendaValue = document.getElementById(EspAziendaId).value;
				if (CheckTitle(EspAziendaValue) == false) boolErrore = true;
				//ottengo il campo Posizione Occupata
				EspPosizioneId = "EspPosizione_"+idFormField;
				EspPosizioneValue = document.getElementById(EspPosizioneId).value;
				if (CheckTitle(EspPosizioneValue) == false) boolErrore = true;
				//ottengo il campo Posizione Occupata
				EspTipoinquadramentoId = "EspTipoinquadramento_"+idFormField;
				EspTipoinquadramentoValue = document.getElementById(EspTipoinquadramentoId).options[document.getElementById(EspTipoinquadramentoId).selectedIndex].value;
				if (CheckTitle(EspTipoinquadramentoValue) == false) boolErrore = true;				

				if (boolErrore) {
					alert(errEspProfessionali + "("+idFormField+") ]");
					myForm.elements[EspPeriododalId].focus();
					return false;
				} else {
					return true;
				}

			}
		}
	}
	//Ok, non ci sono errori
	return true;	
}

// -----------------------------------------------------------------------------
// FORMAZIONE VALIDATION
// Validazione della sezione 
// -----------------------------------------------------------------------------
function checkFormazione(myForm) {

	numEspLav = 0;
	idFormField = 0;	//ID numerico del campo della form
	
	for (var e = 0; e < myForm.elements.length; e++) {
		var el = new String(myForm.elements[e].name);
		//controllo presenza di "periodo dal"
		if (el.indexOf('FormPeriododal_') != -1) {
			numEspLav = numEspLav + 1;  //numero delle esperienze lavorative
			//controllo solo se inserisco il valore nel campo "periodo dal"
			if (myForm.elements[e].value !="") { 
				boolErrore = false;
				//Se il campo "Periodo dal" verifico che anche il resto dei campi sia compilato
				myStr = myForm.elements[e].name;
				strContatore 	= new String(myStr);			//ottengo ID numerico del campo
				splitContatore 	= strContatore.split("_");		//ottengo ID numerico del campo
				idFormField 	= splitContatore[1];			//ottengo ID numerico del campo

				//ottengo il campo Periodo dal
				FormPeriododalId = "FormPeriododal_"+idFormField;
				FormPeriododalValue = document.getElementById(FormPeriododalId).value;
				if (CheckTitle(FormPeriododalValue) == false) boolErrore = true;
				//ottengo il campo Periodo al
				FormPeriodoalId = "FormPeriodoal_"+idFormField;
				FormPeriodoalValue = document.getElementById(FormPeriodoalId).value;
				if (CheckTitle(FormPeriodoalValue) == false) boolErrore = true;
				//ottengo il campo Tipologia di formazione
				FormTipoId = "FormTipo_"+idFormField;
				FormTipoValue = document.getElementById(FormTipoId).options[document.getElementById(FormTipoId).selectedIndex].value;
				if (CheckTitle(FormTipoValue) == false) boolErrore = true;				
				//ottengo il campo Tipologia di studio
				FormTitoloStudioId = "FormTitoloStudio_"+idFormField;
				FormTitoloStudioValue = document.getElementById(FormTitoloStudioId).options[document.getElementById(FormTitoloStudioId).selectedIndex].value;
				if (CheckTitle(FormTitoloStudioValue) == false) boolErrore = true;				


				if (boolErrore) {
					alert(errFormazione + "("+idFormField+") ]");
					myForm.elements[FormPeriododalId].focus();
					return false;
				} else {
					return true;
				}

			}
		}
	}
	//Ok, non ci sono errori
	return true;
}
// -----------------------------------------------------------------------------
// CONOSCENZE INFORMATICHE VALIDATION
// Validazione della sezione 
// -----------------------------------------------------------------------------
function checkConoInfo(myForm) {

	numEspLav = 0;
	idFormField = 0;	//ID numerico del campo della form
	
	for (var e = 0; e < myForm.elements.length; e++) {
		var el = new String(myForm.elements[e].name);
		//controllo presenza di "software"
		if (el.indexOf('ConoInfoSoftware_') != -1) {
			numEspLav = numEspLav + 1;  //numero delle esperienze lavorative
			//controllo solo se inserisco il valore nel campo "periodo dal"
			if (myForm.elements[e].value !="") { 
				boolErrore = false;
				//Se il campo "Periodo dal" verifico che anche il resto dei campi sia compilato
				myStr = myForm.elements[e].name;
				strContatore 	= new String(myStr);			//ottengo ID numerico del campo
				splitContatore 	= strContatore.split("_");		//ottengo ID numerico del campo
				idFormField 	= splitContatore[1];			//ottengo ID numerico del campo

				//ottengo il campo Software / area di competenza
				ConoInfoSoftwareId = "ConoInfoSoftware_"+idFormField;
				ConoInfoSoftwareValue = document.getElementById(ConoInfoSoftwareId).options[document.getElementById(ConoInfoSoftwareId).selectedIndex].value;
				if (CheckTitle(ConoInfoSoftwareValue) == false) boolErrore = true;
				//ottengo il campo Livello di conoscenza
				ConoInfoLivId = "ConoInfoLiv_"+idFormField;
				ConoInfoLivValue = document.getElementById(ConoInfoLivId).options[document.getElementById(ConoInfoLivId).selectedIndex].value;
				if (CheckTitle(ConoInfoLivValue) == false) boolErrore = true;


				if (boolErrore) {
					alert( errConoInfo +"("+idFormField+") ]");
					myForm.elements[ConoInfoSoftwareId].focus();
					return false;
				} else {
					return true;
				}

			}
		}
	}
	//Ok, non ci sono errori
	return true;
}
// -----------------------------------------------------------------------------
// CONOSCENZE LINGUISTICHE VALIDATION
// Validazione della sezione 
// -----------------------------------------------------------------------------
function checkConoLing(myForm) {

	idFormField = 0;	//ID numerico del campo della form
	
	for (var e = 0; e < myForm.elements.length; e++) {
		var el = new String(myForm.elements[e].name);
		//controllo presenza di "periodo dal"
		if (el.indexOf('ConoLingLingua_') != -1) {
			//controllo solo se inserisco il valore nel campo "periodo dal"
			if (myForm.elements[e].value !="") { 
				boolErrore = false;
				//Se il campo "Lingua" verifico che anche il resto dei campi sia compilato
				myStr = myForm.elements[e].name;
				strContatore 	= new String(myStr);			//ottengo ID numerico del campo
				splitContatore 	= strContatore.split("_");		//ottengo ID numerico del campo
				idFormField 	= splitContatore[1];			//ottengo ID numerico del campo

				//ottengo il campo Lingua
				ConoLingLinguaId = "ConoLingLingua_"+idFormField;
				ConoLingLinguaValue = document.getElementById(ConoLingLinguaId).options[document.getElementById(ConoLingLinguaId).selectedIndex].value;
				if (CheckTitle(ConoLingLinguaValue) == false) boolErrore = true;
				//ottengo il campo Livello di conoscenza Orale
				ConoLingLivoraleId = "ConoLingLivorale_"+idFormField;
				ConoLingLivoraleValue = document.getElementById(ConoLingLivoraleId).options[document.getElementById(ConoLingLivoraleId).selectedIndex].value;
				if (CheckTitle(ConoLingLivoraleValue) == false) boolErrore = true;
				//ottengo il campo Livello di conoscenza Lettura
				ConoLingLivletturaId = "ConoLingLivlettura_"+idFormField;
				ConoLingLivletturaValue = document.getElementById(ConoLingLivletturaId).options[document.getElementById(ConoLingLivletturaId).selectedIndex].value;
				if (CheckTitle(ConoLingLivletturaValue) == false) boolErrore = true;
				//ottengo il campo Livello di conoscenza Orale
				ConoLingLivscrittoId = "ConoLingLivscritto_"+idFormField;
				ConoLingLivscrittoValue = document.getElementById(ConoLingLivscrittoId).options[document.getElementById(ConoLingLivscrittoId).selectedIndex].value;
				if (CheckTitle(ConoLingLivscrittoValue) == false) boolErrore = true;				


				if (boolErrore) {
					alert(errConoLing + "("+idFormField+") ]");
					myForm.elements[ConoLingLinguaId].focus();
					return false;
				} else {
					return true;
				}
			}
		}
	}
	//Ok, non ci sono errori
	return true;
}

// Per invio FORM pagina STEP 3
// controllo che tutte le sezioni di informazione siano compilate in maniera corretta e poi invio la form
function checkAndSubmitStep3 (myForm) {
	if ( (checkDatiAnagrafici(myForm)) && (checkSituazioneAttuale(myForm)) && (checkEspProfessionale(myForm)) && (checkFormazione(myForm)) && (checkConoInfo(myForm)) && (checkConoLing(myForm)) ) {
		alert(msgCongratulazioni)
		//window.document.myForm.submit();
	} else {
		return false;
	}
}

// #############################################################################
// Funzioni utilizzate per modificare l'altezza dell'IFRAME 
// associato alle Job Opportunities
//##############################################################

function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function setJobOpportunitiesIframeHeight(IframeID) {
/*
Questa funzione permette di modificare automaticamente l'altezza della IFRAME presente in
CAMOZZIGROUP/JOBOPPORTUNITIES. L'altezza della IFRAME varia in base al contenuto delle pagine
che vengono richiamate e che sono presenti nel sito CURRICULUM.
*/
	/* // CODICE ORIGINALE COMMENTATO DA LMILANI
	  var iframeWin = window.frames[iframeName];
	  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
	  if ( iframeEl && iframeWin ) {
		iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
		var docHt = getDocHeight(iframeWin.document);
		// need to add to height to be sure it will all show
		if (docHt) iframeEl.style.height = docHt + 30 + "px";
	  }
	*/
	//controllo di essere in CamozziGroup e quindi la pagina viene richiamata come IFRAME
	// il valore IframeID è l'ID della IFRAME prensente nella pagina di Job Opportunities
	if (top.document.getElementById(IframeID)) {	
		var iframeName = top.document.getElementById(IframeID).name;
		var iframeWin = top.frames[iframeName];	

		var docHt = getDocHeight(iframeWin.document); //altezza pagina in curriculum
		if (docHt) top.document.getElementById(IframeID).style.height = docHt + 30 + "px";
	} else {
		//mi trovo nella directory CURRICULUM senza essere richiamato tramite IFRAME
	}
}

function addEvent(obj, evt, func) {
 // AGGIUNGE una funzione all'event-handler di un oggetto (es. aggiunge funzione a window.onload)  // anzichè sovrascriverlo (e permette l'uso di "this" nella funzione)
   if(obj[evt]) {
  obj[evt]=function(f,g){
     return function(){
    f.apply(this,arguments);
    return g.apply(this,arguments);
     };
  }(func, obj[evt]);
   } else obj[evt]=func;
}
// #############################################################################


