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 checkct(){
var nome, azienda, citta, telefono, email, oggetto, messaggio, ran1, ran;

var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;

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";

i=0;
nome = trim(document.getElementById('nome').value);
azienda = trim(document.getElementById('azienda').value);
citta = trim(document.getElementById('citta').value);
telefono = trim(document.getElementById('telefono').value);
email = trim(document.getElementById('email').value);
oggetto = trim(document.getElementById('oggetto').value);
messaggio = trim(document.getElementById('messaggio').value);
ran1 = trim(document.getElementById('ran1').value);
ran = trim(document.getElementById('ran').value); 

  if (nome == ""){
  i++;
  }

  if (email == ""){
  i++;
  }
  else
  {
  	
	if (!espressione.test(email))
	{
	i++;
	}
  }
  
  if (oggetto == ""){
  i++;
  }

  if (messaggio == ""){
  i++;
  }

  if (ran == ""){
  i++;
  }
  else
  {
    if ( !((ran == ck[ran1]) || (ran == ck[ran1].toUpperCase())) ){
    i++;
    }
  }
  
  if (i > 0){
  
    if (document.all){
    document.all['cter'].style.visibility = "visible"; 
    }
    else
    {
	
      if(document.getElementById) {
      document.getElementById('cter').style.visibility = "visible";
      }
    }
  
  
  }
  else
  {
  par = "nome=" + nome + "&azienda=" + azienda + "&citta=" + citta + "&telefono=" + telefono + "&email=" + email + "&oggetto=" + oggetto + "&messaggio=" + messaggio + "&ran1=" + ran1 + "&ran=" + ran;
  cc('corpo2', 'verificareg.php', 'post', par);
  }
}

function ctfocus(){
    if (document.all){
    document.all['cter'].style.visibility = "hidden"; 
    }
    else
    {
	
      if(document.getElementById) {
      document.getElementById('cter').style.visibility = "hidden";
      }
    }
}

function arfocus(){
    if (document.all){
    document.all['arer'].style.display = "none"; 
    }
    else
    {
	
      if(document.getElementById) {
      document.getElementById('arer').style.display = "none";
      }
    }
}

function arfocus2(){
    if (document.all){
    document.all['arer2'].style.display = "none"; 
    }
    else
    {
	
      if(document.getElementById) {
      document.getElementById('arer2').style.display = "none";
      }
    }
}

function ver_ar(){
var nomeu, passu, i;
nomeu = document.getElementById('arnomeu').value;
passu = document.getElementById('arpassu').value;

i = 0;
  if (nomeu == ""){
  i++;
  }

  if (passu == ""){
  i++;
  }

  if (i > 0){
    if (document.all){
    document.all['arer'].style.display = "block";
    }
    else
    {
	
      if(document.getElementById){
	  document.getElementById('arer').style.display = "block";
      }
    }
  }
  else
  {
  par = "nomeu=" + nomeu + "&passu=" + passu;
  cc('idareaclienti', 'ar_ver.php', 'post', par);
  }  
}

function ver_ar2(){
var nomeu, passu, i;
nomeu = document.getElementById('arnomeu2').value;
passu = document.getElementById('arpassu2').value;

i = 0;
  if (nomeu == ""){
  i++;
  }

  if (passu == ""){
  i++;
  }

  if (i > 0){
    if (document.all){
    document.all['arer2'].style.display = "block";
    }
    else
    {
	
      if(document.getElementById){
	  document.getElementById('arer2').style.display = "block";
      }
    }
  }
  else
  {
  par = "nomeu=" + nomeu + "&passu=" + passu;
  cc('idareaatleti', 'ar_ver2.php', 'post', par);
  }  
}

function vis_bimg(){
document.getElementById("imgbig").style.visibility = "visible";
}

function no_vis_bimg(){
document.getElementById("imgbig").style.visibility = "hidden";
}