<!--
// Check all fields
function testall(frm)
{
 if ( !testsld(frm) ) return false;
   return true;
}
// Check the sld form
function testsld(frm)
{
  cognome = frm.cognome.value;
  nome    = frm.nome.value;
  email   = frm.email.value;
  citta   = frm.citta.value;
  id_cat  = frm.id_categoria[frm.id_categoria.selectedIndex].value;
  testo   = frm.testo.value;
  informativa = frm.informativa.checked;

  len_cognome = cognome.length;
  len_nome    = nome.length;
  len_email   = email.length;
  len_citta   = citta.length;
  len_id_cat  = id_cat.length;
  len_testo   = testo.length;

   // fail if cognome blank
   if ( len_cognome == "" ) {
      alert("\nNon è stato inserito il Cognome.");
      frm.cognome.focus();
      return false;
   }

   // fail if nome blank
   if ( len_nome == "" ) {
      alert("\nNon è stato inserito il Nome.");
      frm.nome.focus();
      return false;
   }

   // fail if email blank
//   if ( len_email == "" ) {
//      alert("\nNon è stata inserita l'E-Mail.");
//      frm.email.focus();
//      return false;
//  }

   // fail if email not contains any '@'
   if ((email.indexOf('@', 0) == -1) && (len_email > 0)){
      alert("\nIndirizzo E-Mail non corretto.");
      frm.email.value = "";
      frm.email.focus();
      return false;
   }

   // fail if citta blank
//   if ( len_citta == "" ) {
//      alert("\nNon è stato inserito la città.");
//      frm.citta.focus();
//      return false;
//   }

   // fail if id_categoria not choose
   if ( len_id_cat == "" ) {
      alert("\nNon hai scelto la categoria della Frase.");
      frm.id_categoria.focus();
      return false;
   }

   // fail if testo blank
   if ( len_testo == "" ) {
      alert("\nNon è stato inserito il testo della Frase.");
      frm.testo.focus();
      return false;
   }

   // fail if testo > 160 blank
   if ( len_testo > 800) {
      alert("\nLa frase può essere al max di 800 caratteri.");
      frm.testo.focus();
      return false;
   }

   if (!informativa) {
      alert("\nE' necessario accettare l'informativa sulla privacy.");
      frm.informativa.focus();
      return false;
   }

   return true;
}
function popup(link) {
 window.open(link, '', 'toolbar=no,scrollbars=no,resizeable=no,width=570,height=570');
}

function CheckLength(txta,chrs,maxchars)
{
 var chars=txta.value
 if (chars.length > maxchars)
 {
  txta.value=chars.substr(0,maxchars);
  txta.blur();
 }
 chrs.value=maxchars-txta.value.length;
}
// -->


