
/* 
Funzione: validaForm()
Parametri: 
	form	id/nome del form
	lang	codice iso della lingua
Descrizione: esegue la routine di validazione del form.
*/

function validaForm(form, lang) {

	var strErr_it = "Vi preghiamo di verificare i campi segnati in rosso";
	var strOk_it = "La vostra email è stata inviata con successo!";
	
	var strErr = eval("strErr_"+lang);
	
	var bolErr = false;
	
	if (document[form].nome.value ==  "" || document[form].nome.value.length < 3 || document[form].nome.value ==  n_str) {
		document[form].nome.value = n_str;
		document[form].nome.className = "form-error";
		bolErr = true;
	}
	if (document[form].luogo.value ==  "" || document[form].luogo.value.length < 3 || document[form].luogo.value ==  l_str) {
		document[form].luogo.value = l_str;
		document[form].luogo.className = "form-error";
		bolErr = true;
	}
	if (document[form].messaggio.value ==  "" || document[form].messaggio.value.length < 3 || document[form].messaggio.value ==  m_str) {
		document[form].messaggio.value = m_str;
		document[form].messaggio.className = "form-error";
		bolErr = true;
	}
	// se il campo 'email' è vuoto o invalido
	if (document[form].email.value ==  "" || document[form].email.value.indexOf("@") < 2 || document[form].email.value.length < 8 || document[form].email.value.lastIndexOf(".") <= document[form].email.value.indexOf("@") + 2 || document[form].email.value == e_str) {
		document[form].email.value = e_str;
		document[form].email.className = "form-error";
		bolErr = true;
	}

	// restituisce l'errore in un message-box
	if (bolErr) {
		alert(strErr);
		return false;
	}

	//alert(strOk_it);
	return true;
}


