// JavaScript Document
function KunaFormCheckForm(theForm)
{

  if (theForm.nome.value == "")
  {
	alert("Insert \"Name\".");
	theForm.nome.focus();
	return (false);
  }  
  
  if (theForm.cognome.value == "")
  {
	alert("Insert \"Surname\".");
	theForm.cognome.focus();
	return (false);
  }

  if (theForm.EMail.value == "")
  {
	alert("Insert e-Mail.");
	theForm.EMail.focus();
	return (false);
  }
  
  if (KunaFormconvalidaMail(theForm.EMail) == false)
  {
    alert("Insert correct EMail.");
    theForm.EMail.focus();
    return (false);
  } 
  
  if (theForm.message.value == "")
  {
	alert("Insert \"Message\".");
	theForm.message.focus();
	return (false);
  }
  
  if (theForm.CodiceDiControllo.value.length != 8 )
  {
    alert("Insert control code.");
    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;
	}
}