/**
 * 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;
    }
}

/**
 * Funzione per il reset del popup
 */
function ResetPopup(resetString)
{
    var newstr = "";
    resetString = newstr;
	return resetString;
}

function ResetText(resetText)
{
    var newstr = "";
    resetText = newstr;
	return resetText;
}


function ResetCheckBox(resetCheckBox)
{
    var newstr = "";
    resetCheckBox = newstr;
	return resetCheckBox;
}


function ResetPopups(pop1, pop2)
{
	ResetPopup(pop1);
	ResetPopup(pop2);
	ResetText(document.query.comune);
}

function ResetForm()
{
	var form = document.query;
	
	ResetPopup(form.area);
	ResetPopup(form.id_regione);
	ResetPopup(form.id_provincia);
	ResetCheckBox(form.capoluogo);
	ResetText(form.popolazione_da);
	ResetText(form.popolazione_a);
}

