function ControllaForm(form,campi,labels,controls,language) {
	var errore = 0;
	for (i = 0; i < campi.length; i++) {
		var campo = eval("document."+form+"."+campi[i]);
		if(controls[i].substr(0,4) == 'text'){
			var nchars = Number(controls[i].substr(4));
			if (nchars == 0){
				var nchars = 5;
			}
			var msgalert = [	"Il campo '"+labels[i]+"' non è stato riempito correttamente.\nDevi scrivere almeno "+ nchars +" caratteri.",
								"The field '"+labels[i]+"' hasn't been correctly filled.\nYou have to write "+ nchars +" characters at least.",
								"El hueco '"+labels[i]+"' no ha sido llenado correctamente.\nTienes que escribir al menos "+ nchars +" letras."];
			if (campo.value.replace(/\s/gi,"").replace(/\n/gi,"").length < nchars) {
				alert (msgalert[language]);
				campo.focus();
				var errore = 1;
				return false;
			}
		} else if(controls[i] == 'select'){
			var msgalert = [	"Devi selezionare un'opzione nel campo '"+labels[i]+"'.",
								"You have to select one option in the field '"+labels[i]+"'.",
								"Tienes que seleccionar una opción en el hueco '"+labels[i]+"'."];
			if (campo.selectedIndex == 0) {
				alert (msgalert[language]);
				campo.focus();
				var errore = 1;
				return false;
			}
		} else if(controls[i] == 'email'){
			var EmailRegExp = /^([a-zA-Z0-9])+([a-zA-Z0-9_\.\-])+([a-zA-Z0-9])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
			var startsub = campo.value.indexOf("@") + 1;
			var lengthsub = campo.value.lastIndexOf(".") - startsub;
			var nomeserver = campo.value.substr(startsub,lengthsub);
			var ServerRegExp = /^([a-zA-Z0-9])+([a-zA-Z0-9\-])+([a-zA-Z0-9])+$/;
			var msgalert = [	"Il campo '"+labels[i]+"' non è stato riempito correttamente.\nDevi inserire un indirizzo valido.",
								"The field '"+labels[i]+"' hasn't been correctly filled.\nYou have to write a valid email-address.",
								"El hueco '"+labels[i]+"' no ha sido llenado correctamente.\nTienes que escribir una dirección de e-mail valida."];
			if (!EmailRegExp.test(campo.value) || (nomeserver.indexOf("-") != -1 && !ServerRegExp.test(nomeserver)) ) {
				alert (msgalert[language]);
				campo.focus();
				var errore = 1;
				return false;
			}
		} else if(controls[i].substr(0,8) == 'nickpass'){
			var nchars = Number(controls[i].substr(8));
			if (nchars == 0){
				var nchars = 5;
			}
			var NickPassRegExp = /^([a-zA-Z0-9])+([a-zA-Z0-9_\.\-\*\^\|\+])+([a-zA-Z0-9])+$/;
			var msgalert = [	"Il campo '"+labels[i]+"' non è stato riempito correttamente.\nEsso può contenere solo lettere dell'alfabeto inglese (dalla A alla Z - maiuscole e minuscole) o numeri; all'interno della parola (cioè né al principio né alla fine) sono ammessi i seguenti simboli: . - * + _ ^ | .\nNon sono accettati caratteri accentati (à,è,ì,ò,ù,ñ,...) e nemmeno caratteri vuoti (cioè spazi). Infine, devi utilizzare almeno " + nchars + " caratteri.",
								"The field '"+labels[i]+"' hasn't been correctly filled.\nIt may contain only characters of the english alphabet (from A to Z - capital or lower case letters) or numbers; inside the word (that is, neither at the beginning nor at the end) these symbols are admitted: . - * + _ ^ | .\nAccented characters (à,è,ì,ò,ù,ñ,...) and empty characters (that is, spaces) are not accepted. Finally, you have to write "+ nchars +" characters at least.",
								"El hueco '"+labels[i]+"' no ha sido llenado correctamente.\nPuede contener sólo letras del alfabeto inglés (desde A a Z - mayúsculas o minúsculas) o números; en la palabra (es decir, ni al principio ni al final) son admitidos estos símbolos: - * + _ ^ | .\nLas letras acentuadas (à,è,ì,ò,ù,ñ,...) o vacías (es decir, espacios) no son aceptadas. Por fin, tienes que escribir al menos "+ nchars +" letras."];
			if (!NickPassRegExp.test(campo.value) || campo.value.length < nchars) {
				alert (msgalert[language]);
				campo.focus();
				var errore = 1;
				return false;
			}
		} else if(controls[i] == ''){
			continue;
		}
	
	}
	if(errore == 0){
		for (i = 0; i < campi.length; i++) {
			var campo = eval("document."+form+"."+campi[i]);
			campo.value = campo.value.replace(/'/gi,"&prime;").replace(/"/gi,"&Prime;");
		}
	}
}

function AddTextCode(form,campo,code){
	var formx = eval("document."+form);
	var campox = eval("document."+form +"."+campo);
	campox.value = campox.value + code;
}

function AddUrlCode(form,campo,tipo,prefisso){
	var formx = eval("document."+form);
	var campox = eval("document."+form +"."+campo);
	var campoUrl = eval("document."+form +"."+prefisso+"Url");
	var campoTxt = eval("document."+form +"."+prefisso+"Txt");
	if(campoTxt.value == ""){
		alert("Inserisci un testo per questo link");
		campoTxt.focus();
	} else {
		if(tipo == 1){
			//alert(campoUrl.selectedIndex);
			var code = "[url=" + campoUrl.value + "]" + campoTxt.value + "[/url] ";
		} else {
			var code = "[exturl=" + campoUrl.value + "]" + campoTxt.value + "[/exturl] ";
		}
		campox.value = campox.value + code;
	}
}

function AddImgCode(form,campo,tipo,img){
	var formx = eval("document."+form);
	var campox = eval("document."+form +"."+campo);
	var campoImg = eval("document."+form +"."+img);
	if(tipo == 1){
		//alert(campoUrl.selectedIndex);
		var code = "[img]" + campoImg.value + "[/img] ";
		campox.value = campox.value + code;
	} else {
		//var code = "[exturl=" + campoUrl.value + "]" + campoTxt.value + "[/exturl] ";
		alert(campoImg.value);
		//window.open("../uploadimg/" + campoImg.value,'','width=200,height=200 ,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=5,top=5');"
	}
}