var menupic = new Array('2','5','6','7','8','9','10','11');
var menutop = new Array(108,177,251,323,390,459,543,611);

var leftedge = (document.body.clientWidth - 1048) / 2;
if (leftedge < 0) {leftedge = 0;}

var menuheight = document.body.clientHeight - 147;
if (menuheight < 530) {menuheight = 530;}

var mnumber = new Array();
var hiddens = new Array();
var closing = new Array();
var mparent = new Array();
for (i=0; i<=0; i++)
{
	mnumber[i] = 0;
	hiddens[i] = new Array();
	closing[i] = new Array();
	mparent[i] = new Array();
}

function displayMenu(type,which)
{
	clearTimeout(closing[type][which]);
	if (type == 0)
	{
		eval("document.subpage_" + menupic[which] + "pic.src = subpageon_" + menupic[which] + ".src");
	}
	//if (currentID == 9)
	//{
		if ((ie || n6) && (eval("document.getElementById('menu" + type + "_" + which + "').style.visibility == 'hidden'")))
		{
			eval("document.getElementById('menu" + type + "_" + which + "').style.visibility = 'visible'");
		}
		else if (n4) {eval("document.menu" + type + "_" + which + ".visibility = 'visible'");}
	//}
	for (i=0; i<hiddens[type].length; i++)
	{
		if (i != which) {hideMenu(type,i);}
	}
	hiddens[type][which] = false;

	if (type > 0)
	{
		ptype = type - 1;
		displayMenu(ptype,mparent[type][which]);
	}
}

function delayHide(type,which)
{
	clearTimeout(closing[type][which]);
	closing[type][which] = setTimeout('hideMenu(' + type + ',' + which + ')',300);
	if (type > 0)
	{
		ptype = type - 1;
		delayHide(ptype,mparent[type][which]);
	}
}

function hideAll(type)
{
	for (i=0; i<hiddens[type].length; i++)
	{
		hideMenu(type,i);
	}
	if (type > 0)
	{
		ptype = type - 1;
		hideAll(ptype);
	}
}

function hideMenu(type,which)
{
	clearTimeout(closing[type][which]);
	if (ie || n6) {eval("document.getElementById('menu" + type + "_" + which + "').style.visibility = 'hidden'");}
	else if (n4) {eval("document.menu" + type + "_" + which + ".visibility = 'hidden'");}
	hiddens[type][which] = true;

	if (type == 0)
	{
		eval("document.subpage_" + menupic[which] + "pic.src = subpage_" + menupic[which] + ".src");
	}
}

var arrowcount = 0;

function createMenu(type,mtop,mleft,labellist,linklist)
{
	ptype = type - 1;
	ctype = type + 1;
	var labels = labellist.split('|');
	var links = linklist.split('|');

	mtop = menutop[mnumber[type]];
	mleft = leftedge + 117;

	if (labels[0] == '')
	{
		document.write('<DIV id="menu'+type+'_'+mnumber[type]+'" style="TOP:0; LEFT:0; width:0px; height:0px; VISIBILITY:hidden; OVERFLOW:hidden; POSITION:absolute;">');
	}
	else
	{
		document.write('<DIV id="menu'+type+'_'+mnumber[type]+'" style="background-color:#4b6b78; TOP:' + mtop + '; LEFT:' + mleft + '; padding-top:7px; padding-bottom:23px; width:150px; VISIBILITY:hidden; OVERFLOW:hidden; POSITION:absolute; z-index:3" onMouseOver = "displayMenu('+type+','+mnumber[type]+')" onMouseOut = "delayHide('+type+','+mnumber[type]+')">');

		if (labellist != '')
		{
			usebg = '#c5c3bd';
			document.write('<table border="0" width="150" cellpadding="0" cellspacing="0">');
			for (i=0; i<labels.length; i++)
			{
				var linkinfo = links[i].split('^');
				if (linkinfo[1])
				{
					mparent[ctype][linkinfo[1]] = mnumber[type];
					document.write('<tr><td width="150" height="33"><a class="submenu" onMouseOver="displayMenu('+ctype+','+linkinfo[1]+')" onMouseOut="delayHide('+ctype+','+linkinfo[1]+')" href="'+linkinfo[0]+'">&nbsp;&nbsp;'+labels[i]+'&nbsp;&nbsp;</a></td></tr>');
				}
				else
				{
					document.write('<tr><td width="150" height="33"><a class="submenu" href="'+linkinfo[0]+'">'+labels[i]+'</a></td></tr>');
				}
				if (i < labels.length - 1)
				{
					document.write('<tr><td><img src="/images/submenu_line.gif" width="150" height="1" border="0"></td></tr>');
				}
				arrowcount++;
			}
			document.write('</table>');
		}
	}
	document.write('</DIV>');
	hiddens[type][mnumber[type]] = true;
	closing[type][mnumber[type]] = 0;
	mnumber[type]++;
}

