					var heights = Array();
					var menuIsExpanding = false;

					function buildMenuCollapse(id)
					{
						for(x=1;x<=7;x++)
						{
							if(document.getElementById("submenu"+x))
							{
								if(x!=id)
								{
									object = document.getElementById("submenu"+x);
									if(object.style.height!="auto") oldheight = object.style.height.replace("px",""); else oldheight = heights[x];
									newheight = ((oldheight * 1) - 10);
									if(newheight < 0)
									{
										object.style.display = "none";
										menuIsExpanding = false;
									}
									else
									{
										object.style.height = newheight + "px";
										setTimeout(function(){buildMenuCollapse(id)},30);
									}

								}
							}
						}
					}

					function buildMenuExpand(object)
					{
						id = object.id.replace("submenu", "");
						object.style.overflow = "hidden";
						object.style.display = "block";
						if(object.style.height) oldheight = object.style.height.replace("px",""); else oldheight = 0;
						newheight = ((oldheight * 1) + 10);
						if(newheight > heights[id]-10)
						{
							newheight = heights[id];
							object.style.height = "auto";
							buildMenuCollapse(id);
						}
						else
						{
							object.style.height = newheight + "px";
							setTimeout(function(){buildMenuExpand(object)},30);
						}
					}
					
					function buildMenu(openid)
					{
						// chiudo tutti i menu

						for(x=1;x<=7;x++)
						{
							if(document.getElementById("submenu"+x))
							{
								heights[x]=document.getElementById("submenu"+x).offsetHeight;
								if(openid!=x)
									document.getElementById("submenu"+x).style.display="none";
							}
						}
						
						//assegno eventi
						for(x=1;x<=7;x++)
						{
							document.getElementById("menu"+x).onclick = function()
							{
								if(menuIsExpanding == false)
								{
									menuIsExpanding = true;
									x = this.id.replace("menu", "");
									if(document.getElementById("submenu"+x))
									{
										if(document.getElementById("submenu"+x).style.display != "block")
										{
											buildMenuExpand(document.getElementById("submenu"+x));
										}
										else
											buildMenuCollapse();
									}
								}
							}
						}
					}
					