// JavaScript Document
function KunaFormCheckForm(theForm)
{

  if (theForm.Nome.value == "")
  {
	alert("Inserire un valore per il campo \"Nome\".");
	theForm.Nome.focus();
	return (false);
  } 
  
  if (theForm.Cognome.value == "")
  {
	alert("Inserire un valore per il campo \"Cognome\".");
	theForm.Cognome.focus();
	return (false);
  }
  
  if (theForm.Indirizzo.value == "")
  {
	alert("Inserire un valore per il campo \"Indirizzo\".");
	theForm.Indirizzo.focus();
	return (false);
  }
  
  if (theForm.Telefono.value == "")
  {
	alert("Inserire un valore per il campo \"Telefono\".");
	theForm.Telefono.focus();
	return (false);
  }
  
  if (theForm.CAP.value == "")
  {
	alert("Inserire un valore per il campo \"CAP\".");
	theForm.CAP.focus();
	return (false);
  }
  
  if (theForm.Citta.value == "")
  {
	alert("Inserire un valore per il campo \"Citta\".");
	theForm.Citta.focus();
	return (false);
  }

  if (theForm.EMail.value == "")
  {
	alert("Inserire l'indirizzo e-Mail.");
	theForm.EMail.focus();
	return (false);
  }
  
  if (KunaFormconvalidaMail(theForm.EMail) == false)
  {
    alert("Inserire un indirizzo EMail valido.");
    theForm.EMail.focus();
    return (false);
  } 
  
  if (theForm.CodiceDiControllo.value.length != 8 )
  {
    alert("Inserire il codice di controllo corretto.");
    theForm.CodiceDiControllo.focus();
    return (false);
  }   
  
  return (true);
}

function KunaFormconvalidaMail(email)
{
	apos=email.value.indexOf("@");
	dotpos=email.value.lastIndexOf(".");
	lastpos=email.value.length-1;
	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
	{
		return false;
	}
	else 
	{
		return true;
	}
}
