
/* 
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_cz = "Zkontrolujte položky označené červeně";
	var strErr_en = "Some fields are empty or contain invalid information. Please check again.";
	
	var strErr = eval("strErr_"+lang);
	
	var bolErr = false;
	
	if (document[form].cname.value ==  "" || document[form].cname.value.length < 3) {
		document[form].cname.className = "form-error";
		bolErr = true;
	}
	if (document[form].csurname.value ==  "" || document[form].csurname.value.length < 3) {
		document[form].csurname.className = "form-error";
		bolErr = true;
	}
	if (document[form].cmessage.value ==  "" || document[form].cmessage.value.length < 3) {
		document[form].cmessage.className = "form-error";
		bolErr = true;
	}
	// se il campo 'email' è vuoto o invalido
	if (document[form].cemail.value ==  "" || document[form].cemail.value.indexOf("@") < 2 || document[form].cemail.value.length < 8 || document[form].cemail.value.lastIndexOf(".") <= document[form].cemail.value.indexOf("@") + 2) {
		document[form].cemail.className = "form-error";
		bolErr = true;
	}

	// restituisce l'errore in un message-box
	if (bolErr) {
		alert(strErr);
		return false;
	}

	return true;
}

