var code = new Array();
var loaded = 0;
var popTimer = 0;

function Menu(name,top,left,width,parent) {
	this.name = name;
	this.top = top;
	this.left = left;
	this.width = width;
	this.parentMenu = parent;
	this.owner = '';
	this.subitem = new Array();
}
function Item(width,height,menuout,href,itemtext) {
	this.width = width;
	this.height = height;
	this.menuout = menuout;
	this.href = href;
	this.itemtext = itemtext;
}
function popOver(menuNum) {
	if(loaded){
		clearTimeout(popTimer);
		popTimer=0;
		hideAllBut(menuNum);
		showDiv(menu[menuNum].name);
	}
}
function popOut(menuNum) {
	if(loaded){
	if (menuNum == 0)
		hideAllBut(0)
	else{
		if(popTimer==0)
			popTimer = setTimeout('hideAllBut(0)', 500);
	}
	}
}
function getTree(menuNum) {
	itemArray = new Array(menu.length);
	while(1) {
		itemArray[menuNum] = 1;
		if (menuNum == 0) return itemArray;
		menuNum = menu[menuNum].parentMenu;
	}
}
function hideAllBut(menuNum) {
	var keepMenus = getTree(menuNum);
	var threeOn = true;
	var fourOn = true;
	for (count = 1; count < menu.length; count++)
	if (!keepMenus[count]){
 		hideDiv(menu[count].name);
		if(count==3){
			rolloverImage(rStudent,0);
			threeOn = false;
		}
		if(count==4){
			rolloverImage(rAdvanced,0);
			fourOn = false;
		}
	}
	if(descriptionText && !threeOn && !fourOn){writeText('','description');}
}
function rewrite(on,o,me,c)
{
	oLayer = eval('document.' + o + '.document.' + me);
	oHover = eval('document.' + o + '.document.' + me + 'hover');

	if(on){
		resetMenu(c);
		oLayer.visibility = "hidden";
		oHover.visibility = "inherit";
	}
	else{
		oLayer.visibility = "inherit";
		oHover.visibility = "hidden";
	}
}
function resetMenu(c)
{
		oMenu = eval('menu[' + c + ']');
		for(j = 0; j < oMenu.subitem.length; j++){
			oTemp1 = eval('document.' + oMenu.name + '.document.menu' + c + 'item' + j);
			oTemp = eval('document.' + oMenu.name + '.document.menu' + c + 'item' + j + 'hover');
			oTemp.visibility = "hidden";
			oTemp1.visibility = "inherit";
		}
}
function writeMenus() {
	for (count = 1; count < menu.length; count++){
		var str = '';
		inttop = 0;
		divTop = 0;
		for(j = 0; j < menu[count].subitem.length; j++){
			var itemID = 'menu' + count + 'item' + j;
			if (objClient.ns4) {
				str += '<layer id=' + itemID + ' top=' + inttop + ' left=0 width=' + menu[count].subitem[j].width + ' height=' + menu[count].subitem[j].height + ' ';
				str += 'bgcolor=' + backColOut + ' ';
				str += 'onmouseover="rewrite(true,\'' + menu[count].name + '\',\'' + itemID + '\',' + count + ');popOver(' + menu[count].subitem[j].menuout + ')" onmouseout="popOut(' + menu[count].subitem[j].menuout + ')">';
  				str += '<table width="100%"><tr><td valign="middle">';
				str += '<a id="menuNav" href="' + menu[count].subitem[j].href + '"><center>' + menu[count].subitem[j].itemtext + '</center></a>';
  				str += '</td></tr></table></layer>';
				str += '<layer id=' + itemID + 'hover top=' + inttop + ' left=0 width=' + menu[count].subitem[j].width + ' height=' + menu[count].subitem[j].height + ' ';
				str += 'bgcolor=' + backColOver + ' visibility="hidden" ';
				str += 'onmouseover="popOver(' + menu[count].subitem[j].menuout + ')" onmouseout="rewrite(false,\'' + menu[count].name + '\',\'' + itemID + '\',' + count + ');popOut(' + menu[count].subitem[j].menuout + ')">';
  				str += '<table width="100%"><tr><td valign="middle">';
				str += '<a id="menuNavOn" href="' + menu[count].subitem[j].href + '"><center>' + menu[count].subitem[j].itemtext + '</center></a>';
  				str += '</td></tr></table>';
			}
			if (objClient.dom || objClient.ie4) {
				str += '<div id="' + itemID + '" style="position:relative; z-index: 3; width: ' + menu[count].subitem[j].width + '; height: ' + menu[count].subitem[j].height + '; cursor:hand; ';
				str += 'background-color: ' + backColOut + '; " class="menuNav" ';
				str += 'onmouseover="this.style.backgroundColor=\'' + backColOver + '\';this.style.color=\'' + fontColOver + '\';popOver(' + menu[count].subitem[j].menuout + ')" onmouseout="this.style.backgroundColor=\'' + backColOut + '\';this.style.color=\'' + fontColOut + '\';popOut(' + menu[count].subitem[j].menuout + ')" ';
				if(objClient.browser=='nav'){
	  				str += '>';
					str += '<div style="position:relative; width: ' + menu[count].subitem[j].width + '; height: 1;">';
					str += '<img src="images/shim.gif" width="' + menu[count].subitem[j].width + '" height="4">';
					str += '</div>';
					inttop += 1;
					str += '<a id="menuNav" href="' + menu[count].subitem[j].href + '">';
		  			str += '<center>' + menu[count].subitem[j].itemtext + '</center>';
  					str += '</a>';
				}
				else{
					str += 'onClick="javascript:window.location.href=\'' + menu[count].subitem[j].href + '\'">';
					str += '<div style="position:relative; width: ' + menu[count].subitem[j].width + '; height: 1;">';
					str += '<img src="images/shim.gif" width="' + menu[count].subitem[j].width + '" height="4">';
					str += '</div>';
					inttop += 1;
					str += '<center>' + menu[count].subitem[j].itemtext + '</center>';
				}
			}
			str += (objClient.ns4 ? '</layer>' : '</div>');
			inttop += menu[count].subitem[j].height;
			if (j !=  menu[count].subitem.length - 1){
				if(objClient.ns4)
					str += '<layer top=' + inttop + ' left=0 width=' + menu[count].subitem[j].width + ' height=' + menu[count].subitem[j].height + '>';
				else
					str += '<div style="position:relative; width: ' + menu[count].subitem[j].width + '; height: 1;">';
				str += '<img src="images/menu1x1.jpg" width="' + menu[count].subitem[j].width + '" height="2">';
				str += (objClient.ns4 ? '</layer>' : '</div>');
				if(objClient.ns4){inttop += 2;}
				else{inttop += 1;}
			}
		}
		divTop = (objClient.browser=='ie')?menu[count].top + 2:menu[count].top;
		if (objClient.dom) {
			newDiv = document.createElement('div');
			newDiv.id = menu[count].name;
			newDiv.style.position = 'absolute';
			newDiv.style.visibility = 'hidden';
			newDiv.style.top = divTop + 'px';
			newDiv.style.left = menu[count].left + 'px';
			newDiv.style.zIndex = '2';
			document.body.appendChild(newDiv);
			newDiv.innerHTML = str;
		}
		if (objClient.ie4) {
			code[count] = '<div id="' + menu[count].name + '" style="position: absolute; z-index: 2; left: ' + menu[count].left + 'px; top: ' + divTop + 'px; visibility: hidden;">' + str + '</div>';
		}
		if (objClient.ns4) {
			document.write('<layer id="' + menu[count].name + '" top=' + divTop + ' bgcolor="' + backColOut + '" left=' + menu[count].left + ' z-index=50 visibility=hidden>' + str + '</layer>');
		}
	}
}
