function obbligatorio(valore){
	with(document){
		if (valore=='Privato'){
			getElementById('obb_iva').style.display='block';
			getElementById('obb_fis').style.display='none';
			getElementById('obb_azi').style.display='block';
			getElementById('not_iva').style.display='none';
			getElementById('not_fis').style.display='block';
			getElementById('not_azi').style.display='none';

		}else if (valore=='Azienda'){
			getElementById('obb_iva').style.display='none';
			getElementById('obb_fis').style.display='block';
			getElementById('obb_azi').style.display='none';
			getElementById('not_iva').style.display='block';
			getElementById('not_fis').style.display='none';
			getElementById('not_azi').style.display='block';
		}else{
			getElementById('obb_iva').style.display='none';
			getElementById('obb_fis').style.display='none';
			getElementById('obb_azi').style.display='none';
			getElementById('not_iva').style.display='block';
			getElementById('not_fis').style.display='block';
			getElementById('not_azi').style.display='block';
		}
	}	
}

function controlla_iscrizione(){
	with(document){
		var campo=new Array("tipo_utente","cognome","nome","data","nazione","provincia","citta","indirizzo","cap","telefono","email","password","password2","consenso");
		var campo_desc=new Array("Tipo Utente","Cognome","Nome","Data","Nazione","Provincia","Citta'","Indirizzo","CAP","Telefono","E-mail","Password","Conferma password","Consenso al trattamento dei dati personali");
		var data=new Array("data");
		var data_desc=new Array("Data di Nascita");
		var condizione=new Array("(getElementById('tipo_utente').value=='Privato')&&(getElementById('codice_fiscale').value=='Scrivi qui')","(getElementById('tipo_utente').value=='Azienda')&&(getElementById('partitaiva').value=='Scrivi qui')","(getElementById('tipo_utente').value=='Azienda')&&(getElementById('azienda').value=='Scrivi qui')","(getElementById('password').value!=getElementById('password2').value)");
		var condizione_desc=new Array("Il campo Codice Fiscale è obbligatorio","Il campo Partita Iva è obbligatorio","Il campo Azienda è obbligatorio","La password e la conferma della Password devono essere uguali");
		var err="";
		for(var i=condizione.length-1;i>=0;i--){
			valore=eval(condizione[i]);
			if (valore){
				err="   "+condizione_desc[i]+"\n\n"+err;
			}
		}
		for(var i=data.length-1;i>=0;i--){
			valore=getElementById(data[i]).value;
			if ((valore!="Scrivi qui")&&(!isData(valore))){
				err="   Il valore della data nel campo "+data_desc[i]+" è errato\n\n"+err;
				getElementById(data[i]).style.backgroundColor='#EEF088';
				getElementById(data[i]).focus();
			}
		}
		for(var i=campo.length-1;i>=0;i--){
			valore=getElementById(campo[i]).value;
			if ((valore=="Scrivi qui")||(valore=="Scrivi qui il tuo cognome")||(valore=="Scrivi qui il tuo nome")||(valore=="")){
				err="   Il campo "+campo_desc[i]+" e' obbligatorio\n\n"+err;
				getElementById(campo[i]).style.backgroundColor='#EEF088';
				getElementById(campo[i]).focus();
			}	
		}
		if (err!=""){
			alert("Riscontrati i seguenti errori:\n\n"+err);
			return false;
		}else{
			return true;
		}
	}	
}
function controlla_modifica(){
	with(document){
		var campo=new Array("ragionesociale","data","nazione","provincia","citta","indirizzo","cap","telefono","email");
		var campo_desc=new Array("Nome","Data","Nazione","Provincia","Citta'","Indirizzo","CAP","Telefono","E-mail");
		var data=new Array("data");
		var data_desc=new Array("Data di Nascita");
		var condizione=new Array("(getElementById('tipo_utente').value=='Privato')&&(getElementById('codice_fiscale').value=='Scrivi qui')","(getElementById('tipo_utente').value=='Azienda')&&(getElementById('partitaiva').value=='Scrivi qui')");
		var condizione_desc=new Array("Il campo Codice Fiscale e' obbligatorio","Il campo Partita Iva e' obbligatorio");
		var err="";
		for(var i=condizione.length-1;i>=0;i--){
			valore=eval(condizione[i]);
			if (valore){
				err="   "+condizione_desc[i]+"\n\n"+err;
			}
		}
		for(var i=data.length-1;i>=0;i--){
			valore=getElementById(data[i]).value;
			if ((valore!="Scrivi qui")&&(!isData(valore))){
				err="   Il valore della data nel campo "+data_desc[i]+" e' errato\n\n"+err;
				getElementById(data[i]).style.backgroundColor='#EEF088';
				getElementById(data[i]).focus();
			}
		}
		for(var i=campo.length-1;i>=0;i--){
			valore=getElementById(campo[i]).value;
			if ((valore=="Scrivi qui")||(valore=="Scrivi qui il tuo cognome")||(valore=="Scrivi qui il tuo nome")||(valore=="")){
				err="   Il campo "+campo_desc[i]+" e' obbligatorio\n\n"+err;
				getElementById(campo[i]).style.backgroundColor='#EEF088';
				getElementById(campo[i]).focus();
			}	
		}
		if (err!=""){
			alert("Riscontrati i seguenti errori:\n\n"+err);
			return false;
		}else{
			return true;
		}
		//return true;*/
	}
}
  function controlla_pass() {

	 var password_app = document.getElementById('password_app').value;
	 var password1 = document.getElementById('password1').value;
	 var password2 = document.getElementById('password2').value;
	 var password3 = document.getElementById('password3').value;
	
	 var continua=true;
	 var testo_err="";
	 var appo1=true;
	 var appo2=true;

	//password1
	 if ((password1 == "") || (password1 == "undefined")) {
           testo_err= "  Specificare Password Attuale.\n\n" + testo_err;
           document.getElementById('password1').focus();
		   document.getElementById('password1').style.backgroundColor='#EEF088';
		   continua=false;
		   appo1=false;
        }
	//password2
	 if ((password2 == "") || (password2 == "undefined")) {
           testo_err= "  Specificare Nuova Password.\n\n" + testo_err;
           document.getElementById('password2').focus();
		   document.getElementById('password2').style.backgroundColor='#EEF088';
		   continua=false;
		   appo2=false;
        }
	//password3
	 if ((password3 == "") || (password3 == "undefined")) {
           testo_err= "  Confermare Password Nuova.\n\n" + testo_err;
           document.getElementById('password3').focus();
		   document.getElementById('password3').style.backgroundColor='#EEF088';
		   continua=false;
		   appo2=false;
        }
	//password2 e password3
	if (appo2){
	 if (password3 != password2) {
           testo_err= "  Inserite due Nuove Password diverse.\n\n" + testo_err;
           document.getElementById('password3').value='';
		   document.getElementById('password2').value='';
		   document.getElementById('password2').focus();
		   document.getElementById('password3').style.backgroundColor='#EEF088';
		   document.getElementById('password2').style.backgroundColor='#EEF088';
		   continua=false;
        }
	}
	//password1 e password_app
	if (appo1){
	 if (password1 != password_app) {
           testo_err= "  Inserita Password Attuale errata.\n\n" + testo_err;
           document.getElementById('password1').value='';
		   document.getElementById('password1').focus();
		   document.getElementById('password1').style.backgroundColor='#EEF088';
		   continua=false;
        }
	}
	//valida form
	if(continua==false){
		alert("Sono stati riscontrati i seguenti errori: \n\n" + testo_err);
		return false;
	}else{
		return true;
	}
          
  }
