//======================================================================// Libreria contenente classi per la realizzazione di menu DropDown, PopUp ed a colonna.//// Avvertenza:// si esortano gli utilizzatori a non effettuare modifiche non autorizzate su questa libreria. Tali modifiche verrebbero// perse in caso di aggiornamento ed inoltre potrebbero causare malfunzionamenti nelle funzioni che ne fanno uso.//// Prerequisiti:// - Libreria QJS Basic 4.0 o superiore//// Indice delle classi:// - QDropDownMenu					Menu di tipo dropdown in tutte le direzioni// - QDropDownMenuItem				Item di menu di tipo dropdow// - QPopUpMenu							Menu di tipo popup legato alla posizione del mouse o di un nodo.// - QColumnMenu						Menu di tipo a colonna//// Versioni:// - 4.0			Prima versione ufficialmente rilasciata.//// Propriet\u00E0:	Quattroemme S.p.A.// Autore:		Francesco Diamanti//======================================================================//======================================================================// Class QDropDownMenu// Crea un oggetto menu di tipo drop down.//======================================================================function QDropDownMenu(parentItem) {	//Parametri:	//- parentItem			Item al quale il menu appartiene se si tratta di un sottomenu. Se invece \u00E8 il menu	//							di primo livello questo parametro deve essere null.	var closeInterval	var container	var items = new Array()	var that = this	//------------------------------------------------------------------------------------------------------------------------	// Propriet\u00E0 pubbliche	//------------------------------------------------------------------------------------------------------------------------	this.closeOnClick = false						//Se true il menu chiude dopo il click su uno degli item.	this.closeOnMouseOut = false					//Se true, il menu chiuder\u00E0 al mouseout.	this.CSSItem										//Classe della classe CSS dell'item. Ereditaria.	this.CSSLine										//Classe della classe CSS dell'item linea. Ereditaria.	this.CSSMenu										//Classe della classe CSS del menu. Ereditaria.	this.CSSRollover									//Classe della classe CSS dell'effetto rollover sugli item. Ereditaria.	this.direction = "v"								//Direzione del menu: "v" per verticale (default) ed "h" per orizzontale.	this.iconWidth										//Larghezza del contenitore delle icone. Se icone sono utilizzate assume il default 22.	this.position										//Posizione rispetto al nodo di ancoraggio: "top","right","bottom","left". Ereditaria.	this.timeout = 300								//Timeout dei menu a scomparsa (closeOnMouseOut = true). Ereditaria.			//Propriet\u00E0 read-only	this.isOver = false								//Se true, il mouse si trova sul menu.	this.node											//Nodo HTML del menu.		//------------------------------------------------------------------------------------------------------------------------	// Medoti pubblici	//------------------------------------------------------------------------------------------------------------------------	this.addItem = M_addItem						//Aggiunge un item al menu.	this.addMenuItem = M_addMenuItem			//Aggiunge un item contenente un sottomenu.	this.addLine = M_addLine						//Aggiunge un item di tipo Linea di separazione.	this.create = M_create							//Crea il menu. Invocare sempre almeno una volta prima del metodo show.	this.hide = M_hide								//Naconde il menu e tutti i sottomenu.		this.JSONBuilder = M_JSONBuilder				//Costruttore del menu mediante oggetto JSON	this.remove = M_remove						//Rimuove il menu e tutto il suo contenuto.	this.setCSS = M_setCSS						//Assegna tutte le classi css in una volta	this.show = M_show								//Mostra il menu.		//Inizializzazione	initialize()	//------------------------------------------------------------------------------------------------------------------------	// Definizione dei medoti pubblici	//------------------------------------------------------------------------------------------------------------------------	function M_addItem(label, URL, target, icon) {		//Aggiunge un nuovo item di menu e restituisce l'oggetto QDropDownItem.		try {			var index = items.length			items[index] = new QDropDownItem(this, label, URL, target, icon)			if (icon && this.iconWidth == null) this.iconWidth = 22			return items[index]		}		catch(e) {QException(e, "QDropDownMenu.addItem")}	}	//------------------------------------------------------------------------------------------------------------------------	function M_addMenuItem(label, icon) {		//Aggiunge un nuovo item di menu con sottomenu e restituisce l'oggetto QDropDownItem.		try {			var item = this.addItem(label, null, null, icon)			item.addMenu()			return item.menu		}		catch(e) {QException(e, "QDropDownMenu.addMenuItem")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_addLine() {		//Aggiunge una riga di separazione tra gli item e restituisce l'oggetto QDropDownItem.		//NOTA: si utilizza solamente per menu verticali come, ad esempio, per i mouse pop-up.		try {			var item = this.addItem()			var lineNode = document.createElement("div")			lineNode.className = this.CSSLine			lineNode.style.borderWidth = "1px 0px 0px 0px"			item.node.appendChild(lineNode)			return item		}		catch(e) {QException(e, "QDropDownMenu.addLine")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_create(pContainer) {		//Aggiunge un nuovo item di menu e restituisce l'oggetto QDropDownItem.		try {			container = (typeof(pContainer) == "string")? document.getElementById(pContainer) : pContainer			container.appendChild(this.node)			//Assegnazione della classe CSS			this.node.className = this.CSSMenu			//Creazione degli item			for (index in items) {				items[index].create()			}			//Posizionamento rispetto al container			if (this.position) {				//Calcolo bordo del container per correzione della posizione. NOTA: assume che siano in pixel.				var borderStyle = (QIsIE)? "borderTopWidth" : "border-top-width"				var border = QStyleGetAttribute(container, borderStyle, true)[0]				switch (this.position) {					case "top":						this.node.style.left = container.offsetLeft - border						this.node.style.top = container.offsetTop - this.node.offsetHeight						break					case "right":						this.node.style.left = container.offsetLeft + container.offsetWidth						this.node.style.top = container.offsetTop - border						break					case "bottom":						this.node.style.left = container.offsetLeft - border						this.node.style.top = container.offsetTop + container.offsetHeight						break					case "left":						this.node.style.left = container.offsetLeft - this.node.offsetWidth						this.node.style.top = container.offsetTop - border						break				}			}			//Creazione dei sottomenu			for (index in items) {				items[index].createMenu()			}			//Tutti i menu nascono nascosti			this.hide()		}		catch(e) {QException(e, "QDropDownMenu.create")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_hide() {		//Nasconde il menu		try {			if (this.node) {						this.node.style.display = "none"				//Rollover sul parent item				if (parentItem) parentItem.rollOff()			}		}		catch(e) {QException(e, "QDropDownMenu.hide")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_JSONBuilder(JSON) {		//Crea item e sottomenu utilizzando un oggetto JSON avente il seguente formato:		/*				{"menu" : [			{"items" : [				{"label" : "", "icon" : "", "menu" : [					{"items" : [						{"label" : "", "url" : "", "target" : "", "icon" : ""},						{"label" : "", "url" : "", "target" : "", "icon" : ""},					"opt": [						{"direction" : "v", "CSSMenu" : "Menu", "..." : ...}]}]},			"opt" : [				{"direction" : "v", "CSSMenu" : "Menu", "..." : ...}]}]}		*/		try {			if (JSON.menu[0]) {				var items = JSON.menu[0].items				var opt = JSON.menu[0].opt								//Verifica se attivare il rollover e la visibilit\u00E0 del menu, nonch\u00E8 l'effetto one at time (un sottomenu per volta)				if (opt) {					M_setCSS(opt[0].CSSMenu, opt[0].CSSItem, opt[0].CSSRollover, opt[0].CSSLine)					if (opt[0].direction) this.direction = opt[0].direction					if (opt[0].iconWidth) this.iconWidth = opt[0].iconWidth					if (opt[0].position && opt[0].position != "") this.position = opt[0].position				}				//Verifica se creare gli items				if (items) {					for (var i = 0; i < items.length; i++) {						//Verifica se l'item sia la testata di un sottomenu o meno						if (items[i].menu) {							var menu = this.addMenuItem(items[i].label, items[i].icon)							menu.JSONBuilder(items[i])						}						else this.addItem(items[i].label, items[i].url, items[i].target, items[i].icon)					}				}			}		}		catch(e) {QException(e, "QDropDownMenu.JSONBuilder")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_remove() {		//Rimuove il menu e tutti gli item e sottomenu		try {			if (this.node) {				var parent = this.node.parentNode				if (parent) parent.removeChild(this.node)				//Elimina tutti gli item				for (index in items) {					items[index].remove()				}				//Elimina il menu				this.node = null			}		}		catch(e) {QException(e, "QDropDownMenu.remove")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_setCSS(menu, item, rollover, line) {		//Assegna tutte le classi css in una volta		try {			that.CSSMenu = (menu == null || menu == "")? null : menu			that.CSSItem = (item == null || item == "")? null : item			that.CSSRollover = (rollover == null || rollover == "")? null : rollover			that.CSSLine = (line == null || line == "")? null : line		}		catch(e) {QException(e, "QDropDownMenu.setCSS")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_show() {		//Mostra il menu		try {			if (this.node && this.node.style.display == "none") {				this.node.style.display = "block"				//Rollover sul parent item				if (parentItem) parentItem.rollOn()				//Se prevista la chiusura automatica del menu, avvia la funzione di chiusura ad intervallo				if (this.closeOnMouseOut) {								this.isOver = true					closeInterval = setInterval(queryClose, this.timeout)				}			}		}		catch(e) {QException(e, "QDropDownMenu.show")}	}		//------------------------------------------------------------------------------------------------------------------------	// Medoti privati	//------------------------------------------------------------------------------------------------------------------------	function initialize() {		//Inizializzazione dell'oggetto		try {			that.node = document.createElement("div")			//Attributi CSS di base			that.node.style.position = "absolute"		}		catch(e) {QException(e, "QDropDownItem.initialize")}	}		//------------------------------------------------------------------------------------------------------------------------	function queryClose() {		//Funzione ad intervallo che verifica che il menu sia da chiudere.		try {			if (that.isOver == false) {				//Chiude l'intervallo e nasconde il menu				closeInterval = clearInterval(closeInterval)				that.hide()			}		}		catch(e) {QException(e, "QDropDownMenu.queryClose")}	}}//======================================================================// Class QDropDownItem//======================================================================function QDropDownItem(parentMenu, label, URL, pTarget, icon) {	var target = (pTarget)? pTarget : "_blank"	var that = this		//------------------------------------------------------------------------------------------------------------------------	// Propriet\u00E0 pubbliche	//------------------------------------------------------------------------------------------------------------------------	this.menu	this.node		//------------------------------------------------------------------------------------------------------------------------	// Medoti pubblici	//------------------------------------------------------------------------------------------------------------------------	this.addMenu = M_addMenu	this.create = M_create	this.createMenu = M_createMenu	this.remove = M_remove	this.rollOff = M_rollOff	this.rollOn = M_rollOn		//Inizializzazione	initialize()	//------------------------------------------------------------------------------------------------------------------------	// Definizione dei medoti pubblici	//------------------------------------------------------------------------------------------------------------------------	function M_addMenu() {		//Aggiunge un menu all'item e restituisce l'oggetto QMenu		try {			this.menu = new QDropDownMenu(this)			this.menu.closeOnMouseOut = true			this.menu.closeOnClick = true			//Imposta le propriet\u00E0 ereditarie			this.menu.CSSMenu = parentMenu.CSSMenu			this.menu.CSSItem = parentMenu.CSSItem			this.menu.CSSRollover = parentMenu.CSSRollover			this.menu.CSSLine = parentMenu.CSSLine			this.menu.position = parentMenu.position			this.menu.timeout = parentMenu.timeout			return this.menu		}		catch(e) {QException(e, "QDropDownItem.addMenu")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_create() {		//Crea il codice HTML del nodo item		try {			//Assegnazione della calsse CSS			this.node.className = parentMenu.CSSItem			//Orientamento orizzontale degli item			if (parentMenu.direction == "h") {				if (QIsIE) this.node.style.styleFloat = "left"				else this.node.style.cssFloat = "left"			}			//L'icona			if (parentMenu.iconWidth) {				var iconContainer = document.createElement("span")				iconContainer.style.width = parentMenu.iconWidth				if (label) iconContainer.style.verticalAlign = "middle"				if (icon) {					var iconNode = document.createElement("img")					iconNode.setAttribute("src", QCurPath + "/" + icon)					iconContainer.appendChild(iconNode)									}				this.node.appendChild(iconContainer)			}			//Assegna la label			if (label) {				var labelNode = document.createElement("span")				labelNode.innerHTML = label				this.node.appendChild(labelNode)			}			//Assegna gli eventi			if (URL) this.node.onclick = onClick			this.node.onmouseout = onMouseOut			this.node.onmouseover = onMouseOver			parentMenu.node.appendChild(this.node)		}		catch(e) {QException(e, "QDropDownItem.create")}	}	//------------------------------------------------------------------------------------------------------------------------	function M_createMenu() {		//Crea il sottomenu.		try {			if (this.menu) this.menu.create(this.node)		}		catch(e) {QException(e, "QDropDownItem.createMenu")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_remove() {		//Rimuove il nodo dell'item e quello del sottomenu.		try {			if (this.menu) this.menu.remove()			this.node = null		}		catch(e) {QException(e, "QDropDownItem.rollOff")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_rollOff() {		//Spegne l'effetto rollover.		try {			if (parentMenu.CSSRollover) that.node.className = parentMenu.CSSItem		}		catch(e) {QException(e, "QDropDownItem.rollOff")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_rollOn() {		//Accende l'effetto rollover		try {			if (parentMenu.CSSRollover) that.node.className = parentMenu.CSSRollover		}		catch(e) {QException(e, "QDropDownItem.rollOn")}	}		//------------------------------------------------------------------------------------------------------------------------	// Medoti privati	//------------------------------------------------------------------------------------------------------------------------	function initialize() {		//Inizializzazione dell'oggetto		try {			that.node = document.createElement("div")			//Attributi CSS di base			that.node.style.position = "static"			that.node.style.whiteSpace = "nowrap"		}		catch(e) {QException(e, "QDropDownItem.initialize")}	}		//------------------------------------------------------------------------------------------------------------------------	function onClick() {		//Evento onclick sul nodo dell'item di menu. Un URL pu\u00F2 essere:		//- Una funzione					Verr\u00E0 eseguita.		//- Un nome di funzione			In una stringa nome funzione js si possono specificare i seguenti parametri:		//									- "this" per il nodo dell'item.		//									- "that" per l'oggetto js QDropDownItem.		//- Un URL						Un url pu\u00F2 essere scritto omettendo l'iniziale "http://".		//									Se l'url inizia per "/" verr\u00E0 anteposto il percorso del db corrente.		//									Il target pu\u00F2 essere "_self", "_blank" o l'id di un iframe.		try {			if (typeof(URL) == "function") URL()			else if (URL.substring(0, 11).toLowerCase() == "javascript:") eval(URL.substring(11))			else {				//Apre l'url al target indicato				switch (target.toLowerCase()) {					case "_blank":						window.open(URL)						break					case "_self":						window.location.href = URL						break					default:						var iframe = document.getElementById(target)						if (iframe) iframe.src = URL						break				}			}			//Se richiesto, chiude il menu dopo il click.			if (parentMenu.closeOnClick) parentMenu.hide()		}		catch(e) {QException(e, "QDropDownItem.onClick")}	}		//------------------------------------------------------------------------------------------------------------------------	function onMouseOut() {		//Gestione evento onmouseout		try {			if (that.menu) that.menu.isOver = false			else if (URL) that.rollOff()		}		catch(e) {QException(e, "QDropDownItem.onMouseOut")}	}		//------------------------------------------------------------------------------------------------------------------------	function onMouseOver() {		//Gestione evento onmouseover		try {			//Apre il sottomenu			if (that.menu) {				that.menu.isOver = true				that.menu.show()			}			else if (URL) that.rollOn()		}		catch(e) {QException(e, "QDropDownItem.onMouseOver")}	}}//======================================================================// Class QPopUpMenu// Definisce un oggetto menu di tipo pop-up. Si tratta di un menu della specie dei drop-down ma fluttuante,// legato, a scelta, o alla posizione del mouse o a quella di un nodo. Dato l'uso fluttuante, contrariemente ai menu// drop-down viene creato al momento dello show e distrutto alla chiusura.// NOTA: si basa sulla classe QDropDowMenu.//======================================================================function QPopUpMenu() {		var that = this		//------------------------------------------------------------------------------------------------------------------------	// Propriet\u00E0 pubbliche	//------------------------------------------------------------------------------------------------------------------------	this.menu										//L'oggetto QDropDownMenu utilizzato per generare il menu popup.													//Per definire le proprieta del menu, fare riferimento a quest'oggetto.	//------------------------------------------------------------------------------------------------------------------------	// Metodi pubblici	//------------------------------------------------------------------------------------------------------------------------	this.addItem = function(label, URL, target, icon) {return this.menu.addItem(label, URL, target, icon)}	this.addMenuItem = function(label, icon) {return this.menu.addMenuItem(label, icon)}	this.addLine = function() {this.menu.addLine()}	this.setCSS = function(menu, item, rollover, line) {this.menu.setCSS(menu, item, rollover, line)}	this.show = M_show	//Inizializzazione	initialize()	//------------------------------------------------------------------------------------------------------------------------	// Definizione dei metodi pubblici		//------------------------------------------------------------------------------------------------------------------------	function M_show(anchor, position, margin, direction) {		//Crea e mostra il menu basandosi sulla classe QDropDowMenu.		//Parametri:		//- anchor					Nodo o id del nodo di ancoraggio. Se non definito assume la posizione del mouse.		//- position				Posizione del menu rispetto al nodo di ancoraggio, se indicato.		//- margin					Distanza in pixel del menu dal nodo.		//- direction				Direzione di dispiegamento degli item del menu.		try {			//Impostazioni del menu			this.menu.closeOnMouseOut = true			this.menu.closeOnClick = true			this.menu.node.onmouseover = function() {that.menu.isOver = true}			this.menu.node.onmouseout = function() {that.menu.isOver = false}			//Crea il menu legandolo al nodo o, se non indicato, al mouse.			if (anchor) createAnchorMenu(anchor, position, margin, direction)			else createMouseMenu()		}		catch(e) {QException(e, "QPopUpMenu.show")}	}		//------------------------------------------------------------------------------------------------------------------------	// Metodi privati	//------------------------------------------------------------------------------------------------------------------------	function createAnchorMenu(anchor, position, margin, direction) {		//Crea un menu legato ad un nodo. Per i parametri vedere il metodo M_show		try {			if (direction) that.menu.direction = direction			if (position) that.menu.position = position			that.menu.create(anchor)			//Mostra il menu			that.menu.show()			//Se \u00E8 stato indicato un margine riposizione il menu in base a questo			if (margin) {				switch (position) {					case "top":						that.menu.node.style.top = that.menu.node.offsetTop - margin						break					case "right":						that.menu.node.style.left = that.menu.node.offsetLeft + margin						break					case "bottom":						that.menu.node.style.top = that.menu.node.offsetTop + margin						break					case "left":						that.menu.node.style.left = that.menu.node.offsetLeft - margin						break				}			}			//Override del metodo hide del menu drop down			that.menu.hide = function() {this.remove()}		}		catch(e) {QException(e, "QPopUpMenu.createAnchorMenu")}	}			//------------------------------------------------------------------------------------------------------------------------	function createMouseMenu() {		//Crea un menu legato alla posizione del mouse.		try {			//Esclude il context menu.			document.oncontextmenu = function() {return false}			that.menu.create(document.body)			that.menu.node.style.zIndex = 9996			that.menu.show()			//Riposizione in base alla posizione del mouse ed ai limiti dello schermo.			var windowX = (QIsIE)? document.body.clientWidth : window.innerWidth			var windowY = (QIsIE)? document.body.clientHeight : window.innerHeight			var incX = (QMouseX + that.menu.node.offsetWidth > windowX)? that.menu.node.offsetWidth - 5 : 5			var incY = (QMouseY + that.menu.node.offsetHeight > windowY)? that.menu.node.offsetHeight - 5 : 5			//Imposta le coordinate definitive del menu				that.menu.node.style.left = QMouseX - incX			that.menu.node.style.top = QMouseY - incY			//Override del metodo hide del menu drop down			that.menu.hide = function() {this.remove(); document.oncontextmenu = null}		}		catch(e) {QException(e, "QPopUpMenu.createMouseMenu")}	}		//------------------------------------------------------------------------------------------------------------------------		function initialize() {		//Inizializza l'oggetto		try {			that.menu = new QDropDownMenu()		}		catch(e) {QException(e, "QPopUpMenu.initialize")}	}}//======================================================================// Class QColumnMenu// Crea un oggetto menu di tipo a colonna//======================================================================//Generatore di id per gli oggetti QColumnMenuvar QCMEnumfunction QColumnMenu(containerX) {	//Cotruisce un menu a colonna a pi\u00F9 livelli.	//I css sono associati ai differenti livelli. Es per il livello 1 avremo QCMLevel1, per il livello 2 avremo QCMLevel2	var containerNode = (typeof(containerX) == "string")? document.getElementById(containerX) : containerX	var that = this		//------------------------------------------------------------------------------------------------------------------------	// Propriet\u00E0 pubbliche	//------------------------------------------------------------------------------------------------------------------------	this.CSSIcon										//Prefisso della classe CSS delle icone.	this.CSSItem										//Prefisso della classe CSS dell'item.	this.CSSFooter									//Classe CSS del footer	this.CSSLabel										//Prefisso della classe CSS delle label.	this.CSSRollover									//Prefisso della classe CSS dell'effetto rollover sugli item.	this.iconPosition = "left"							//Posizione delle icone. Assume "left" o "right"		//------------------------------------------------------------------------------------------------------------------------	// Metodi pubblici	//------------------------------------------------------------------------------------------------------------------------	this.addItem = M_addItem								//Aggiunge un item	this.addMenu = M_addMenu								//Aggiunge un item con sottomenu	this.addFooter = M_addFooter							//Aggiunge il footer	this.JSONBuilder = M_JSONBuilder						//Genera un menu a partire da un oggetto JSON	this.setCSS = M_setCSS								//Assegna tutte le classi CSS in una volta.	this.setExpandMode = M_setExpandMode				//Imposta la modalit\u00E0 di espansione dei sottomenu.																//Assume "all" per tutti i sottomenu e "one" per uno sottomeu alla volta.		if (QCMEnum == undefined) QCMEnum = new QEnum("QCM", 3)	//------------------------------------------------------------------------------------------------------------------------	// Definizione dei metodi pubblici	//------------------------------------------------------------------------------------------------------------------------	function M_addItem(label, action, target, icon) {		//Crea e restituisce un nuovo item di menu		try {			//Verifica l'esistenza del contenitore			if (containerNode) {				//Aggiunta di un item				var itemNode = document.createElement("div")				itemNode.className = this.CSSItem				//Se richiesto abilita l'effetto rollover				if (this.CSSRollover) {					itemNode.onmouseover = onMouseOverItem					itemNode.onmouseout = onMouseOutItem				}				//Assegna l'azione relativa al click sull'item				if (action && action != "") {					itemNode.action = action					if (action && action != "") itemNode.target = target					itemNode.onclick = onClickItem				}				containerNode.appendChild(itemNode)				//Se richiesto crea l'icona				if (icon) {					var iconNode = document.createElement("img")					iconNode.src = QCurPath + "/" + icon					iconNode.className = this.CSSIcon					itemNode.appendChild(iconNode)				}				//Crea la label				var labelNode = document.createElement("a")				labelNode.innerHTML += label				labelNode.className = this.CSSLabel				itemNode.appendChild(labelNode)				//Restituisce il nodo item				return itemNode			}		}		catch(e) {QException(e, "QColumnMenu.addItem")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_addMenu(label, icon, visible) {		//Crea un sottomenu generando un falso item di testata e lo restituisce.		try {			//Verifica l'esistenza del contenitore			if (containerNode) {				//Aggiunta di un falso item usato come testata del menu				var itemNode = this.addItem(label, "", "", icon)				itemNode.menuId = QCMEnum.getNew()				itemNode.onclick = onClickMenu				//Creazione di un nuovo menu				var menuNode = document.createElement("div")				menuNode.id = itemNode.menuId				//Imposta la visibilit\u00E0 del menu come da parametro				if (visible == false) menuNode.style.display = "none"				//Appende il nodo				containerNode.appendChild(menuNode)				//Crea l'oggetto QColumnMenu che verr\u00E0 restituito dalla funzione				var menu = new QColumnMenu(menuNode)				//Eredita i CSS				menu.CSSIcon = this.CSSIcon				menu.CSSItem = this.CSSItem				menu.CSSFooter = this.CSSFooter				menu.CSSLabel = this.CSSLabel				menu.CSSRollover = this.CSSRollover				return menu			}		}		catch(e) {QException(e, "QColumnMenu.addMenu")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_addFooter() {		//Crea un footer di chiusura del menu.		try {			//Verifica l'esistenza del contenitore			if (containerNode) {				var footerNode = document.createElement("div")				footerNode.className = this.CSSFooter				containerNode.appendChild(footerNode)			}		}		catch(e) {QException(e, "QColumnMenu.addFooter")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_JSONBuilder(JSON) {		//Crea item e sottomenu utilizzando un oggetto JSON avente il seguente formato:		/*				{"menu" : [			{"items" : [				{"label" : "", "icon" : "", "menu" : [					{"items" : [						{"label" : "", "action" : "", "target" : "", "icon" : ""},						{"label" : "", "action" : "", "target" : "", "icon" : ""},					"opt": [						{"CSSItem" : "CSSItem", "visible" : false, "oneAtTime" : true}]}]},			"opt" : [				{"footer" : true, "CSSItem" : "CSSItem" , "visible" : false, "oneAtTime" : true}]}]}		*/		try {					if (JSON.menu[0]) {				var items = JSON.menu[0].items				var opt = JSON.menu[0].opt								//Verifica se attivare il rollover e la visibilit\u00E0 del menu, nonch\u00E8 l'effetto one at time (un sottomenu per volta)				if (opt) {					M_setCSS(opt[0].CSSItem, opt[0].CSSRollover, opt[0].CSSLabel, opt[0].CSSIcon, opt[0].CSSFooter)					if (opt[0].visible == false) containerNode.style.display = "none"					if (opt[0].oneAtTime) this.setExpandMode("one")				}				//Verifica se creare gli items				if (items) {					for (var i = 0; i < items.length; i++) {						//Verifica se l'item sia la testata di un sottomenu o meno						if (items[i].menu) {							var menu = this.addMenu(items[i].label, items[i].icon)							menu.JSONBuilder(items[i])						}						else this.addItem(items[i].label, items[i].action, items[i].target, items[i].icon)					}				}							//Verifica se creare il footer				if (opt) {					if (opt[0].footer) this.addFooter()				}			}		}		catch(e) {QException(e, "QColumnMenu.JSONBuilder")}	}		//------------------------------------------------------------------------------------------------------------------------	function M_setCSS(item, rollover, label, icon, footer) {		//Assegna tutte le classi css in una volta		try {			that.CSSItem = (item == null || item == "")? null : item			that.CSSRollover = (rollover == null || rollover == "")? null : rollover			that.CSSLabel = (label == null || label == "")? null : label			that.CSSIcon = (icon == null || icon == "")? null : icon			that.CSSFooter = (footer == null || footer == "")? null : footer		}		catch(e) {QException(e, "QDropDownMenu.setCSS")}	}		//------------------------------------------------------------------------------------------------------------------------															function M_setExpandMode(mode) {		//Imposta la modalit\u00E0 di espansione dei sottomenu. Assume "all" per tutti o "one" per uno sottomeu alla volta.		//Il default \u00E8 "all".		try {			containerNode.mode = mode		}		catch(e) {QException(e, "QColumnMenu.setExpandMode")}	}																																//------------------------------------------------------------------------------------------------------------------------	// Metodi privati	//------------------------------------------------------------------------------------------------------------------------	function onClickItem() {		//Effettua l'azione prevista al click di un item		//Se l'azione \u00E8 un indirizzo HTTP lo apre nel target indicato. Se il target \u00E8 diverso da "_self" e "_blank",		//assume che si tratti dell'id di un iframe.		//Se l'azione \u00E8 una funzione JS, la esegue		try {			var action = this.action			var target = this.target						if (action.substring(0, 11).toLowerCase() == "javascript:") {				//Valuta una funzione javascript				eval(action.substring(11))			}			else {				//Apre l'url al target indicato				switch (target.toLowerCase()) {					case "_blank":						window.open(action)						break					case "_self":						window.location.href = action						break					default:						var iframe = document.getElementById(target)						if (iframe) iframe.src = action						break				}			}		}		catch(e) {QException(e, "QColumnMenu.onClickItem")}	}	//------------------------------------------------------------------------------------------------------------------------	function onClickMenu() {		try {			var mode = this.parentNode.mode			var submenu						if (mode == "one") {				//Espande o comprime il menu cliccato chiudendo gli altri dello stesso livello.				var nodes = this.parentNode.childNodes				if (nodes) {					for (var i = 0; i < nodes.length; i++) {						if (nodes[i].menuId) {							submenu = document.getElementById(nodes[i].menuId)							if (submenu.id == this.menuId) {								if (submenu.style.display == "none") submenu.style.display = "block"								else submenu.style.display = "none"							}							else submenu.style.display = "none"						}					}				}			}			else {				//Espande o comprime il solo menu cliccato incurante degli altri.				var submenu = document.getElementById(this.menuId)				if (submenu) {					if (submenu.style.display == "none") submenu.style.display = "block"					else submenu.style.display = "none"				}			}		}		catch(e) {QException(e, "QColumnMenu.onClickMenu")}	}		//------------------------------------------------------------------------------------------------------------------------	function onMouseOverItem() {		try {			this.className = that.CSSRollover		}		catch(e) {QException(e, "QColumnMenu.onMouseOverItem")}	}		//------------------------------------------------------------------------------------------------------------------------	function onMouseOutItem() {		try {			this.className = that.CSSItem		}		catch(e) {QException(e, "QColumnMenu.onMouseOutItem")}	}}