//***** FUNZIONI DI CONVALIDA DEI DATI INSERITI NEL FORM DI CONTATTO *****

function IsEmailValid(){
	var EmailOk  = true
	var Temp     = document.frmModulo.txtEmail.value;
	var AtSym    = Temp.indexOf('@')
	var Period   = Temp.lastIndexOf('.')
	var Space    = Temp.indexOf(' ')
	var Length   = Temp.length - 1   
	// Array is from 0 to length-1
	if (Temp == "") { 
	return true; }
	if ((AtSym < 1) ||                     
	    (Period <= AtSym+1) ||             
	    (Period == Length ) ||             
	    (Space  != -1))
		{                 
	      alert("Inserire un indirizzo E-mail valido.");
			document.frmModulo.txtEmail.focus();
	      EmailOk = false
	   }

	return EmailOk
}

function Convalida(){ 
	if (document.frmModulo.txtNome.value==""){
		alert("Inserire nome e cognome");
		document.frmModulo.txtNome.focus();
		return false;
	}
	if (document.frmModulo.txtIndirizzo.value==""){
		alert("Inserire l'indirizzo");
		document.frmModulo.txtIndirizzo.focus();
		return false;
	}
	
	if (document.frmModulo.txtCAP.value==""){
		alert("Inserire il CAP");
		document.frmModulo.txtCAP.focus();
		return false;
	}
	
	if (document.frmModulo.txtCitta.value==""){
		alert("Inserire la Cittą");
		document.frmModulo.txtCitta.focus();
		return false;
	}
	
	if (document.frmModulo.txtProvincia.value==""){
		alert("Inserire la provincia");
		document.frmModulo.txtProvincia.focus();
		return false;
	}
	
	
	
	if ((document.frmModulo.txtEmail.value=="")&&(document.frmModulo.txtTel.value=="")){
		alert("Inserire almeno o l' E-Mail o il telefono");
		document.frmModulo.txtEmail.focus();
		return false;
	}
	
	
	if (IsEmailValid()==false){
		return false;
	}
		
	return true;

}
//***** FINE FUNZIONI DI CONVALIDA DEI DATI INSERITI NEL FORM DI CONTATTO ****** 
