<!--

function verify(validation) 
{
	var name	= document.mail.fullname;
	var email	= document.mail.email;
	var subj	= document.mail.subject;
	var message = document.mail.message;

	var ok = 1;

	var errors = new Array();
	var lang	= document.mail.lng.value;
	var max_name_length = 50;
	var max_subj_length = 50;
	var max_msg_length = 3000;

switch (lang)
	{
		case 'en':
		default:
			errors['name-generic'] = "ERROR: Please enter your name";
			errors['name-both'] = "ERROR: Your must enter both first and last names";
			errors['name-spec'] = "ERROR: Full name cannot contain characters like @ > < & * - ` \ | /";
			errors['name-spac'] = "ERROR: Full name cannot begin with spaces";
			errors['name-len' ] = "ERROR: Full name cannot be more than " + max_name_length + " characters long";
			errors['name-sugg'] = "first-and-lastname";
			
			errors['email']		= "ERROR: Your email is invalid.";
			errors['email-sugg'] = "(write your email here)";

			errors['sub-spac'] = "ERROR: Subject cannot begin with spaces";
			errors['sub-spec'] = "ERROR: Subject cannot contain characters like @ > < & * - ` \ | /";
			errors['sub-len'] =  "ERROR: Subject cannot be more than " + max_subj_length + " characters long";
			errors['sub-sugg'] = "No subject";

			errors['msg-empt'] = "ERROR: Message cannot be empty";
			errors['msg-len'] = "ERROR: Message length cannot be more than " + max_msg_length + " characters";
		break;
		
		case 'it':
			errors['name-generic'] = "ERRORE: Vogliate specificare un nome";
			errors['name-both'] = "ERRORE: Vogliate scrivere entrambi nome e congnome";
			errors['name-spec'] = "ERRORE: Nome e cognome non possono contenere caratteri come @ > < & * - ` \ | /";
			errors['name-spac'] = "ERRORE: Nome e congnome non possono cominciare con uno o più spazi";
			errors['name-len' ] = "ERRORE: Nome e cognome non possono contenere più di " + max_name_length + " caratteri";
			errors['name-sugg'] = "nome-e-cognome";
			
			errors['email']		= "ERRORE: L'email fornito non è stato correttamente scritto.";
			errors['email-sugg'] = "(digita il tuo email qui)";

			errors['sub-spac'] = "ERRORE: Il soggetto non può cominciare con spazi";
			errors['sub-spec'] = "ERRORE: Il soggetto non può contenere caratteri come @ > < & * - ` \ | /";
			errors['sub-len'] = "ERRORE: Il soggetto non può superare i " + max_subj_length + " caratteri di lunghezza";
			errors['sub-sugg'] = "Senza soggetto";

			errors['msg-empt'] = "ERRORE: il messaggio non può essere vuoto";
			errors['msg-len'] = "ERRORE: la lunghezza del messaggio non può superare i " + max_msg_length + " caratteri";
		break;

		case 'fr':
			errors['name-generic'] = "ERREUR: Merci d'indiquer votre nom";
			errors['name-both'] = "ERREUR: Veuillez indiquer soit le nom soit le prénon";
			errors['name-spec'] = "ERREUR: Nom et prénon me peuvent pas contenir des caractères comme @ > < & * - ` \ | /";
			errors['name-spac'] = "ERREUR: Le nom ne peut pas commencer par des espaces";
			errors['name-len' ] = "ERREUR: Le nom et le prénom ne peuvent pas contenir plus de " + max_name_length + " caractères";
			errors['name-sugg'] = "nom-prénom";
			
			errors['email']		= "ERREUR: L'email n'est pas correct.";
			errors['email-sugg'] = "(écrire email ici)";

			errors['sub-spac'] = "ERREUR: Le sujet ne peut pas commencer par des espaces.";
			errors['sub-spec'] = "ERREUR: Le sujet ne peut pas contenir des caractères comme @ > < & * - ` \ | /";
			errors['sub-len'] =  "ERREUR: Le sujet ne peut pas contenir plus de " + max_subj_length + " caractères";
			errors['sub-sugg'] = "Sans sujet";

			errors['msg-empt'] = "ERREUR: le message ne peut pas être vide";
			errors['msg-len'] =  "ERREUR: la longueur du message ne peut pas supérer les " + max_msg_length + " caractères";
		break;

		case 'es':
			errors['name-generic'] = "ERROR: Favor de indicar su nombre";
			errors['name-both'] = "ERROR: Favor de indicar un nombre completo";
			errors['name-spec'] = "ERROR: El nombre no puede contener caracteres como @ > < & * - ` \ | /";
			errors['name-spac'] = "ERROR: El nombre no puede comenzar con espacios";
			errors['name-len' ] = "ERROR: El nombre no puede tener más de " + max_name_length + " caracteres";
			errors['name-sugg'] = "nombres-apellidos";
			
			errors['email']		= "ERROR: El email no está correctamente escrito";
			errors['email-sugg'] = "(escribir email aquí)";

			errors['sub-spac'] = "ERROR: El subjeto no puede empezar por espacios";
			errors['sub-spec'] = "ERROR: El subjeto no puede contener caracteres como @ > < & * - ` \ | /";
			errors['sub-len'] =  "ERROR: El subjeto no puede contener más de " + max_subj_length + " caracteres";
			errors['sub-sugg'] = "Sin sujeto";

			errors['msg-empt'] = "ERROR: el mensaje no puede ser vacío";
			errors['msg-len'] =  "ERROR: la longitud del mensaje no puede superar los " + max_msg_length + " caracteres";
		break;
	}

//TEST FULL NAME
	if(name.value.search(/[^\w \-àèìòùâêîôûäëïöüáéíóúñçæœÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÁÉÍÓÚÇÑÆŒ\.,\']/) != -1) {alert(errors['name-spec']);ok=0;}
	
	if(validation == 'strict')
	{
		if ( name.value.search(/^\s+/)!= -1) {alert(errors['name-spac']);ok=0;}		
		if(	name.value.length > 50) {alert(errors['name-len']);ok=0;}
		if(name.value.length == 0){
		alert(errors['name-generic']);ok=0;
	}
	}

	if(ok == 0)
	{
	name.select();
	return;
	}

	if (email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+/) == -1)
	{
		alert(errors['email']);
		email.value = errors['email-sugg'];
		email.select();
		return;
	}	
	
	// TEST SUBJECT
	if( subj.value.search(/^\s+/) != -1) {alert(errors['sub-spac']);ok=0;}
	if(subj.value.search(/[^\w \-àèìòùâêîôûäëïöüáéíóúñçæœÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÁÉÍÓÚÇÑÆŒ\.,\']/) != -1) {alert(errors['sub-spec']);ok=0;}
	if(	subj.value.length > 50) {alert(errors['sub-len']);ok=0;}
	if( subj.value == ""){subj.value=errors['sub-sugg']; ok=1;} //subj is an optional field
	if(ok == 0)
	{
			subj.select();
			return;
	}
	

	if (message.value == "")
	{
		alert(errors['msg-empt']);
		message.focus();
		return;
	}
	
	if (message.value.length > 3000)
	{
		alert(errors['msg-len']);
		message.select();
		return;
	}

	document.mail.submit();		
}

//-->
