function checkEmailPassword() {
    var strOut = "";
    if (trim(document.getElementById("email").value) == "") {
        strOut += "E-Mail non valida \n";
    }
    if (trim(document.getElementById("email").value) != "") {
        var eml = checkEmail(document.getElementById("email"));
        if(!eml)
            strOut += "Formato E-Mail non valido \n";
    }
    if (strOut=="")
        document.forms[1].submit();
    else
        alert(strOut);
}

function checkFormArticolo() {
    var strOut = "";
    if (trim(document.getElementById("titolo").value) == "") {
        strOut += "Titolo non valido \n";
    }
    if (trim(document.getElementById("testo").value) == "") {
        strOut += "Testo non valido \n";
    }
    if (strOut=="")
        document.forms[1].submit();
    else
        alert(strOut);
}

function checkFormCollabora() {
    var strOut = "";
    if (trim(document.getElementById("nome").value) == "") {
	strOut += "Nome non valido \n";
    }
    if (trim(document.getElementById("cognome").value) == "") {
	strOut += "Cognome non valido \n";
    }
    if (trim(document.getElementById("indirizzo").value) == "") {
	strOut += "Indirizzo non valido \n";
    }
    if (trim(document.getElementById("citta").value) == "") {
	strOut += "Città non valida \n";
    }
    if (trim(document.getElementById("codice").value) == "") {
	strOut += "Codice postale non valido \n";
    }
    if (trim(document.getElementById("nazione").value) == "") {
	strOut += "Nazione non valida \n";
    }
    if (trim(document.getElementById("telefono").value) == "") {
	strOut += "Telefono non valido \n";
    }
    if (trim(document.getElementById("email").value) == "") {
	strOut += "E-Mail non valida \n";
    }
    if (trim(document.getElementById("email").value) != "") {
	var eml = checkEmail(document.getElementById("email"));
	if(!eml)
	    strOut += "Formato E-Mail non valido \n";
    }    
    if (strOut=="")
	document.forms[1].submit();
    else 
	alert(strOut);
}

function checkEmail(email) {
    //var email = document.getElementById(’emailaddress’);
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(trim(email.value))) {
	return false;
    }
    return true;
}

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

