

var NS4 = (navigator.appName.indexOf("Netscape")>=0 && parseFloat(navigator.appVersion) >= 4 && parseFloat(navigator.appVersion) < 5)? true : false;
var IE4 = (document.all)? true : false;
var NS6 = (parseFloat(navigator.appVersion) >= 5 && navigator.appName.indexOf("Netscape")>=0 )? true: false;

var IE = IE4
var NS = NS4 || NS6



function OpenPopUpWindow(what,popWidth,popHeight) {
	window.open(what,'','scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width='+ popWidth + ',height=' + popHeight);
}



//----------------------- menu ---------------------------

function finestra(x, y, w, h, url, nome, xscrollbars, xresize, xstatus, xtoolbar, xmenubar, xlocation, xdependent) {
	if (w!=null) {
		if (x==null) x=(screen.width - w)/2
	}
	if (h!=null) {
		if (y==null) y=(screen.availHeight - h)/2
	}
  
  
  if (xscrollbars==null) xscrollbars = 'no';
	if (xresize==null) xresizable = 'no';
	if (xstatus==null) xstatus = 'no';
	if (xtoolbar==null) xtoolbar= 'no';
	if (xmenubar==null) xmenubar = 'no';
	if (xlocation==null) xlocation = 'no';
  if (xdependent==null) xdependent = 'no';
  
  
  formattazione = 'scrollbars=' + xscrollbars +
						    ', resizable=' + xresize +
                ', status=' + xstatus +
							  ', toolbar=' + xtoolbar +
						    ', menubar=' + xmenubar +
						    ', location=' + xlocation +
						    ', dependent=' + xdependent +
  		 (w!=null?', width=' + w:'') +
       (h!=null?', height=' + h:'') +
       (x!=null?', left=' + x + ', screenX=' + x:'') +
  	   (y!=null?', top=' + y + ', screenY=' + y:'') 
  //alert(formattazione)
	return window.open(url,nome,formattazione);
														
	/*
	features Value Description 
	---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	alwaysLowered  	When set to yes, this creates a window that always floats below other windows. 
	alwaysRaised  	When set to yes, this creates a window that always floats above other windows. 
	dependent  			When set to yes, the new window is created as a child (closes when the parent window closes and does not appear on the task bar on Windows platforms) of the current window. 
	directories 		When set to yes, the new browser window has the standard directory buttons. 
	height 					This sets the height of the new window in pixels. 
	hotkeys  				When set to no, this disables the use of hotkeys (except security and quit hotkeys) in a window without a menubar. 
	innerHeight  		This sets the inner height of the window in pixels. 
	innerWidth  		This sets the inner width of the window in pixels. 
	location 				When set to yes, this creates the standard Location entry feild in the new browser window. 
	menubar 				When set to yes, this creates a new browser window with the standard menu bar (File, Edit, View, etc.). 
	outerHeight  		This sets the outer height of the new window in pixels. 
	outerWidth  		This sets the outer width of the new window in pixels. 
	resizable 			When set to yes this allows the resizing of the new window by the user. 
	screenX  				This allows a new window to be created at a specified number of pixels from the left side of the screen. 
	screenY  				This allows a new window to be created at a specified number of pixels from the top of the screen. 
	scrollbars 			When set to yes the new window is created with the standard horizontal and vertical scrollbars, where needed 
	status 					When set to yes, the new window will have the standard browser status bar at the bottom. 
	titlebar  			When set to yes the new browser window will have the standard title bar. 
	toolbar				  When set to yes the new window will have the standard browser tool bar (Back, Forward, etc.). 
	width 					This sets the width of the new window in pixels. 
	z-lock  				When set to yes this prevents the new window from rising above other windows when it is made active (given focus). 
	---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------														
	preso da http://www.devguru.com/technologies/ecmascript/quickref/win_open.html	
	*/	
}

var myWindow_login = null

// Richiama la maschera di login
function login(url, richiama, applicazione){
	//var url='/intranet/login.jspf'
	if (richiama!=null) url = url + '?richiama=' + richiama
  if (applicazione!=null) {
		if (richiama!=null) { url = url + '&' }  else { url = url + '?'}
		url = url + 'applicazione=' + applicazione
	}
	
  //alert(url)  
	myWindow_login = finestra(null,null,320,222,url,'login','no','no','no','no','no','no')
}

// Richiama la pagina di anteprima di stampa
function stampa(url, modulo, indice) {
	//var url='/intranet/anteprima.jsp
	// Il valore 'indice' e' obbligatorio per indicizzare il vettore di dati 
	if (indice==null) alert ("Valorizzare il campo 'indice' della funzione stampa")
	
	url = url + '?modulo=' + modulo + "&indice=" + indice
	myWindow=finestra(10,10,640,690,url,'anteprima','no','no','no','no','no','no')
}

// Richiama la area interna
function inside(url, nuova) {
	if (nuova==null) nuova=true
	if (nuova) {
		// Apre una nuova finestra dalle dimensioni e con le caratteristiche impostate
		myWindow = finestra(null,null,800,600,url,'mastermind','no','no','no','no','no','no')
	} else { // oppure
		// L'applicazione viene eseguita nella pagina chiamante
		if (window.opener.location!=null) {
			window.opener.location.href = url		
		} else {
			window.location.href = url		
		}
	}
}

// Collegamenti (---)
function collegamento(nome, menu, abilitato) {
	if (abilitato) { 
		document.write("<a href=\"javascript:local_esegui('"+nome+"')\" class=\"menuNormale\"><b>" + menu + "</b></a>")
	} else { 
		// colore Disattivato non clickabile
		document.write("<font class=\"menuDisattivato\"><b>" + menu + "</b>&nbsp;</font>") 			
	}
}

// Voce di menu (---)
function topbar(nome, menu, w, h, abilitato, tooltip) {
	if (abilitato==null) abilitato=true
	if (tooltip==null) tooltip=""
	
	document.write("<td align=\"center\" valign=\"middle\" nowrap class=\"vuoto\">")
	document.write("  <table width=\""+w+"\" height=\""+h+"\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"left\" class=\"topbarNormal\">")
	document.write("    <tr>")
	//document.write("			<td align=\"right\" valign=\"middle\" nowrap class=\"vuoto\">")
	//document.write("        &nbsp;")
	//document.write("			</td>")	
	document.write("			<td align=\"center\" valign=\"middle\" nowrap class=\"vuoto\">")
	if (abilitato) { 
		document.write("<a name=\""+nome+"\" id=\""+nome+"\" title=\""+tooltip+"\" href=\"javascript:local_esegui('"+nome+"')\" class=\"topbarNormal\">" + menu + "</a>")
	} else { 
		// colore Disattivato non clickabile
		document.write("<font class=\"topbarDisable\">" + menu + "</font>") 			
	}
	document.write("			</td>")	
	//document.write("			<td align=\"left\" valign=\"middle\" nowrap class=\"vuoto\">")
	//document.write("        &nbsp;")
	//document.write("			</td>")
	document.write("    </tr>")
	document.write("  </table>")
	document.write("</td>")
}

// COOKIES -----------------------------------------------

function scriviCookie(quale, valore) {
	nextyear = new Date()
	nextyear.setFullYear(nextyear.getFullYear() + 1)
	
	window.top.document.cookie = quale + '=' + valore +
	 						    '; name = restarting' +
	 						    '; expires = ' + nextyear.toGMTString()
									
	//alert(window.top.document.cookie)
}
/*
function scriviCookie(name,value,expires,path,domain,secure) {
    window.top.document.cookie = name + "=" +escape(value) +
        ( (expires!=null) ? ";expires=" + expires.toGMTString() : "") +
        ( (path!=null) ? ";path=" + path : "") + 
        ( (domain!=null) ? ";domain=" + domain : "") +
        ( (secure!=null) ? ";secure" : "");
				
		alert(window.top.document.cookie)
}*/

function leggiCookie(quale) {  
	var allcookies = window.top.document.cookie 
	// Normalizzazione della stringa
	if (allcookies.length>0) {
		if (allcookies.substring(allcookies.length)!=";") {
		  allcookies+=";"
		}
	}
	//alert(allcookies)		
		
	var start = 0
	var pos = -1
	var continua = true
	do {
		pos = allcookies.indexOf(quale, start)	
		//alert("Variabile cercata: '" + quale + "', start = " + start + ", pos = " + pos)	
			
		if (pos < 0) continua = false
		
		if (pos >= 0) {
		  var uguale=allcookies.indexOf("=", pos)
			var confronto=allcookies.substring(pos, uguale)			
			//alert("Variabile cercata: '" + quale + "', letta: '" + confronto + "'")	
			
			if (confronto==quale) {
				// E' proprio la variabile che cercavo
				//alert("A posizione " + pos + " ho la variabile '" + quale + "' che cercavo")	
				var inizio = pos + (quale.length+1)
				var fine = allcookies.indexOf(';', inizio)
								
				//alert("Da " + inizio + " a " + fine + ", "+ quale + " = '" + allcookies.substring(inizio, fine)+ "'")
				return allcookies.substring(inizio, fine)	
			} 
			
			start = pos+1
		}
	} while (continua)
	
	return "null"
}		

// -----------------------------------------------------

// Bottoni (FORM INPUT BUTTON)
function bottone(nome, testo, w, h, attributi, indice, tooltip) {
	if (w==null) w=80
	if (h==null) h=22
	if (attributi==null) attributi="";	
	if (indice==null) indice=""; else indice=",'"+indice+"'"
	
	document.write("<input type=\"button\" id=\""+nome+"\" name=\""+nome+"\" "+(tooltip!=null?"title=\""+tooltip+"\"":"")+"value=\""+testo+"\" "+attributi+" width=\""+w+"\" height=\""+h+"\" style=\"width: "+w+"px; height: "+h+"px;\" class=\"bottoneNormale\" onClick=\"javascript:local_esegui('"+nome+"'"+indice+")\">")			
}


// Bottoni (FORM INPUT BUTTON)
function bottoncino(nome, testo, w, h, attributi, indice, tooltip) {
	if (w==null) w=80
	if (h==null) h=22
	if (attributi==null) attributi="";	
	if (indice==null) indice=""; else indice=",'"+indice+"'"
	
	document.write("<input type=\"button\" id=\""+nome+"\" name=\""+nome+"\" "+(tooltip!=null?"title=\""+tooltip+"\"":"")+"value=\""+testo+"\" "+attributi+" width=\""+w+"\" height=\""+h+"\" style=\"width: "+w+"px; height: "+h+"px;\" class=\"bottoncinoNormale\" onClick=\"javascript:local_esegui('"+nome+"'"+indice+")\">")			
}


// Tasto nascosto per gestire il bottone con il dafault focus
function hiddensubmit() {
	w=0
	h=0
	attributi="";
	
  // Ricordarsi di valorizzare l'evento OnSubmit nel TAG FORM, altrimenti non funziona  
	if (IE) {		
  	// EXPLORER
		document.write("<input type=\"submit\" id=\"hiddensubmit\" name=\"hiddensubmit\" value=\"\" "+attributi+" width=\""+w+"\" height=\""+h+"\" style=\"width: "+w+"px; height: "+h+"px;\" class=\"vuoto\" >")			
  } else {
    // Mozilla
    document.write("<div style='visibility: hidden;'>")
    document.write("<input type=\"submit\" id=\"hiddensubmit\" name=\"hiddensubmit\" value=\"\" "+attributi+" width=\""+w+"\" height=\""+h+"\" style=\"width: "+w+"px; height: "+h+"px;\" class=\"vuoto\" >")			
    document.write("</div>")      
	}
}

var tree_nLayer = (document.layers) ? 1:0 

// Nasconde un D<link rel="STYLESHEET" type="text/css" href="../style/intranet.css">IV
function nascondi(obj) {
	try {
    // Sostituito per compatibilità con Mozilla
    //var css = (tree_nLayer) ? eval("document."+obj):eval("document.all."+obj+".style")	
		var css = (tree_nLayer) ? eval("document."+obj):eval("document.getElementById('"+obj+"').style")	
    
    css.visibility="hidden"
	} catch (e) {
		// l'oggetto indicato non esiste    
    //alert (obj +": \n" +e)
		return
	}
}

// Visualizza un DIV
function visualizza(obj) {	
	try {
    // Sostituito per compatibilità con Mozilla
    //var css = (tree_nLayer) ? eval("document."+obj):eval("document.all."+obj+".style") 
		var css = (tree_nLayer) ? eval("document."+obj):eval("document.getElementById('"+obj+"').style")	
		css.visibility="visible"
	} catch (e) {
		// l'oggetto indicato non esiste
		return
	}
}

// ----------------------------------------------
// Nasconde un DIV e la sua LABEL

var errore_parametri = new Array();
var conta_errore=0

// Gestione parametri errati comunicati dalla SERVLET
function estraiParametroErrato (name, etichetta) {		
	//l=conta_errore
	conta_errore=0
	for (i=0; i<errore_parametri.length; i++) {
		if (errore_parametri[conta_errore] != null) {
			if (errore_parametri[conta_errore] == name) {
				errore_parametri[conta_errore] = etichetta
				return true
			}
		}
		conta_errore++
	}	
	return false
}
// ------------------------------------------
// Variabili di appoggio per la gestione della MEMORIA per i campi SELECT e TEXT-SELECT
var last_object_abilitato = true
var last_object_memoria = null
var last_object_name = ""
var last_object_value = null

function scriviIntoMemoria(campoSelect, memoria, option_change) {
	if (memoria) {
		scriviCookie('memoria.'+campoSelect.name, (campoSelect.value!=''?campoSelect.value:'null'))
	}
	if (option_change!=null) eval(option_change)
}

function pulisciMemoria(campo) {
	scriviCookie('memoria.'+campo, 'null')	
}

// Filler a SINISTRA
function fillerSinistra(s, sc, n) {
	if (s!=null) {
		for (i=s.length;i<n;i++) s = sc + s
	  return s
	} else {
		return ''
	}
}

// ...gestione campi! - funzione privata
function campoINPUT (tipo, etichetta, name, size, maxlength, value, controllo, abilitato, memoria, decimali, prefisso, suffisso) {
	// valori di default
	if (decimali==null) decimali=0	
	if (abilitato==null) abilitato=true	
	if (memoria==null) memoria=false
	terzocampo=(controllo.indexOf("ppp")>0)
						
	// variabili valorizzate per la chiusura.....
	last_object_abilitato = abilitato
	last_object_memoria = memoria
	last_object_value = value
	last_object_name = name
	
	if (value==null || value=='null') value=""			
	
	// Gestione campo text o password 	
	if (etichetta!=null && etichetta!="") {
		//...nel caso in cui l'etichetta non e' presente
		if (estraiParametroErrato(name, etichetta)) {
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoErrore\">")			
	 	} else {	
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoEtichetta\">")		
		}	
		if (abilitato) {
			document.write("<div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;"+etichetta+"&nbsp;</div>")
		} else {
  		document.write("<div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;"+etichetta+"&nbsp;</div>")  	    
			//document.write("  <div id=\"label_"+name+"\">&nbsp;<b>"+etichetta+"</b>&nbsp;</div>")  	    
		}
		document.write("</td>")
	}
	
	if (abilitato) {
		document.write("<td height=\"23\" align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
	} else {
		// ...il campo disabilitato e' piu' basso del campo abilitato 
		document.write("<td height=\"18\" align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
	}
	
	document.write("<div id=\"field_"+name+"\">")				
	if (terzocampo) {
		document.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"vuoto\">")
		document.write("  <tr>")
		// eventuale PREFISSO
		if (controllo=='text.ppp.prefisso') {
			document.write("<td valign=\"middle\" align=\"left\" class=\"formtextfield\" >")
			document.write(prefisso+"&nbsp;")
			document.write("</td>")
		}
		document.write("<td height=\"18\" align=\"left\" valign=\"middle\" nowrap class=\"formtextfield\">")
	}
	if (abilitato) {	
		// DISABLED = FALSE
		switch (controllo) {
			case 'hidden': 
				document.write("<input type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" value=\""+value+"\" class=\"vuoto\">")
				break
			case 'text': case 'text.ppp.prefisso': case 'text.ppp.suffisso': case 'password':
			  document.write("<input style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" "+(maxlength>0?"maxlength=\""+maxlength+"\"":"")+" value=\""+value+"\" class=\"formtextfield\" onblur=\"uscita=strigaOk_DBinsert(value);if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else focus();\">&nbsp;")
				break;
	 		case 'email': 
			  document.write("<input style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" "+(maxlength>0?"maxlength=\""+maxlength+"\"":"")+" value=\""+value+"\" class=\"formtextfield\" onblur=\"uscita=strigaOk_DBinsert(value);if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else focus();\">&nbsp;")
				break;
			case 'text.upper': 
			  document.write("<input style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" "+(maxlength>0?"maxlength=\""+maxlength+"\"":"")+" value=\""+value+"\" class=\"formtextfield\" onblur=\"value=value.toUpperCase();uscita=strigaOk_DBinsert(value);if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else focus();\">&nbsp;")
				break;
			case 'file': 
				document.write("<input style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" "+(maxlength>0?"maxlength=\""+maxlength+"\"":"")+" class=\"formtextfield\" >&nbsp;")
				break	
			case 'number':
				document.write("<input style=\"text-align:'right'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" maxlength=\""+maxlength+"\" value=\""+value+"\" class=\"formtextfield\" onblur=\"uscita=isNumero("+name+","+decimali+");if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else {this.value='';return focus();}\">&nbsp;")
				break
	 		case 'number.filler':
				document.write("<input style=\"text-align:'right'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" maxlength=\""+maxlength+"\" value=\""+value+"\" class=\"formtextfield\" onblur=\"uscita=isNumero("+name+","+decimali+");if(uscita){ if(this.value!='') {this.value=fillerSinistra(this.value,'0',"+maxlength+")} scriviIntoMemoria("+name+","+memoria+",null)} else {this.value='';focus();}\">&nbsp;")
				break
			case 'CAP': 
				document.write("<input style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" maxlength=\""+maxlength+"\" value=\""+value+"\" class=\"formtextfield\" onchange=\"uscita=verificaCAP(value);if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else return false;\">&nbsp;")
				break	
			case 'country': 
				document.write("<input style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" maxlength=\""+maxlength+"\" value=\""+value+"\" class=\"formtextfield\" onblur=\"if (!strigaOk_DBinsert(this.value)) this.focus(); else { app=new String(this.value); this.value=app.toUpperCase(); }\">&nbsp;")
				break	
			case 'partitaIVA': 
				document.write("<input style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" maxlength=\""+maxlength+"\" value=\""+value+"\" class=\"formtextfield\" onblur=\"uscita=verificaPartitaIVA(value);if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else focus();\">&nbsp;")
				break
			case 'telephon': 			
				document.write("<input style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" maxlength=\""+maxlength+"\" value=\""+value+"\" class=\"formtextfield\" onblur=\"uscita=verificaTelefono(value);if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else focus();\">&nbsp;")
				break	
			case 'date': 
				document.write("<input title=\"Formato gg/mm/aaaa\" style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" maxlength=\""+maxlength+"\" value=\""+value+"\" class=\"formtextfield\" onblur=\"uscita=formattaData("+name+",'/');if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else focus();\">&nbsp;")
				break		
			case 'year': 
				document.write("<input title=\"Formato aaaa\" style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" maxlength=\""+maxlength+"\" value=\""+value+"\" class=\"formtextfield\" onblur=\"uscita=formattaAnno("+name+");if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else focus();\">&nbsp;")
				break	
			case 'month_year': 
				document.write("<input title=\"Formato mm/aaaa\" style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" maxlength=\""+maxlength+"\" value=\""+value+"\" class=\"formtextfield\" onblur=\"uscita=formattaMeseAnno("+name+",'/');if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else focus();\">&nbsp;")
				break		
 			case 'hour': 
				document.write("<input title=\"Formato hh:mi:ss\" style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" maxlength=\""+maxlength+"\" value=\""+value+"\" class=\"formtextfield\" onblur=\"uscita=formattaOra("+name+",':');if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else focus();\">&nbsp;")
				break	
 			case 'hour_minute': 
				document.write("<input title=\"Formato hh:mm\" style=\"text-align:'left'; width:"+size+"px;\" type=\""+tipo+"\" id=\""+name+"\" name=\""+name+"\" maxlength=\""+maxlength+"\" value=\""+value+"\" class=\"formtextfield\" onblur=\"uscita=formattaOreMinuti("+name+",':');if(uscita)scriviIntoMemoria("+name+","+memoria+",null);else focus();\">&nbsp;")
				break	
		}	
	} else {
		// DISABLED = TRUE		
		if (controllo=='progressivo') { 
			if (value!=null && value!="-1") {	
				// ...valorizzato
				document.write("  <font class=\"formtextfield\"><b>" + value + "</b></font>&nbsp;")
			} else {
				// non valorizzato
				document.write("  <font class=\"formtextfield\"><b>???</b></font>&nbsp;")				
			}
		} else if (controllo=='password') { 
			if (value!=null && value!="") {	
				// ...valorizzato
				document.write("  <font class=\"formtextfield\"><b>********</b></font>&nbsp;")
			} else {
				// non valorizzato
				document.write("  <font class=\"formtextfield\">&nbsp;</font>&nbsp;")				
			}
		} else {
			document.write("  <font class=\"formtextfield\"><b>" + value + "</b></font>&nbsp;")			
		}
		//...aggiungo un campo nascosto perche' il campo DISABLED non viene passato come parametro alla servlet
		document.write("  <input type=\"hidden\" id=\""+name+"\" name=\""+name+"\" value=\""+value+"\" class=\"vuoto\">")
		
		/* ...non utilizzato....
		eval ("document.all."+name+".style.fontWeight='bold'");
		eval ("document.all."+name+".disabled=true");
		*/
	}		
	if (terzocampo) {
		document.write("</td>")
		if (controllo=='text.ppp.suffisso') {
			// eventuale SUFFISSO
			document.write("<td valign=\"middle\" align=\"left\" class=\"testoEtichetta\" >")
			document.write("&nbsp;"+suffisso+"&nbsp;")
			document.write("</td>")
		}
		document.write("	</tr>")
		document.write("</table>")	
	}
	document.write("</div>")
	document.write("</td>")
	
	// MEMORIA
	if (last_object_memoria && (last_object_value==null || last_object_value=='null')) {
		// Legge il cookie relativo e assegna al campo
		last_object_value = leggiCookie('memoria.'+last_object_name)		
	}	
	if (last_object_value==null || last_object_value=='null') last_object_value=""	
	eval("document.forms[0]."+last_object_name+".value=\""+ last_object_value+"\"")
}

// Gestione codice progressivo non valorizzato inizialmente
function campoProgressivo (etichetta, name, value) {
	campoINPUT("Text", etichetta, name, 40, 10, value, 'progressivo', false, false)
}

// Campo nascosto
function campoHidden (name, value) {
	document.write("<input type=\"Hidden\" id=\""+name+"\" name=\""+name+"\" value=\""+value+"\" class=\"vuoto\">")
}

// Campo TEXT standard
function campoText (etichetta, name, size, maxlength, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, size, maxlength, value, 'text', abilitato, memoria)
}

// Campo TEXT standard con uppercase dei caratteri al cambio di focus
function campoTextUpper (etichetta, name, size, maxlength, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, size, maxlength, value, 'text.upper', abilitato, memoria)
}

// Campo TEXT standard con testo prefisso
function campoTextPrefisso (etichetta, name, size, maxlength, prefisso, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, size, maxlength, value, 'text.ppp.prefisso', abilitato, memoria, 0, prefisso, "")
}

// Campo TEXT standard con testo suffisso
function campoTextSuffisso (etichetta, name, size, maxlength, value, suffisso, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, size, maxlength, value, 'text.ppp.suffisso', abilitato, memoria, 0, "", suffisso)
}

// Campo FILE per la gestione del'UPLOAD 
function campoFile (etichetta, name, size, abilitato) {
	campoINPUT("File", etichetta, name, size, 0, null, 'file', abilitato, false)
}

// Campo per la visualizzazione e la cancellazione degli allegati
function campoAllegato_view (etichetta, name, size, value, option, progressivo) {
	if (option==null) option="";
	if (progressivo!=null) name = name + "_" + progressivo	
	
	/*
		Nota: utilizzare size >0 per allineare il check elimina
	*/	
	document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
  document.write("  &nbsp;"+etichetta+"&nbsp;")
  document.write("</td>")
	document.write("<td height=\"23\" align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
	document.write("  <table align=\"left\" "+(size>0?"width=\""+size+"\"":"")+" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">")
	document.write("    <tr>")
	document.write("	    <td align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
	document.write("        <font class=\"formtextfield\"><b>" + value + "</b></font>&nbsp;")
	document.write("      </td>")
	document.write("      <td width=\""+(size>0?"100%":30)+"\" class=\"vuoto\">")
	document.write("		    &nbsp;")
	document.write("	    </td>")	
	document.write("	    <td align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
	document.write("        <div id=\"field_ELIMINA_"+name+"\">")				
	document.write("        <input type=\"Checkbox\" name=\"ELIMINA_"+name+"\" value=\""+value+"\" class=\"formtextfield\" "+option+">")
	document.write("        </div>")					
	document.write("	    </td>")
	document.write("	    <td align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
	document.write("		    <div id=\"label_ELIMINA_"+name+"\">Elimina&nbsp;</div>")  		
	document.write("	    </td>")
	document.write("	  </tr>")
	document.write("  </table>")
	document.write("</td>")
}

// Campo testo che accetta soltanto valori numerici
function campoNumero (etichetta, name, size, maxlength, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, size, maxlength, value, 'number', abilitato, memoria, 0)
}

// Campo testo/numerico che riempe con 0 i valori
function campoNumeroFiller (etichetta, name, size, maxlength, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, size, maxlength, value, 'number.filler', abilitato, memoria, 0)
}

// Campo testo che accetta decimali, per la gestione delle valute
function campoValuta (etichetta, name, size, maxlength, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, size, maxlength, value, 'number', abilitato, memoria, 2)
}

// Campo testo che accetta valori decimali
function campoDecimale (etichetta, name, size, decimali, maxlength, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, size, maxlength, value, 'number', abilitato, memoria, decimali)
}

// Campo per l'insrimento dei CAP postali
function campoCAP (etichetta, name, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, 38, 5, value, 'CAP', abilitato, memoria)
}

// Campo di 2 caratteri per i codici provincia
function campoProvincia (etichetta, name, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, 20, 2, value, 'country', abilitato, memoria)
}

// Campo testo/numerico per inserire numeri telefonici
function campoTelefono (etichetta, name, size, maxlength, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, size, maxlength, value, 'telephon', abilitato, memoria)
}

// Campo testo per l0inserimento di email
function campoEmail (etichetta, name, size, maxlength, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, size, maxlength, value, 'email', abilitato, memoria)
}

//Campo testo per l'inserimento del codice fiscale  (campagna 2010)
function campoCodFiscale (etichetta, name, size, maxlength, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, size, maxlength, value, 'email', abilitato, memoria)
}

// Campo per la gestione delle date, in ogni formato
function campoData (etichetta, name, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, 62, 10, value, 'date', abilitato, memoria)
}

// Campo per la gestione delle date, in ogni formato
function campoAnno (etichetta, name, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, 32, 4, value, 'year', abilitato, memoria)
}

// Campo per la gestione delle date, in ogni formato
function campoMeseAnno (etichetta, name, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, 58, 7, value, 'month_year', abilitato, memoria)
}

// Campo per la gestione delle ore, in ogni formato
function campoOra (etichetta, name, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, 48, 8, value, 'hour', abilitato, memoria)
}

// Campo per la gestione delle ore, in ogni formato
function campoOreMinuti (etichetta, name, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, 36, 5, value, 'hour_minute', abilitato, memoria)
}

// Campo criptato per l'inserimento di password
function campoPassword (etichetta, name, size, maxlength, value, abilitato, memoria) {
	campoINPUT("Password", etichetta, name, size, maxlength, value, 'password', abilitato, memoria)
}

// Campo numerico per il cointrollo della validita della partita IVA italiana
function campoPartitaIVA (etichetta, name, value, abilitato, memoria) {
	campoINPUT("Text", etichetta, name, 76, 11, value, 'partitaIVA', abilitato, memoria)
}

// Campo RADIO OPTION
var memoria_confronto_radio = null
var radio_abilitato = true

function campoRadioEtichetta(etichetta, name, confronto, abilitato, memoria) {
	if (abilitato==null) abilitato = true
	radio_abilitato = abilitato
	if (memoria==null) memoria=false
					
	if (memoria) {	
		// variabili valorizzate per la chiusura.....
		last_object_abilitato = abilitato
		last_object_memoria = memoria
		last_object_value = confronto
		last_object_name = name
		
		// MEMORIA
		// Legge il cookie relativo e assegna al campo
		last_object_value = leggiCookie('memoria.'+last_object_name)	
	
		if (last_object_value==null || last_object_value=='null') last_object_value=""	
		if (last_object_value!="") confronto = last_object_value		
	}
	
	// Valore di confronto
	memoria_confronto_radio = confronto
	
	// Gestione campo text o password 	
	if (etichetta!=null && etichetta!="") {
		//...nel caso in cui l'etichetta e' presente
		if (estraiParametroErrato(name, etichetta)) {
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoErrore\">")			
	 	} else {	
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoEtichetta\">")		
		}	
		if (abilitato) {
			document.write("<div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;"+etichetta+"&nbsp;</div>")
		} else {
  		document.write("<div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;"+etichetta+"&nbsp;</div>")  	    
			//document.write("  <div id=\"label_"+name+"\">&nbsp;<b>"+etichetta+"</b>&nbsp;</div>")  	    
		}
		document.write("</td>")
	}
}

function campoRadio (etichetta, name, value, default_checked, abilitato, option) {
	//Nota: confronto, default_checked, abilitato basta definirli soltanto nella prima chiamata al RADIO
	if (abilitato==null) abilitato = radio_abilitato
	if (default_checked==null) default_checked=false
	if (option==null) option=""	
	
	if (last_object_memoria) {	
		// Attenzione se presente ONCLICK sullo script si può creare un conflitto
		option+=" onClick=\"javascript:scriviCookie('memoria."+name+"','"+value+"')\""
	}
	
	if (memoria_confronto_radio!=null && memoria_confronto_radio!="") {
		default_checked = (memoria_confronto_radio==value)
	} 
	document.write("<td class=\"vuoto\" valign=\"middle\" align=\"center\" height=\"23\" width=\"21\">")
	document.write("<input type=\"Radio\" id=\""+name+"\" name=\""+name+"\" value=\""+value+"\" "+(abilitato?"":"disabled")+" class=\"formtextfield\" "+(default_checked?"checked":"")+" "+option+">")
	document.write("</td>")
	if (etichetta!=null && etichetta!="") {
		// ...non stampo l'etichetta se vuota!!!
		document.write("<td class=\"formtextfield\" valign=\"middle\" align=\"left\" nowrap>")
		document.write("<font class=\"vuoto\">&nbsp;</font>")
		if (abilitato) {
			document.write(etichetta+"&nbsp;")
		} else {
			if (default_checked) {
				document.write("<b>"+etichetta+"</b>&nbsp;")
			} else {
				document.write(etichetta+"&nbsp;")
			}
		}
		document.write("</td>")		  
	}
}

// Campo FLAG acceso/spento
function campoFlag (etichetta, name, value, confronto, abilitato, memoria, option, immagine) {
	if (option==null) option="";
	if (abilitato==null) abilitato=true;	
	if (memoria==null) memoria=false;	
	
	if (memoria) {	
		// Attenzione se presente ONCLICK sullo script si può creare un conflitto
		option+=" onClick=\"javascript:scriviCookie('memoria."+name+"',checked?'"+value+"':'null')\""
		
		// MEMORIA
		// Legge il cookie relativo e assegna al campo
		confronto = leggiCookie('memoria.'+name)	
	
		if (confronto==null || confronto=='null') confronto=""			
		default_checked = (confronto==value)
	}
	
	if (etichetta!=null && etichetta!="") {
		//...nel caso in cui l'etichetta e' presente
		if (estraiParametroErrato(name, etichetta)) {
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoErrore\">")			
	 	} else {	
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoEtichetta\">")		
		}	
		if (abilitato) {
			document.write("<div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;"+etichetta+"&nbsp;</div>")
		} else {
  		document.write("<div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;"+etichetta+"&nbsp;</div>")  	    
			//document.write("  <div id=\"label_"+name+"\">&nbsp;<b>"+etichetta+"</b>&nbsp;</div>")  	    
		}
		document.write("</td>")
	}	
	/*
	document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoEtichetta\">")		
	document.write("  <div id=\"label_"+name+"\">" + etichetta + "&nbsp;</div>")
	document.write("</td>")
	*/	
	
	document.write("<td height=\"23\" valign=\"middle\" align=\"left\" class=\"vuoto\" >")
	document.write(" <div id=\"field_"+name+"\">")				
	if (immagine!=null) {
		document.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"vuoto\">")
		document.write("  <tr>")
		document.write("		<td align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
	}
	document.write("  	  	<input type=\"Checkbox\" id=\""+name+"\" name=\""+name+"\" "+(abilitato?"":"disabled")+" value=\""+value+"\" "+option+" class=\"formtextfield\">")
	if (immagine!=null) {
		document.write("		</td>")
		document.write("  	<td valign=\"middle\" align=\"left\" class=\"testoEtichetta\" >")
		document.write("			&nbsp;")
		document.write("	  </td>")
		document.write("		<td valign=\"middle\" align=\"left\" class=\"vuoto\" >")
		document.write("			<img border=\"0\" width=\"16\" height=\"16\" vspace=\"0\" src=\""+immagine+"\">")
		document.write("	  </td>")
		document.write("	</tr>")
		document.write("</table>")	
	}
	document.write(" </div>")				
	document.write("</td>")		
	
	if (value==confronto) {
		eval("document.forms[0]."+name+".checked=true")
	}
}

function replace (s1,a,b) {
	s2=""
	k=a.length
	i=s1.indexOf(a)
	if (i>0) {		
		while (i>0) {			
			s2+=s1.substring(0,i) + b
			s1=s1.substring(i+k)
			i=s1.indexOf(a)
		} 
		s2+=s1
		return s2		
	} else {
		return s1
	}
}

// Campo TEXT-AREA
//function campoTextArea(etichetta, name, colonne, righe, valore, abilitato) {
function campoTextArea(etichetta, name, size, altezza, valore, abilitato) {
	if (valore==null) valore=""	
	if (abilitato==null) abilitato=true	
	
	// Gestione campo textarea	
	if (etichetta!=null && etichetta!="") {	
		if (estraiParametroErrato(name, etichetta)) {
			document.write("<td align=\"right\" valign=\"top\" nowrap class=\"testoErrore\">")			
	 	} else {	
			document.write("<td align=\"right\" valign=\"top\" nowrap class=\"testoEtichetta\">")		
		}		
		if (abilitato) {
			document.write("<div id=\"label_"+name+"\" name=\"label_"+name+"\">" + etichetta + "&nbsp;</div>")
		} else {
			document.write("<div id=\"label_"+name+"\" name=\"label_"+name+"\">" + etichetta + "&nbsp;</div>")
			//document.write("<div id=\"label_"+name+"\"><b>"+etichetta+"</b>&nbsp;</div>")  	    
		}
		document.write("</td>")		
	}
	
	document.write("<td height=\"23\" align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
	  document.write("<div id=\"field_"+name+"\">")	
 	  //document.write("<textarea name=\""+name+"\" cols=\""+colonne+"\" rows=\""+righe+"\" "+(abilitato?"":"disabled")+" class=\"formtextfield\" onchange=\"return strigaOk_DBinsert(value)\"></textarea>")
    document.write("<textarea id=\""+name+"\" name=\""+name+"\" style=\"width:"+size+"; height:"+altezza+"\" "+(abilitato?"":"disabled")+" class=\"formtextfield\" onchange=\"return strigaOk_DBinsert(value)\"></textarea>")
	  document.write("</div>")		
	document.write("</td>")
	
	/*
		NOTA:
		In fase di passaggio parametri devo sostituire i caratteri speciali \n \r \t con altri caratteri per poi
		ripiazzarli con la sequenza \\n \\r \\t
	*/
	valore = replace(valore,"ç","\\");  
	
	// ...adesso posso inserire il valore nel campo
	// cambiato per compatibilità con Mozilla
  //eval("document.all."+name+".value=\""+valore+"\"")  
  eval("document.getElementById('"+name+"').value=\""+valore+"\"")  
  
  
}


// Campo Multiline apeciale, 3 fasi
var ms_name2
var ms_option_change
var ms_bottoni1
var	ms_bottoni2

function controllaAggiungiTogli(l1,l2,b1,b2) {
	eval("if (document.forms[0]."+l2+".value!=\"\") { document.forms[0]."+b1+".disabled = false } else {	document.forms[0]."+b1+".disabled = true	}")
	eval("if (document.forms[0]."+l1+".value!=\"\") { document.forms[0]."+b2+".disabled = false } else {	document.forms[0]."+b2+".disabled = true	}")	
}


// Campo a DOPPIA LISTA con possibilita' di AGGIUNGI e TOGLI
function apri_campoMultilineEtichetta(etichetta, name1 ,name2, righe, abilitato) {
	//if (valore==null) valore=""	
	if (abilitato==null) abilitato=true	
	
	last_object_name = name1
	ms_name2 = name2
	last_object_abilitato = abilitato
	ms_bottoni1='sel_'+last_object_name+'_aggiungi';
	ms_bottoni2='sel_'+last_object_name+'_togli';
	ms_option_change = "onchange=\"controllaAggiungiTogli('"+last_object_name+"','"+ms_name2+"','"+ms_bottoni1+"','"+ms_bottoni2+"')\""
	
	
	if (estraiParametroErrato(name1, etichetta)) {
		document.write("<td align=\"right\" valign=\"top\" nowrap class=\"testoErrore\">")			
 	} else {	
		document.write("<td align=\"right\" valign=\"top\" nowrap class=\"testoEtichetta\">")		
	}		
	if (abilitato) {
		document.write("<div id=\"label_"+name1+"\" name=\"label_"+name1+"\">&nbsp;" + etichetta + "&nbsp;</div>")
	} else {
		document.write("<div id=\"label_"+name1+"\" name=\"label_"+name1+"\">&nbsp;" + etichetta + "&nbsp;</div>")
		//document.write("<div id=\"label_"+name+"\"><b>"+etichetta+"</b>&nbsp;</div>")  	    
	}
	document.write("</td>")		
	document.write("<td align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
	document.write("<div id=\"field_"+name1+"\">")
	document.write("	<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"vuoto\">")
	document.write("		<tr>")
	document.write("			<td align=\"left\" valign=\"top\" class=\"vuoto\">")
	document.write("	<select size=\""+righe+"\" name=\""+last_object_name+"\" multiple class=\"formtextfield\" "+(last_object_abilitato?ms_option_change:"disabled")+">")	
}
	
function continua_campoMultilineEtichetta(immagine) {	
	eval("if (document.frmMaschera."+last_object_name+".length==0) document.frmMaschera."+last_object_name+".style.width='100px'")
	document.write("  </select>")
	document.write("      </td>")
	document.write("			<td align=\"left\" valign=\"top\" class=\"vuoto\">")
	document.write("				<img border=\"0\" width=\"8\" src=\""+immagine+"\">		")
	document.write("			</td>")
	document.write("			<td align=\"left\" valign=\"top\" class=\"vuoto\">")	
	document.write("				<table border=\"0\" align=\"left\" cellpadding=\"0\" cellspacing=\"0\" class=\"vuoto\">")
	document.write("					<tr>")
	document.write("						<td height=\"1\" class=\"vuoto\">")
	document.write("						  <img border=\"0\" height=\"1\" src=\""+immagine+"\">")								
	document.write("						</td>")
	document.write("				  </tr>")
	document.write("					<tr>")
	document.write("						<td align=\"left\" valign=\"top\" class=\"vuoto\">")
	w=80; h=18;	 testo='&lt&lt Aggiungi';	attributi = 'disabled'							
	document.write("<input type=\"button\" name=\""+ms_bottoni1+"\" value=\""+testo+"\" "+attributi+" width=\""+w+"\" height=\""+h+"\" style=\"width: "+w+"px; height: "+h+"px;\" class=\"bottoneNormale\" onClick=\"javascript:local_esegui('"+ms_bottoni1+"')\">")		
	document.write("						</td>")
	document.write("					</tr>")
	document.write("					<tr>")
	document.write("						<td height=\"22\" class=\"vuoto\">")
	document.write("							<img border=\"0\" height=\"1\" src=\""+immagine+"\">")								
	document.write("						</td>")
	document.write("					</tr>")
	document.write("					<tr>")
	document.write("						<td align=\"left\" valign=\"bottom\" class=\"vuoto\">")
	w=80; h=18;	 testo='Togli &gt;&gt';	attributi = 'disabled'							
	document.write("<input type=\"button\" name=\""+ms_bottoni2+"\" value=\""+testo+"\" "+attributi+" width=\""+w+"\" height=\""+h+"\" style=\"width: "+w+"px; height: "+h+"px;\" class=\"bottoneNormale\" onClick=\"javascript:local_esegui('"+ms_bottoni2+"')\">")		
	document.write("						</td>")
	document.write("					</tr>")											
	document.write("				</table>")						
	document.write("			</td>")
	document.write("			<td align=\"left\" valign=\"top\" class=\"vuoto\">")
	document.write("				<img border=\"0\" width=\"8\" src=\""+immagine+"\">")		
	document.write("			</td>")
	document.write("			<td align=\"left\" valign=\"top\" class=\"vuoto\">")
	document.write("  <select name=\""+ms_name2+"\" class=\"formtextlist\" "+(last_object_abilitato?ms_option_change:"disabled")+">")		
}

function chiudi_campoMultilineEtichetta() {		
	document.write("  </select>")
	eval("document.forms[0]."+ms_name2+".value=\"\"")		
	document.write("			</td>")												
	document.write("		</tr>")
	document.write("	</table>")	
	document.write("</div>")	
	document.write("</td>")
}


// Campo select, diviso in 2 parti
function apri_campoSelect(etichetta, name, value, abilitato, memoria, option_change, option) {
	if (option_change==null) option_change="null" 
	if (option==null) option=""
	if (abilitato==null) abilitato=false
	if (memoria==null) memoria=false	
	
	// variabili valorizzate per la chiusura.....
	last_object_abilitato = abilitato
	last_object_memoria = memoria
	last_object_value = value
	last_object_name = name
	
	if (value==null || value=='null') value=""			
		
	// Gestione campo senza etichetta
	if (etichetta!=null && etichetta!="") {
		//...nel caso in cui l'etichetta non e' presente
		if (estraiParametroErrato(name, etichetta)) {
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoErrore\">")			
	 	} else {	
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoEtichetta\">")		
		}		
		if (abilitato) {
			document.write("  <div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;"+etichetta+"&nbsp;</div>")
		} else {
			document.write("  <div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;"+etichetta+"&nbsp;</div>")  	    
		}
		document.write("</td>")		
	}
	
	document.write("<td height=\"23\" align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
	document.write("<div id=\"field_"+name+"\">")
	if (abilitato) {
		document.write("  <select id=\""+name+"\" name=\""+name+"\" class=\"formtextlist\" onchange=\"scriviIntoMemoria("+name+","+memoria+","+option_change+")\" "+option+">")
	} else {
		document.write("  <select id=\""+name+"_dis\" name=\""+name+"_dis\" class=\"formtextlist\" disabled >")
		// Sostituito per compatibilità con Mozilla
    //eval ("document.all."+name+"_dis.style.fontWeight='bold'");		
    eval("document.getElementById('"+name+"_dis').style.fontWeight='bold'")  
	}
}

function chiudi_campoSelect() {		
	document.write("  </select>")	
	if (!last_object_abilitato) {
		//...aggiungo un campo nascosto perche' il campo DISABLED non viene passato come parametro alla servlet
		document.write("  <input type=\"hidden\" name=\""+last_object_name+"\" value=\""+last_object_value+"\" class=\"vuoto\">")
	}	
	document.write("</div>")
	document.write("</td>")
	if (last_object_memoria && (last_object_value==null || last_object_value=='null')) {
		// Legge il cookie relativo e assegna al campo
		last_object_value = leggiCookie('memoria.'+last_object_name)			
	}	
	if (last_object_value==null || last_object_value=='null') last_object_value=""	

	eval("document.forms[0]."+last_object_name+".value=\""+last_object_value+"\"")
	if (!last_object_abilitato) {
		eval("document.forms[0]."+last_object_name+"_dis.value=document.forms[0]."+last_object_name+".value")
	}						
}


// Campo SELECT (con allegato campo TEXT) con memoria su COOKIE --------------------------
function scriviIntoText(campoText, campoSelect, memoria) {
	campoText.value = campoSelect.value	
	if (memoria) {
		scriviCookie('memoria.'+campoSelect.name, (campoSelect.value!=''?campoSelect.value:'null'))
	}
}

function scriviIntoSelect(campoText, campoSelect, memoria) {
	if (!strigaOk_DBinsert(campoText.value)) return false
	
	campoText.value = campoText.value.toUpperCase()
	campoSelect.value = campoText.value	
	if (memoria) {
		scriviCookie('memoria.'+campoSelect.name, (campoSelect.value!=''?campoSelect.value:'null'))
	}
	
	if (campoText.value==campoSelect.value)	 {
  	if (campoText.value=="") campoSelect.selectedIndex = -1
		//campoSelect[0].selected=true		
		return true	
	} else {
		// ...il valore dell campo TXT è diverso daL SELECT
		campoText.value = campoSelect.value			
	}
	return false				
}

function apri_campoSelect_collegato(etichetta, name, size, maxlength, value, abilitato, memoria, option_change, option, tipo) {
	if (option_change==null) option_change="null" 
	if (option==null) option=""
	if (abilitato==null) abilitato=false
	if (memoria==null) memoria=false							
	if (tipo==null) tipo='text'							
					
	// variabili valorizzate per la chiusura.....
	last_object_abilitato = abilitato
	last_object_memoria = memoria
	last_object_value = value
	last_object_name = name
	
	if (value==null || value=='null') value=""				
	if (tipo=='text') {
		allineamento = "left"
	} else if (tipo=='number') {
		allineamento = "right"
	} else {
		allineamento = "left"
	}
	
	document.write("<!-- TEXT-SELECT "+name+" - Fine (cerca la fine) -->")	
	// Gestione campo senza etuichetta
	if (etichetta!=null && etichetta!="") {
		//...nel caso in cui l'etichetta non e' presente
		if (estraiParametroErrato(name, etichetta)) {
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoErrore\">")			
	 	} else {	
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoEtichetta\">")		
		}
		
		if (abilitato) {
			document.write("  <div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;" + etichetta + "&nbsp;</div>")
		} else {
			document.write("  <div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;"+etichetta+"&nbsp;</div>")  	    
		}
		document.write("</td>")	
	}
	
	
	document.write("<td height=\"23\" align=\"left\" valign=\"middle\" nowrap class=\"vuoto\">")
	document.write("<div id=\"field_"+name+"\">")
	document.write("	<table height=\"23\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"vuoto\">")
	document.write("  	<tr>")
	document.write("			<td height=\"23\" align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
  if (abilitato) {
		document.write("  			<input style=\"text-align:'"+allineamento+"'; width:"+size+"px;\" type=\"text\" name=\""+name+"_TEXT\" "+(maxlength>0?"maxlength=\""+maxlength+"\"":"")+" value=\""+value+"\" class=\"formtextfield\" onchange=\"if (scriviIntoSelect("+name+"_TEXT,"+name+","+memoria+")) { "+option_change+" } else return false\")\">&nbsp;")
	}	else {
		document.write("  			<input style=\"text-align:'"+allineamento+"'; width:"+size+"px;\" type=\"text\" name=\""+name+"_TEXT\" value=\""+value+"\" disabled class=\"formtextfield\" >&nbsp;")
		//...aggiungo un campo nascosto perche' il campo DISABLED non viene passato come parametro alla servlet
		document.write("        <input type=\"hidden\" id=\""+name+"\" name=\""+name+"\" value=\""+value+"\" class=\"vuoto\">")
	}
	document.write("			</td>")
	document.write("			<td height=\"23\" align=\"left\" valign=\"middle\" nowrap class=\"testoEtichetta\">")
	if (abilitato) {
		document.write("  		  <select id=\""+name+"\" name=\""+name+"\" class=\"formtextlist\" onchange=\"scriviIntoText("+name+"_TEXT,"+name+","+memoria+");"+option_change+"\" "+option+">")
	} else {
		document.write("  		  <select id=\""+name+"_LOCKED\" name=\""+name+"_LOCKED\" class=\"formtextlist\" disabled "+option+">")
	}
}

function chiudi_campoSelect_collegato() {		
	document.write("        </select>")
	document.write("&nbsp;</td>")
	document.write("	  </tr>")
	document.write("  </table>")
	document.write("</div>")
	document.write("</td>")
	if (last_object_memoria && (last_object_value==null || last_object_value=='null')) {
		// Legge il cookie relativo e assegna al campo
		last_object_value = leggiCookie('memoria.'+last_object_name)			
	}	
	if (last_object_value==null || last_object_value=='null') last_object_value=""	
	
	eval("document.forms[0]."+last_object_name+".value=\""+ last_object_value+"\"")	
	eval("document.forms[0]."+last_object_name+"_TEXT.value = document.forms[0]."+last_object_name+".value")
	if (!last_object_abilitato) {
		// ...se disabilitato cambia il nome della SELECT
		eval("document.forms[0]."+last_object_name+"_LOCKED.value=\""+ last_object_value+"\"")	
	}	
	document.write("<!-- TEXT-SELECT "+name+" - Fine (cerca l'inizio) -->")						
}
// -------------------------------------------------------------------------------------


function soloEtichetta(etichetta, name, abilitato) {
	if (abilitato==null) abilitato=false
		
	// Gestione campo senza etuichetta
	if (etichetta!=null && etichetta!="") {
		//...nel caso in cui l'etichetta non e' presente
		if (estraiParametroErrato(name, etichetta)) {
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoErrore\">")			
	 	} else {	
			document.write("<td align=\"right\" valign=\"middle\" nowrap class=\"testoEtichetta\">")		
		}		
		if (abilitato) {
			document.write("  <div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;"+etichetta+"&nbsp;</div>")
		} else {
			document.write("  <div id=\"label_"+name+"\" name=\"label_"+name+"\">&nbsp;"+etichetta+"&nbsp;</div>")  	    
		}
		document.write("</td>")		
	}
}

// Nasconde un DIV e la sua LABEL
function nascondiText(obj) {
	//alert(eval("document.all."+obj+"!=null"))
	//eval("if (document.all."+obj+"!=null) nascondi(obj)")	
	
	nascondi("field_"+obj)
	nascondi("label_"+obj)
}

// Visualizza un DIV e la sua LABEL
function visualizzaText(obj) {	
	visualizza("field_"+obj)
	visualizza("label_"+obj)
}

// Cambia lo stato di visibilità di un DIV e la sua LABEL
function cambiaStatoText(obj) {
  // Sostituito per compatibilità con Mozilla
  //var css = (tree_nLayer) ? eval("document.field_"+obj):eval("document.all.field_"+obj+".style") 
	var css = (tree_nLayer) ? eval("document.field_"+obj):eval("document.getElementById('field_"+obj+"').style") 
	
	if (css.visibility=="visible") {
		nascondiText(obj)
	} else {
		visualizzaText(obj)
	}
}


