function validEmailAddress(addr) {
  if (window.RegExp) {
    var notvalid = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var valid = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    var regnv = new RegExp(notvalid);
    var regv = new RegExp(valid);
    if (!regnv.test(addr) && regv.test(addr))
      return true;
    return false;
	}
  else {
    if(addr.indexOf("@") >= 0)
      return true;
    return false;
  	}
  }

function trimValue(val){

    while(val.charAt(val.length - 1) == " ")
        val = val.substr(0,val.length - 1);
    while(val.charAt(0) == " ")
        val = val.substr(1);
    
    return val;
}

function controlla(modulo){
    
    eval("f = document."+modulo);

    if(trimValue(f.nome.value) == ""){
        alert("Inserire il proprio nome.");
        f.nome.focus();
        return false;
    }

    if(trimValue(f.cognome.value) == ""){
        alert("Inserire il proprio cognome.");
        f.nome.focus();
        return false;
    }

    if(trimValue(f.userName.value) == ""){
        alert("Inserire il proprio username.");
        f.nome.focus();
        return false;
    }

    
    if(!validEmailAddress(f.email.value)){
        alert("L\'indirizzo email non è stato scritto correttamente (es. tuonome@tuodominio.it).");
        f.email.focus();
        return false;
    }
       
    f.submit();

}

function goMotDon(){

  if (document.getElementById("argosel").options[document.getElementById("argosel").selectedIndex].value == "noarg")
   alert("Selezionare un argomento dalla prima tendina e una voce relativa dalla seconda tendina");
  else
   document.location.href=document.getElementById("argosel").options[document.getElementById("argosel").selectedIndex].value;

};