	var menuIds = [];
	var currentMenuId;
	var menus = [];
	var initiatedMenuX = false;
	function makeMenu(menuId, submenus){
		menus.push([menuId, submenus]);
	}
	function initMenu(){
		if (!initiatedMenuX){
			initiatedMenuX = true;
			for (var i=0; i < menus.length; i++){
				//if(menus[i][1]){
					makeMenu2(menus[i][0], menus[i][1]);
				//}
			}
			updatePositions();
		} else {
			//alert(".");
			//updatePositions();
		}
	}
	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;
		pos[0] -= 1;
		thisId = "mainmenusubid_" + menuIdx[3];
		//alert(menuIdx);
		if (submenus.length > 0){
			disp = "block";
			toWrite += "<div id='" + thisId + "' style='position:absolute; top:" + pos[1] + "px; left:" + pos[0] + "px; overflow:hidden; display:" + disp + ";'>";
			toWrite += "<div id='sub' style=''>";
			toWrite += "<div id='subsub' class='menuSubHolder'>";
			for (i = 0; i < submenus.length; i++){
				submenuName = submenus[i][0];
				submenuUrl  = submenus[i][1];
				submenuImg  = submenus[i][2];
				toWrite += "    <div class='menuSub' onClick='topMenuClicked(1279); window.location=\"" + submenuUrl + "\"' onMouseOver='this.className=\"menuSub menuSubHover\"' onMouseOut='this.className=\"menuSub\"' >\n";
				toWrite += "      &nbsp;&nbsp;&nbsp;&nbsp;" + submenuName + "\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";
			menuObj.hasSub = 1;
		} else {
			menuObj.hasSub = 0;
		}
		menuIds.push(menuObj);
	}
	function doOpenSub(){
		if (currentMenuId != this.id){
			for (i=0; i < menuIds.length; i++){
				obj = menuIds[i];
				obj.className = 'mainMenu';
				if (obj.hasSub){
					objs = obj.subMenu;
					objs.wait = 0;
				}
			}
		}
		this.className = 'mainMenu mainMenuHover';
		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){
		if (obj.hasSub){
			pos = getPositions(obj);
			pos[1] += obj.offsetHeight;
			pos[0] -= 1;
			obj.pos = pos;
		}
	}
	function doLoop(){
		for (i=0; i < menuIds.length; i++){
			obj = menuIds[i];
			if (obj.hasSub == 1){
				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;
	
					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.5){
							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";
						} else {
							objs.style.display = "none";
							obj.className = 'mainMenu';
						}
					}
				}
			}
		}
	}
	setInterval("doLoop()", 10);
	function getPositions(obj){
		fixTop = 0;
		if (navigator.userAgent.match("Chrome")){
			fixTop = -10;
		} else if (navigator.userAgent.match("Safari")){
			fixTop = -9;
		}
			
		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;
		}
		pT += fixTop;
		pos = new Array(pL, pT);

		return pos;
	}