/* 
function soloNumeri(nomeform,campo)
{
if (nomeform.elements[campo].value.charAt(0) == "-") 
 {
 var len =  nomeform.elements[campo].length;
 var testoNumerico = nomeform.elements[campo].value.substring(1);
 }
 else
 {
 var testoNumerico = nomeform.elements[campo].value;
 }

testoNumerico = testoNumerico.replace(/\,/g, '.');


if(isNaN(testoNumerico))
   {
   alert("Inserire solo valori numerici, grazie!");
   nomeform.elements[campo].value = "";
   nomeform[campo].focus();
   }

}


function trimString(str)
{
str= this != window? this : str;
return str.replace(/^\s+/g,'').replace(/\s+$/g,'');
}




function validateForm(form)
{
for (var e = 0;e < form.elements.length;e++)
    {
    var el = form.elements[e];
    if (el.type == 'text' || el.type == 'password' || el.type == 'file')
     {
     if (el.value == '' || trimString(el.value) == '' || el.value == '-')
        {    
        el.value = '';
        alert('Il form deve essere completato in ogni sua parte');
        el.focus();
        return false;
        }
    }
    else 
    if (el.type.indexOf('select') != -1)
       {
       if (el.selectedIndex == -1)
          { 
          alert('Seleziona un valore nel campo' + el.name);
        el.focus();
        return false;
          }    
       }
    else
      if (el.type == 'radio')
       {
       var group = form[el.name];
       var checked = false;
       if (!group.length)
        checked = el.checked;    
        else
        for ( var r=0; r < group.length; r++)
            if ((checked = group[r].checked))
              break;    
        if (!checked)
           {
           alert('Seleziona uno dei radio bottonii' + el.name);
             el.focus();    
           return false;
           }

       }
      if (el.type == 'checkbox')
       {
       var group = form[el.name];
       if (group.length)
        {
        var checked = false;
        for ( var r=0; r< group.length; r++)
            if ((checked = group[r].checked))
              break;    
        if (!checked)
           {
           alert('Seleziona uno dei radio bottoni' + el.name);
             el.focus();    
           return false;
           }
         }
       }        
    }

return true;

}

function inizializza() {
window.focus();
document.contatti.abi.focus();}

*/






function check_form(lang)
{
var email=document.lista.email;
var tipo=document.lista.tipo[0];
var acconsento=document.lista.acconsento.checked;

// Messaggi di errore
if (lang=='E')
{
	var t1 = "You must agree to the privacy therms and conditions!";			
	var t2 = "Insert a valid email value!"
}
else if (lang=='F')
{
	var t1 = "You must agree to the privacy therms and conditions!";			
	var t2 = "Insert a valid email value!"
}
else if (lang=='D')
{
	var t1 = "You must agree to the privacy therms and conditions!";			
	var t2 = "Insert a valid email value!"
}
else 
{
	var t1 = "Manca il consenso al trattamento dei dati personali";
	var t2 = "Indirizzo email non valido!"
}


// Rimetto tutto con la classe iniziale
email.className="";

   
   // Controllo la mail
	if (email.value == "") 
	{	email.className="frm_errore";
		alert (t2);
		email.focus();
		return false;
	}
	
	if (email.value.indexOf ('@',0) == -1 || email.value.indexOf ('.',0) == -1)
	{
		email.className="frm_errore";
		alert (t2);
		email.focus();
		return false;
	} 
	
	// Controllo che sia stato dato il consenso al trattamento dei dati personali
	if ((tipo.checked) && (acconsento == false) )
	{
		acconsento.className="errorepopon";
		alert(t1);
		return false;
	} 
	
	return true;
}




function winret() {
     location.href = "frm_contatti.php";
}
