function ctrl_preventivo()
	{var tuttoOK = true
		
		var totale_prod = 0
		
		for(i=1;i<=17;i++){
				if ((ControllaCampo(eval('document.preventivo.FP' + i + '.value')) == 'KO') && (tuttoOK == true))
					{
						window.alert('Le quantitą inserite devono essere zero o un numero maggiore di zero.\nNon sono ammessi valori alfanumerici.');
						tuttoOK = false
					} else {
						totale_prod = totale_prod + eval('document.preventivo.FP' + i + '.value')
					}
			}
		
		if ((totale_prod == 0) && (tuttoOK == true))
			{
				window.alert('Per un preventivo, scegliere almeno un prodotto.');
				tuttoOK = false
			}
		
		if ((document.preventivo.azienda.value == '') && (tuttoOK == true))
			{
				window.alert('Indicare il nome dell\'azienda');
				tuttoOK = false
			}
		if ((document.preventivo.nominativo.value == '') && (tuttoOK == true))
			{
				window.alert('Inserire il nominativo');
				tuttoOK = false
			}
		if ((ControllaMail(document.preventivo.email.value) == 'KO') && (tuttoOK == true))
			{
				window.alert('L\'indirizzo di posta elettronica inserito\nnon sembra essere valido.\nVi preghiamo di controllarlo. Grazie');
				tuttoOK = false
			}	
		
		if ((document.preventivo.telefono.value == '') && (tuttoOK == true))
			{
				window.alert('Inserire un numero di telefono');
				tuttoOK = false
			}
		if ((document.preventivo.indirizzo.value == '') && (tuttoOK == true))
			{
				window.alert('Indirizzo mancante');
				tuttoOK = false
			}
			
		if ((document.preventivo.cap.value == '') && (tuttoOK == true))
			{
				window.alert('Cap mancante');
				tuttoOK = false
			}
			
		if ((document.preventivo.citta.value == '') && (tuttoOK == true))
			{
				window.alert('Indicare la cittą');
				tuttoOK = false
			}
		if ((document.preventivo.provincia.value == '') && (tuttoOK == true))
			{
				window.alert('Provincia mancate');
				tuttoOK = false
			}
		if ((document.preventivo.privacy[0].checked == false) && (tuttoOK == true))
			{
				window.alert('Per procedere occorre aver letto l\'informativa sulla privacy');
				tuttoOK = false
			}
		if (tuttoOK == true)
			{document.preventivo.submit();}
	}

function ControllaMail(EmailAddr)
   {
   Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
   if (Filtro.test(EmailAddr))
      return 'OK';
   else
      {
      return 'KO';
      }
   }
  
function ControllaCampo(valorecampo)
   {
	   //Filtro = /^([\-])?([0-9]+)([0-9]*)$/;
	   Filtro = /^([0-9]+)([0-9]*)$/;
	   if (Filtro.test(valorecampo))
			{return 'OK';}
	   else
			{return 'KO';}	
   }