function contacar(txtarea) {
	var lunghezza = txtarea.value.length;
	var msg;

	if (lunghezza < 1001) return false;

	msg = "_______________________________________________\n\n"; 
	msg += "Attention your support request is too long.\n"; 
	msg += "You may use max 1000 characters,\n";
	msg += "while at the moment you are using " + lunghezza + " characters\n\n";
	msg += "Cancel something and try again.\n\n";
	msg += "_______________________________________________\n\n"; 


	return msg; 
	}

function campovuoto(campo) { //verifica se il campo è vuoto 
for(var i = 0; i < campo.length; i++) 
	{ var c = campo.charAt(i); 
	if ((c != ' ') && (c != '\n') && (c != '\t')) 
	return false; 
	} 
	return true; 
	} 

function verifica(f,note) { //Funzione di verifica del modulo, richiamata da onSubmit(). Controlla i campi di testo e le //textarea che non hanno come parametro optional per verificare che non siano vuote.
//Poi controlla il numero di caratteri della textarea. Ricordarsi di inserire onSubmit(). 

	var msg; 
	var campi_vuoti = "";
	var errors = "";
	var car = "";
	for(var i = 0; i < f.length; i++)
	{ 
	var e = f.elements[i]; 
	if (((e.type == "text") || (e.type == "textarea") || (e.type == "select")) && !e.optional) 
		{ 
		if ((e.value == null) || (e.value == "") || campovuoto(e.value)) 
			{ campi_vuoti += "\n " + e.name;
			 continue; 
			} 
		}
	}
	if (f.privacy.checked == "") 
		{ errors += "- You didn't selected privacy checkbox.\n";
		}
	if (contacar(note))
	{
	car += contacar(note);
	}
	if (!campi_vuoti && !errors && !car) return true; 
	msg = "_______________________________________________\n\n"; 
	msg += "The form has not been posted owing to the following errors.\n"; 
	msg += "Please correct the errors and send the form again.\n";
	msg += "_______________________________________________\n\n"; 
	if (campi_vuoti) 
	{ 
		msg +="- Following obligatory fields are empty:" + campi_vuoti + "\n";
		if (errors) msg += "\n";
	} 
	msg += errors;
	msg += car;
	alert(msg); 
	return false; 
	}
