//Funzione di validazione nella form di richiesta info da parte del cliente
function validate(lang, rag_soc, ind, loc, piva, usr, email, chk_access, chk_catalog) {
  var isInteger_re = /^\s*(\+|-)?\d+\s*$/;
  var isEmail_re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
  if(!chk_access && !chk_catalog) {
    if(lang == 'it') alert('Selezionare almeno un tipo di richiesta da inoltrare');
    else alert('You should choose at least one request');
    return;
  }
  if(fd_trim(ind) == '') {
    if(lang == 'it') alert('Il campo "Indirizzo e\' obbligatorio');
    else alert('Field "Address" is required');
    return;
  }
  if(fd_trim(loc) == '') {
    if(lang == 'it') alert('Il campo "Localita\'" e\' obbligatorio');
    else alert('Field "City" is required');
    return;
  }
  if(fd_trim(piva) != '') {
    if(piva.search(isInteger_re) == -1) {
      if(lang == 'it') alert('Il campo "Partita IVA non e\' valido');
      else alert('Field "VAT No" is not valid');
      return;
    }
  }
  //if(fd_trim(usr) == '') {
  //  if(lang == 'it') alert('Il campo "Nome referente" e\' obbligatorio');
  //  else alert('Field "Contact name" is required');
  //  return;
  //}
  if(fd_trim(email) == '') {
    if(lang == 'it') alert('Il campo "E-mail" e\' obbligatorio');
    else alert('Field "E-mail" is required');
    return;
  } else if(email.search(isEmail_re) == -1) {
    if(lang == 'it') alert('Il campo "E-mail" non e\' valido');
    else alert('Field "E-mail" is not valid');
    return;
  }
  document.forms.f.submit();
}

