  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 newsl_submit(){
  //alert("ciao");
  var nome2, email2;
  var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
  var espressione2 = /^[_a-zA-Z0-9+-\.\'\s]+$/;


  i=0;
  nome2 = trim(document.getElementById('id_nome2').value);
  email2 = trim(document.getElementById('id_email2').value);

  if (nome2 == "" || !espressione2.test(nome2) || nome2.length < 3 ){
  document.getElementById('id_nome2').style.background = "#f498ee";
  i++;
  }

  if (email2 == ""){
  document.getElementById('id_email2').style.background = "#f498ee";
  i++;
  }
  else
  {
  	
	if (!espressione.test(email2))
	{
	document.getElementById('id_email2').style.background = "#f498ee";
	i++;
	}
  }
  
    if (i > 0){
    cc('id_newsl_errore', 'newsl_errore.php');
    }
    else
    {
    par = "&nome2=" + nome2 + "&email2=" + email2;
    //alert(par);  
    cc('id_newsl', 'newsl.php', 'post', par);
  }

}
  
  function newsl_del_campo(val){
  if (document.getElementById(val)){
  document.getElementById(val).style.background = "#ebebeb";
  }
  cc('id_newsl_errore', 'form_errore_vuoto.php');  
  }