function BOB_checkForm(lingua, formo) {
	
	var i, sName, sValue, bemail;	
	if (formo == null) {formo = "bob_formo"}

	for (i=0;i < document.forms[formo].length; i++) {
		sName = document.forms[formo].elements[i].name;

		if (sName == "_EMAIL_NAZIONALE") {bemail = ((document.forms[formo].elements[i].value).indexOf("@")>-1)}
		if (sName == "_EMAIL_TERRITORIALE" && ((document.forms[formo].elements[i].value).indexOf("@")==-1) && !bemail) {
			if (lingua == "ita") alert ("Devi inserire almeno un indirizzo di email valido!")
			else if (lingua == "eng") alert ("Please insert a valid e-mail address!")
			else alert ("...");
			document.forms[formo].elements["_EMAIL_NAZIONALE"].focus();
			break
		}
		
		if (sName == "PRESENTAZIONE_ENTE") {
			sValue = document.forms[formo].elements[i].value
			if (sValue.length > 600) {
				if (lingua == "ita") alert ("Il campo [ PRESENTAZIONE ENTE ] è troppo lungo (Max 600 caratteri compresa la punteggiatura)!")
				else if (lingua == "eng") alert ("All fields are required!")
				else alert ("...");
				document.forms[formo].elements[i].focus();
				break
			}
		}
		
		if (sName == "_ESPOSIZIONE") {
			sValue = document.forms[formo].elements[i].value
			if (sValue.length > 300) {
				if (lingua == "ita") alert ("Il campo [ PRODOTTI O PROGETTI ESPOSTI ] è troppo lungo (Max 300 caratteri compresa la punteggiatura)!")
				else if (lingua == "eng") alert ("All fields are required!")
				else alert ("...");
				document.forms[formo].elements[i].focus();
				break
			}
		}
		
		if (sName.charAt(0) != "_") {
			//alert("sName: " + sName)
			
			if (document.forms[formo].elements[i].value == "") {			
				if (lingua == "ita") alert ("Il campo  [ " + sName + " ]  è obbligatorio!")
				else if (lingua == "eng") alert ("All fields are required!")
				else alert ("...");
				document.forms[formo].elements[i].focus();
				break
			} else {
				if (((sName == "email") || (sName == "email_mittente") || (sName == "email_destinatario"))
				 && ((document.forms[formo].elements[i].value).indexOf("@")==-1)) {
					if (lingua == "ita") alert ("L'email inserita non è valida!")
					else if (lingua == "eng") alert ("Please insert a valid e-mail address!")
					else alert ("...");
					document.forms[formo].elements[i].focus();
					break
				}
			}
		}

	}
	
	if (i == document.forms[formo].length) {
		return true
	} else {
		return false
	}
}

function BOB_submit(lingua, formo) {
	if (formo == null) {formo = "bob_formo"}
	if (BOB_checkForm(lingua, formo)) {
		document.forms[formo].submit();
	}
}

function BOB_saveformo(tabella, lingua) {
	testo = "?";
	if (lingua == "ita") {testo = "Sei sicuro di voler aggiornare questo/a " + tabella + "?"}

	if (confirm(testo)) {
		if (BOB_checkForm(lingua)) {
			document.bob_formo.submit()
		}
	}
}

function BOB_delart(tabella, lingua) {
	testo1 = "?";
	testo2 = "!";
	if (lingua == "ita") {
		testo1 = "Sei sicuro di voler eliminare questo/a " + tabella + "?"
		testo2 = "Nessun" + tabella + " selezionata!"
	}

	if (confirm(testo1)) {
		if (document.bob_formo._ID.value == "") {
			alert (testo2);
		} else {
			document.bob_formo._Cosa.value = "Del";
			document.bob_formo.submit()
		}
	}
}

function BOB_openBrWindow(theURL,winName,features) {
  mywin = window.open(theURL,winName,features);
  mywin.focus();
}
