/**
 * This function regenerates the menu bar frame based on the abstract
 * representation coded in the calling page.  It takes three parameters,
 * the ID of the current page, whether the current page's tree should be
 * displayed in expanded form, and whether or not to load the current
 * page in the specified frame.
 */
function reDisplay(currentNumber,currentIsExpanded,loadPage) {
	if (arguments.length < 3)
		loadPage = true; // whether or not to load the current page, or just redraw the menu
	//with (menubar.document) {
	with (top.frames[1].document) {
		open();
		writeln("<html>\n<head>\n<title>ToC</title>\n");
		writeln("<style>" + inline_style + "</style>");
		writeln("</head>\n");
		writeln("<body id=\"menu_body\" background=\"" + docBackground + "\" topmargin=\"0\" bottommargin=\"0\" rightmargin=\"0\" leftmargin=\"0\" marginheight=\"0\" marginwidth=\"0\">\n");
		writeln("<table border=0 cellspacing=0 cellpadding=0 HEIGHT=\"100%\" style=\"background-image:url(" + tableBackground + ");background-repeat:no-repeat;\">\n<tr>\n<td width=\"" + leftmargin + "\"><img src=\"" + imageschemerootdir +  "spacer.gif\" width=\"" + leftmargin + "\" height=\"1\" border=\"0\" /></td><td VALIGN=\"top\">\n");
		writeln("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n<tr>");
		var currentNumArray = currentNumber.split(".");
		var currentLevel = currentNumArray.length-1;
		var scrollY=0, addScroll=true, theHref="", theTarget="";
		for (i=initialMenuBucket; i<tocTab.length; i++) {
			thisNumber = tocTab[i][0];
			var isCurrentNumber = (thisNumber == currentNumber);
			if (isCurrentNumber) {
				theHref=tocTab[i][2];
				theTarget = tocTab[i][3];
			}
			var thisNumArray = thisNumber.split(".");
			var thisLevel = thisNumArray.length-1;
			var toDisplay = true;
			if (thisLevel > 0) {
				for (j=0; j<thisLevel; j++) {
					toDisplay = (j>currentLevel)?false:toDisplay && (thisNumArray[j] == currentNumArray[j]);
				}
			}
			thisIsExpanded = toDisplay && (thisNumArray[thisLevel] == currentNumArray[thisLevel])
			if (currentIsExpanded) {
				toDisplay = toDisplay && (thisLevel<=currentLevel);
				if (isCurrentNumber) thisIsExpanded = false;
			}
			
			if (toDisplay) {
				if (i==0) {
					writeln("\n<td colspan=" + (nCols+1) + "><a href=\"javaScript:\parent.reDisplay('" + thisNumber + "'," + thisIsExpanded + ")\" style=\"font-family: " + fontTitle + "; font-weight:bold; font-size:" + textSizes[0] + "px; color: " + titleColor + "; text-decoration:none\">" + tocTab[i][1] + "</a></td></tr>");
					for (k=0; k<nCols; k++) {
						write("<td>&nbsp;</td>");
					}
					write("<td width=240>&nbsp;</td></tr>");
				} else {
					if (addScroll)
						scrollY+=((thisLevel<2)?mdi:sml)*25;
					if (isCurrentNumber)
						addScroll=false;
					var isLeaf = (i==tocTab.length-1) || (thisLevel >= tocTab[i+1][0].split(".").length-1);
					writeln("<tr>");
					for (k=1; k<=thisLevel; k++) {
						writeln("<td>&nbsp;</td>");
					}
					write("<td valign=top>");
					if (imagescheme == "none") {
						write("<img src=\"" + imageschemerootdir + "spacer.gif\" border=\"0\" />");
					} else {
						img = imageschemerootdir + imagescheme + "_";
						img += (isLeaf)?"leaf":(thisIsExpanded)?"minus":"plus";
						write("<a href=\"javaScript:parent.reDisplay('" + thisNumber + "'," + thisIsExpanded + ");\"><img src=\"" + img + ".gif\" border=\"0\"></a>");
					}
					write("</td> <td colspan=" + (nCols-thisLevel) + "><a href=\"javaScript:\parent.reDisplay('" + thisNumber + "'," + thisIsExpanded + ")\" style=\"font-family: " + fontLines + ";" + ((thisLevel<=mLevel)?"font-weight:bold":"") +  "; font-size:" + ((thisLevel<=mLevel)?mdi:sml) + "px; color: ");
					// see if we need to use the toplevelcolor attribute
					if (thisLevel == 0 && toplevelcolor.length != 0) {
						write(toplevelcolor);
					} else {
						write(isCurrentNumber ? currentColor : normalColor);
					}
					write("; text-decoration:none\">" + ((showNumbers)?(thisNumber+" "):"") + tocTab[i][1] + "</a>");
					if (verticalspacing > 0) {
						write("<br /><img src=\"" + imageschemerootdir + "spacer.gif\" width=\"1\" height=\"" + verticalspacing + "\" border=\"0\" />");
					}
					writeln("</td></tr>");
				}
			}
		}
	
		writeln("</table>");
		writeln("</td>");
		writeln("</tr>");
		writeln("</table>\n</body>");
		writeln("</html>");
		close();
	} // end with(toc.document)
	//menubar.scroll(0,scrollY);
	if (loadPage) {
		if ( theTarget == "new" ) {
			//window.open(theHref,""," dialogWidth:800; dialogHeight:580; resizeable=yes;");
			//window.open(theHref,"","scrollbars=yes, resizeable=yes, width=800, height=580");
			window.open(theHref,"","toolbar=yes, location=yes, status=yes, menubar=yes, scrollbars=yes, width=800, height=500'");
		} else {
			if (theHref != "") {
				
				content.location.href = '/'+theHref;
			}
		}
	}
}


