// JavaScript Document

function validate_form ( )
{
    
    if ( document.modulo.cognome.value == "" )
    {
        alert ( "Please, complete all the fields" );
        return (false);
    }
	
	if ( document.modulo.nome.value == "" )
    {
        alert ( "Please, complete all the fields" );
        return (false);
    }
	
	if ( document.modulo.nascita_giorno.selectedIndex == 0  )
    {
        alert ( "Please, complete all the fields" );
		return (false);
    }
	
	if ( document.modulo.nascita_mese.selectedIndex == 0  )
    {
        alert ( "Please, complete all the fields" );
		return (false);
    }
	
	if ( document.modulo.nascita_anno.selectedIndex == 0  )
    {
        alert ( "Please, complete all the fields" );
		return (false);
    }
	
	if ( document.modulo.indirizzo.value == "" )
    {
        alert ( "Please, complete all the fields" );
        return (false);
	}
	
	
	if ( document.modulo.cap.value == "" )
         {
                alert( "Please, complete all the fields" );
                return ( false );
         }
         var cifre= "0123456789.";
         var verifica= document.modulo.cap.value;
         var allValid = true;

         var allNum = "";
         for ( i = 0; i < verifica.length; i++ )
         {
                ch = verifica.charAt( i );
                for ( j = 0; j < cifre.length; j++ )
                 if ( ch == cifre.charAt( j ))
                        break;
                if ( j == cifre.length )
                {
                 allValid = false;
                 break;
                }
                allNum += ch;
         }
         if (!allValid)
         {
                alert( "Postcode must contain numbers" );
                return ( false );
         }
		 
		 
	
	if ( document.modulo.citta.value == "" )
    {
        alert ( "Please, complete all the fields" );
        return (false);
	}
	
	if ( document.modulo.nazione.selectedIndex == 0  )
    {
        alert ( "Please, complete all the fields" );
		return (false);
    }
	
	if ( document.modulo.telefono.value == "" )
         {
                alert( "Please, complete all the fields" );
                return ( false );
         }
         var cifre= "0123456789./- ";
         var verifica= document.modulo.telefono.value;
         var allValid = true;

         var allNum = "";
         for ( i = 0; i < verifica.length; i++ )
         {
                ch = verifica.charAt( i );
                for ( j = 0; j < cifre.length; j++ )
                 if ( ch == cifre.charAt( j ))
                        break;
                if ( j == cifre.length )
                {
                 allValid = false;
                 break;
                }
                allNum += ch;
         }
         if (!allValid)
         {
                alert( "Telephone must contain numbers" );
                return ( false );
         }
		 
	
	if (document.modulo.email.value.indexOf("@")==-1)
    {
    	alert("Please, insert a valid email address");
    	return (false);
    }
	
	if ( document.modulo.livello_educazione.selectedIndex == 0  )
    {
        alert ( "Please, complete all the fields" );
		return (false);
    }
	
	if ( document.modulo.conoscenze.value == ""  )
    {
        alert ( "Please, complete all the fields" );
        return (false);
    }
	
		if ( document.modulo.esperienze_lavorative.value == ""  )
    {
        alert ( "Please, complete all the fields" );
        return (false);
    }
	

var radio_choice = false;
for (counter = 0; counter < document.modulo.inglese.length; counter++)
{
if (document.modulo.inglese[counter].checked)
radio_choice = true; 
}
if (!radio_choice)
{
alert("Please, complete all the fields");
return (false);
}

var radio_choice2 = false;
for (counter = 0; counter < document.modulo.patente.length; counter++)
{
if (document.modulo.patente[counter].checked)
radio_choice2 = true; 
}
if (!radio_choice2)
{
alert("Please, complete all the fields");
return (false);
}


if ( document.modulo.privacy.checked == false )
    {
        alert ( "Please, accept the privacy condition" );
        return (false);
    }


}
