// Validazione form Stefanesi nel Mondo.

function valida(){
	
	//alert("dentro");
	var nome = document.world.nome.value;
	var cognome = document.world.cognome.value;
	var nazione = document.world.nazione.value;
	var regione = document.world.regione.value;
	var provincia = document.world.provincia.value;
	var citta = document.world.citta.value;
	
	if(trim(nome)=="" || nome == "undefined"){
		alert("Il campo NOME e' obbligatorio.");
		document.world.nome.focus();
		return false;
	}
	
	else if(trim(cognome)=="" || cognome =="undefined"){
		alert("Il campo COGNOME e' obbligatorio.");
		document.world.cognome.focus();
		return false;
	}
		
	else if (trim(nazione)=="" || nazione == "undefined"){
		alert("Il campo NAZIONE e' obbligatorio.");
		document.world.nazione.focus();
		return false;
	}
		
	else if(trim(regione)=="" || regione =="undefined"){
		alert("Il campo REGIONE e' obbligatorio");
		document.world.regione.focus();
		return false;
	}
	
	else if(trim(provincia)=="" || provincia=="undefined"){
		alert("Il campo PROVINCIA e' obbligatorio.");
		document.world.provincia.focus();
		return false;
	}
	
	else if(trim(citta) == "" || citta=="undefined"){
		alert("Il campo CITTA' e' obbligatorio.");
		document.world.citta.focus();
		return false;
	}
	
	else{
		document.world.action="./e107_themes/Stefanesi/scripts/on_the_world/on_the_world_insert.php";
		document.world.submit();
	}
}
	
	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;
}
