var ie4 = document.all ? 1 : 0;
var dom = document.getElementById ? 1 : 0;
function getObject(objName) {
	if (dom)
		return document.getElementById(objName);
	else if (ie4)
		return document.all[objName];
}


var objVis = new Array();

function openMenu(id)
{
	if (objVis[id])
		return;
	obj = getObject('submenu' + id);

	if (obj.className.indexOf('submenu2') > -1)
		obj.className = 'submenu2 show';
	else
		obj.className = 'submenu show';

	objVis[id] = true;

	/* stay parent menu rollover */
	// is parent menu
	if (allParentID.indexOf(id + ',') > -1)
	{
		obj.parentNode.childNodes[0].className = 'stayrollover';
		over(obj.parentNode.childNodes[0].childNodes[0].name);
	}
}

function closeMenu(id)
{
	if (objVis[id])
		return;
	obj = getObject('submenu' + id);

	if (obj.className.indexOf('submenu2') > -1)
		obj.className = 'submenu2 hide';
	else
		obj.className = 'submenu hide';

	/* unstay parent menu rollover */
	// is parent menu
	if (allParentID.indexOf(id + ',') > -1)
	{
		obj.parentNode.childNodes[0].className = '';
		out(obj.parentNode.childNodes[0].childNodes[0].name);
	}
}

var walksubmenuID, allParentID = '';
function adaptSubmenu()
{
	return true;
	var submenuObj = getObject('submenu' + walksubmenuID);
	var tempULs = adaptSubmenuUL(submenuObj);

	for (key in tempULs)
	{
		if (tempULs[key] == 1)
		{
			submenuObj = getObject(key);
			adaptSubmenuUL(submenuObj);
			tempULs[key] = 0;
		}
	}

	allParentID += walksubmenuID + ',';
}

function adaptSubmenuUL(ULobj)
{
	return true;
	var tempULs = new Array();

	/* get most width */
	var width = 0;

	for (i=0; i<ULobj.childNodes.length; i++)
	{
		var child = ULobj.childNodes[i];
		if (child.tagName == 'LI')
		{
			iWidth = child.childNodes[0].childNodes[0].getAttribute('width');
			iWidth = parseInt(iWidth);

			// msie bug
			if (iWidth == 0)
			{
				regex = new RegExp('width="?([0-9]+)"?');
				match = regex.exec(child.childNodes[0].innerHTML);
				iWidth = parseInt(match[1]);
			}
			// ~~~

			if (iWidth > width) {
				width = iWidth;
			}
		}
	}

	/* apply width to all LI and A */
	for (i=0; i<ULobj.childNodes.length; i++)
	{
		var child = ULobj.childNodes[i];
		if (child.tagName == 'LI')
		{
			child.style.width = width + 'px';

			oA = child.childNodes[0];
			oA.style.width = width + 'px';

			// sub UL
			if (child.childNodes[1])
			{
				if (child.childNodes[1].nodeName == 'UL')
				{
					child.childNodes[1].style.left = width + 'px';
					tempULs[child.childNodes[1].id] = 1;
				}
			}
		}
	}
	return tempULs;
}