
function AssoloMultiMenu(id,myConfigs,myItems) 
{
	this.DEBUG = false;
	this.Configs = {
		DeltaMenu : 0,
		IsVertical: false,
		ImgL1LineaI: "", 
		ImgL1LineaM: "", 
		ImgL1LineaF: "",
		ImgL2LineaI: "", 
		ImgL2LineaM: "", 
		ImgL2LineaF: "",
		ImgL3LineaI: "", 
		ImgL3LineaM: "", 
		ImgL3LineaF: "",
		maindiv_L1 : "",
		maindiv_L2 : "",
		maindiv_L3 : "",
		maintab_L1: "",
		maintab_L2: "",
		maintab_L3: "",
		CssL1Div : "",
		CssL1DivSel : "",
		CssL1DivOver : "",
		CssL2Div : "",
		CssL2DivSel : "",
		CssL2DivOver : "",
		CssL3Div: "",
		CssL3DivSel: "",
		CssL3DivOver: "",
		CssL1Tab : "",
		CssL2Tab : "",
		CssL3Tab : "",
		CssL1Link: "",
		CssL1LinkSel: "",
		CssL2Link: "",
		CssL2LinkSel: "",
		CssL3Link: "",
		CssL3LinkSel: "",
		L3_usa_L2: ""
    };
	/*if (this.DEBUG) {
        this._DEBUG_WINDOW = window.open("","DEBUG_WINDOW","scrollbars=1,menubar=1,resizable=1,width=350,height=250"); 
        this._DEBUG_WINDOW.document.body.innerHTML = "<br><br>PROGRAM STARTED <input type='button' value=' svuota ' onclick='document.getElementById(\"DEBUG\").innerHTML = \"\"'><br><br>\n<div id=\"DEBUG_COORD\"></div><div id=\"DEBUG\"></div>";
        this._DEBUG_WINDOW.document.documentElement.style.overflow = "scroll";        
	}*/

    this.DeltaLeft = 0;
    this.DeltaTop  = 0;
	
	if (myConfigs) {
		if (myConfigs.DeltaMenu) this.Configs.DeltaMenu  = myConfigs.DeltaMenu;
		if (myConfigs.IsVertical) this.Configs.IsVertical = myConfigs.IsVertical;
		if (myConfigs.ImgL1LineaI && (myConfigs.ImgL1LineaI != "%26nbsp%3B")) this.Configs.ImgL1LineaI = URLDecode(myConfigs.ImgL1LineaI);
		if (myConfigs.ImgL1LineaM && (myConfigs.ImgL1LineaM != "%26nbsp%3B")) this.Configs.ImgL1LineaM = URLDecode(myConfigs.ImgL1LineaM);
		if (myConfigs.ImgL1LineaF && (myConfigs.ImgL1LineaF != "%26nbsp%3B")) this.Configs.ImgL1LineaF = URLDecode(myConfigs.ImgL1LineaF);
		if (myConfigs.ImgL2LineaI && (myConfigs.ImgL2LineaI != "%26nbsp%3B")) this.Configs.ImgL2LineaI = URLDecode(myConfigs.ImgL2LineaI);
		if (myConfigs.ImgL2LineaM && (myConfigs.ImgL2LineaM != "%26nbsp%3B")) this.Configs.ImgL2LineaM = URLDecode(myConfigs.ImgL2LineaM);
		if (myConfigs.ImgL2LineaF && (myConfigs.ImgL2LineaF != "%26nbsp%3B")) this.Configs.ImgL2LineaF = URLDecode(myConfigs.ImgL2LineaF);
		if (myConfigs.ImgL3LineaI && (myConfigs.ImgL3LineaI != "%26nbsp%3B")) this.Configs.ImgL3LineaI = URLDecode(myConfigs.ImgL3LineaI);
		if (myConfigs.ImgL3LineaM && (myConfigs.ImgL3LineaM != "%26nbsp%3B")) this.Configs.ImgL3LineaM = URLDecode(myConfigs.ImgL3LineaM);
		if (myConfigs.ImgL3LineaF && (myConfigs.ImgL3LineaF != "%26nbsp%3B")) this.Configs.ImgL3LineaF = URLDecode(myConfigs.ImgL3LineaF);
		if (myConfigs.maindiv_L1) this.Configs.maindiv_L1 = myConfigs.maindiv_L1;
		if (myConfigs.maindiv_L2) this.Configs.maindiv_L2 = myConfigs.maindiv_L2;
		if (myConfigs.maindiv_L3) this.Configs.maindiv_L3 = myConfigs.maindiv_L3;
		if (myConfigs.maintab_L1) this.Configs.maintab_L1 = myConfigs.maintab_L1;
		if (myConfigs.maintab_L2) this.Configs.maintab_L2 = myConfigs.maintab_L2;
		if (myConfigs.maintab_L3) this.Configs.maintab_L3 = myConfigs.maintab_L3;
		if (myConfigs.CssL1Div) this.Configs.CssL1Div = myConfigs.CssL1Div;
		if (myConfigs.CssL2Div) this.Configs.CssL2Div = myConfigs.CssL2Div;
		if (myConfigs.CssL3Div) this.Configs.CssL3Div = myConfigs.CssL3Div;
		if (myConfigs.CssL1Tab) this.Configs.CssL1Tab = myConfigs.CssL1Tab;
		if (myConfigs.CssL2Tab) this.Configs.CssL2Tab = myConfigs.CssL2Tab;
		if (myConfigs.CssL3Tab) this.Configs.CssL3Tab = myConfigs.CssL3Tab;
		if (myConfigs.CssL1Link) this.Configs.CssL1Link = myConfigs.CssL1Link;
		if (myConfigs.CssL1LinkSel) this.Configs.CssL1LinkSel = myConfigs.CssL1LinkSel;
		if (myConfigs.CssL2Link) this.Configs.CssL2Link = myConfigs.CssL2Link;
		if (myConfigs.CssL2LinkSel) this.Configs.CssL2LinkSel = myConfigs.CssL2LinkSel;
		if (myConfigs.CssL3Link) this.Configs.CssL3Link = myConfigs.CssL3Link;
		if (myConfigs.CssL3LinkSel) this.Configs.CssL3LinkSel = myConfigs.CssL3LinkSel;
		if (myConfigs.L3_usa_L2) this.Configs.L3_usa_L2 = myConfigs.L3_usa_L2;
		if (myConfigs.CssL1DivSel) this.Configs.CssL1DivSel = myConfigs.CssL1DivSel;
		if (myConfigs.CssL2DivSel) this.Configs.CssL2DivSel = myConfigs.CssL2DivSel;
		if (myConfigs.CssL3DivSel) this.Configs.CssL3DivSel = myConfigs.CssL3DivSel;
		if (myConfigs.CssL1DivOver) this.Configs.CssL1DivOver = myConfigs.CssL1DivOver;
		if (myConfigs.CssL2DivOver) this.Configs.CssL2DivOver = myConfigs.CssL2DivOver;
		if (myConfigs.CssL3DivOver) this.Configs.CssL3DivOver = myConfigs.CssL3DivOver;
	}
    
	this.ItemsMenu = myItems;
	this.MenuDIVID  = id;
	this.MenuDIV = document.getElementById(id);
	if (this.Configs.maindiv_L1) {
		this.MenuDIV.className = this.Configs.maindiv_L1;
	}
	this.MakeMainMenu();
	
	var oSelf = this;
	function myCheckMultiMenu(ev)
	{
		oSelf.CheckMultiMenu(ev);
	}
	function myResize(ev)
	{
		oSelf.doResize(ev);
	}
	
	try {
		document.addEventListener('mousemove',myCheckMultiMenu,true);
	} catch(err) {
		document.attachEvent('onmousemove', myCheckMultiMenu);
	}
	try {
		window.addEventListener('resize',myResize,true);
	} catch(err) {
		window.attachEvent('onresize', myResize);
	}

    setTimeout( function(){ oSelf.doResize(); }, 10);
//    setTimeout( function(){ oSelf.OpenALL(); }, 5000);
}

AssoloMultiMenu.prototype.LookForItemClick = function(ItemsMenu, itemid)
{
	for (var i = 0; i < ItemsMenu.length; i++) {
		if (ItemsMenu[i].id == itemid) {
			if (ItemsMenu[i].GoToLink) {
				document.location = str_replace("&amp;", "&", URLDecode(ItemsMenu[i].GoToLink));				
			} else if (ItemsMenu[i].GoToJs) {
				var myJs = URLDecode(ItemsMenu[i].GoToJs);
				eval(myJs);
			}
			break;
		} else if (isdefined(ItemsMenu[i].SubMenu)) {
			this.LookForItemClick(ItemsMenu[i].SubMenu, itemid);
		}
	}
}

AssoloMultiMenu.prototype.HandleClick = function(itemid) 
{
	this.LookForItemClick(this.ItemsMenu, itemid);
}

AssoloMultiMenu.prototype.MakeMainMenu = function() 
{
	this.MenuTable   = document.createElement("table");
	this.MenuTable.border="0";
	this.MenuTable.cellPadding="0";
	this.MenuTable.cellSpacing="0";
	if (this.Configs.maintab_L1) {
		this.MenuTable.className = this.Configs.maintab_L1;
	}
	
	if (!this.Configs.IsVertical) {
		var MenuTableRow = this.MenuTable.insertRow(0);
	} else {
		var MenuTableRow;
	}

	var CurCell = null;
	var CurCellDiv = null;
	var CurLink = null;
	var oSelf = this;

	for (var i = 0; i < this.ItemsMenu.length; i++) {
		var CurId = "MultiMenu_item_"+this.MenuDIVID+"_"+i;
		this.ItemsMenu[i].id = CurId;

		if (!this.Configs.IsVertical) 
		{
			if (i == 0) {
				if (this.Configs.ImgL1LineaI) {
					CurCell = MenuTableRow.insertCell(-1);
					CurCell.innerHTML = this.Configs.ImgL1LineaI;
				}
			} else {
				if (this.Configs.ImgL1LineaM) {
					CurCell = MenuTableRow.insertCell(-1);
					CurCell.innerHTML = this.Configs.ImgL1LineaM;
				}
			}
			CurCell = MenuTableRow.insertCell(-1);
		}
		else 
		{
			if (i == 0) {
				if (this.Configs.ImgL1LineaI) {
					MenuTableRow = this.MenuTable.insertRow(-1);
					CurCell = MenuTableRow.insertCell(0);
					CurCell.innerHTML = this.Configs.ImgL1LineaI;
				}
			} else {
				if (this.Configs.ImgL1LineaM) {
					MenuTableRow = this.MenuTable.insertRow(-1);
					CurCell = MenuTableRow.insertCell(0);
					CurCell.innerHTML = this.Configs.ImgL1LineaM;
				}
			}
		
			MenuTableRow = this.MenuTable.insertRow(-1);
			CurCell = MenuTableRow.insertCell(0);
		}
		
		CurCellDiv = document.createElement("div");
		CurCellDiv.id = CurId;
		if (this.ItemsMenu[i].IsSelected) {
			CurCellDiv.className = this.Configs.CssL1DivSel;
			if (this.Configs.CssL1DivOver) {
				CurCellDiv.onmouseover = function () { this.className=oSelf.Configs.CssL1DivOver };
				CurCellDiv.onmouseout  = function () { this.className=oSelf.Configs.CssL1DivSel };
			}
		} else {
			CurCellDiv.className = this.Configs.CssL1Div;
			if (this.Configs.CssL1DivOver) {
				CurCellDiv.onmouseover = function () { this.className=oSelf.Configs.CssL1DivOver };
				CurCellDiv.onmouseout  = function () { this.className= oSelf.Configs.CssL1Div };
			}
		}
		
		if (this.ItemsMenu[i].GoToLink) {
		
			if (this.ItemsMenu[i].Icon) {
				CurCellDiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0' "+(this.Configs.CssL1Tab?"class='"+this.Configs.CssL1Tab+"'":"")+"><tr><td>"+this.ItemsMenu[i].Icon+"</td><td>"+
										"<a href=\""+str_replace("&amp;", "&", URLDecode(this.ItemsMenu[i].GoToLink))+"\" class=\""+(this.ItemsMenu[i].IsSelected?this.Configs.CssL1LinkSel:this.Configs.CssL1Link)+"\">"+URLDecode(this.ItemsMenu[i].Content)+"</a>"+
										"</td></tr></table>";
			} else {
				CurCellDiv.innerHTML = "<a href=\""+str_replace("&amp;", "&", URLDecode(this.ItemsMenu[i].GoToLink))+"\" class=\""+(this.ItemsMenu[i].IsSelected?this.Configs.CssL1LinkSel:this.Configs.CssL1Link)+"\">"+URLDecode(this.ItemsMenu[i].Content)+"</a>";
			}
		} else {
			if (this.ItemsMenu[i].Icon) {
				CurCellDiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0' "+(this.Configs.CssL1Tab?"class='"+this.Configs.CssL1Tab+"'":"")+"><tr><td>"+this.ItemsMenu[i].Icon+"</td><td>"+
										URLDecode(this.ItemsMenu[i].Content)+
										"</td></tr></table>";
			} else {
				CurCellDiv.innerHTML = URLDecode(this.ItemsMenu[i].Content);
			}
		}
		CurCellDiv.onclick = function() { oSelf.HandleClick(this.id) }
		CurCellDiv.style.cursor = "pointer";
		CurCell.appendChild(CurCellDiv);
		
		if (!this.Configs.IsVertical) 
		{
			if (i == (this.ItemsMenu.length-1)) {
				if (this.Configs.ImgL1LineaF) {
					CurCell = MenuTableRow.insertCell(-1);
					CurCell.innerHTML = this.Configs.ImgL1LineaF;
				}
			}
		}
		else 
		{
			if (i == (this.ItemsMenu.length-1)) {
				if (this.Configs.ImgL1LineaF) {
					MenuTableRow = this.MenuTable.insertRow(-1);
					CurCell = MenuTableRow.insertCell(0);
					CurCell.innerHTML = this.Configs.ImgL1LineaF;
				}
			}
		}		
	}

	this.MenuDIV.appendChild(this.MenuTable);

	for (var i = 0; i < this.ItemsMenu.length; i++) 
	{
		var CurId = "MultiMenu_item_"+this.MenuDIVID+"_"+i;
	
		if (isdefined(this.ItemsMenu[i].SubMenu)) {
			var Box = GetXYWH(document.getElementById(this.ItemsMenu[i].id));
			this.ItemsMenu[i].titleLeft   = Box[0] + this.DeltaLeft;
			this.ItemsMenu[i].titleRight  = Box[0]+Box[2];
			this.ItemsMenu[i].titleTop    = Box[1] + this.DeltaTop;
			this.ItemsMenu[i].titleBottom = Box[1]+Box[3];

            //this.AddDebug("MakeMainMenu["+this.ItemsMenu[i].id+"]=("+this.ItemsMenu[i].titleLeft+";"+this.ItemsMenu[i].titleRight+";"+this.ItemsMenu[i].titleTop+";"+this.ItemsMenu[i].titleBottom+")", false);
            
			this.MakeSubMenu(this.ItemsMenu[i], CurId, Box, !this.Configs.IsVertical, 2);
		} else {
			var Box = GetXYWH(document.getElementById(CurId));
			this.ItemsMenu[i].titleLeft   = Box[0] + this.DeltaLeft;
			this.ItemsMenu[i].titleRight  = Box[0]+Box[2];
			this.ItemsMenu[i].titleTop    = Box[1] + this.DeltaTop;
			this.ItemsMenu[i].titleBottom = Box[1]+Box[3];
            //this.AddDebug("MakeMainMenu["+this.ItemsMenu[i].id+"]=("+this.ItemsMenu[i].titleLeft+";"+this.ItemsMenu[i].titleRight+";"+this.ItemsMenu[i].titleTop+";"+this.ItemsMenu[i].titleBottom+")", false);
		}
	}
}

AssoloMultiMenu.prototype.MakeSubMenu = function(CurMenu, myCurId, Box, IsSotto, Level) 
{
	CurMenu.id 		  = myCurId;

	CurMenu.SubMenuDiv = document.createElement("div");

	if ((this.Configs.L3_usa_L2 == "1") || (Level == 2)) {
		if (this.Configs.maindiv_L2) {
			CurMenu.SubMenuDiv.className = this.Configs.maindiv_L2;
		}
	} else {
		if (this.Configs.maindiv_L3) {
			CurMenu.SubMenuDiv.className = this.Configs.maindiv_L3;
		}
	}
	
	CurMenu.SubMenuDiv.style.position = "absolute";
    CurMenu.SubMenuDiv.style.visibility="hidden";

	if (IsSotto) {
		CurMenu.SubMenuDiv.style.left = Box[0]+"px";
		CurMenu.SubMenuDiv.style.top  = (Box[1]+Box[3]-this.Configs.DeltaMenu)+"px";
	} else {
		CurMenu.SubMenuDiv.style.left = (Box[0]+Box[2]-this.Configs.DeltaMenu)+"px";
		CurMenu.SubMenuDiv.style.top  = Box[1]+"px";
	}
	
	CurMenu.SubMenuTable = document.createElement("table");
	CurMenu.SubMenuTable.border="0";
	CurMenu.SubMenuTable.cellPadding="0";
	CurMenu.SubMenuTable.cellSpacing="0";
	
	if ((this.Configs.L3_usa_L2 == "1") || (Level == 2)) {
		if (this.Configs.maintab_L2) {
			CurMenu.SubMenuTable.className = this.Configs.maintab_L2;
		}
	} else {
		if (this.Configs.maintab_L3) {
			CurMenu.SubMenuTable.className = this.Configs.maintab_L3;
		}
 	}

	var oSelf = this;
	var ImgLineaI;
	var ImgLineaM;
	var ImgLineaF;

	for (var i = 0; i < CurMenu.SubMenu.length; i++) 
	{
	
		if ((this.Configs.L3_usa_L2 == "1") || (Level == 2)) {
			ImgLineaI = this.Configs.ImgL2LineaI;
			ImgLineaM = this.Configs.ImgL2LineaM;
			ImgLineaF = this.Configs.ImgL2LineaF;
		} else {
			ImgLineaI = this.Configs.ImgL3LineaI;
			ImgLineaM = this.Configs.ImgL3LineaM;
			ImgLineaF = this.Configs.ImgL3LineaF;
		}
	
		var CurId = myCurId+"_"+i;
		CurMenu.SubMenu[i].id = CurId;

		if (i == 0) {
			if (ImgLineaI) {
				var CurRow = CurMenu.SubMenuTable.insertRow(-1);
				var CurCell = CurRow.insertCell(0);
				CurCell.innerHTML = ImgLineaI;
			}
		} else {
			if (ImgLineaM) {
				var CurRow = CurMenu.SubMenuTable.insertRow(-1);
				var CurCell = CurRow.insertCell(0);
				CurCell.innerHTML = ImgLineaM;
			}
		}
		
		var CurRow = CurMenu.SubMenuTable.insertRow(-1);
		var CurCell = CurRow.insertCell(0);
		
		CurCellDiv = document.createElement("div");
		CurCellDiv.id = CurId;
		
		if ((this.Configs.L3_usa_L2 == "1") || (Level == 2)) {
			if (CurMenu.SubMenu[i].IsSelected) {
				CurCellDiv.className = this.Configs.CssL2DivSel;
				if (this.Configs.CssL2DivOver) {
					CurCellDiv.onmouseover = function () { this.className=oSelf.Configs.CssL2DivOver };
					CurCellDiv.onmouseout  = function () { this.className=oSelf.Configs.CssL2DivSel };
				}
			} else {
				CurCellDiv.className = this.Configs.CssL2Div;
				if (this.Configs.CssL2DivOver) {
					CurCellDiv.onmouseover = function () { this.className=oSelf.Configs.CssL2DivOver };
					CurCellDiv.onmouseout  = function () { this.className=oSelf.Configs.CssL2Div };
				}
			}
		} else {
			if (CurMenu.SubMenu[i].IsSelected) {
				CurCellDiv.className = this.Configs.CssL3DivSel;
				if (this.Configs.CssL3DivOver) {
					CurCellDiv.onmouseover = function () { this.className=oSelf.Configs.CssL3DivOver };
					CurCellDiv.onmouseout  = function () { this.className=oSelf.Configs.CssL3DivSel };
				}
			} else {
				CurCellDiv.className = this.Configs.CssL3Div;
				if (this.Configs.CssL3DivOver) {
					CurCellDiv.onmouseover = function () { this.className=oSelf.Configs.CssL3DivOver };
					CurCellDiv.onmouseout  = function () { this.className=oSelf.Configs.CssL3Div };
				}
			}
		}
		
		if ((this.Configs.L3_usa_L2 == "1") || (Level == 2)) {
			if (CurMenu.SubMenu[i].GoToLink) {
				if (CurMenu.SubMenu[i].Icon) {
					CurCellDiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0' "+(this.Configs.CssL2Tab?"class='"+this.Configs.CssL2Tab+"'":"")+"><tr><td>"+CurMenu.SubMenu[i].Icon+"</td><td>"+
											"<a href=\""+str_replace("&amp;", "&", URLDecode(CurMenu.SubMenu[i].GoToLink))+"\" class=\""+(CurMenu.SubMenu[i].IsSelected?this.Configs.CssL2LinkSel:this.Configs.CssL2Link)+"\">"+URLDecode(CurMenu.SubMenu[i].Content)+"</a>"+
											"</td></tr></table>";
				} else {
					CurCellDiv.innerHTML = "<a href=\""+str_replace("&amp;", "&", URLDecode(CurMenu.SubMenu[i].GoToLink))+"\" class=\""+(CurMenu.SubMenu[i].IsSelected?this.Configs.CssL2LinkSel:this.Configs.CssL2Link)+"\">"+URLDecode(CurMenu.SubMenu[i].Content)+"</a>";
				}
			} else {
				if (CurMenu.SubMenu[i].Icon) {
					CurCellDiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0' "+(this.Configs.CssL2Tab?"class='"+this.Configs.CssL2Tab+"'":"")+"><tr><td>"+CurMenu.SubMenu[i].Icon+"</td><td>"+
											URLDecode(CurMenu.SubMenu[i].Content)+
											"</td></tr></table>";
				} else {
					CurCellDiv.innerHTML = URLDecode(CurMenu.SubMenu[i].Content);
				}
			}
			CurCellDiv.onclick = function() { oSelf.HandleClick(this.id) }
			CurCellDiv.style.cursor = "pointer";
		} else {
			if (CurMenu.SubMenu[i].GoToLink) {
				if (CurMenu.SubMenu[i].Icon) {
					CurCellDiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0' "+(this.Configs.CssL3Tab?"class='"+this.Configs.CssL3Tab+"'":"")+"><tr><td>"+CurMenu.SubMenu[i].Icon+"</td><td>"+
											"<a href=\""+str_replace("&amp;", "&", URLDecode(CurMenu.SubMenu[i].GoToLink))+"\" class=\""+(CurMenu.SubMenu[i].IsSelected?this.Configs.CssL3LinkSel:this.Configs.CssL3Link)+"\">"+URLDecode(CurMenu.SubMenu[i].Content)+"</a>"+
											"</td></tr></table>";
				} else {
					CurCellDiv.innerHTML = "<a href=\""+str_replace("&amp;", "&", URLDecode(CurMenu.SubMenu[i].GoToLink))+"\" class=\""+(CurMenu.SubMenu[i].IsSelected?this.Configs.CssL3LinkSel:this.Configs.CssL3Link)+"\">"+URLDecode(CurMenu.SubMenu[i].Content)+"</a>";
				}
			} else {
				if (CurMenu.SubMenu[i].Icon) {
					CurCellDiv.innerHTML = "<table border='0' cellpadding='0' cellspacing='0' "+(this.Configs.CssL3Tab?"class='"+this.Configs.CssL3Tab+"'":"")+"><tr><td>"+CurMenu.SubMenu[i].Icon+"</td><td>"+
											URLDecode(CurMenu.SubMenu[i].Content)+
											"</td></tr></table>";
				} else {
					CurCellDiv.innerHTML = URLDecode(CurMenu.SubMenu[i].Content);
				}
			}
			CurCellDiv.onclick = function() { oSelf.HandleClick(this.id) }
			CurCellDiv.style.cursor = "pointer";
		}

		CurCell.appendChild(CurCellDiv);
		
		if (i == (CurMenu.SubMenu.length-1)) {
			if (ImgLineaF) {
				var CurRow = CurMenu.SubMenuTable.insertRow(-1);
				var CurCell = CurRow.insertCell(0);
				CurCell.innerHTML = ImgLineaF;
			}
		}		
	}
	
	CurMenu.SubMenuDiv.appendChild(CurMenu.SubMenuTable);
	document.body.appendChild(CurMenu.SubMenuDiv);
	
	var Box = GetXYWH(CurMenu.SubMenuDiv.firstChild);
	CurMenu.SubMenuDiv.style.width  = parseInt(Box[2])+"px";
	CurMenu.SubMenuDiv.style.height = parseInt(Box[3])+"px";
	CurMenu.boxLeft   = Box[0] + this.DeltaLeft;
	CurMenu.boxRight  = Box[0]+Box[2];
	CurMenu.boxTop    = Box[1] + this.DeltaTop;
	CurMenu.boxBottom = Box[1]+Box[3];

	for (var i = 0; i < CurMenu.SubMenu.length; i++) 
	{
		var Box = GetXYWH(document.getElementById(CurMenu.SubMenu[i].id));

		CurMenu.SubMenu[i].titleLeft   = Box[0] + this.DeltaLeft;
		CurMenu.SubMenu[i].titleRight  = Box[0]+Box[2];
		CurMenu.SubMenu[i].titleTop    = Box[1] + this.DeltaTop;
		CurMenu.SubMenu[i].titleBottom = Box[1]+Box[3];

		//this.AddDebug("MakeSubMenu["+CurMenu.SubMenu[i].id+"]=("+CurMenu.SubMenu[i].titleLeft+";"+CurMenu.SubMenu[i].titleRight+";"+CurMenu.SubMenu[i].titleTop+";"+CurMenu.SubMenu[i].titleBottom+")", false);
			
		if (isdefined(CurMenu.SubMenu[i].SubMenu)) {
			var CurId = myCurId+"_"+i;
			this.MakeSubMenu(CurMenu.SubMenu[i], CurId, Box, false, Level+1);
		}	
	}
	//if (!this.DEBUG) {
		setTimeout( function(){ oSelf.OpenMenu(""); }, 10);
	//}
}

AssoloMultiMenu.prototype.AddDebug = function(txt, clearIt)
{
	if (this.DEBUG) {
        if (this._DEBUG_WINDOW) {
            var d = this._DEBUG_WINDOW.document;
            if (d) {
                var my_date = new Date();
                dateStr = ""+my_date.getFullYear()+"."+(my_date.getMonth()+1)+"."+my_date.getDate() +" "+my_date.getHours() +":"+my_date.getMinutes() +"."+my_date.getSeconds() +","+my_date.getMilliseconds();
                if (clearIt) {
                    d.getElementById("DEBUG").innerHTML = "";
                }
                d.getElementById("DEBUG").appendChild(d.createElement("br"));
                d.getElementById("DEBUG").appendChild(d.createTextNode(' - '+dateStr+": "+txt+'\n'));
            }
        }
	}
}

AssoloMultiMenu.prototype.AddDebugMOUSE = function(mousex,mousey)
{
	if (this.DEBUG) {
        if (this._DEBUG_WINDOW) {
            var d = this._DEBUG_WINDOW.document;
            if (d) {
                d.getElementById("DEBUG_COORD").innerHTML = "("+mousex+";"+mousey+")";
            }
        }
	}
}

AssoloMultiMenu.prototype.CheckMultiMenu = function(evt)
{
	var myWidth, 
		myHeight,
		deltaW = 0,
		deltaH = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {	//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myWidth += (document.body.scrollLeft + document.documentElement.scrollLeft);
		myHeight += (document.body.scrollTop + document.documentElement.scrollTop);
		deltaW = 0;
		deltaH = 0;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		myWidth += (document.body.scrollLeft + document.documentElement.scrollLeft);
		myHeight += (document.body.scrollTop + document.documentElement.scrollTop);
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		myWidth += (document.body.scrollLeft + document.documentElement.scrollLeft);
		myHeight += (document.body.scrollTop + document.documentElement.scrollTop);
	} else {
		myWidth = 0;
		myHeight = 0;
	}

	ev = evt || window.event;

	if (ev.pageX || ev.pageY) {
	  mousex = ev.pageX;
	  mousey = ev.pageY;
	} else if (ev.clientX || ev.clientY) {
	  mousex = ev.clientX;
	  mousey = ev.clientY;
      mousex += (document.body.scrollLeft + document.documentElement.scrollLeft);
      mousey += (document.body.scrollTop + document.documentElement.scrollTop);
	}
	
	this.AddDebugMOUSE(mousex,mousey);

	var idx = "";
	for (var i = 0; i < this.ItemsMenu.length; i++) 
	{
		if ((this.ItemsMenu[i].titleLeft || this.ItemsMenu[i].titleRight) && (this.ItemsMenu[i].titleTop || this.ItemsMenu[i].titleBottom)) {
			if ( (mousex > this.ItemsMenu[i].titleLeft) && (mousex < this.ItemsMenu[i].titleRight) && (mousey > this.ItemsMenu[i].titleTop) && (mousey < this.ItemsMenu[i].titleBottom) ) {
				idx = this.ItemsMenu[i].id;
			}
		}

		if (idx != "") {
            this.AddDebug("AAA CheckMultiMenu["+idx+"]", false);
			break;
		}
	
		if (isdefined(this.ItemsMenu[i].SubMenu)) {
			idx = this.CheckMultiMenuRec(mousex, mousey, this.ItemsMenu[i]);
			if (idx != "") {
				break;
			}
		}
	}

    /*if (idx != "") {
        this.AddDebug("CCC CheckMultiMenu["+idx+"]", false);
    }*/
    
	this.OpenMenu(idx);
}

AssoloMultiMenu.prototype.CheckMultiMenuRec = function(mousex, mousey, CurItem)
{
	var idx = ""; 
	
	if ((CurItem.titleLeft || CurItem.titleRight) && (CurItem.titleTop || CurItem.titleBottom)) {
		if ( (mousex >= CurItem.titleLeft) && (mousex <= CurItem.titleRight) && (mousey >= CurItem.titleTop) && (mousey <= CurItem.titleBottom) ) {
			idx = CurItem.id;
		}
	}

	if (idx == "") {
		if (CurItem.SubMenuDiv) {
			if (CurItem.SubMenuDiv.style.visibility=="visible") {
				if (isdefined(CurItem.SubMenu)) {
					for (var i = 0; i < CurItem.SubMenu.length; i++) {
						idx = this.CheckMultiMenuRec(mousex, mousey, CurItem.SubMenu[i]);
						if (idx != "") {
                            //this.AddDebug("CCC CheckMultiMenu["+idx+"]", false);
							break;
						}
					}
				}
				if (idx == "") {
					if ((CurItem.boxLeft || CurItem.boxRight) && (CurItem.boxTop || CurItem.boxBottom)) {
						if ( (mousex >= CurItem.boxLeft) && (mousex <= CurItem.boxRight) && (mousey >= CurItem.boxTop) && (mousey <= CurItem.boxBottom) ) {
							idx = CurItem.id;
                            if (idx!="") {
                                this.AddDebug("DDD CheckMultiMenu["+idx+"]["+CurItem.boxLeft+"]["+CurItem.boxRight+"]["+CurItem.boxTop +"]["+CurItem.boxBottom+"]["+mousex +"]["+mousey+"]", false);
                            }
						}
					}
				}
			}
		}
	} else {
        this.AddDebug("BBB CheckMultiMenu["+idx+"]", false);
    }
	
	return idx;
}

AssoloMultiMenu.prototype.OpenMenuRec = function(ItemsMenu, itemid, isInline)
{
   var myWidth, myHeight;
	
	if( typeof( window.innerWidth ) == 'number' ) {	//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myWidth += (document.body.scrollLeft + document.documentElement.scrollLeft);
		myHeight += (document.body.scrollTop + document.documentElement.scrollTop);
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		myWidth += (document.body.scrollLeft + document.documentElement.scrollLeft);
		myHeight += (document.body.scrollTop + document.documentElement.scrollTop);
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	} else {
		myWidth = 0;
		myHeight = 0;
	}

	for (var i = 0; i < ItemsMenu.length; i++) 
	{
		if (itemid == "") {
			isParentOf = -1;
			isChildOf = -1;
			isItself = false;
		} else if (itemid == ItemsMenu[i].id) {
			isParentOf = 1;
			isChildOf = 1;
			isItself = true;
		} else {
			isItself = false;		
			isParentOf = strpos(ItemsMenu[i].id, itemid);
			isChildOf = strpos(itemid, ItemsMenu[i].id);
		}

		if ((!isInline) || ((isParentOf === -1) && (isChildOf === -1))) {
			curDisplay = "hidden";
			curInline = false;
			curItemid = itemid;
		} else {
			curDisplay = "visible";
			curInline = true;
			curItemid = itemid;
		}

		if (isdefined(ItemsMenu[i].SubMenuDiv)) {
			ItemsMenu[i].SubMenuDiv.style.visibility = curDisplay;
            if (curDisplay == "visible") {
                ItemsMenu[i].SubMenuDiv.style.zIndex = getMaxZIndex(document.body, ItemsMenu[i].SubMenuDiv)+1;
            }            
		}
        
		if (isdefined(ItemsMenu[i].SubMenu)) {
			if ((!curInline) || (ItemsMenu[i].id != itemid)) {
				this.OpenMenuRec(ItemsMenu[i].SubMenu, curItemid, curInline);
			}
		}
	}
}

AssoloMultiMenu.prototype.OpenMenu = function(itemid) 
{
	this.OpenMenuRec(this.ItemsMenu, itemid, true);
}

AssoloMultiMenu.prototype.doResize = function(evt)
{
	var myWidth, 
		myHeight,
		deltaW = 0,
		deltaH = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {	//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myWidth += (document.body.scrollLeft + document.documentElement.scrollLeft);
		myHeight += (document.body.scrollTop + document.documentElement.scrollTop);
		deltaW = 0;
		deltaH = 0;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		myWidth += (document.body.scrollLeft + document.documentElement.scrollLeft);
		myHeight += (document.body.scrollTop + document.documentElement.scrollTop);
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	} else {
		myWidth = 0;
		myHeight = 0;
	}

    var Box = GetXYWH(this.MenuDIV);
    this.DeltaLeft=Box[0]-this.DeltaLeft;
	this.doResizeRec(this.ItemsMenu);
}


AssoloMultiMenu.prototype.doResizeRec = function(ItemsMenu)
{
    for (var i = 0; i < ItemsMenu.length; i++) 
    {
		if (isdefined(ItemsMenu[i].SubMenu)) 
        {
            var Box = GetXYWH(ItemsMenu[i].SubMenuDiv.firstChild);
            ItemsMenu[i].boxLeft   = Box[0] + this.DeltaLeft;
            ItemsMenu[i].boxRight  = Box[0]+Box[2];
            ItemsMenu[i].boxTop    = Box[1] + this.DeltaTop;
            ItemsMenu[i].boxBottom = Box[1]+Box[3];

			var Box = GetXYWH(document.getElementById(ItemsMenu[i].id));

            if (ItemsMenu == this.ItemsMenu) {
                if (this.Configs.IsVertical) {
                    ItemsMenu[i].titleLeft   = Box[0];
                    ItemsMenu[i].titleRight  = Box[0]+Box[2];
                    ItemsMenu[i].titleTop    = Box[1];
                    ItemsMenu[i].titleBottom = Box[1]+Box[3];

                    ItemsMenu[i].SubMenuDiv.style.left = (Box[0]+Box[2])+"px";
                    ItemsMenu[i].SubMenuDiv.style.top  = (Box[1] - this.Configs.DeltaMenu + this.DeltaTop)+"px";
                } else {
                    ItemsMenu[i].titleLeft   = Box[0];
                    ItemsMenu[i].titleRight  = Box[0]+Box[2];
                    ItemsMenu[i].titleTop    = Box[1];
                    ItemsMenu[i].titleBottom = Box[1]+Box[3];

                    ItemsMenu[i].SubMenuDiv.style.left = (Box[0])+"px";
                    ItemsMenu[i].SubMenuDiv.style.top  = (Box[1] + Box[3] - this.Configs.DeltaMenu + this.DeltaTop)+"px";
                }
            } else {
                ItemsMenu[i].titleLeft   = Box[0];
                ItemsMenu[i].titleRight  = Box[0]+Box[2];
                ItemsMenu[i].titleTop    = Box[1];
                ItemsMenu[i].titleBottom = Box[1]+Box[3];

                ItemsMenu[i].SubMenuDiv.style.left = (Box[0]+Box[2])+"px";
                ItemsMenu[i].SubMenuDiv.style.top  = (Box[1] - this.Configs.DeltaMenu + this.DeltaTop)+"px";
            }

            //this.AddDebug("doResizeRec["+ItemsMenu[i].id+"]=("+ItemsMenu[i].titleLeft+";"+ItemsMenu[i].titleRight+";"+ItemsMenu[i].titleTop+";"+ItemsMenu[i].titleBottom+")", false);
            this.doResizeRec(ItemsMenu[i].SubMenu, Box);
        } else {
			var Box = GetXYWH(document.getElementById(ItemsMenu[i].id));
			ItemsMenu[i].titleLeft   = Box[0];
			ItemsMenu[i].titleRight  = Box[0]+Box[2];
			ItemsMenu[i].titleTop    = Box[1];
			ItemsMenu[i].titleBottom = Box[1]+Box[3];
            //this.AddDebug("doResizeRec["+ItemsMenu[i].id+"]=("+ItemsMenu[i].titleLeft+";"+ItemsMenu[i].titleRight+";"+ItemsMenu[i].titleTop+";"+ItemsMenu[i].titleBottom+")", false);
		}
	}
}

AssoloMultiMenu.prototype.OpenALL = function() 
{
	this.OpenMenuALL(this.ItemsMenu);
}

AssoloMultiMenu.prototype.OpenMenuALL = function(ItemsMenu)
{
	for (var i = 0; i < ItemsMenu.length; i++) {
		if (isdefined(ItemsMenu[i].SubMenuDiv)) {
			ItemsMenu[i].SubMenuDiv.style.visibility = "visible";
            ItemsMenu[i].SubMenuDiv.style.zIndex = getMaxZIndex(document.body, ItemsMenu[i].SubMenuDiv)+1;
		}
		if (isdefined(ItemsMenu[i].SubMenu)) {
            this.OpenMenuALL(ItemsMenu[i].SubMenu);
		}
	}
}

