/*******************************************************************************************************************/
/*******************************************************************************************************************/
/**** FUNZIONI VARIE ***********************************************************************************************/
/*******************************************************************************************************************/

/********************************************************/
/** Visualiza elemento tramite id **/
function visualizzaById(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}


/********************************************************/
/** Nasconde elemento tramite id **/
function nascondiById(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

/********************************************************/
/** Redirige a pagina da select **/
function go() {
   url = document.selectPage.page.value;
   // alert(url);
   location.href = url;
} 

/********************************************************/
/** Valida partita IVA **/
function checkPartitaIva(sz_Codice)
   {
   var n_Val,n_Som1=0,n_Som2=0,lcv;
   if (sz_Codice.length!=11 || isNaN(parseFloat(sz_Codice)) || parseFloat(sz_Codice)<parseFloat(0))
      return false;
   
   for (lcv=0;lcv<9;lcv+=2)
   {
      n_Val=parseInt(sz_Codice.charAt(lcv));
      n_Som1+=n_Val;
      n_Val=parseInt(sz_Codice.charAt(lcv+1));
      n_Som1+=Math.floor(n_Val/5) + (n_Val<<1) % 10;
   }
   n_Som2 = 10 - (n_Som1 % 10);
   n_Val=parseInt(sz_Codice.charAt(10));
   if (n_Som2==n_Val)
      return true;
   return false;
   }

/********************************************************/
/** Valida codice fiscale **/
function checkCodiceFiscale(cfins) 
   {
   var cf = cfins.toUpperCase();
   var cfReg = /^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/;
   if (!cfReg.test(cf))
      return false;
   var set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
   var s = 0;
   for( i = 1; i <= 13; i += 2 )
      s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
   for( i = 0; i <= 14; i += 2 )
      s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
   if ( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) )
      return false;
   return true;
   }

/********************************************************/
/** Valida email **/
function checkEmail(indirizzo) {
	  if (window.RegExp) {
	    var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
	    var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
	    var regnv = new RegExp(nonvalido);
	    var regv = new RegExp(valido);
	    if (!regnv.test(indirizzo) && regv.test(indirizzo))
	      return true;
	    return false;
	  }
	  else {
	    if(indirizzo.indexOf("@") >= 0)
	      return true;
	    return false;
	  }
}

/*******************************************************************************************************************/
/*******************************************************************************************************************/
/**** CONTROLLO DATI FORM ******************************************************************************************/
/*******************************************************************************************************************/

/**(1)**************************************************/
/** visura_camera_di_commercio.php **/
function checkcomcam001(){
	var d = document.comcam001;
	var richiesta_visura = d.richiesta_visura;
	/**var camera_commercio = d.camera_commercio.value;**/
	var denominazione = d.denominazione.value;
	/**var numero_rea = d.numero_rea.value;**/
	/**var indirizzo = d.indirizzo.value;**/
	/**var citta = d.citta.value;**/
	/**var cap = d.cap.value;**/
	var provincia = d.provincia.value;
	
	if ((!richiesta_visura[0].checked) && (!richiesta_visura[1].checked)) {
		alert("SELEZIONARE TIPO VISURA DA RICHIEDERE.");
		return false;
	}	

	/**else if ((camera_commercio == "") || (camera_commercio == "undefined")) {
		alert("INSERIRE CAMPO CAMERA COMMERCIO.");
		d.camera_commercio.style.background = "yellow";
	   d.camera_commercio.focus();
	   return false;
	} **/
	
	else if ((denominazione == "") || (denominazione == "undefined")) {
		alert("INSERIRE CAMPO RAGIONE SOCIALE.");
		d.denominazione.style.background = "yellow";
	   d.denominazione.focus();
	   return false;
	} 
	
	
	/**else if ((isNaN(numero_rea)) || (numero_rea == "") || (numero_rea == "undefined")) { 
	 alert("INSERIRE CAMPO NUMERO REA, SOLO NUMERICO.");
		d.numero_rea.value = "";
		d.numero_rea.style.background = "yellow";
	   d.numero_rea.focus();
	   return false; 
	} 
	
	
	else if ((indirizzo == "") || (indirizzo == "undefined")) {
		alert("INSERIRE CAMPO INDIRIZZO.");
		d.indirizzo.style.background = "yellow";
	   d.indirizzo.focus();
	   return false;
	} **/
	
	/**else if ((citta == "") || (citta == "undefined")) {
		alert("INSERIRE CAMPO CITTA.");
		d.citta.style.background = "yellow";
	   d.citta.focus();
	   return false;
	} **/

	/**else if ((isNaN(cap)) || (cap == "") || (cap == "undefined")) {
		alert("INSERIRE CAMPO CAP, SOLO NUMERICO.");
		d.cap.value = "";
		d.cap.style.background = "yellow";
	   d.cap.focus();
	   return false;
	} **/

	else if ((provincia == "") || (provincia == "undefined")) {
		alert("INSERIRE CAMPO PROVINCIA.");
		d.provincia.style.background = "yellow";
	   d.provincia.focus();
	   return false;
	} 

	else {
		return true;
	}
}/** end function **/


/**(2)***************************************************/
/** visura_protesti.php **/
function checkcomcam002(){
	var d = document.comcam002;
	var soggetto = d.soggetto;
	
	/** caso privato **/
	if(soggetto[0].checked){
         	var cognome = d.cognome.value;
			var nome = d.nome.value;
         	/**var data_di_nascita = d.data_di_nascita.value;
         	var citta_di_nascita = d.citta_di_nascita.value;**/
         	var provincia_di_residenza = d.provincia_di_residenza.value;
         	/**var comune_di_residenza = d.comune_di_residenza.value; **/
         	var codice_fiscale = d.codice_fiscale.value;
         	var codice_fiscale_ok = checkCodiceFiscale(codice_fiscale);	
			   
				
			    if ((cognome == "") || (cognome == "undefined")) {
					alert("INSERIRE CAMPO COGNOME.");
					d.cognome.style.background = "yellow";
				   d.cognome.focus();
				   return false;
				}
				
				else if ((nome == "") || (nome == "undefined")) {
					alert("INSERIRE CAMPO NOME.");
					d.nome.style.background = "yellow";
				   d.nome.focus();
				   return false;
				}
				
			   /**else if ((data_di_nascita == "") || (data_di_nascita == "undefined")) {
					alert("INSERIRE CAMPO DATA DI NASCITA IN FORMATO GG/MM/AAAA.");
					d.data_di_nascita.style.background = "yellow";
				   d.data_di_nascita.focus();
				   return false;
				}

	        else if (data_di_nascita.substring(2,3) != "/" ||
	             data_di_nascita.substring(5,6) != "/" ||
	             isNaN(data_di_nascita.substring(0,2)) ||
	             isNaN(data_di_nascita.substring(3,5)) ||
	             isNaN(data_di_nascita.substring(6,10))) {
	             alert("IL CAMPO DATA DI NASCITA DEVE AVERE IL FORMATO GG/MM/AAAA.");
	             d.data_di_nascita.value = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
	             return false;
	        }
	
	        else if (data_di_nascita.substring(0,2) > 31) {
	             alert("NEL CAMPO DATA DI NASCITA IL VALORE DI GG E MASSIMO 31");
	             d.data_di_nascita.value = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
	             return false;
	        }
	        else if (data_di_nascita.substring(3,5) > 12) {
	             alert("NEL CAMPO DATA DI NASCITA IL VALORE DI MM E MASSIMO 12");
	             d.data_di_nascita.value = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
	             return false;
	        }
	        else if (data_di_nascita.substring(6,10) < 1900) {
	             alert("NEL CAMPO DATA DI NASCITA IL VALORE DI AAAA NON PUO ESSERE INFERIORE A 1900");
	             d.data_di_nascita.value = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
	             return false;
	        }
	
			  else if ((citta_di_nascita == "") || (citta_di_nascita == "undefined")) {
					alert("INSERIRE CAMPO CITTA DI NASCITA.");
					d.citta_di_nascita.style.background = "yellow";
				   d.citta_di_nascita.focus();
				   return false;
				}**/

			   else if ((provincia_di_residenza == "") || (provincia_di_residenza == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA DI DOMICILIO.");
					d.provincia_di_residenza.style.background = "yellow";
				   d.provincia_di_residenza.focus();
				   return false;
				}

			  /** else if ((comune_di_residenza == "") || (comune_di_residenza == "undefined")) {
					alert("INSERIRE CAMPO COMUNE DI RESIDENZA.");
					d.comune_di_residenza.style.background = "yellow";
				   d.comune_di_residenza.focus();
				   return false;
				} **/

			   else if ((codice_fiscale == "") || (codice_fiscale == "undefined")) {
					alert("INSERIRE CAMPO CODICE FISCALE.");
					d.codice_fiscale.style.background = "yellow";
				   d.codice_fiscale.focus();
				   return false;
				}
				
				else if(codice_fiscale_ok == false){
					alert("CODICE FISCALE INSERITO NON VALIDO.");
					d.codice_fiscale.value = "";
					d.codice_fiscale.style.background = "yellow";
				   d.codice_fiscale.focus();
				   return false;
				}

				else {
					return true;
				}
	}


	/** caso azienda **/
	if(soggetto[1].checked){
         	var ragione_sociale = d.ragione_sociale.value;
         	var indirizzo_sede_legale = d.indirizzo_sede_legale.value;
         	var citta_sede_legale = d.citta_sede_legale.value;
         	/**var cap_sede_legale = d.cap_sede_legale.value;**/
         	var provincia_sede_legale = d.provincia_sede_legale.value;
         	var partita_iva = d.partita_iva.value;
         	var piva_ok = checkPartitaIva(partita_iva);

			   if ((ragione_sociale == "") || (ragione_sociale == "undefined")) {
					alert("INSERIRE CAMPO RAGIONE SOCIALE.");
					d.ragione_sociale.style.background = "yellow";
				   d.ragione_sociale.focus();
				   return false;
				}
				
			   /**else if ((indirizzo_sede_legale == "") || (indirizzo_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO INDIRIZZO SEDE LEGALE.");
					d.indirizzo_sede_legale.style.background = "yellow";
				   d.indirizzo_sede_legale.focus();
				   return false;
				}

			   else if ((citta_sede_legale == "") || (citta_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO CITTA SEDE LEGALE.");
					d.citta_sede_legale.style.background = "yellow";
				   d.citta_sede_legale.focus();
				   return false;
				} **/

			  /** else if ((isNaN(cap_sede_legale)) || (cap_sede_legale == "") || (cap_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO CAP SEDE LEGALE.");
	            d.cap_sede_legale.value = "";
					d.cap_sede_legale.style.background = "yellow";
				   d.cap_sede_legale.focus();
				   return false;
				}**/

			   

				else if ((partita_iva == "") || (partita_iva == "undefined")) {
					alert("INSERIRE CAMPO PARTITA IVA.");
					d.partita_iva.style.background = "yellow";
				   d.partita_iva.focus();
				   return false;
				}
				
				else if (piva_ok==false) {
				   alert("PARTITA IVA INSERITA NON VALIDA");
					d.partita_iva.value = "";
					d.partita_iva.style.background = "yellow";
				   d.partita_iva.focus();
				   return false;
				}
				
				else if ((provincia_sede_legale == "") || (provincia_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA.");
					d.provincia_sede_legale.style.background = "yellow";
				   d.provincia_sede_legale.focus();
				   return false;
				}
					      
				else {
					return true;
				}
	}
}/** end function **/

/**(3)**************************************************/
/** report_aziende.php **/
function checkcominf001(){
		var d = document.cominf001;
		var richiesta_report = d.richiesta_report;
		var denominazione = d.denominazione.value;		
		var partita_iva = d.partita_iva.value;
        var piva_ok = checkPartitaIva(partita_iva);
		//var codice_fiscale = d.codice_fiscale.value;
		//var codice_fiscale_ok = checkCodiceFiscale(codice_fiscale);
		/**var numero_rea = d.numero_rea.value;
		var provincia = d.provincia.value;**/
		
		if ((!richiesta_report[0].checked) && (!richiesta_report[1].checked)) {
			alert("SELEZIONARE TIPO REPORT DA RICHIEDERE.");
			return false;
		}	

		else if ((denominazione == "") || (denominazione == "undefined")) {
			alert("INSERIRE CAMPO RAGIONE SOCIALE.");
			d.denominazione.style.background = "yellow";
		   d.denominazione.focus();
		   return false;
		}
		
		else if ((partita_iva == "") || (partita_iva == "undefined")) {
					alert("INSERIRE CAMPO PARTITA IVA.");
					d.partita_iva.style.background = "yellow";
				   d.partita_iva.focus();
				   return false;
				}
				
				else if (piva_ok==false) {
				   alert("PARTITA IVA INSERITA NON VALIDA");
					d.partita_iva.value = "";
					d.partita_iva.style.background = "yellow";
				   d.partita_iva.focus();
				   return false;
				}
		
		
				
		/*****else if ((codice_fiscale == "") || (codice_fiscale == "undefined")) {
			alert("INSERIRE CAMPO CODICE FISCALE.");
			d.codice_fiscale.style.background = "yellow";
		   d.codice_fiscale.focus();
		   return false;
		}
		
		else if (codice_fiscale_ok==false) {
		   alert("CODICE FISCALE INSERITO NON VALIDO");
			d.codice_fiscale.value = "";
			d.codice_fiscale.style.background = "yellow";
		   d.codice_fiscale.focus();
		   return false;
		}

		else if ((isNaN(numero_rea)) || (numero_rea == "") || (numero_rea == "undefined")) {
			alert("INSERIRE CAMPO NUMERO REA, SOLO NUMERICO.");
			d.numero_rea.value = "";
			d.numero_rea.style.background = "yellow";
		   d.numero_rea.focus();
		   return false;
		} 
		
		else if ((provincia == "") || (provincia == "undefined")) {
			alert("INSERIRE CAMPO PROVINCIA.");
			d.provincia.style.background = "yellow";
		   d.provincia.focus();
		   return false;
		} **/

		else {
			return true;
		}
}/** end function **/


/**(4)**************************************************/
/** report_persona.php **/
function checkcominf002(){
		var d = document.cominf002;
		var nome = d.nome.value;
		var cognome = d.cognome.value;
		/**var data_di_nascita = d.data_di_nascita.value;
		var citta_di_nascita = d.citta_di_nascita.value;
		var provincia_di_nascita = d.provincia_di_nascita.value;**/
		var codice_fiscale = d.codice_fiscale.value;
		var codice_fiscale_ok = checkCodiceFiscale(codice_fiscale);	
		
       if ((cognome == "") || (cognome == "undefined")) {
			alert("INSERIRE CAMPO COGNOME.");
			d.cognome.style.background = "yellow";
		   d.cognome.focus();
		   return false;
		}


	   else if ((nome == "") || (nome == "undefined")) {
			alert("INSERIRE CAMPO NOME.");
			d.nome.style.background = "yellow";
		   d.nome.focus();
		   return false;
		}
		
	   /**else if ((data_di_nascita == "") || (data_di_nascita == "undefined")) {
			alert("INSERIRE CAMPO DATA DI NASCITA IN FORMATO GG/MM/AAAA.");
			d.data_di_nascita.style.background = "yellow";
		   d.data_di_nascita.focus();
		   return false;
		}

     else if (data_di_nascita.substring(2,3) != "/" ||
          data_di_nascita.substring(5,6) != "/" ||
          isNaN(data_di_nascita.substring(0,2)) ||
          isNaN(data_di_nascita.substring(3,5)) ||
          isNaN(data_di_nascita.substring(6,10))) {
          alert("IL CAMPO DATA DI NASCITA DEVE AVERE IL FORMATO GG/MM/AAAA.");
          d.data_di_nascita.value = "";
			 d.data_di_nascita.style.background = "yellow";
			 d.data_di_nascita.focus();
          return false;
     }

     else if (data_di_nascita.substring(0,2) > 31) {
          alert("NEL CAMPO DATA DI NASCITA IL VALORE DI GG E MASSIMO 31");
          d.data_di_nascita.value = "";
			 d.data_di_nascita.style.background = "yellow";
			 d.data_di_nascita.focus();
          return false;
     }
     else if (data_di_nascita.substring(3,5) > 12) {
          alert("NEL CAMPO DATA DI NASCITA IL VALORE DI MM E MASSIMO 12");
          d.data_di_nascita.value = "";
			 d.data_di_nascita.style.background = "yellow";
			 d.data_di_nascita.focus();
          return false;
     }
     else if (data_di_nascita.substring(6,10) < 1900) {
          alert("NEL CAMPO DATA DI NASCITA IL VALORE DI AAAA NON PUO ESSERE INFERIORE A 1900");
          d.data_di_nascita.value = "";
			 d.data_di_nascita.style.background = "yellow";
			 d.data_di_nascita.focus();
          return false;
     }

	   else if ((citta_di_nascita == "") || (citta_di_nascita == "undefined")) {
			alert("INSERIRE CAMPO CITTA DI NASCITA.");
			d.citta_di_nascita.style.background = "yellow";
		   d.citta_di_nascita.focus();
		   return false;
		}

	   else if ((provincia_di_nascita == "") || (provincia_di_nascita == "undefined")) {
			alert("INSERIRE CAMPO PROVINCIA DI NASCITA.");
			d.provincia_di_nascita.style.background = "yellow";
		   d.provincia_di_nascita.focus();
		   return false;
		}**/
		
	   else if ((codice_fiscale == "") || (codice_fiscale == "undefined")) {
			alert("INSERIRE CAMPO CODICE FISCALE.");
			d.codice_fiscale.style.background = "yellow";
		   d.codice_fiscale.focus();
		   return false;
		}
		
		else if(codice_fiscale_ok == false){
			alert("CODICE FISCALE INSERITO NON VALIDO.");
			d.codice_fiscale.value = "";
			d.codice_fiscale.style.background = "yellow";
		   d.codice_fiscale.focus();
		   return false;
		}
		
		else {
			return true;
		}		
}/** end function **/

/**(5)***************************************************/
/** bilancio_aziendale.php **/
function checkcominf003(){
		var d = document.cominf003;
		var richiesta_report = d.richiesta_report;
		var ragione_sociale = d.ragione_sociale.value;
		var partita_iva = d.partita_iva.value;
		var partita_iva_ok = checkPartitaIva(partita_iva);
		/**var numero_rea = d.numero_rea.value;**/
		var provincia = d.provincia.value;

		if ((!richiesta_report[0].checked) && (!richiesta_report[1].checked)) {
			alert("SELEZIONARE TIPO REPORT DA RICHIEDERE.");
			return false;
		}

		else if ((ragione_sociale == "") || (ragione_sociale == "undefined")) {
			alert("INSERIRE CAMPO RAGIONE SOCIALE.");
			d.ragione_sociale.style.background = "yellow";
		   d.ragione_sociale.focus();
		   return false;
		} 

		else if ((partita_iva == "") || (partita_iva == "undefined")) {
			alert("INSERIRE CAMPO PARTITA IVA.");
			d.partita_iva.style.background = "yellow";
		   d.partita_iva.focus();
		   return false;
		}
		
		else if (partita_iva_ok==false) {
		   alert("PARTITA IVA INSERITA NON VALIDA");
			d.partita_iva.value = "";
			d.partita_iva.style.background = "yellow";
		   d.partita_iva.focus();
		   return false;
		}
		
		/**else if ((isNaN(numero_rea)) || (numero_rea == "") || (numero_rea == "undefined")) {
			alert("INSERIRE CAMPO NUMERO REA, SOLO NUMERICO.");
			d.numero_rea.value = "";
			d.numero_rea.style.background = "yellow";
		   d.numero_rea.focus();
		   return false;
		} **/

		else if ((provincia == "") || (provincia == "undefined")) {
			alert("INSERIRE CAMPO PROVINCIA.");
			d.provincia.style.background = "yellow";
		   d.provincia.focus();
		   return false;
		} 

		else {
			return true;
		}	
}/** end function **/

/****(6)*************************************************/
/** visura_catastale_immobile.php **/
function checkimmcat001(){
		var d = document.immcat001;
		var richiesta_visura = d.richiesta_visura;
		var terreno_o_immobile = d.terreno_o_immobile;
		
		var provincia = d.provincia.value;
		var comune = d.comune.value;
		var foglio = d.foglio.value;
		var particella = d.particella.value;
		
		/**var subalterno = d.subalterno.value;
		var indirizzo = d.indirizzo.value;
		var numero_civico = d.numero_civico.value;
		var piano = d.piano.value;
		var interno = d.interno.value;**/
		
	   if ((provincia == "") || (provincia == "undefined")) {
			alert("INSERIRE CAMPO PROVINCIA.");
			d.provincia.style.background = "yellow";
		   d.provincia.focus();
		   return false;
		}
		
	   else if ((comune == "") || (comune == "undefined")) {
			alert("INSERIRE CAMPO COMUNE.");
			d.comune.style.background = "yellow";
		   d.comune.focus();
		   return false;
		}

	   else if ((isNaN(foglio)) || (foglio == "") || (foglio == "undefined")) {
			alert("INSERIRE CAMPO FOGLIO.");
			d.foglio.value = "";
			d.foglio.style.background = "yellow";
		   d.foglio.focus();
		   return false;
		}

	   else if ((isNaN(particella)) || (particella == "") || (particella == "undefined")) {
			alert("INSERIRE CAMPO PARTICELLA.");
			d.particella.value = "";
			d.particella.style.background = "yellow";
		   d.particella.focus();
		   return false;
		}

		else if(terreno_o_immobile[1].checked){
			   /**if ((isNaN(subalterno)) || (subalterno == "") || (subalterno == "undefined")) {
					alert("INSERIRE CAMPO SUBALTERNO.");
					d.subalterno.value = "";
					d.subalterno.style.background = "yellow";
				   d.subalterno.focus();
				   return false;
				}
			   else if ((indirizzo == "") || (indirizzo == "undefined")) {
					alert("INSERIRE CAMPO INDIRIZZO.");
					d.indirizzo.style.background = "yellow";
				   d.indirizzo.focus();
				   return false;
				}
			   else if ((isNaN(numero_civico)) || (numero_civico == "") || (numero_civico == "undefined")) {
					alert("INSERIRE CAMPO NUMERO CIVICO.");
	            d.numero_civico.value = "";
					d.numero_civico.style.background = "yellow";
				   d.numero_civico.focus();
				   return false;
				}
			   else if ((isNaN(piano)) || (piano == "") || (piano == "undefined")) {
					alert("INSERIRE CAMPO PIANO.");
	            d.piano.value = "";
					d.piano.style.background = "yellow";
				   d.piano.focus();
				   return false;
				}
			   else if ((interno == "") || (interno == "undefined")) {
					alert("INSERIRE CAMPO INTERNO.");
					d.interno.style.background = "yellow";
				   d.interno.focus();
				   return false;
				}**/
		}/** end if su terreno_o_immobile[1].checked **/

		else {
			return true;
		}

}/** end function **/


/***(7)*************************************************/
/** visura_catastale_per_nominativo.php **/
function checkimmcat002(){
		var d = document.immcat002;
		var soggetto = d.soggetto;
		var provinciale_o_nazionale = d.provinciale_o_nazionale;

		if(provinciale_o_nazionale[0].checked){
         var provincia = d.provincia.value;
      }

  		/** caso privato **/
		if(soggetto[0].checked){
      		var nome = d.nome.value;
      		var cognome = d.cognome.value;
      		/**var data_di_nascita = d.data_di_nascita.value;
      		var citta_di_nascita = d.citta_di_nascita.value;
      		var provincia_di_nascita = d.provincia_di_nascita.value;**/
      		var codice_fiscale = d.codice_fiscale.value;
      		var codice_fiscale_ok = checkCodiceFiscale(codice_fiscale);
      		/**var indirizzo_dell_immobile = d.indirizzo_dell_immobile.value;**/
      			
				if ((provinciale_o_nazionale[0].checked) && (provincia == "") || (provincia == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA.");
					d.provincia.style.background = "yellow";
				   d.provincia.focus();
				   return false;
				}
				else if ((nome == "") || (nome == "undefined")) {
					alert("INSERIRE CAMPO NOME.");
					d.nome.style.background = "yellow";
				   d.nome.focus();
				   return false;
				} 
				
				else if ((cognome == "") || (cognome == "undefined")) {
					alert("INSERIRE CAMPO COGNOME.");
					d.cognome.style.background = "yellow";
				   d.cognome.focus();
				   return false;
				} 

			   /**else if ((data_di_nascita == "") || (data_di_nascita == "undefined")) {
					alert("INSERIRE CAMPO DATA DI NASCITA IN FORMATO GG/MM/AAAA.");
					d.data_di_nascita.style.background = "yellow";
				   d.data_di_nascita.focus();
				   return false;
				}
			  else if (data_di_nascita.substring(2,3) != "/" ||
			       data_di_nascita.substring(5,6) != "/" ||
			       isNaN(data_di_nascita.substring(0,2)) ||
			       isNaN(data_di_nascita.substring(3,5)) ||
			       isNaN(data_di_nascita.substring(6,10))) {
			       alert("IL CAMPO DATA DI NASCITA DEVE AVERE IL FORMATO GG/MM/AAAA.");
			       d.data_di_nascita = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
			       return false;
			  }
			  else if (data_di_nascita.substring(0,2) > 31) {
			       alert("NEL CAMPO DATA DI NASCITA IL VALORE DI GG E MASSIMO 31");
			       d.data_di_nascita.value = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
			       return false;
			  }
			  else if (data_di_nascita.substring(3,5) > 12) {
			       alert("NEL CAMPO DATA DI NASCITA IL VALORE DI MM E MASSIMO 12");
			       d.data_di_nascita.value = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
			       return false;
			  }
			  else if (data_di_nascita.substring(6,10) < 1900) {
			       alert("NEL CAMPO DATA DI NASCITA IL VALORE DI AAAA NON PUO ESSERE INFERIORE A 1900");
			       d.data_di_nascita.value = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
			       return false;
			  }

			  else if ((citta_di_nascita == "") || (citta_di_nascita == "undefined")) {
					alert("INSERIRE CAMPO CITTA DI NASCITA.");
					d.citta_di_nascita.style.background = "yellow";
				   d.citta_di_nascita.focus();
				   return false;
			  } 

			  else if ((provincia_di_nascita == "") || (provincia_di_nascita == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA DI NASCITA.");
					d.provincia_di_nascita.style.background = "yellow";
				   d.provincia_di_nascita.focus();
				   return false;
			  } **/

			  else if ((codice_fiscale == "") || (codice_fiscale == "undefined")) {
					alert("INSERIRE CAMPO CODICE FISCALE.");
					d.codice_fiscale.style.background = "yellow";
				   d.codice_fiscale.focus();
				   return false;
			  }
				
			  else if(codice_fiscale_ok == false){
					alert("CODICE FISCALE INSERITO NON VALIDO.");
					d.codice_fiscale.value = "";
					d.codice_fiscale.style.background = "yellow";
				   d.codice_fiscale.focus();
				   return false;
			  }
			  /**
			  else if ((indirizzo_dell_immobile == "") || (indirizzo_dell_immobile == "undefined")) {
					alert("INSERIRE CAMPO INDIRIZZO IMMOBILE.");
					d.indirizzo_dell_immobile.style.background = "yellow";
				   d.indirizzo_dell_immobile.focus();
				   return false;
			  } **/

			  else {
			  		return true;
			  }
		}/** end if su soggetto[0] **/	
		
		/** caso azienda **/
		if(soggetto[1].checked){
      		var denominazione = d.denominazione.value;
      		var partita_iva = d.partita_iva.value;
      		var partita_iva_ok = checkPartitaIva(partita_iva);
      		/**var sede_legale = d.sede_legale.value;
      		var provincia_sede_legale = d.provincia_sede_legale.value;
      		var indirizzo_immobile = d.indirizzo_immobile.value;**/
		
				if ((provinciale_o_nazionale[0].checked) && (provincia == "") || (provincia == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA.");
					d.provincia.style.background = "yellow";
				   d.provincia.focus();
				   return false;
				}

				else if ((denominazione == "") || (denominazione == "undefined")) {
					alert("INSERIRE CAMPO DENOMINAZIONE.");
					d.denominazione.style.background = "yellow";
				   d.denominazione.focus();
				   return false;
				} 
		
				else if ((partita_iva == "") || (partita_iva == "undefined")) {
					alert("INSERIRE CAMPO PARTITA IVA.");
					d.partita_iva.style.background = "yellow";
				   d.partita_iva.focus();
				   return false;
				}
				
				else if (partita_iva_ok==false) {
				   alert("PARTITA IVA INSERITA NON VALIDA");
					d.partita_iva.value = "";
					d.partita_iva.style.background = "yellow";
				   d.partita_iva.focus();
				   return false;
				}
/**
				else if ((sede_legale == "") || (sede_legale == "undefined")) {
					alert("INSERIRE CAMPO SEDE LEGALE.");
					d.sede_legale.style.background = "yellow";
				   d.sede_legale.focus();
				   return false;
				} 

				else if ((provincia_sede_legale == "") || (provincia_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA SEDE LEGALE.");
					d.provincia_sede_legale.style.background = "yellow";
				   d.provincia_sede_legale.focus();
				   return false;
				} 

			  else if ((indirizzo_immobile == "") || (indirizzo_immobile == "undefined")) {
					alert("INSERIRE CAMPO INDIRIZZO IMMOBILE.");
					d.indirizzo_immobile.style.background = "yellow";
				   d.indirizzo_immobile.focus();
				   return false;
			  } **/
				
				else {
					return true;
				}
		}/** end if su soggetto[1] **/

}/** end function **/

/**(8)****************************************************/
/** elaborato_planimetrico.php **/
function checkimmcat006(){
		var d = document.immcat006;
		var provincia = d.provincia.value;
		var comune = d.comune.value;
		/**var indirizzo = d.indirizzo.value;**/
		var foglio = d.foglio.value;
		var particella = d.particella.value;
		
	  if ((provincia == "") || (provincia == "undefined")) {
			alert("INSERIRE CAMPO PROVINCIA.");
			d.provincia.style.background = "yellow";
		   d.provincia.focus();
		   return false;
	  } 
	  else if ((comune == "") || (comune == "undefined")) {
			alert("INSERIRE CAMPO COMUNE.");
			d.comune.style.background = "yellow";
		   d.comune.focus();
		   return false;
	  } 
	  /**else if ((indirizzo == "") || (indirizzo == "undefined")) {
			alert("INSERIRE CAMPO INDIRIZZO.");
			d.indirizzo.style.background = "yellow";
		   d.indirizzo.focus();
		   return false;
	  } **/
	  else if ((isNaN(foglio)) || (sezione == "") || (sezione == "undefined")) {
			alert("INSERIRE CAMPO SEZIONE/FOGLIO.");
			d.foglio.value = "";
			d.foglio.style.background = "yellow";
		   d.foglio.focus();
		   return false;
	  } 
	  else if ((isNaN(particella)) || (particella == "") || (particella == "undefined")) {
			alert("INSERIRE CAMPO PARTICELLA/MAPPALE.");
			d.particella.value = "";
			d.particella.style.background = "yellow";
		   d.particella.focus();
		   return false;
	  } 
		else {
			return true;
		}
}/** end function **/


/**(9)****************************************************/
/** planimetria_catastale.php **/
function checkimmcat005(){
		var d = document.immcat005;
		var provincia = d.provincia.value;
		var comune = d.comune.value;
		var foglio = d.foglio.value;
		var particella = d.particella.value;
		/** var subalterno = d.subalterno.value;
		var indirizzo = d.indirizzo.value;
		var piano = d.piano.value; **/		
		
	  if ((provincia == "") || (provincia == "undefined")) {
			alert("INSERIRE CAMPO PROVINCIA.");
			d.provincia.style.background = "yellow";
		   d.provincia.focus();
		   return false;
	  } 
	  else if ((comune == "") || (comune == "undefined")) {
			alert("INSERIRE CAMPO COMUNE.");
			d.comune.style.background = "yellow";
		   d.comune.focus();
		   return false;
	  } 
	  else if ((isNaN(foglio)) || (foglio == "") || (foglio == "undefined")) {
			alert("INSERIRE CAMPO FOGLIO.");
			d.foglio.value = "";
			d.foglio.style.background = "yellow";
		   d.foglio.focus();
		   return false;
	  } 
	  else if ((isNaN(particella)) || (particella == "") || (particella == "undefined")) {
			alert("INSERIRE CAMPO PARTICELLA.");
			d.particella.value = "";
			d.particella.style.background = "yellow";
		   d.particella.focus();
		   return false;
	  } 
	  /** else if ((isNaN(subalterno)) || (subalterno == "") || (subalterno == "undefined")) {
			alert("INSERIRE CAMPO SUBALTERNO.");
			d.subalterno.value = "";
			d.subalterno.style.background = "yellow";
		   d.subalterno.focus();
		   return false;
	  } 
	  else if ((indirizzo == "") || (indirizzo == "undefined")) {
			alert("INSERIRE CAMPO INDIRIZZO.");
			d.indirizzo.style.background = "yellow";
		   d.indirizzo.focus();
		   return false;
	  } 
	  else if (isNaN(piano) || (piano == "") || (piano == "undefined")) {
			alert("INSERIRE CAMPO PIANO.");
			d.piano.value="";
			d.piano.style.background = "yellow";
		   d.piano.focus();
		   return false;
	  } **/
		else {
			return true;
		}
}/** end function **/

/**(10)****************************************************/
/** estratto_di_mappa.php **/
/** elemento formato non controllato **/
function checkimmcat003(){
		var d = document.immcat003;
		var provincia = d.provincia.value;
		var comune = d.comune.value;
		/**var sezione = d.sezione.value; **/
		var foglio = d.foglio.value;
		var particella = d.particella.value;
		
	  if ((provincia == "") || (provincia == "undefined")) {
			alert("INSERIRE CAMPO PROVINCIA.");
			d.provincia.style.background = "yellow";
		   d.provincia.focus();
		   return false;
	  } 
	  else if ((comune == "") || (comune == "undefined")) {
			alert("INSERIRE CAMPO COMUNE.");
			d.comune.style.background = "yellow";
		   d.comune.focus();
		   return false;
	  } 
	  /**else if ((isNaN(sezione)) || (sezione == "") || (sezione == "undefined")) {
			alert("INSERIRE CAMPO SEZIONE.");
			d.sezione.value = "";
			d.sezione.style.background = "yellow";
		   d.sezione.focus();
		   return false;
	  } **/
	  else if ((isNaN(foglio)) || (foglio == "") || (foglio == "undefined")) {
			alert("INSERIRE CAMPO FOGLIO.");
			d.foglio.value = "";
			d.foglio.style.background = "yellow";
		   d.foglio.focus();
		   return false;
	  } 
	  else if ((isNaN(particella)) || (particella == "") || (particella == "undefined")) {
			alert("INSERIRE CAMPO PARTICELLA.");
			d.particella.value = "";
			d.particella.style.background = "yellow";
		   d.particella.focus();
		   return false;
	  } 
		else {
			return true;
		}
}/** end function **/


/**(11)****************************************************/
/** elenco_fabbricato.php **/
function checkimmcat004(){
		var d = document.immcat004;
		var provincia = d.provincia.value;
		var comune = d.comune.value;
		/**var sezione = d.sezione.value; **/
		var foglio = d.foglio.value;
		var particella = d.particella.value;
		
	  if ((provincia == "") || (provincia == "undefined")) {
			alert("INSERIRE CAMPO PROVINCIA.");
			d.provincia.style.background = "yellow";
		   d.provincia.focus();
		   return false;
	  } 
	  else if ((comune == "") || (comune == "undefined")) {
			alert("INSERIRE CAMPO COMUNE.");
			d.comune.style.background = "yellow";
		   d.comune.focus();
		   return false;
	  } 
	 /** else if ((isNaN(sezione)) || (sezione == "") || (sezione == "undefined")) {
			alert("INSERIRE CAMPO SEZIONE.");
			d.sezione.value = "";
			d.sezione.style.background = "yellow";
		   d.sezione.focus();
		   return false;
	  } **/
	  
	  else if ((isNaN(foglio)) || (foglio == "") || (foglio == "undefined")) {
			alert("INSERIRE CAMPO FOGLIO.");
			d.foglio.value = "";
			d.foglio.style.background = "yellow";
		   d.foglio.focus();
		   return false;
	  } 
	  else if ((isNaN(particella)) || (particella == "") || (particella == "undefined")) {
			alert("INSERIRE CAMPO PARTICELLA.");
			d.particella.value = "";
			d.particella.style.background = "yellow";
		   d.particella.focus();
		   return false;
	  } 
		else {
			return true;
		}
}/** end function **/


/**(12)****************************************************/
/** visura_ipotecaria_per_immobile.php **/
function checkimmcon002(){
		var d = document.immcon002;
		var provincia = d.provincia.value;
		var comune = d.comune.value;
		/**var sezione = d.sezione.value;**/
		var foglio = d.foglio.value;
		var particella = d.particella.value;
		/**var subalterno = d.subalterno.value;**/
		
	   if ((provincia == "") || (provincia == "undefined")) {
			alert("INSERIRE CAMPO PROVINCIA.");
			d.provincia.style.background = "yellow";
		   d.provincia.focus();
		   return false;
		}
		
	   else if ((comune == "") || (comune == "undefined")) {
			alert("INSERIRE CAMPO COMUNE.");
			d.comune.style.background = "yellow";
		   d.comune.focus();
		   return false;
		}

	   /**else if ((isNaN(sezione)) || (sezione == "") || (sezione == "undefined")) {
			alert("INSERIRE CAMPO SEZIONE.");
			d.sezione.value = "";
			d.sezione.style.background = "yellow";
		   d.sezione.focus();
		   return false;
		} **/

	   else if ((isNaN(foglio)) || (foglio == "") || (foglio == "undefined")) {
			alert("INSERIRE CAMPO FOGLIO.");
			d.foglio.value = "";
			d.foglio.style.background = "yellow";
		   d.foglio.focus();
		   return false;				   
		}

	   else if ((isNaN(particella)) || (particella == "") || (particella == "undefined")) {
			alert("INSERIRE CAMPO PARTICELLA.");
			d.particella.value = "";
			d.particella.style.background = "yellow";
		   d.particella.focus();
		   return false;
		}
	   /**else if ((isNaN(subalterno)) || (subalterno == "") || (subalterno == "undefined")) {
			alert("INSERIRE CAMPO SUBALTERNO.");
			d.subalterno.value = "";
			d.subalterno.style.background = "yellow";
		   d.subalterno.focus();
		   return false;
		} **/
		 else {
		 	return true;
		}
}/** end function **/

/**(13)****************************************************/
/** visura_ipotecaria_per_nota.php **/
function checkimmcon003(){
		var d = document.immcon003;
		var conservatoria = d.conservatoria.value;
		var notaa = d.nota.selectedIndex;
		var numero_protocollo = d.numero_protocollo.value;
		var anno = d.anno.value;
		
	  if ((conservatoria == "") || (conservatoria == "undefined")) {
			alert("INSERIRE CAMPO CONSERVATORIA.");
			d.conservatoria.style.background = "yellow";
		   d.conservatoria.focus();
		   return false;
	  } 
	 else if (notaa == 0){
			alert("SCEGLIERE IL TIPO DI NOTA.");
		   d.nota.style.background = "yellow";
		   d.nota.focus();
		   return false;
	  } 
	  else if (isNaN(numero_protocollo) || (numero_protocollo == "") || (numero_protocollo == "undefined")) {
			alert("INSERIRE CAMPO NUMERO PROTOCOLLO.");
			d.numero_protocollo.value="";
			d.numero_protocollo.style.background = "yellow";
		   d.numero_protocollo.focus();
		   return false;
	  } 
	  else if (isNaN(anno) || (anno == "") || (anno == "undefined")) {
			alert("INSERIRE CAMPO ANNO FORMATO AAAA.");
			d.anno.value="";
			d.anno.style.background = "yellow";
		   d.anno.focus();
		   return false;
	  } 
	  else if (isNaN(anno) || (anno < 1900)) {
			alert("INSERIRE CAMPO ANNO FORMATO AAAA.");
			d.anno.value="";
			d.anno.style.background = "yellow";
		   d.anno.focus();
		   return false;
	  } 
		else {
			return true;
		}
		

}/** end function **/


/**(14)****************************************************/
/** visura_ipotecaria_per_soggetto.php **/
function checkimmcon001(){
		var d = document.immcon001;
		var soggetto = d.soggetto;
		var conservatoria = d.conservatoria.value;
		
		/** caso privato **/
		if(soggetto[0].checked){
         		var nome = d.nome.value;
         		var cognome = d.cognome.value;
         		/**var data_di_nascita = d.data_di_nascita.value;
         		var citta_di_nascita = d.citta_di_nascita.value;
         		var provincia_di_nascita = d.provincia_di_nascita.value;**/
         		var codice_fiscale = d.codice_fiscale.value;
         		var codice_fiscale_ok = checkCodiceFiscale(codice_fiscale);

				   if ((conservatoria == "") || (conservatoria == "undefined")) {
						alert("INSERIRE CAMPO CONSERVATORIA.");
						d.conservatoria.style.background = "yellow";
					   d.conservatoria.focus();
					   return false;
					}

				   else if ((nome == "") || (nome == "undefined")) {
						alert("INSERIRE CAMPO NOME.");
						d.nome.style.background = "yellow";
					   d.nome.focus();

					   return false;
					}
					
				   else if ((cognome == "") || (cognome == "undefined")) {
						alert("INSERIRE CAMPO COGNOME.");
						d.cognome.style.background = "yellow";
					   d.cognome.focus();
					   return false;
					}
					
				   /**else if ((data_di_nascita == "") || (data_di_nascita == "undefined")) {
						alert("INSERIRE CAMPO DATA DI NASCITA IN FORMATO GG/MM/AAAA.");
						d.data_di_nascita.style.background = "yellow";
					   d.data_di_nascita.focus();
					   return false;
					}
	
		        else if (data_di_nascita.substring(2,3) != "/" ||
		             data_di_nascita.substring(5,6) != "/" ||
		             isNaN(data_di_nascita.substring(0,2)) ||
		             isNaN(data_di_nascita.substring(3,5)) ||
		             isNaN(data_di_nascita.substring(6,10))) {
		             alert("IL CAMPO DATA DI NASCITA DEVE AVERE IL FORMATO GG/MM/AAAA.");
		             d.data_di_nascita.value = "";
						 d.data_di_nascita.style.background = "yellow";
						 d.data_di_nascita.focus();
		             return false;
		        }
		
		        else if (data_di_nascita.substring(0,2) > 31) {
		             alert("NEL CAMPO DATA DI NASCITA IL VALORE DI GG E MASSIMO 31");
		             d.data_di_nascita.value = "";
						 d.data_di_nascita.style.background = "yellow";
						 d.data_di_nascita.focus();
		             return false;
		        }
		        else if (data_di_nascita.substring(3,5) > 12) {
		             alert("NEL CAMPO DATA DI NASCITA IL VALORE DI MM E MASSIMO 12");
		             d.data_di_nascita.value = "";
						 d.data_di_nascita.style.background = "yellow";
						 d.data_di_nascita.focus();
		             return false;
		        }
		        else if (data_di_nascita.substring(6,10) < 1900) {
		             alert("NEL CAMPO DATA DI NASCITA IL VALORE DI AAAA NON PUO ESSERE INFERIORE A 1900");
		             d.data_di_nascita.value = "";
						 d.data_di_nascita.style.background = "yellow";
						 d.data_di_nascita.focus();
		             return false;
		        } **/
		
				   /**else if ((citta_di_nascita == "") || (citta_di_nascita == "undefined")) {
						alert("INSERIRE CAMPO CITTA DI NASCITA.");
						d.citta_di_nascita.style.background = "yellow";
					   d.citta_di_nascita.focus();
					   return false;
					}
	
				   else if ((provincia_di_nascita == "") || (provincia_di_nascita == "undefined")) {
						alert("INSERIRE CAMPO PROVINCIA DI NASCITA.");
						d.provincia_di_nascita.style.background = "yellow";
					   d.provincia_di_NASCITA.focus();
					   return false;
					} **/
	
				   else if ((codice_fiscale == "") || (codice_fiscale == "undefined")) {
						alert("INSERIRE CAMPO CODICE FISCALE.");
						d.codice_fiscale.style.background = "yellow";
					   d.codice_fiscale.focus();
					   return false;
					}
					
					else if(codice_fiscale_ok == false){
						alert("CODICE FISCALE INSERITO NON VALIDO.");
						d.codice_fiscale.value = "";
						d.codice_fiscale.style.background = "yellow";
					   d.codice_fiscale.focus();
					   return false;
					}
	
					else {
						return true;
					}
		}/** end if su soggetto[0].checked **/
		
		/** caso azienda **/
		if(soggetto[1].checked){
      		var denominazione = d.denominazione.value;
      		var partita_iva = d.partita_iva.value;
      		var piva_ok = checkPartitaIva(partita_iva);
      		/**var sede_legale = d.sede_legale.value;**/
		
			   if ((conservatoria == "") || (conservatoria == "undefined")) {
					alert("INSERIRE CAMPO CONSERVATORIA.");
					d.conservatoria.style.background = "yellow";
				   d.conservatoria.focus();
				   return false;
				}
				
			   else if ((denominazione == "") || (denominazione == "undefined")) {
					alert("INSERIRE CAMPO RAGIONE SOCIALE.");
					d.denominazione.style.background = "yellow";
				   d.denominazione.focus();
				   return false;
				}

				else if ((partita_iva == "") || (partita_iva == "undefined")) {
					alert("INSERIRE CAMPO PARTITA IVA.");
					d.partita_iva.style.background = "yellow";
				   d.partita_iva.focus();
				   return false;
				}
				
				else if (piva_ok==false) {
				   alert("PARTITA IVA INSERITA NON VALIDA");
					d.partita_iva.value = "";
					d.partita_iva.style.background = "yellow";
				   d.partita_iva.focus();
				   return false;
				}
					      
			   /**else if ((sede_legale == "") || (sede_legale == "undefined")) {
					alert("INSERIRE CAMPO SEDE LEGALE.");
					d.sede_legale.style.background = "yellow";
				   d.sede_legale.focus();
				   return false;
				} **/

				else {
					return true;
				}
				
		}/** end if su soggetto[1].checked **/

}/** end function **/


/**(15)(16)****************************************************/
/** visure_pra_richiesta.php **/
function checkveixxx000(){
		var d = document.veixxx000;
		var richiesta_visura = d.richiesta_visura;
		
		/** caso targa **/
		var periodo_richiesta = d.periodo_richiesta;
		var tipologiaa = d.tipologia.selectedIndex;
		var targa_veicolo = d.targa_veicolo.value;
		
		if(richiesta_visura[0].checked){
				if (tipologiaa == 0){
					alert("SCEGLIERE IL TIPO DI VEICOLO.");
					d.tipologia.style.background = "yellow";
				    d.tipologia.focus();
					return false;
				} 
				
			   else if ((targa_veicolo == "") || (targa_veicolo == "undefined")) {
					alert("INSERIRE CAMPO TARGA VEICOLO.");
					d.targa_veicolo.style.background = "yellow";
				    d.targa_veicolo.focus();
				   return false;
				}

				else {
					return true;
				}
		}/** end if su richiesta_visura[0]**/

		/** caso targa **/
		var telaio = d.telaio.value;

		if(richiesta_visura[1].checked){
			   if ((telaio == "") || (telaio == "undefined")) {
					alert("INSERIRE CAMPO TELAIO.");
					d.telaio.style.background = "yellow";
				   d.telaio.focus();
				   return false;
				}

				else {
					return true;
				}
		}/** end if su richiesta_visura[0]**/
}/** end function **/

/**(17)***************************************************/
/** visure_centrali_rischi.php **/
function checkcentrisc000(){
	var d = document.centrisc000;
	var soggetto = d.soggetto;
	
	/** caso privato **/
	if(soggetto[0].checked){
         	var cognome = d.cognome.value;
			var nome = d.nome.value;
         	/**var data_di_nascita = d.data_di_nascita.value;
         	var citta_di_nascita = d.citta_di_nascita.value;**/
         	var provincia_di_residenza = d.provincia_di_residenza.value;
         	/**var comune_di_residenza = d.comune_di_residenza.value; **/
         	var codice_fiscale = d.codice_fiscale.value;
         	var codice_fiscale_ok = checkCodiceFiscale(codice_fiscale);	

			   
				
			    if ((cognome == "") || (cognome == "undefined")) {
					alert("INSERIRE CAMPO COGNOME.");
					d.cognome.style.background = "yellow";
				   d.cognome.focus();
				   return false;
				}
				
				else if ((nome == "") || (nome == "undefined")) {
					alert("INSERIRE CAMPO NOME.");
					d.nome.style.background = "yellow";
				   d.nome.focus();
				   return false;
				}
				
			   /**else if ((data_di_nascita == "") || (data_di_nascita == "undefined")) {
					alert("INSERIRE CAMPO DATA DI NASCITA IN FORMATO GG/MM/AAAA.");
					d.data_di_nascita.style.background = "yellow";
				   d.data_di_nascita.focus();
				   return false;
				}

	        else if (data_di_nascita.substring(2,3) != "/" ||
	             data_di_nascita.substring(5,6) != "/" ||
	             isNaN(data_di_nascita.substring(0,2)) ||
	             isNaN(data_di_nascita.substring(3,5)) ||
	             isNaN(data_di_nascita.substring(6,10))) {
	             alert("IL CAMPO DATA DI NASCITA DEVE AVERE IL FORMATO GG/MM/AAAA.");
	             d.data_di_nascita.value = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
	             return false;
	        }
	
	        else if (data_di_nascita.substring(0,2) > 31) {
	             alert("NEL CAMPO DATA DI NASCITA IL VALORE DI GG E MASSIMO 31");
	             d.data_di_nascita.value = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
	             return false;
	        }
	        else if (data_di_nascita.substring(3,5) > 12) {
	             alert("NEL CAMPO DATA DI NASCITA IL VALORE DI MM E MASSIMO 12");
	             d.data_di_nascita.value = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
	             return false;
	        }
	        else if (data_di_nascita.substring(6,10) < 1900) {
	             alert("NEL CAMPO DATA DI NASCITA IL VALORE DI AAAA NON PUO ESSERE INFERIORE A 1900");
	             d.data_di_nascita.value = "";
					 d.data_di_nascita.style.background = "yellow";
					 d.data_di_nascita.focus();
	             return false;
	        }
	
			  else if ((citta_di_nascita == "") || (citta_di_nascita == "undefined")) {
					alert("INSERIRE CAMPO CITTA DI NASCITA.");
					d.citta_di_nascita.style.background = "yellow";
				   d.citta_di_nascita.focus();
				   return false;
				}**/

			   else if ((provincia_di_residenza == "") || (provincia_di_residenza == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA DI DOMICILIO.");
					d.provincia_di_residenza.style.background = "yellow";
				   d.provincia_di_residenza.focus();
				   return false;
				}

			  /** else if ((comune_di_residenza == "") || (comune_di_residenza == "undefined")) {
					alert("INSERIRE CAMPO COMUNE DI RESIDENZA.");
					d.comune_di_residenza.style.background = "yellow";
				   d.comune_di_residenza.focus();
				   return false;
				} **/

			   else if ((codice_fiscale == "") || (codice_fiscale == "undefined")) {
					alert("INSERIRE CAMPO CODICE FISCALE.");
					d.codice_fiscale.style.background = "yellow";
				   d.codice_fiscale.focus();
				   return false;
				}
				
				else if(codice_fiscale_ok == false){
					alert("CODICE FISCALE INSERITO NON VALIDO.");
					d.codice_fiscale.value = "";
					d.codice_fiscale.style.background = "yellow";
				   d.codice_fiscale.focus();
				   return false;
				}

				else {
					return true;
				}
	}


	/** caso azienda **/
	if(soggetto[1].checked){
         	var ragione_sociale = d.ragione_sociale.value;
         	var indirizzo_sede_legale = d.indirizzo_sede_legale.value;
         	var citta_sede_legale = d.citta_sede_legale.value;
         	/**var cap_sede_legale = d.cap_sede_legale.value;**/
         	var provincia_sede_legale = d.provincia_sede_legale.value;
         	var partita_iva = d.partita_iva.value;
         	var piva_ok = checkPartitaIva(partita_iva);

			   if ((ragione_sociale == "") || (ragione_sociale == "undefined")) {
					alert("INSERIRE CAMPO RAGIONE SOCIALE.");
					d.ragione_sociale.style.background = "yellow";
				   d.ragione_sociale.focus();
				   return false;
				}
				
			   /**else if ((indirizzo_sede_legale == "") || (indirizzo_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO INDIRIZZO SEDE LEGALE.");
					d.indirizzo_sede_legale.style.background = "yellow";
				   d.indirizzo_sede_legale.focus();
				   return false;
				}

			   else if ((citta_sede_legale == "") || (citta_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO CITTA SEDE LEGALE.");
					d.citta_sede_legale.style.background = "yellow";
				   d.citta_sede_legale.focus();
				   return false;
				} **/

			  /** else if ((isNaN(cap_sede_legale)) || (cap_sede_legale == "") || (cap_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO CAP SEDE LEGALE.");
	            d.cap_sede_legale.value = "";
					d.cap_sede_legale.style.background = "yellow";
				   d.cap_sede_legale.focus();
				   return false;
				}**/

			   

				else if ((partita_iva == "") || (partita_iva == "undefined")) {
					alert("INSERIRE CAMPO PARTITA IVA.");
					d.partita_iva.style.background = "yellow";
				   d.partita_iva.focus();
				   return false;
				}
				
				else if (piva_ok==false) {
				   alert("PARTITA IVA INSERITA NON VALIDA");
					d.partita_iva.value = "";
					d.partita_iva.style.background = "yellow";
				   d.partita_iva.focus();
				   return false;
				}
				
				else if ((provincia_sede_legale == "") || (provincia_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA.");
					d.provincia_sede_legale.style.background = "yellow";
				   d.provincia_sede_legale.focus();
				   return false;
				}
					      
				else {
					return true;
				}
	}
}/** end function **/





/******************************************************/
/** rechargekart.php **/
function checkrechargekart(){
		var d = document.ricarica_conto; /*  nome del form da controllare*/
		var totale_ricarica = d.totale_ricarica;
        var seleziona_fondo = d.seleziona_fondo.value;
		
		
		if ((!totale_ricarica[0].checked) && (!totale_ricarica[1].checked) && (!totale_ricarica[2].checked) && (!totale_ricarica[3].checked)&& (!totale_ricarica[4].checked)) {
		alert("SCEGLI UNA RICARICA DA EFFETTUARE TRA LE CINQUE IN LISTINO.");
		return false;
	}	
		
 
 else if ((seleziona_fondo == "") || (seleziona_fondo == "undefined")) {
			alert("SCEGLI COME EFFETTUARE Il PAGAMENTO.");
			d.seleziona_fondo.style.background = "yellow";
		    d.seleziona_fondo.focus();
		   return false;
		} 
		
		
       else {
					return true;
		    }  
		
}
/***********************************************************************/
/** controllo dati no utente **/
/** operation/index.php **/
function checkinserisciordinenouser(){
		var d = document.inserisci_ordine;
		var usoggetto = d.usoggetto;
		
		/** caso privato **/		
		if(usoggetto[0].checked){
				var unome = d.unome.value;
				var ucognome = d.ucognome.value;
				var ucodice_fiscale = d.ucodice_fiscale.value;
				var ucodice_fiscale_ok = checkCodiceFiscale(ucodice_fiscale);
				var uindirizzo = d.uindirizzo.value;
				var ucitta = d.ucitta.value;
				var ucap = d.ucap.value;
				var uprovincia = d.uprovincia.value;
				var unazione = d.unazione.value;
				//var utelefono = d.utelefono.value;
				//var ufax = d.ufax.value;
				var uemail = d.uemail.value;
				var uconsenso_trattamento_dati = d.uconsenso_trattamento_dati;
				
			   if ((unome == "") || (unome == "undefined")) {
					alert("INSERIRE CAMPO NOME.");
					d.unome.style.background = "yellow";
				   d.unome.focus();
				   return false;
				}
				
			   else if ((ucognome == "") || (ucognome == "undefined")) {
					alert("INSERIRE CAMPO COGNOME.");
					d.ucognome.style.background = "yellow";
				   d.ucognome.focus();
				   return false;
				}

			   else if ((ucodice_fiscale == "") || (ucodice_fiscale == "undefined")) {
					alert("INSERIRE CAMPO CODICE FISCALE.");
					d.ucodice_fiscale.style.background = "yellow";
				   d.ucodice_fiscale.focus();
				   return false;
				}
				
				else if(ucodice_fiscale_ok == false){
					alert("CODICE FISCALE INSERITO NON VALIDO.");
					d.ucodice_fiscale.value = "";
					d.ucodice_fiscale.style.background = "yellow";
				   d.ucodice_fiscale.focus();
				   return false;
				}

			   else if ((uindirizzo == "") || (uindirizzo == "undefined")) {
					alert("INSERIRE CAMPO INDIRIZZO.");
					d.uindirizzo.style.background = "yellow";
				   d.uindirizzo.focus();
				   return false;
				}
				
			   else if ((ucitta == "") || (ucitta == "undefined")) {
					alert("INSERIRE CAMPO CITTA.");
					d.ucitta.style.background = "yellow";
				   d.ucitta.focus();
				   return false;
				}

			  else if (isNaN(ucap) || (ucap == "") || (ucap == "undefined")) {
					alert("INSERIRE CAMPO CAP.");
					d.ucap.value="";
					d.ucap.style.background = "yellow";
				   d.ucap.focus();
				   return false;
			  } 

			   else if ((uprovincia == "") || (uprovincia == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA.");
					d.uprovincia.style.background = "yellow";
				   d.uprovincia.focus();
				   return false;
				}

			   else if ((unazione == "") || (unazione == "undefined")) {
					alert("INSERIRE CAMPO NAZIONE.");
					d.unazione.style.background = "yellow";
				   d.unazione.focus();
				   return false;
				}

				else if (checkEmail(uemail) == 0) {
					alert("INSERIRE INDIRIZZO EMAIL CORRETTO.");
					d.uemail.value = "";
					d.uemail.style.background = "yellow";
				   d.uemail.focus();
					return false;
				}
				
				else if(uconsenso_trattamento_dati.checked == false){
					alert("BISOGNA DARE IL CONSENSO AL TRATTAMENTO DATI.");
					return false;
				}
				
				else {
					return true;
				}
		}/** end if su soggetto[1].checked **/


		/** caso azienda **/		
		if(usoggetto[1].checked){
				var uragione_sociale = d.uragione_sociale.value;
				var uindirizzo_sede_legale = d.uindirizzo_sede_legale.value;
				var ucitta_sede_legale = d.ucitta_sede_legale.value;
				var ucap_sede_legale = d.ucap_sede_legale.value;
				var uprovincia_sede_legale = d.uprovincia_sede_legale.value;
				var unazione_sede_legale = d.unazione_sede_legale.value;
				var upartita_iva = d.upartita_iva.value;
				var upartita_iva_ok = checkPartitaIva(upartita_iva);
				//var utelefono_sede_legale = d.utelefono_sede_legale.value;
				//var ufax_sede_legale = d.ufax_sede_legale.value;
				var uemail = d.uemail.value;
				var uconsenso_trattamento_dati = d.uconsenso_trattamento_dati;
				
			   if ((uragione_sociale == "") || (uragione_sociale == "undefined")) {
					alert("INSERIRE CAMPO RAGIONE SOCIALE.");
					d.uragione_sociale.style.background = "yellow";
				   d.uragione_sociale.focus();
				   return false;
				}
			
			   if ((uindirizzo_sede_legale == "") || (uindirizzo_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO INDIRIZZO SEDE LEGALE.");
					d.uindirizzo_sede_legale.style.background = "yellow";
				   d.uindirizzo_sede_legale.focus();
				   return false;
				}

			   if ((ucitta_sede_legale == "") || (ucitta_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO CITTA SEDE LEGALE.");
					d.ucitta_sede_legale.style.background = "yellow";
				   d.ucitta_sede_legale.focus();
				   return false;
				}

			  else if (isNaN(ucap_sede_legale) || (ucap_sede_legale == "") || (ucap_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO CAP SEDE LEGALE.");
					d.ucap_sede_legale.value="";
					d.ucap_sede_legale.style.background = "yellow";
				   d.ucap_sede_legale.focus();
				   return false;
			  } 

			   else if ((uprovincia_sede_legale == "") || (uprovincia_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA SEDE LEGALE.");
					d.uprovincia_sede_legale.style.background = "yellow";
				   d.uprovincia_sede_legale.focus();
				   return false;
				}

			   else if ((unazione_sede_legale == "") || (unazione_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO NAZIONE SEDE LEGALE.");
					d.unazione_sede_legale.style.background = "yellow";
				   d.unazione_sede_legale.focus();
				   return false;
				}

			   else if ((upartita_iva == "") || (upartita_iva == "undefined")) {
					alert("INSERIRE CAMPO PARTITA IVA.");
					d.upartita_iva.style.background = "yellow";
				   d.upartita_iva.focus();
				   return false;
				}
				
				else if (upartita_iva_ok == false){
					alert("PARTITA IVA INSERITA NON VALIDA.");
					d.upartita_iva.value = "";
					d.upartita_iva.style.background = "yellow";
				   d.upartita_iva.focus();
				   return false;
				}

				else if (checkEmail(uemail) == 0) {
					alert("INSERIRE INDIRIZZO EMAIL CORRETTO.");
					d.uemail.value = "";
					d.uemail.style.background = "yellow";
				   d.uemail.focus();
					return false;
				}
				
				else if(uconsenso_trattamento_dati.checked == false){
					alert("BISOGNA DARE IL CONSENSO AL TRATTAMENTO DATI.");
					return false;
				}
				
				else {
					return true;
				}
		}/** end if soggetto[2].checked **/
}/** end function **/


/***********************************************************************/
/** controllo dati fatturazione **/
/** admu/registra_dati_fatturazione.php **/
function checkDatiFatturazioneForm(){
		var d = document.inserisci_ordine;
		var usoggetto = d.usoggetto;
		
		/** caso privato **/		
		if(usoggetto[0].checked){
				var unome = d.unome.value;
				var ucognome = d.ucognome.value;
				var ucodice_fiscale = d.ucodice_fiscale.value;
				var ucodice_fiscale_ok = checkCodiceFiscale(ucodice_fiscale);
				var uindirizzo = d.uindirizzo.value;
				var ucitta = d.ucitta.value;
				var ucap = d.ucap.value;
				var uprovincia = d.uprovincia.value;
				var unazione = d.unazione.value;
				//var utelefono = d.utelefono.value;
				//var ufax = d.ufax.value;
				//var uemail = d.uemail.value;
				//var uconsenso_trattamento_dati = d.uconsenso_trattamento_dati;
				
			 if ((unome == "") || (unome == "undefined")) {
					alert("INSERIRE CAMPO NOME.");
					d.unome.style.background = "yellow";
				   d.unome.focus();
				   return false;
				}
				
			   else if ((ucognome == "") || (ucognome == "undefined")) {
					alert("INSERIRE CAMPO COGNOME.");
					d.ucognome.style.background = "yellow";
				   d.ucognome.focus();
				   return false;
				}

			   else if ((ucodice_fiscale == "") || (ucodice_fiscale == "undefined")) {
					alert("INSERIRE CAMPO CODICE FISCALE.");
					d.ucodice_fiscale.style.background = "yellow";
				   d.ucodice_fiscale.focus();
				   return false;
				}
				
				else if(ucodice_fiscale_ok == false){
					alert("CODICE FISCALE INSERITO NON VALIDO.");
					d.ucodice_fiscale.value = "";
					d.ucodice_fiscale.style.background = "yellow";
				   d.ucodice_fiscale.focus();
				   return false;
				}

			   else if ((uindirizzo == "") || (uindirizzo == "undefined")) {
					alert("INSERIRE CAMPO INDIRIZZO.");
					d.uindirizzo.style.background = "yellow";
				   d.uindirizzo.focus();
				   return false;
				}
				
			   else if ((ucitta == "") || (ucitta == "undefined")) {
					alert("INSERIRE CAMPO CITTA.");
					d.ucitta.style.background = "yellow";
				   d.ucitta.focus();
				   return false;
				}

			  else if (isNaN(ucap) || (ucap == "") || (ucap == "undefined")) {
					alert("INSERIRE CAMPO CAP.");
					d.ucap.value="";
					d.ucap.style.background = "yellow";
				   d.ucap.focus();
				   return false;
			  } 

			   else if ((uprovincia == "") || (uprovincia == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA.");
					d.uprovincia.style.background = "yellow";
				   d.uprovincia.focus();
				   return false;
				}

			   else if ((unazione == "") || (unazione == "undefined")) {
					alert("INSERIRE CAMPO NAZIONE.");
					d.unazione.style.background = "yellow";
				   d.unazione.focus();
				   return false;
				}

				/*else if (checkEmail(uemail) == 0) {
					alert("INSERIRE INDIRIZZO EMAIL CORRETTO.");
					d.uemail.value = "";
					d.uemail.style.background = "yellow";
				   d.uemail.focus();
					return false;
				}*/
				
				/*else if(uconsenso_trattamento_dati.checked == false){
					alert("BISOGNA DARE IL CONSENSO AL TRATTAMENTO DATI.");
					return false;
				}*/
				
				else {
					return true;
				}
		}/** end if su soggetto[1].checked **/


		/** caso azienda **/		
		if(usoggetto[1].checked){
				var uragione_sociale = d.uragione_sociale.value;
				var uindirizzo_sede_legale = d.uindirizzo_sede_legale.value;
				var ucitta_sede_legale = d.ucitta_sede_legale.value;
				var ucap_sede_legale = d.ucap_sede_legale.value;
				var uprovincia_sede_legale = d.uprovincia_sede_legale.value;
				var unazione_sede_legale = d.unazione_sede_legale.value;
				//var upartita_iva = d.upartita_iva.value;
				var upartita_iva_ok = checkPartitaIva(upartita_iva);
				//var utelefono_sede_legale = d.utelefono_sede_legale.value;
				//var ufax_sede_legale = d.ufax_sede_legale.value;
				//var uemail = d.uemail.value;
				//var uconsenso_trattamento_dati = d.uconsenso_trattamento_dati;
				
			   if ((uragione_sociale == "") || (uragione_sociale == "undefined")) {
					alert("INSERIRE CAMPO RAGIONE SOCIALE.");
					d.uragione_sociale.style.background = "yellow";
				   d.uragione_sociale.focus();
				   return false;
				}
			
			   if ((uindirizzo_sede_legale == "") || (uindirizzo_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO INDIRIZZO SEDE LEGALE.");
					d.uindirizzo_sede_legale.style.background = "yellow";
				   d.uindirizzo_sede_legale.focus();
				   return false;
				}

			   if ((ucitta_sede_legale == "") || (ucitta_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO CITTA SEDE LEGALE.");
					d.ucitta_sede_legale.style.background = "yellow";
				   d.ucitta_sede_legale.focus();
				   return false;
				}

			  else if (isNaN(ucap_sede_legale) || (ucap_sede_legale == "") || (ucap_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO CAP SEDE LEGALE.");
					d.ucap_sede_legale.value="";
					d.ucap_sede_legale.style.background = "yellow";
				   d.ucap_sede_legale.focus();
				   return false;
			  } 

			   else if ((uprovincia_sede_legale == "") || (uprovincia_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO PROVINCIA SEDE LEGALE.");
					d.uprovincia_sede_legale.style.background = "yellow";
				   d.uprovincia_sede_legale.focus();
				   return false;
				}

			   else if ((unazione_sede_legale == "") || (unazione_sede_legale == "undefined")) {
					alert("INSERIRE CAMPO NAZIONE SEDE LEGALE.");
					d.unazione_sede_legale.style.background = "yellow";
				   d.unazione_sede_legale.focus();
				   return false;
				}

			   /*else if ((upartita_iva == "") || (upartita_iva == "undefined")) {
					alert("INSERIRE CAMPO PARTITA IVA.");
					d.upartita_iva.style.background = "yellow";
				   d.upartita_iva.focus();
				   return false;
				}
				
				else if (upartita_iva_ok == false){
					alert("PARTITA IVA INSERITA NON VALIDA.");
					d.upartita_iva.value = "";
					d.upartita_iva.style.background = "yellow";
				   d.upartita_iva.focus();
				   return false;
				}*/

				/*else if (checkEmail(uemail) == 0) {
					alert("INSERIRE INDIRIZZO EMAIL CORRETTO.");
					d.uemail.value = "";
					d.uemail.style.background = "yellow";
				   d.uemail.focus();
					return false;
				}*/
				
				/*else if(uconsenso_trattamento_dati.checked == false){
					alert("BISOGNA DARE IL CONSENSO AL TRATTAMENTO DATI.");
					return false;
				}*/
				
				else {
					return true;
				}
		}/** end if soggetto[2].checked **/
}/** end function **/


/** controllo dati per download pratrica**/
/** download/index.php **/
function checkdownloadfile(){
   var d = document.downloader;
   var ucodeord = d.ucodeord.value;
   var uemail = d.uemail.value;
   if ((ucodeord == "") || (ucodeord == "undefined")) {
      alert("INSERIRE CAMPO CODICE ORDINE.");
      d.ucodeord.style.background = "yellow";
      d.ucodeord.focus();
      return false;
   }
   else if (checkEmail(uemail) == 0) {
      alert("INSERIRE INDIRIZZO EMAIL CORRETTO.");
      d.uemail.value = "";
      d.uemail.style.background = "yellow";
      d.uemail.focus();
      return false;
   }
   else {
      return true;
   }
}/** fine funzione **/


/** controllo dati per ricarica credito utente**/
/** admu/rechargekart.php **/
function checkselectrecharge(){
		var d = document.ricarica_conto;
		var ricaricada = d.totale_ricarica.selectedIndex;
		var fondida = d.seleziona_fondo.selectedIndex;
		
		if (ricaricada == 0){
			alert("SCEGLIERE IL TAGLIO DELLA RICARICA.");
			return false;
		} 
		
	   else if (fondida == 0) {
			alert("SCEGLIERE IL TIPO PRELEVA FONDI.");
		   return false;
		}

		else {
			return true;
		}
}

/** controllo dati per cambio password**/
/** admu/changepassword.php **/
function checkChangeasswd(){
		var d = document.cambia_passwd;
		var email = d.new_password.value;
		
   if ((email == "") || (email == "undefined")) {
      alert("INSERIRE NUOVA PASSWORD.");
      d.new_password.style.background = "yellow";
      d.new_password.focus();
      return false;
   }
   
   else {
      return true;
   }
   
}


/** controllo elimina rigo da carrello**/
/** admu/delkart.php **/
function confermaEliminaRigoCarrello(){
   var answer = confirm("Vuoi davvero eliminare il corrente ordine?")
	if (answer){
		alert("Ordine Eliminato..")
		return true;
	} else {
		alert("Azione Annullata..")
		return false;
	}
}


/** controllo dati per recupero password**/
/** lost_password.php **/
function checkRecoveryPasswd(){
      var d = document.recupera_password;
      var selezionato = d.cf_piva_selezionato;
      
      if(selezionato[0].checked){
            var email = d.uemail.value;
            var codice_fiscale = d.cf_piva.value;
            var codice_fiscale_ok = checkCodiceFiscale(codice_fiscale);
            
            if ((email == "") || (email == "undefined")) {
               alert("INSERIRE VOSTRA EMAIL.");
               d.uemail.style.background = "yellow";
               d.uemail.focus();
               return false;
            }  
            

				else if (checkEmail(email) == 0) {
					alert("INSERIRE INDIRIZZO EMAIL CORRETTO.");
					d.uemail.value = "";
					d.uemail.style.background = "yellow";
				   d.uemail.focus();
					return false;
				}            

			   else if ((codice_fiscale == "") || (codice_fiscale == "undefined")) {
					alert("INSERIRE CAMPO CODICE FISCALE.");
					d.cf_piva.style.background = "yellow";
				   d.cf_piva.focus();
				   return false;
				}                        
            
				else if (codice_fiscale_ok == false){
					alert("CODICE FISCALE INSERITO NON VALIDO.");
					d.cf_piva.value = "";
					d.cf_piva.style.background = "yellow";
				   d.cf_piva.focus();
				   return false;
				}
				            
            else {
               return true;
            }      
      } 
      
      
      if(selezionato[1].checked){
            var email = d.uemail.value;
            var partita_iva = d.cf_piva.value;
            var partita_iva_ok = checkPartitaIva(partita_iva);
            
            if ((email == "") || (email == "undefined")) {
               alert("INSERIRE VOSTRA EMAIL.");
               d.uemail.style.background = "yellow";
               d.uemail.focus();
               return false;
            }  

				else if (checkEmail(email) == 0) {
					alert("INSERIRE INDIRIZZO EMAIL CORRETTO.");
					d.uemail.value = "";
					d.uemail.style.background = "yellow";
				   d.uemail.focus();
					return false;
				}            

			   else if ((partita_iva == "") || (partita_iva == "undefined")) {
					alert("INSERIRE CAMPO PARTITA IVA.");
					d.cf_piva.style.background = "yellow";
				   d.cf_piva.focus();
				   return false;
				}
				
				else if (partita_iva_ok == false){
					alert("PARTITA IVA INSERITA NON VALIDA.");
					d.cf_piva.value = "";
					d.cf_piva.style.background = "yellow";
				   d.cf_piva.focus();
				   return false;
				}            
            
            else {
               return true;
            }      
      }
   
}

/** Usata per la verifica della data in emissuìione fattura **/
/** /html/adma/gfatturazione2.php **/
function verificaFormatoData(stringa){
	var espressione = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/;
	if (!espressione.test(stringa)) {
	    return false;
	} else {
		anno = parseInt(stringa.substr(6),10);
		mese = parseInt(stringa.substr(3, 2),10);
		giorno = parseInt(stringa.substr(0, 2),10);
		
		var data=new Date(anno, mese-1, giorno);
		if(data.getFullYear()==anno && data.getMonth()+1==mese && data.getDate()==giorno){
			return true;
		} else {
			return false;
		}
	}
}

/** Usata per la verifica della data in emissuìione fattura **/
/** /html/adma/gfatturazione2.php **/
function verificaData(){
   var d = document.crea_fattura;
   var progressivo = d.progressivo.value;
   var data_emissione = d.data_emissione.value;
   var data_emissione_ok = verificaFormatoData(data_emissione);

    if ((progressivo == "") || (progressivo == "undefined")) {
		alert("INSERIRE CAMPO PROGRESSIVO FATTURA.");
		d.progressivo.style.background = "yellow";
	   d.progressivo.focus();
	   return false;
	} 
	
   else if (isNaN(progressivo)) {
		alert("IL CAMPO PROGRESSIVO FATTURA DEVE ESSERE NUMERICO.");
		d.progressivo.value = "";
		d.progressivo.style.background = "yellow";
	   d.progressivo.focus();
	   return false;
	} 

	else if ((data_emissione == "") || (data_emissione == "undefined")) {
		alert("INSERIRE CAMPO DATA EMISSIONE.");
		d.data_emissione.style.background = "yellow";
	   d.data_emissione.focus();
	   return false;
	} 
	
	else if (data_emissione_ok == false){
		alert("CAMPO DATA EMISSIONE ERRATO. IL FORMATO DEVE ESSERE GG/MM/AAAA");
		d.data_emissione.value = "";
		d.data_emissione.style.background = "yellow";
	   d.data_emissione.focus();
	   return false;
	}
	
	else {
	   return true;
	}
}


/** Usata per la verifica dei dati in emissuione fattura libera **/
/** /html/adma/gfatturazione2.php **/
function verificaDataFatturaLibera(){
      var d = document.crea_fattura_libera;
      var denominazione = d.denominazione.value;
      var indirizzo = d.indirizzo.value;
      var citta = d.citta.value;
      var provincia = d.provincia.value;

      var piva_eo_codfis = d.piva_eo_codfis.value;
      var cf_piva = d.cf_piva.value;

      var progressivo = d.progressivo.value;
      var data_emissione = d.data_emissione.value;
      var data_emissione_ok = verificaFormatoData(data_emissione);
      var codice = d.codice.value;
      var descrizione = d.descrizione.value;
      var iva = d.iva.value;
      var imponibile = d.imponibile.value;

      var exist_email = d.exist_email;
   	if (exist_email.checked){
            var email = d.email.value;
            var email_ok = checkEmail(email);
            
            if ((email == "") || (email == "undefined")) {
               alert("INSERIRE VOSTRA EMAIL.");
               d.email.style.background = "yellow";
               d.email.focus();
               return false;
            }  
   			else if (email_ok == 0) {
   				alert("INSERIRE INDIRIZZO EMAIL CORRETTO.");
   				d.email.value = "";
   				d.email.style.background = "yellow";
   			   d.email.focus();
   				return false;
   			}  
   			else {
   			   return true;
   			}          
   	}	

      
      if(piva_eo_codfis == "iva"){
         var piva_ok = checkPartitaIva(cf_piva);
         var testo_alerta = "PARTITA IVA INSERITA NON CORRETTA.";
      } else {
         var piva_ok = checkCodiceFiscale(cf_piva);
         var testo_alerta = "CODICE FICALE INSERITO NON CORRETTO.";
      }   	
   	


       if ((denominazione == "") || (denominazione == "undefined")) {
   		alert("INSERIRE CAMPO DENOMINAZIONE.");
   		d.denominazione.style.background = "yellow";
   	   d.denominazione.focus();
   	   return false;
   	} 
  	   else if ((indirizzo == "") || (indirizzo == "undefined")) {
   		alert("INSERIRE CAMPO INDIRIZZO.");
   		d.indirizzo.style.background = "yellow";
   	   d.indirizzo.focus();
   	   return false;
   	} 
   	else if ((citta == "") || (citta == "undefined")) {
   		alert("INSERIRE CAMPO CITTA.");
   		d.citta.style.background = "yellow";
   	   d.citta.focus();
   	   return false;
   	} 
   	else if ((provincia == "") || (provincia == "undefined")) {
   		alert("INSERIRE CAMPO PROVINCIA.");
   		d.provincia.style.background = "yellow";
   	   d.provincia.focus();
   	   return false;
   	} 
   	else if ((cf_piva == "") || (cf_piva == "undefined")) {
   		alert("INSERIRE CAMPO PARTITA IVA / CODICE FISCALE.");
   		d.cf_piva.style.background = "yellow";
   	   d.cf_piva.focus();
   	   return false;
   	} 
		else if (piva_ok == false){
			alert(testo_alerta);
			d.cf_piva.value = "";
			d.cf_piva.style.background = "yellow";
		   d.cf_piva.focus();
		   return false;
		}
      else if ((progressivo == "") || (progressivo == "undefined")) {
   		alert("INSERIRE CAMPO PROGRESSIVO FATTURA.");
   		d.progressivo.style.background = "yellow";
   	   d.progressivo.focus();
   	   return false;
   	} 
      else if (isNaN(progressivo)) {
   		alert("IL CAMPO PROGRESSIVO FATTURA DEVE ESSERE NUMERICO.");
			d.progressivo.value = "";
   		d.progressivo.style.background = "yellow";
   	   d.progressivo.focus();
   	   return false;
   	} 
   	else if ((data_emissione == "") || (data_emissione == "undefined")) {
   		alert("INSERIRE CAMPO DATA EMISSIONE.");
   		d.data_emissione.style.background = "yellow";
   	   d.data_emissione.focus();
   	   return false;
   	} 
   	else if (data_emissione_ok == false){
   		alert("CAMPO DATA EMISSIONE ERRATO. IL FORMATO DEVE ESSERE GG/MM/AAAA");
   		d.data_emissione.value = "";
   		d.data_emissione.style.background = "yellow";
   	   d.data_emissione.focus();
   	   return false;
   	}
   	else if ((codice == "") || (codice == "undefined")) {
   		alert("INSERIRE CAMPO CODICE.");
   		d.codice.style.background = "yellow";
   	   d.codice.focus();
   	   return false;
   	} 
   	else if ((descrizione == "") || (descrizione == "undefined")) {
   		alert("INSERIRE CAMPO DESCRIZIONE.");
   		d.descrizione.style.background = "yellow";
   	   d.descrizione.focus();
   	   return false;
   	} 
   	else if ((iva == "") || (iva == "undefined")) {
   		alert("INSERIRE CAMPO IVA.");
   		d.iva.style.background = "yellow";
   	   d.iva.focus();
   	   return false;
   	} 
   	else if ((imponibile == "") || (imponibile == "undefined")) {
   		alert("INSERIRE CAMPO IMPONIBILE.");
   		d.imponibile.style.background = "yellow";
   	   d.imponibile.focus();
   	   return false;
   	} 
   	else {
   	   return true;
   	}
}

/** Usata per la verifica del numero progressivo fattura ricarica **/
/** /html/adma/ricarica_account.php **/
function checkProgressivoFatturaRicarica(){
   var d = document.spefatt;
   var progressivo = d.progressivo.value;
   var data_emissione = d.data_emissione.value;
   var data_emissione_ok = verificaFormatoData(data_emissione);
   
   if ((progressivo == "") || (progressivo == "undefined")) {
		alert("INSERIRE CAMPO PROGRESSIVO FATTURA.");
		d.progressivo.style.background = "yellow";
	   d.progressivo.focus();
	   return false;
	} 
   else if (isNaN(progressivo)) {
		alert("IL CAMPO PROGRESSIVO FATTURA DEVE ESSERE NUMERICO.");
		d.progressivo.value = "";
		d.progressivo.style.background = "yellow";
	   d.progressivo.focus();
	   return false;
	} 
	else if ((data_emissione == "") || (data_emissione == "undefined")) {
   	alert("INSERIRE CAMPO DATA EMISSIONE.");
   	d.data_emissione.style.background = "yellow";
      d.data_emissione.focus();
      return false;
   } 
   else if (data_emissione_ok == false){
   	alert("CAMPO DATA EMISSIONE ERRATO. IL FORMATO DEVE ESSERE GG/MM/AAAA");
   	d.data_emissione.value = "";
   	d.data_emissione.style.background = "yellow";
      d.data_emissione.focus();
      return false;
   } else {
      return true;
   }

}
