/**
 * Funzione per la verifica di un indirizzo E-mail
 */
function checkEmail(checkString)
{
    var newstr = "";
    var at = false;
    var dot = false;

    // L'email deve contenere il carattere @
    if (checkString.indexOf("@") != -1) {
      at = true;

    // deve contenere il .
    } else if (checkString.indexOf(".") != -1) {
      dot = true;
    }
    // deve contenere i seguenti caratteri
    for (var i = 0; i < checkString.length; i++) {
        ch = checkString.substring(i, i + 1)
        if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
                || (ch == "@") || (ch == ".") || (ch == "_")
                || (ch == "-") || (ch >= "0" && ch <= "9")) {
                newstr += ch;
                if (ch == "@") {
                    at=true;
                }
                if (ch == ".") {
                    dot=true;
                }
        }
    }
    if ((at == true) && (dot == true)) {
        return newstr;
    }
    else {
      // Errore
      alert ("Attenzione\nLa e-mail inserita non e' esatta.\nUsare la notazione: utente@provider.it\noppure: utente.organizazione@provider.it");
	  document.controllo.email.focus();
	  return false;
      return checkString;
    }
}


