	var menuIds = [];
	var currentMenuId;
	var menus = [];
	function makeMenu(menuId, submenus){
			menus.push([menuId, submenus]);
	}
	function initMenu(){
		for (var i=0; i < menus.length; i++){
			if(menus[i][1]){
				makeMenu2(menus[i][0], menus[i][1]);
			}
		}
	}
	function makeMenu2(menuId, submenus){
		toWrite = "";
		menuIdx = menuId.split("_");
		var menuObj = document.getElementById(menuId);
		if (!menuObj){
			return false;
		}
		menuObj.onmouseover = doOpenSub;
		menuObj.onmouseout = doCloseSub;
		pos = getPositions(menuObj);
		pos[1] += menuObj.offsetHeight + 2;
		pos[0] -= 10;
		thisId = "mainmenusubid_" + menuIdx[1];
		toWrite += "<div id='" + thisId + "' style='background-color:#eeeeee; background-color:#ffffff; position:absolute; top:" + pos[1] + "px; left:" + pos[0] + "px; overflow:hidden'>";
		toWrite += "<div id='sub' style=''>";
		toWrite += "<div id='subsub' style=''>";
		for (i = 0; i < submenus.length; i++){
			submenuName = submenus[i][0];
			submenuUrl  = submenus[i][1];
			submenuImg  = submenus[i][2];
			toWrite += "    <div style='background-color:#eeeeee; height:25px; padding-left:5px; font-weight:bold; padding-right:5px; padding-top:6px; text-align:left; cursor:pointer; width:150px; color:#6d6e71' onClick='window.location=\"" + submenuUrl + "\"' onMouseOver='this.style.backgroundColor=\"#ffffff\"' onMouseOut='this.style.backgroundColor=\"#eeeeee\"' >\n";
			toWrite += "      " + submenuName + "<br />\n";
			toWrite += "    </div>\n";
		}
		toWrite += "	</div>\n";
		toWrite += "	</div>\n";
		toWrite += "</div>\n";
		d = document.createElement("div");
		d.innerHTML = toWrite
		document.body.appendChild(d);
		thisObj = document.getElementById(thisId);
		thisObj.oh = thisObj.offsetHeight - 12;
		thisObj.ow = thisObj.firstChild.offsetWidth;
		thisObj.h = 0;
		thisObj.w = 0;
		thisObj.o = 0;
		
		thisObj.wait = 0;
		thisObj.style.display = 'none';
		thisObj.style.height = '1px';
		//thisObj.style.width = '1px';
		menuObj.subMenu = thisObj;

		menuObj.appendChild(thisObj);
		//thisObj.style.width = thisObj.firstChild.offsetWidth + "px";
		//thisObj.style.height = "1px";
		menuIds.push(menuObj);
		updatePosition(menuObj);
	}
	function doOpenSub(){
		if (currentMenuId != this.id){
			for (i=0; i < menuIds.length; i++){
				obj = menuIds[i];
				objs = obj.subMenu;
				objs.wait = 0;
			}
		}
		currentMenuId = this.id;
	}
	function doCloseSub(){
		if (currentMenuId == this.id){
			currentMenuId = 0;
		}
	}
	window.onresize = updatePositions;
	function updatePositions(){
		for (var i = 0; i < menuIds.length; i++){
				updatePosition(menuIds[i]);
		}
	}
	function updatePosition(obj){
		pos = getPositions(obj);
		pos[1] += obj.offsetHeight + 2;
		pos[0] -= 0;
		obj.pos = pos;
	}
	function doLoop(){
		for (i=0; i < menuIds.length; i++){
			obj = menuIds[i];
			objs = obj.subMenu;
			objs.style.left = obj.pos[0];
			objs.style.top= obj.pos[1];
			if (currentMenuId == obj.id){
				objs.style.display = 'block';
				hh = objs.oh + 12;
				ww = objs.ow;
				beforeh = objs.h;
				difh = (hh - objs.h) * 0.18;;
				difha = Math.abs(difh);
				if (difha <= 0.1){
					objs.wait = 50;
					objs.h = hh;
					objs.w = ww;
				} else {
					if (difha < 0.5){
						if (difha > 0){
							difha = 0.5;
						} else {
							difha = -0.5;
						}
					}
					objs.h += difh
					objs.w += (ww - objs.w) * 0.18;
				}
				objs.o += (95 - objs.o) * 0.18;
				if(objs.filters){
					objs.style.filter = 'alpha(opacity=' + objs.o + ')';
				} else {
					if (document.op){
						objs.style.opacity = objs.o / 100;
					} else {
						objs.style.MozOpacity = objs.o / 100;
					}
				}
				objs.firstChild.style.position = "relative";
				objs.firstChild.style.top = (objs.h - hh) + "px";
				objs.style.height = objs.h + "px";
				//objs.style.width = objs.w + "px";
			} else {
				if (objs.wait > 0){
					objs.wait--;
				} else {
					if (objs.h > 1){
						objs.o += (0 - objs.o) * 0.18;
						hh = objs.oh;
						ww = objs.ow;
						hh = 1;
						ww = 1;
						objs.h += (hh - objs.h) * 0.18;
						objs.w += (ww - objs.w) * 0.18;
						objs.firstChild.style.top = (objs.h - objs.oh) + "px";
						objs.style.height = objs.h + "px";
						//objs.style.width = objs.w + "px";
						if(objs.filters){
							objs.style.filter = 'alpha(opacity=' + objs.o + ')';
						} else {
							if (document.op){
								objs.style.opacity = objs.o / 100;
							} else {
								objs.style.MozOpacity = objs.o / 100;
							}
						}
						
						if (objs.h > 0 && objs.h < 2){
							objs.h = 1;
							objs.style.display = 'none';
						}
					}					
				}
			}
		}
	}
	setInterval("doLoop()", 10);
	function getPositions(obj){
		var el = obj;
		var pL = 0;
		while(el){
			pL+=el.offsetLeft;
			el=el.offsetParent;
		}
		var el = obj;
		var pT = 0;
		while(el){
			pT+=el.offsetTop;
			el=el.offsetParent;
		}
		pos = new Array(pL, pT);
		return pos;	
	}
