/*
#####################################################################################################
POPUP
#####################################################################################################
*/
function popup(id){
	var w = 800;
	var h = 550;
	var x=( screen.Width - w )/2;
	var y=( screen.Height - h )/2;
	var win=window.open("popup.php?id="+id,"allegato","resizable=0,width= "+w+" ,height="+h+", status=0, left="+x+", top="+y+", scrollbars=1, menubar=0, toolbars=0, directories=0");
	win.focus();
}

// JavaScript Document    Commentata il 19/10/2006
/*function aggiornaSomma(tipo){ //Primo tipo di visualizzazione per iscrizione e apprendistato
	var thisForm=document.dati;
		thisForm.forzalavoro_modificata.value="1";
	switch (tipo){
		case "1":
			thisForm.tot5.value=eval(thisForm.dirigenti.value) + eval(thisForm.quadri.value) + eval(thisForm.imp_e_operai.value) + eval(thisForm.soci_lav_e_coll_fam.value);
		break;
		case "2":
			thisForm.tot11.value=eval(thisForm.apprend.value) + eval(thisForm.ctr_inser.value) + eval(thisForm.ctr_reins.value) + eval(thisForm.a_t_det.value) + eval(thisForm.somm_a_t_det.value)+ eval(thisForm.tot5.value);
		break;
	}
}

function aggiornaSomma4(tipo){
	var thisForm=document.registrazione;
		thisForm.forzalavoro_modificata.value="1";
	switch (tipo){
		case "1":
			thisForm.tot5.value=eval(thisForm.dirigenti.value) + eval(thisForm.quadri.value) + eval(thisForm.imp_e_operai.value) + eval(thisForm.soci_lav_e_coll_fam.value);
		break;
		case "2":
			thisForm.tot11.value=eval(thisForm.apprend.value) + eval(thisForm.ctr_inser.value) + eval(thisForm.ctr_reins.value) + eval(thisForm.a_t_det.value) + eval(thisForm.somm_a_t_det.value)+ eval(thisForm.tot5.value);
		break;
	}
}*/

function pianoFormativo(ordine,idMenuPianoFormativo,idAzienda,idComunicazione){
	
	
	
	
	var w = 600;
	var h = 800;
	var x=( screen.Width - w )/2;
	var y=( screen.Height - h )/2;    

	var win=window.open("updatePianoFormativo.php?id="+idMenuPianoFormativo+"&ordine="+ordine+"&idcomunicazione="+idComunicazione+"&idazienda="+idAzienda,"", "resizable=0,width= "+w+" ,height="+h+", status=0, left="+x+", top="+y+", scrollbars=1, menubar=0, toolbars=0, directories=0");
	win.focus();
}


// JavaScript Document
/*function aggiornaSomma(tipo){ //Primo tipo di visualizzazione per iscrizione e apprendistato
	var thisForm=document.dati;
		thisForm.forzalavoro_modificata.value="1";
	switch (tipo){
		case "1":
			thisForm.tot5.value=eval(thisForm.dirigenti.value) + eval(thisForm.quadri.value) + eval(thisForm.imp_e_operai.value) + eval(thisForm.soci_lav_e_coll_fam.value);
		break;
		case "2":
			thisForm.tot11.value=eval(thisForm.apprend.value) + eval(thisForm.ctr_inser.value) + eval(thisForm.ctr_reins.value) + eval(thisForm.a_t_det.value) + eval(thisForm.somm_a_t_det.value)+ eval(thisForm.tot5.value);
		break;
	}
}*/

function aggiornaSomma(tipo){ 
	var thisForm=document.dati;
	thisForm.forzalavoro_modificata.value="1";

	switch (tipo){
	case "1":
		if(thisForm.tot4){
		thisForm.tot4.value=eval(thisForm.dirigenti.value) + eval(thisForm.quadri.value) + eval(thisForm.imp_e_operai.value);
		thisForm.tot11.value=eval(thisForm.tot4.value)+eval(thisForm.a_termine.value)+eval(thisForm.lavoro_extra.value)  +
eval(thisForm.apprend.value)+eval(thisForm.ctr_inser.value)+eval(thisForm.ctr_reinser.value)+eval(thisForm.ripartito.value)+eval(thisForm.a_t_det.value)+eval(thisForm.somm_a_t_det.value)+eval(thisForm.soci_lav_e_coll_fam.value)+eval(thisForm.contratti_a_chiamata.value);
		}
		if(thisForm.tot4_terni){
		thisForm.tot4_terni.value=eval(thisForm.dirigenti_terni.value) + eval(thisForm.quadri_terni.value) + eval(thisForm.imp_e_operai_terni.value);
		thisForm.tot11_terni.value=eval(thisForm.tot4_terni.value)+eval(thisForm.a_termine_terni.value)+eval(thisForm.lavoro_extra_terni.value)  +
eval(thisForm.apprend_terni.value)+eval(thisForm.ctr_inser_terni.value)+eval(thisForm.ctr_reinser_terni.value)+eval(thisForm.ripartito_terni.value)+eval(thisForm.a_t_det_terni.value)+eval(thisForm.somm_a_t_det_terni.value)+eval(thisForm.soci_lav_e_coll_fam_terni.value)+eval(thisForm.contratti_a_chiamata_terni.value);
		}
		
		
		break;
		
		case "2":
		if(thisForm.tot11){
thisForm.tot11.value=eval(thisForm.tot4.value)+eval(thisForm.a_termine.value)+eval(thisForm.lavoro_extra.value)  +
eval(thisForm.apprend.value)+eval(thisForm.ctr_inser.value)+eval(thisForm.ctr_reinser.value)+eval(thisForm.ripartito.value)+eval(thisForm.a_t_det.value)+eval(thisForm.somm_a_t_det.value)+eval(thisForm.soci_lav_e_coll_fam.value)+eval(thisForm.contratti_a_chiamata.value);
		}
		if(thisForm.tot11_terni){
thisForm.tot11_terni.value=eval(thisForm.tot4_terni.value)+eval(thisForm.a_termine_terni.value)+eval(thisForm.lavoro_extra_terni.value)  +
eval(thisForm.apprend_terni.value)+eval(thisForm.ctr_inser_terni.value)+eval(thisForm.ctr_reinser_terni.value)+eval(thisForm.ripartito_terni.value)+eval(thisForm.a_t_det_terni.value)+eval(thisForm.somm_a_t_det_terni.value)+eval(thisForm.soci_lav_e_coll_fam_terni.value)+eval(thisForm.contratti_a_chiamata_terni.value);
		}
	break;
		
	}
}


function aggiornaSommaRegistrazione(tipo){ 
	var thisForm=document.registrazione;
	thisForm.forzalavoro_modificata.value="1";

	switch (tipo){
	case "1":
		if(thisForm.tot4){
		thisForm.tot4.value=eval(thisForm.dirigenti.value) + eval(thisForm.quadri.value) + eval(thisForm.imp_e_operai.value);
		thisForm.tot11.value=eval(thisForm.tot4.value)+eval(thisForm.a_termine.value)+eval(thisForm.lavoro_extra.value)  +
eval(thisForm.apprend.value)+eval(thisForm.ctr_inser.value)+eval(thisForm.ctr_reinser.value)+eval(thisForm.ripartito.value)+eval(thisForm.a_t_det.value)+eval(thisForm.somm_a_t_det.value)+eval(thisForm.soci_lav_e_coll_fam.value);
		}
		if(thisForm.tot4_terni){
		thisForm.tot4_terni.value=eval(thisForm.dirigenti_terni.value) + eval(thisForm.quadri_terni.value) + eval(thisForm.imp_e_operai_terni.value);
		thisForm.tot11_terni.value=eval(thisForm.tot4_terni.value)+eval(thisForm.a_termine_terni.value)+eval(thisForm.lavoro_extra_terni.value)  +
eval(thisForm.apprend_terni.value)+eval(thisForm.ctr_inser_terni.value)+eval(thisForm.ctr_reinser_terni.value)+eval(thisForm.ripartito_terni.value)+eval(thisForm.a_t_det_terni.value)+eval(thisForm.somm_a_t_det_terni.value)+eval(thisForm.soci_lav_e_coll_fam_terni.value);
		}
		
		
		break;
		
		case "2":
		if(thisForm.tot11){
thisForm.tot11.value=eval(thisForm.tot4.value)+eval(thisForm.a_termine.value)+eval(thisForm.lavoro_extra.value)  +
eval(thisForm.apprend.value)+eval(thisForm.ctr_inser.value)+eval(thisForm.ctr_reinser.value)+eval(thisForm.ripartito.value)+eval(thisForm.a_t_det.value)+eval(thisForm.somm_a_t_det.value)+eval(thisForm.soci_lav_e_coll_fam.value);
		}
		if(thisForm.tot11_terni){
thisForm.tot11_terni.value=eval(thisForm.tot4_terni.value)+eval(thisForm.a_termine_terni.value)+eval(thisForm.lavoro_extra_terni.value)  +
eval(thisForm.apprend_terni.value)+eval(thisForm.ctr_inser_terni.value)+eval(thisForm.ctr_reinser_terni.value)+eval(thisForm.ripartito_terni.value)+eval(thisForm.a_t_det_terni.value)+eval(thisForm.somm_a_t_det_terni.value)+eval(thisForm.soci_lav_e_coll_fam_terni.value);
		}
	break;
		
	}
}




function aggiornaSomma4(tipo){ //Primo tipo di visualizzazione per iscrizione e apprendistato
	var thisForm=document.registrazione;
		thisForm.forzalavoro_modificata.value="1";

	switch (tipo){
		case "1":
		thisForm.tot4.value=eval(thisForm.dirigenti.value) + eval(thisForm.quadri.value) + eval(thisForm.imp_e_operai.value);
		thisForm.tot11.value=eval(thisForm.tot4.value)+eval(thisForm.a_termine.value)+eval(thisForm.lavoro_extra.value)  +
eval(thisForm.apprend.value)+eval(thisForm.ctr_inser.value)+eval(thisForm.ctr_reinser.value)+eval(thisForm.ripartito.value)+eval(thisForm.a_t_det.value)+eval(thisForm.somm_a_t_det.value)+eval(thisForm.soci_lav_e_coll_fam.value);

		break;
		
		case "2":
thisForm.tot11.value=eval(thisForm.tot4.value)+eval(thisForm.a_termine.value)+eval(thisForm.lavoro_extra.value)  +
eval(thisForm.apprend.value)+eval(thisForm.ctr_inser.value)+eval(thisForm.ctr_reinser.value)+eval(thisForm.ripartito.value)+eval(thisForm.a_t_det.value)+eval(thisForm.somm_a_t_det.value)+eval(thisForm.soci_lav_e_coll_fam.value);

	break;
		
	}
}



function controlForm(){
	thisForm=document.accesso;
	
	if(thisForm.partita_iva.value==''){
		alert("Inserire la Partita IVA");
		thisForm.user.focus();
		return;
	}
	if(thisForm.user.value==''){
		alert("Inserire nome utente");
		thisForm.user.focus();
		return;
	}
	if(thisForm.pass.value==''){
		alert("Inserire la password");
		thisForm.pass.focus();
		return;
	}
	thisForm.submit();
}

function richiediPwd(){
	thisForm=document.richiedi;
	if(!checkEmailAddress(nomeForm.email)) return;
	thisForm.action="_class/classAzioni.php";
	thisForm.submit();
}

function aggiornaSomma3(tipo){
	var thisForm=document.dati;
	switch (tipo){
		case "1":
			thisForm.tot5.value=eval(thisForm.dirigenti.value) + eval(thisForm.quadri.value) + eval(thisForm.imp_e_operai.value) + eval(thisForm.soci_lav_e_coll_fam.value);
		break;
		case "2":
			thisForm.tot11.value=eval(thisForm.apprend.value) + eval(thisForm.ctr_inser.value) + eval(thisForm.ctr_reins.value) + eval(thisForm.a_t_det.value) + eval(thisForm.somm_a_t_det.value)+ eval(thisForm.tot5.value);
		break;
	}
}

function aggiornaSomma2(tipo){
	var thisForm=document.dati;
	switch (tipo){
		case "1":
			thisForm.tot5.value=eval(thisForm.dirigenti.value) + eval(thisForm.quadri.value) + eval(thisForm.imp_e_operai.value) + eval(thisForm.soci_lav_e_coll_fam.value);
		break;
		case "2":
			thisForm.tot11.value=eval(thisForm.apprend.value) + eval(thisForm.ctr_inser.value) + eval(thisForm.ctr_reins.value) + eval(thisForm.a_t_det.value) + eval(thisForm.somm_a_t_det.value)+ eval(thisForm.tot5.value);
		break;
	}
}


// FUNZIONI AZIENDA
function addAttivita(){
	var w = 1000;
	var h = 160;
	var x=( screen.Width - w )/2;
	var y=( screen.Height - h )/2;    //era uploadLink
	var win=window.open("aziende/addAttivita.php","link","resizable=0,width= "+w+" ,height="+h+", status=0, left="+x+", top="+y+", scrollbars=0, menubar=0, toolbars=0, directories=0");
	win.focus();
}
function deleteAttivita(sezione, tabella, id){   //era deleteInsertLink.php
	var delAttivita=window.open(sezione + "/deleteAttivita.php?tabella="+tabella+"&id="+id, "delAtt", "width=4, height=3, scrollbars=0, status=0, menubar=0, toolbars=0, directories=0, left=4000, top=3000");
}

// FUNZIONI AZIENDA
function addAttivitaRlst(id){
	var w = 760;
	var h = 160;
	var x=( screen.Width - w )/2;
	var y=( screen.Height - h )/2;    //era uploadLink
	var win=window.open("aziende/addAttivita.php?rslt=1&idAzienda="+id,"link","resizable=0,width= "+w+" ,height="+h+", status=0, left="+x+", top="+y+", scrollbars=0, menubar=0, toolbars=0, directories=0");
	win.focus();
}
function deleteAttivitaRlst(sezione, tabella, id){   //era deleteInsertLink.php
	var delAttivita=window.open(sezione + "/deleteAttivita.php?rslt=1&tabella="+tabella+"&id="+id, "delAtt", "width=4, height=3, scrollbars=0, status=0, menubar=0, toolbars=0, directories=0, left=4000, top=3000");
}

function addSedeOperativa(){
	var w = 360;
	var h = 400;
	var x=( screen.Width - w )/2;
	var y=( screen.Height - h )/2;    //era uploadLink
	var win=window.open("aziende/addSede.php","link","resizable=0,width= "+w+" ,height="+h+", status=0, left="+x+", top="+y+", scrollbars=0, menubar=0, toolbars=0, directories=0");
	win.focus();
}
function deleteSedeOperativa(sezione, tabella, id){   //era deleteInsertLink.php
	var delAttivita=window.open(sezione + "/deleteSede.php?tabella="+tabella+"&id="+id, "delLink", "width=4, height=3, scrollbars=0, status=0, menubar=0, toolbars=0, directories=0, left=4000, top=3000");
}
function apriSedi(idSede){
	var w = 360;
	var h = 300;
	var x=( screen.Width - w )/2;
	var y=( screen.Height - h )/2;    //era uploadLink
	var win=window.open("aziende/viewSede.php?id="+idSede,"sede","resizable=0,width= "+w+" ,height="+h+", status=0, left="+x+", top="+y+", scrollbars=0, menubar=0, toolbars=0, directories=0");
	win.focus();
}

function confirmUpdate(){
	thisForm=document.dati;
	
	if(thisForm.username.value==''){
		alert("Inserire username");
		thisForm.username.focus();
		return;
	}
	
	thisForm.method="POST";
	thisForm.action='_class/classAzioni.php';
	thisForm.submit();
}

function confermarlst(){
	thisForm=document.dati;

	if(alertControlForm(thisForm.nomeCognome, 'nome e cognome')==false) return;	
	if((thisForm.legaleRappresentante.checked==false)&&(thisForm.socio.checked==false)&&(thisForm.titolare.checked==false)){
		if(alertControlForm(thisForm.legaleRappresentante, 'L.R o socio o titolare')==false) return;	
	}
	
	if(alertControlForm(thisForm.ragioneSociale, 'Ragione Sociale')==false) return;	
	if(alertControlForm(thisForm.idProvincia, 'Provincia')==false) return;
	
	if((thisForm.idProvincia.value==88)||(thisForm.idProvincia.value==63))
	if(alertControlForm(thisForm.idComune, 'comune')==false) return;
		
	if(alertControlForm(thisForm.cap, 'cap')==false) return;	
	if(alertControlForm(thisForm.indirizzo, 'indirizzo')==false) return;	
	if(alertControlForm(thisForm.piva, 'partita iva')==false) return;	
	if(alertControlForm(thisForm.codice_inps, 'codice inps')==false) return;	
	if(alertControlForm(thisForm.codice_inail, 'codice inail')==false) return;
	
	if(alertControlForm(thisForm.telefono, 'telefono')==false) return;
	//if(alertControlForm(thisForm.fax, 'fax')==false) return;	
	if(alertControlForm(thisForm.email, 'email')==false) return;	
	
	if(alertControlForm(thisForm.referente, 'referente')==false) return;
	if(alertControlForm(thisForm.lav_gg, 'data in lavoratori in forza')==false) return;
	if(alertControlForm(thisForm.lav_mm, 'data in lavoratori in forza')==false) return;
	if(alertControlForm(thisForm.lav_aaaa, 'data in lavoratori in forza')==false) return;
	if(alertControlForm(thisForm.lavoratori_num, 'numero lavoratori in forza')==false) return;
	if(alertControlForm(thisForm.soc_gg, 'data in soci lavoratori in forza')==false) return;
	if(alertControlForm(thisForm.soc_mm, 'data in soci lavoratori in forza')==false) return;
	if(alertControlForm(thisForm.soc_aaaa, 'data in soci lavoratori in forza')==false) return;
	if(alertControlForm(thisForm.soci_num, 'data in soci lavoratori in forza')==false) return;
	if(alertControlForm(thisForm.consensook, 'Autorizzo')==false) return;
	if(alertControlForm(thisForm.consensook1, 'Autorizzo')==false) return;
	
	thisForm.azione.value="insertRlst";
	thisForm.method = "POST";
	
	setDisp('confirm', 'block');	
}


function confirmUpdateAzienda(){
	thisForm=document.dati;
	
	nomeTemp="indirizzo";
	if(alertControlForm(thisForm.elements[nomeTemp], 'indirizzo')==false) return;
	
	
	//nomeTemp="telefono";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'telefono')==false) return;
	
	//nomeTemp="fax";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'fax')==false) return;
	
	//nomeTemp="cellulare";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'cellulare')==false) return;
	
	//nomeTemp="email";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'email')==false) return;
	
	//nomeTemp="username";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'username')==false) return;
	
	//nomeTemp="password";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'password')==false) return;
	
	if(window.confirm("ATTENZIONE ! Verificare la correttezza completa dei dati. \n \ Si vuole procedere alla modifica dei dati?")) {

	thisForm.method="POST";
	thisForm.action='_class/classAzioni.php';
	thisForm.submit();
	}
}


function confirmUpdateConsulente(){
	thisForm=document.dati;
	
	/*nomeTemp="nome";
	if(alertControlForm(thisForm.elements[nomeTemp], 'nome')==false) return;
	
	nomeTemp="cognome";
	if(alertControlForm(thisForm.elements[nomeTemp], 'cognome')==false) return;
	*/
	nomeTemp="indirizzo";
	if(alertControlForm(thisForm.elements[nomeTemp], 'indirizzo')==false) return;
	
	nomeTemp="telefono";
	if(alertControlForm(thisForm.elements[nomeTemp], 'telefono')==false) return;
	
	nomeTemp="email";
	if(alertControlForm(thisForm.elements[nomeTemp], 'email')==false) return;
	
	if(window.confirm("ATTENZIONE ! Verificare la correttezza completa dei dati. \n \ Si vuole procedere alla modifica dei dati?")) {

	thisForm.method="POST";
	thisForm.action='_class/classAzioni.php';
	thisForm.submit();
	
	}
}

function insertAzienda(){
	thisForm=document.registrazione;
		
	if((thisForm.periodo_paga_gg.value=="")||(thisForm.periodo_paga_mm.value=="")||(thisForm.periodo_paga_aa.value=="")){
		thisForm.periodo_paga_gg.value="";
		alertControlForm(thisForm.elements["periodo_paga_gg"], 'periodo di paga');
		return
	}
	
	nomeTemp="ragioneSociale";
	if(alertControlForm(thisForm.elements[nomeTemp], 'ragione sociale')==false) return;
	
	nomeTemp="idTipo";
	if(alertControlForm(thisForm.elements[nomeTemp], 'tipo azienda')==false) return;
	
	nomeTemp="partitaIVA";
	if(alertControlForm(thisForm.elements[nomeTemp], 'partita IVA')==false) return;
	
	//nomeTemp="matricola_inps";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'matricola INPS')==false) return;
	
	//nomeTemp="matricola_inail";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'matricola INAIL')==false) return;
	
	nomeTemp="nome";
	if(alertControlForm(thisForm.elements[nomeTemp], 'nome')==false) return;
	
	nomeTemp="cognome";
	if(alertControlForm(thisForm.elements[nomeTemp], 'cognome')==false) return;
	
	nomeTemp="indirizzo";
	if(alertControlForm(thisForm.elements[nomeTemp], 'indirizzo')==false) return;
	
	
	
	nomeTemp="cap_aggiuntivo";
	if(alertControlForm(thisForm.elements[nomeTemp], 'CAP')==false) return;
	
	
	
	//nomeTemp="telefono";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'telefono')==false) return;
	
	//nomeTemp="fax";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'fax')==false) return;
	
	//nomeTemp="cellulare";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'cellulare')==false) return;
	
	//nomeTemp="email";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'email')==false) return;
	
	var dentro=false;
	for (i=0; i<thisForm.elements.length; i++) {
		if ((thisForm.elements[i].type == "checkbox")&&(thisForm.elements[i].name=="attivitaAggiuntiva")) {
			if (thisForm.elements[i].checked) dentro=true;
		}
	}
	
	//if(dentro==false){
	//	alertControlForm(thisForm.attivitaAggiuntiva[0], 'Tipologia Attivita');
	//	return;
	//}		
	
	nomeTemp="attivita_modificata";
	if(alertControlForm(thisForm.elements[nomeTemp], 'ATTIVITA\'')==false) return;
	
	nomeTemp="username";
	if(alertControlForm(thisForm.elements[nomeTemp], 'username')==false) return;
	
	nomeTemp="password";
	if(alertControlForm(thisForm.elements[nomeTemp], 'password')==false) return;
	
	nomeTemp="acconsento";
	if(alertControlForm(thisForm.elements[nomeTemp], 'per il consenso al trattamento dei dati personali')==false) return;
	

	if(window.confirm("ATTENZIONE ! Verificare la correttezza completa dei dati. \n Premendo il tasto ok si dichiara di aver preso visione e di accettare tutte le condizioni dell'iscrizione. \n Si vuole procedere all'inserimento dei dati e all'iscrizione?")) {

	thisForm.action='_class/classAzioni.php';
	thisForm.method="POST";
	
	thisForm.azione.value="insertAzienda";
	thisForm.submit();
	}
}

function insertAziendaCons(){
	thisForm=document.dati;
	
	if((thisForm.periodo_paga_gg.value=="")||(thisForm.periodo_paga_mm.value=="")||(thisForm.periodo_paga_aa.value=="")){
		thisForm.periodo_paga_gg.value="";
		alertControlForm(thisForm.elements["periodo_paga_gg"], 'periodo di paga');
		return
	}
	
	nomeTemp="ragioneSociale";
	if(alertControlForm(thisForm.elements[nomeTemp], 'ragione sociale')==false) return;

		
	nomeTemp="idTipo";
	if(alertControlForm(thisForm.elements[nomeTemp], 'tipo azienda')==false) return;
	
	nomeTemp="partitaIVA";
	if(alertControlForm(thisForm.elements[nomeTemp], 'partita IVA')==false) return;
	
	//nomeTemp="matricola_inps";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'matricola INPS')==false) return;
	
	//nomeTemp="matricola_inail";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'matricola INAIL')==false) return;
	
	nomeTemp="nome";
	if(alertControlForm(thisForm.elements[nomeTemp], 'nome')==false) return;
	
	nomeTemp="cognome";
	if(alertControlForm(thisForm.elements[nomeTemp], 'cognome')==false) return;
	
	nomeTemp="indirizzo";
	if(alertControlForm(thisForm.elements[nomeTemp], 'indirizzo')==false) return;
	
	nomeTemp="cap_aggiuntivo";
	if(alertControlForm(thisForm.elements[nomeTemp], 'CAP')==false) return;
	
	

	
	//nomeTemp="telefono";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'telefono')==false) return;
	
	//nomeTemp="fax";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'fax')==false) return;
	
	//nomeTemp="cellulare";
	//if(alertControlForm(thisForm.elements[nomeTemp], 'cellulare')==false) return;
	
	//nomeTemp="email";---Modificato il 10-01-2006
	//if(alertControlForm(thisForm.elements[nomeTemp], 'email')==false) return;
	
	/*nomeTemp="username";
	if(alertControlForm(thisForm.elements[nomeTemp], 'username')==false) return;
	
	nomeTemp="password";
	if(alertControlForm(thisForm.elements[nomeTemp], 'password')==false) return;
	*/
	var dentro=false;
	for (i=0; i<thisForm.elements.length; i++) {
		if ((thisForm.elements[i].type == "checkbox")&&(thisForm.elements[i].name=="attivitaAggiuntiva")) {
			if (thisForm.elements[i].checked) dentro=true;
		}
	}
	
	if(dentro==false){
		alertControlForm(thisForm.attivitaAggiuntiva[0], 'Tipologia Attivita');
		return;
	}	
	
	nomeTemp="attivita_modificata";
	if(alertControlForm(thisForm.elements[nomeTemp], 'ATTIVITA\'')==false) return;
		
	nomeTemp="acconsento";
	if(alertControlForm(thisForm.elements[nomeTemp], 'per il consenso al trattamento dei dati personali')==false) return;	
		
	if(window.confirm("ATTENZIONE ! Verificare la correttezza completa dei dati. \n Premendo il tasto ok si dichiara di aver preso visione e di accettare tutte le condizioni dell'iscrizione per l\'azienda in considerazione. \n Si vuole procedere all'inserimento dei dati e all'iscrizione?")) {
	
	thisForm.action='_class/classAzioni.php';
	thisForm.method="POST";
	
	thisForm.azione.value="insertAziendaCons";
	thisForm.submit();
	}
}

function insertConsulente(){
	
		
	
	thisForm=document.registrazione;
	
	nomeTemp="ragioneSociale";
	if(alertControlForm(thisForm.elements[nomeTemp], 'Ragione Sociale')==false) return;
	
	
	nomeTemp="partitaIVA";
	if(alertControlForm(thisForm.elements[nomeTemp], 'partita IVA')==false) return;
	
	/*nomeTemp="nome";
	if(alertControlForm(thisForm.elements[nomeTemp], 'nome')==false) return;
	
	nomeTemp="cognome";
	if(alertControlForm(thisForm.elements[nomeTemp], 'cognome')==false) return;
	*/
	nomeTemp="indirizzo";
	if(alertControlForm(thisForm.elements[nomeTemp], 'indirizzo')==false) return;
	
	nomeTemp="telefono";
	if(alertControlForm(thisForm.elements[nomeTemp], 'telefono')==false) return;
	
	nomeTemp="email";
	if(alertControlForm(thisForm.elements[nomeTemp], 'email')==false) return;
	
	nomeTemp="username";
	if(alertControlForm(thisForm.elements[nomeTemp], 'username')==false) return;
	
	nomeTemp="password";
	if(alertControlForm(thisForm.elements[nomeTemp], 'password')==false) return;
	
	nomeTemp="acconsento";
	if(alertControlForm(thisForm.elements[nomeTemp], 'per il consenso al trattamento dei dati personali')==false) return;
	
	if(window.confirm("ATTENZIONE ! Verificare la correttezza completa dei dati. \n\ Ricordiamo inoltre che all'atto dell'iscrizione sarà possibile inserire da subito i dati delle aziende.\n\n Si vuole procedere all'iscrizione?")) {

	thisForm.action='_class/classAzioni.php';
	thisForm.method="POST";
	
	thisForm.azione.value="insertConsulente";
	thisForm.submit();
	
	}
}

function insertComunicazione(){

	var rslt=false;
	thisForm=document.dati;
	thisForm2=document.reload;
	tipoCom=thisForm.tipoComunicazione.value;
	switch(tipoCom){
		case "8": // APPRENDISTATO
			nomeTemp="c1_1";
			if(alertControlForm(thisForm.elements[nomeTemp], 'compilare almeno una riga')==false) return;
			for(var i=1; i<=5; i++){
				nomeTemp="c1_"+i;
				if(thisForm.elements[nomeTemp].value!=""){
					for (var t=1; t<=7; t++){
						nomeTemp2="c"+t+"_"+i;
						if (thisForm.elements[nomeTemp2].type!="select-one"){
							if(alertControlForm(thisForm.elements[nomeTemp2], 'mancante')==false) return;
						}
						else if (thisForm.elements[nomeTemp2].options.length>1){
							if(alertControlForm(thisForm.elements[nomeTemp2], 'mancante')==false) return;
						}
					}
				}
			}
			
			if((thisForm.ravs2.value!=0)||(thisForm.ravs3.value!=0)||(thisForm.ravs4.value!=0)||(thisForm.ravs5.value!=0)||(thisForm.ravs6.value!=0)||(thisForm.ravs7.value!=0)){
				if(thisForm.ravs1.value==0){
					alert("Attenzione! Riempire il campo Rapporti apprendistato In totale");
					return false;
				}
			}
			/*if( !(thisForm.conformita[0].checked) && !(thisForm.conformita[1].checked) ){
				alert("Selezionare la conformità");
				return;
			}*/
		break;
			
		case "11": //RLST
			if(alertControlForm(thisForm.referente, 'referente')==false) return;
			if(alertControlForm(thisForm.lav_gg, 'data in lavoratori in forza')==false) return;
			if(alertControlForm(thisForm.lav_mm, 'data in lavoratori in forza')==false) return;
			if(alertControlForm(thisForm.lav_aaaa, 'data in lavoratori in forza')==false) return;
			if(alertControlForm(thisForm.lavoratori_num, 'numero lavoratori in forza')==false) return;
			if(alertControlForm(thisForm.soc_gg, 'data in soci lavoratori in forza')==false) return;
			if(alertControlForm(thisForm.soc_mm, 'data in soci lavoratori in forza')==false) return;
			if(alertControlForm(thisForm.soc_aaaa, 'data in soci lavoratori in forza')==false) return;
			if(alertControlForm(thisForm.soci_num, 'data in soci lavoratori in forza')==false) return;
			if(alertControlForm(thisForm.consensook, 'Autorizzo')==false) return;
			if(alertControlForm(thisForm.consensook1, 'Autorizzo')==false) return;
			var rslt=true;
			
		break;
		
		case "12": // TEMPO DET.
			if(alertControlForm(thisForm.da_gg, 'quadrimestre dal')==false) return;
			if(alertControlForm(thisForm.da_mm, 'quadrimestre dal')==false) return;
			if(alertControlForm(thisForm.da_aaaa, 'quadrimestre dal')==false) return;
			if(alertControlForm(thisForm.a_gg, 'quadrimestre al')==false) return;
			if(alertControlForm(thisForm.a_mm, 'quadrimestre al')==false) return;
			if(alertControlForm(thisForm.a_aaaa, 'quadrimestre al')==false) return;
			nomeTemp="c1_1";
			if(alertControlForm(thisForm.elements[nomeTemp], 'compilare almeno una riga')==false) return;
			for(var i=1; i<=5; i++){
				nomeTemp="c1_"+i;
				if(thisForm.elements[nomeTemp].value!=""){
					for (var t=1; t<=6; t++){
						if( (t!=5) && (t!=4) ){
							nomeTemp2="c"+t+"_"+i;
							if(alertControlForm(thisForm.elements[nomeTemp2], 'compilare tutti i campi')==false) return;
						}
						else{
							nomeTemp2="c"+t+"_"+i+"_data_gg";
							if(alertControlForm(thisForm.elements[nomeTemp2], 'compilare tutti i campi')==false) return;
							nomeTemp2="c"+t+"_"+i+"_data_mm";
							if(alertControlForm(thisForm.elements[nomeTemp2], 'compilare tutti i campi')==false) return;
							nomeTemp2="c"+t+"_"+i+"_data_aa";
							if(alertControlForm(thisForm.elements[nomeTemp2], 'compilare tutti i campi')==false) return;
						}
						
					}
				}
			}
			
		break;
	}
	
	controlModifica=false;
	controlModifica2=false;
	if(thisForm.forzalavoro_modificata.value=="1"){
		if(confirm("La forza lavoro aziendale risulta diversa da quella dell'iscrizione. \n Si vuole quindi modificare anche la forza lavoro per l'iscrizione ? (OK=si, Annulla=no)")){
			controlModifica=true;
		}else{
			controlModifica=false;
		}
		
	}
	
	if(thisForm.dislocazione_modificata.value=="1"){
		if(confirm("La dislocazione della forza lavoro indicata nelle unità locali risulta diversa da quella dell\’iscrizione. \n DOVETE CLICCARE SU OK IN MODO DA AGGIORNARE TUTTI I DATI.  (ok=si; Annulla=NO)")){
			controlModifica2=true;
		}else{
			controlModifica2=false;
		}
	}
	
	if(rslt==true) var messaggio ="Il modello deve essere stampato firmato e spedito con gli allegati richiesti. Fino a quando non arriva il formato cartaceo tale inserimento non ha alcun valore.";	
	else var messaggio="ATTENZIONE ! Verificare la correttezza completa dei dati. \nDigitare ok per la conferma e l'invio telematico.";
	if(window.confirm(messaggio)) {
		thisForm.action='_class/classAzioni.php';
		thisForm.method="POST";	
		thisForm.azione.value="insertComunicazione";
		if(!controlModifica) thisForm.forzalavoro_modificata.value="0";
		if(!controlModifica2) thisForm.dislocazione_modificata.value="0";	
		thisForm.submit();
	}//Fine if confirm
}


function alertControlForm(campo, variabile){
	tipo=campo.type;
	switch (tipo){
		case "text":
			if(campo.value==''){
				alert("Attenzione! Riempire il campo "+ variabile.toUpperCase());
				return false;
			}
		break;
		case "radio":
			if(!(campo.checked)){
				alert("Attenzione! Selezionare il campo "+ variabile.toUpperCase());
				return false;
			}
		break;
			case "checkbox":
			if(!(campo.checked)){
				alert("Attenzione! Selezionare il campo "+ variabile.toUpperCase());
				return false;
			}
		break;
		case "select-one":
			if(campo.selectedIndex==0){
				alert("Attenzione! Selezionare un valore per "+ variabile.toUpperCase());
				return false;
			}
			break;
		case "hidden":
			if((campo.value=='0')){
				alert("Attenzione! Riempire il campo "+ variabile.toUpperCase());
				return false;
			}
		break;

	}
}

var indirizzoEmail;
function checkEmailAddress(field) {

     var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
     
     if (goodEmail){
        indirizzoEmail = true;
     } 
     else {
        alert('Inserire un indirizzo email valido');
        field.focus();
        field.select();
        indirizzoEmail = false;
        }
  	return indirizzoEmail;
}


function controlFormContatti(){

	thisForm=document.contattaci;
	
	if(thisForm.nome.value==''){
		alert("Inserire un nome per il contatto");
		thisForm.nome.focus();
		return;
	}
	if(thisForm.cognome.value==''){
		alert("Inserire un cognome per il contatto");
		thisForm.cognome.focus();
		return;
	}
	if(thisForm.email.value==''){
		alert("Inserire un indirizzo email valido per il contatto");
		thisForm.email.focus();
		return;
	}
	if(!checkEmailAddress(thisForm.email)) return;
	thisForm.submit();
}

