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 form_rec_pass(){
//alert("ciao");
var nomeut, email, ran1, ran;
var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;

i=0;
//nomeut = trim(document.getElementById('id_nomeut').value);
email = trim(document.getElementById('id_remail').value);
ran1 = document.getElementById('id_rran1').value;
ran = document.getElementById('id_rran').value;
var ck = new Array();
ck[1] = "a7f1c8";
ck[2] = "b2r3ac";
ck[3] = "q2et89";
ck[4] = "p1y5h3";
ck[5] = "mh3g77";
ck[6] = "nf33t4";
ck[7] = "l2ep77";
ck[8] = "nu55h3";
ck[9] = "nu55h3";
ck[10] = "yh3na2";
ck[11] = "yv77e8";
ck[12] = "psa662";
ck[13] = "wf43l1";
ck[14] = "cxz234";
ck[15] = "ke2p37";


  if (email == ""){
  document.getElementById('id_remail').style.background = "#f498ee";
  i++;
  }
  else
  {
  	
	if (!espressione.test(email))
	{
	document.getElementById('id_remail').style.background = "#f498ee";
	i++;
	}
  }
  
  /*
  if (nomeut == ""){
  document.getElementById('id_nomeut').style.background = "#f498ee";
  i++;
  }
  */

  if (ran == ""){
  document.getElementById('id_rran').style.background = "#f498ee";
  i++;
  }
  else
  {
    if ( !((ran == ck[ran1]) || (ran == ck[ran1].toUpperCase())) ){
    document.getElementById('id_rran').style.background = "#f498ee";
    i++;
    }
  }
  
  if (i > 0){
  document.getElementById('id_rerrore').innerHTML = "";
  }
  else
  {
  par = "&email=" + email;
  //alert(par);  
   if (document.getElementById('id_rec_login')){
   cc('id_recupera', 'rec_real.php', 'post', par);
   }
   else
   {
   cc('id_recupera', 'rec_real.php', 'post', par);
   }
  
  }

}

function form_rdel_campo(val){
  if (document.getElementById(val)){
  document.getElementById(val).style.background = "#ffffff";
  document.getElementById('id_rerrore').innerHTML = "";
  } 
}
