function lib_check_mail(address, msg_txt)
  {
  if (msg_txt == null)
    msg_txt = "Attenzione, indirizzo e-mail non corretto.";
  re = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
  if (!re.test(address))
    {
    if (msg_txt != "")
      alert(msg_txt);
    return false;
    }
  else
    return true;
  }

function trim(str) {
  return str.replace(/\s+$|^\s+/g,"");
}