  function trim(stringa){
    while (stringa.substring(0,1) == ' '){
        stringa = stringa.substring(1, stringa.length);
    }
    while (stringa.substring(stringa.length-1, stringa.length) == ' '){
        stringa = stringa.substring(0,stringa.length-1);
    }
    return stringa;
  }
  function login_submit(){
  var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
  var espressione2 = /^[_a-zA-Z0-9+-\.\'\s]+$/;

  //alert("ciao");
  var nomeut2, passw2;

  i=0;
  nomeut2 = trim(document.getElementById('id_nomeut2').value);
  passw2 = trim(document.getElementById('id_passw2').value);

  if ( nomeut2 == "" || !espressione2.test(nomeut2) || nomeut2.length < 3 ){
  document.getElementById('id_nomeut2').style.background = "#a3cdf9";
  i++;
  }
  
  if ( passw2 == "" || !espressione2.test(passw2) || passw2.length < 3 ){
  document.getElementById('id_passw2').style.background = "#a3cdf9";
  i++;
  }



    if (i > 0){
    cc('id_login_errore', 'login_errore.php');
    }
    else
    {
    par = "&nomeut2=" + nomeut2 + "&passw2=" + passw2;
    //alert(par);  
    cc('id_login', 'login.php', 'post', par);
  }

}
  
  function login_del_campo(val){
  if (document.getElementById(val)){
  document.getElementById(val).style.background = "#ffffff";
  }
  cc('id_login_errore', 'login_errore_vuoto.php');  
  }
  
function vai(){
timerID = setTimeout('vai2()', 1200);
}

function vai2(){
clearTimeout(timerID); 
cc('id_down', 'down_elenco.php');
}
