//************************************************************************************

function LunghezzaMinima(campo,nome,lun)
{ if (campo.value.length<lun) { alert("Attenzione: il campo '"+nome+"' e' troppo corto! (min."+lun+" caratteri)"); campo.focus(); return true; } return false; }

function Lunghezza(campo,nome,lun)
{ if (campo.value.length!=lun) { alert("Attenzione: il campo '"+nome+"' e' non corretto! Controlla la lunghezza "); campo.focus(); return true; } return false; }

function IsDifferent(campo1,campo2,nome1,nome2)
{ if (campo1.value!=campo2.value) { alert("Attenzione: i campi '"+nome1+"' e '"+nome2+"' devono essere uguali!"); campo1.focus(); return true; } return false; }

function TestoVuoto(campo,nome)
{ if (campo.value=="") { alert("Attenzione: il campo '"+nome+"' e' obbligatorio!");  return true; } return false; }

function StringaVuotaLista(campo,nome,flag)
{ var indice=campo.selectedIndex; if (campo.options[indice].text=="") { if (flag) { alert("Attenzione: il campo '"+nome+"' è obbligatorio!"); campo.focus(); } return true; } return false; }

function ErrorString(campo,nomeCampo)
{ var st=campo.value; for (var k=0;k<st.length;k++) if ((st.charAt(k)>="0") && (st.charAt(k)<="9")) { alert("Attenzione: Il campo "+nomeCampo+" non deve contenere caratteri numerici."); campo.focus(); return true; } return false; }  

function ErrorStringChar(campo,nomeCampo)
{ var st=campo.value.toUpperCase(); 
  for (var k=0;k<st.length;k++) 
    if (
      !(
	( (st.charAt(k)>="0") && (st.charAt(k)<="9") )||
        ( (st.charAt(k)>="A") && (st.charAt(k)<="Z") )
       )
        ) { alert("Attenzione: Il campo "+nomeCampo+" deve contenere caratteri alfanumerici."); campo.focus(); return true; } return false; }  

function ErrorNumber(campo,nomeCampo)
{ var st=campo.value; for (var k=0;k<st.length;k++) if ( ((st.charAt(k)<"0") || (st.charAt(k)>"9")) && (st.charAt(k)!="-") && (st.charAt(k)!="+") && (st.charAt(k)!=".")   ) { alert("Attenzione: Il campo "+nomeCampo+" deve contenere caratteri numerici."); campo.focus(); return true; } return false; }  


function ErrorEmail(campo)
{ var st=campo.value; 
  if (  (st.indexOf("@")==-1) ||
       	(st.indexOf(".")==-1) || 
		(st.length < 6) ||
		(st.indexOf("@.")!=-1) ||
       	(st.indexOf("@@")!=-1) 
     ) {  alert("Attenzione: indirizzo E- mail non valido."); campo.focus(); return true;} return false;
}

function ErrorTel(campo,nomeCampo)
{var st=campo.value;
 var car;
  for (var k=0;k<st.length;k++)
  { car=st.charAt(k);
    if (
        ((car<'0') || (car>'9'))
//        &&
//        ((car != '+') && (car !='/') && (car !='-'))
       )
     { alert("Attenzione: numero di "+nomeCampo+" non valido.");
       campo.focus();
       return true;
     }
  }
  return false;
}  

//************************************************************************************

function showLinkArea(elem){
    var ce = 0;
    if(elem.style.display == 'none' || elem.style.display == ''){
        elem.style.display='block';
    }
    else{
        elem.style.display='none';
    }
}				

//************************************************************************************

function CheckLoginForm() {
 if (document.getElementById('fl_user').value=="") { 
    alert('Inserisci Username e Password');
    return false;
 }
 if (document.getElementById('fl_password').value=="") { 
    alert('Inserisci Username e Password');
    return false;
 }
 return true;
}
 
