

function fontSize(val){
	var size = 12 + (2 * val);
	obj = document.getElementById('body-id');
	obj.style.fontSize = size+'px';
}


function validaForm(theForm) {
	if ((theForm.consenso2 != undefined && theForm.consenso2.checked) || (theForm.consensochk != undefined && !theForm.consensochk.checked)) {
		alert("Impossibile procedere senza il consenso al trattamento dei suoi dati personali.");
		return false;
	}
	
	if (theForm.cognome.value.length < 2) {
		alert("Riempire il campo 'Cognome'.");
		theForm.cognome.focus();
		return false;
	}
	
	if (theForm.nome.value.length < 2) {
		alert("Riempire il campo 'Nome'.");
		theForm.nome.focus();
		return false;
	}
	
	if (theForm.professione.value == 0) {
		alert("Selezionare la professione.");
		theForm.professione.focus();
		return false;
	}
	
	if(!validaemail(theForm.email.value)) {
		alert("Inserire un indirizzo di e-mail valido.");
		theForm.email.focus();
		return false;
	}
	
	theForm.codice.value = 'richiesta';
	return true;
}


function validaemail(email) {
	if (email.indexOf('@')==-1) return false;
	
	var splitemail = email.split('@');
	
	if (splitemail[0].length == 0 || splitemail[0].length > 63) return false;
	
	if (splitemail[1].indexOf('.') == -1) return false;
	
	var validdomain = splitemail[1].split('.');
	
	if (validdomain[0].length == 0 || validdomain[0].length > 63) return false;
	
	return true;
}
