// Controlla i dati inseriti nel form di 'contatto'
function checkMailto(form)
{
	var mess = form.mBODY.value;
	var nome = form.mNAME.value;
	var mail = form.mEMAIL.value;

	if (mess.length == 0) {
		alert('Manca il TESTO della mail !!!');
		form.mBODY.focus();
		return false;
	}

	if (nome.length == 0) {
		alert('Scrivere il NOME !!!');
		form.mNAME.focus();
		return false;
	}
	
	if (mail.length == 0) {
		alert('Scrivere l\'indirizzo E-MAIL !!!');
		form.mEMAIL.focus();
		return false;
	}

	if (mail.length > 0) {
		test = emailValidation(form.mEMAIL, 'Indirizzo e-mail NON valido !!!');
		if (test==false) return false;
	}

	return true;  // tutto OK
}


// Controlla la correttezza di un indirizzo di posta elettronica
function emailValidation(entered, alertbox)
{
	with (entered)
	{
		apos=value.indexOf("@"); 
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
		{
			if (alertbox) { alert(alertbox); }
  			select(); 
  			focus(); 
			return false; 
		}
		else
		{ 
			return true;
		}
	}
} 

