function _onload()
{
this.document.form.metodo.disabled = true;
this.document.form.metodo.blur();
}


function emailCheck(txt) {
	if (txt.indexOf("@")<3){
		return false;
	}else{return true;}
	
	if ((txt.indexOf(".com")<5)&&(txt.indexOf(".net")<5)
	&&(txt.indexOf(".org")<5)&&(txt.indexOf(".edu")<5)
	&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".mil")<5)
	&&(txt.indexOf(".it")<5)){
		return false;
  	}else{return true;}
}

function campopieno(txt){
	if ((txt.length<1)||(txt.substring(0,5)=="")) {
		return false;
	}else{return true;}
}
   
function messaggio(){
	alert("Campi obbligatori mancanti. Inserire dati.")
}	


function _onclick(){
  txt=this.document.form.Mail.value;
  nome1=this.document.form.Nome.value;
  ctr2=this.document.form.Via.value;
  ctr3=this.document.form.Localita.value;
  ctr4=this.document.form.Referente.value;
  ctrOR1=this.document.form.Tel.value;
  ctrOR2=this.document.form.Fax.value;
  pienidiretti = (campopieno(nome1) && campopieno(ctr2) && campopieno(ctr3) && campopieno(ctr4)) ;
  ctrOR1e2 = campopieno(ctrOR1) || campopieno(ctrOR2) ;

  if (emailCheck(txt) == false ) {
	alert("Probabile errore nel campo E-MAIL.");
	this.document.form.metodo.disabled = true;
	this.document.form.Nome.disabled = false;
	this.document.form.Mail.disabled = false;
  }

  if (( pienidiretti && ctrOR1e2 )) {
  	this.document.form.metodo.disabled = false;
	this.document.form.Nome.disabled = false;
	this.document.form.Mail.disabled = false;
	}
	else
	{
	this.document.form.metodo.disabled = true;
	// permettiamo che i campi vengano scritti
	this.document.form.Nome.disabled = false;
	this.document.form.Mail.disabled = false;

	messaggio();
  	}
}
