  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 iemail, ipassw, i;
  var espressione = /^[_a-zA-Z0-9+-\.\'\s]+$/;
 //alert("ciao");
  i=0;
  iemail = trim(document.getElementById('id_iemail').value);
  ipassw = trim(document.getElementById('id_ipassw').value);
  

	if (!espressione.test(iemail))
	{
	document.getElementById('id_iemail').style.background = "#f498ee";
	i++;
	}

    if (ipassw.length < 6){
    document.getElementById('id_ipassw').style.background = "#f498ee";
    i++;
    }
  
    if (i > 0){
	document.getElementById("id_login_errore").innerHTML = "<div style='font-family:verdana;font-size:11px;color:red;'>Errore!</font>";
    }
    else
    {
	document.forms["mylogin"].submit();
    }

}
  
  function login_del_campo(val){
  if (document.getElementById(val)){
  document.getElementById(val).style.background = "#ffffff";
  }
   if (document.getElementById("id_login_errore")){
   document.getElementById("id_login_errore").innerHTML = "";
   }
  }
