//alert("initing stuff");



function TocClickIt(which, indx, doc)
{
	if(which == 0)	nodes = tocnodes;
	else if(which == 1)	nodes = indxnodes;
	else if(which == 2)	nodes = topcnodes;
	else	return;

//	alert("TocClickIt");
//	alert(which);
//	s = doc.URL;
//	alert(s);
//	alert(indx);
	if(nodes[indx].type == typeNode || nodes[indx].type == typeIndxNode )
	{
//		alert(nodes[indx].state);
		nodes[indx].state = 1 - nodes[indx].state;	// toggle the state
//		alert(nodes[indx].state);
		if(which == 0)	DrawTocAll(doc);
		else if(which == 1)	DrawIndxAll(doc);
		else if(which == 2) DrawTopcAll(doc);
	}
	else
	{
		if(nodes[indx].link != "")
		{
			window.top.RightFrm.location = "files/" + nodes[indx].link;
		}
	}
}

function DrawNode(node, which, level, doc)
{
	var i;
	var k;

//	alert("DrawNode");
//	alert(node.title);
//	alert("node.state");
//	alert(node.state);
//	alert(which);
//	s = doc.URL;
//	alert(s);

	doc.write("<P style=\"margin-top:3.00pt;margin-bottom:1.00pt;\">");
	for(k = 0; k < level; k++)
	{
		doc.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
	}

	if(node.type == typeLeaf || node.type == typeIndxLeaf )
	{
		if(which == 0)
		{
			doc.write("<A class=\"TocLeaf\" HREF=\"#\" onClick=\"toc_doclick(event, " + node.indx + "); return false\"");
			nodes = tocnodes;
		}
		else if(which == 1)
		{
			if(level == 0)
			{
				doc.write("<A class=\"TocEmptyNode\" HREF=\"#\" onClick=\"indx_doclick(event, " + node.indx + "); return false\"");
			}
			else
			{
				doc.write("<A class=\"TocLeaf\" HREF=\"#\" onClick=\"indx_doclick(event, " + node.indx + "); return false\"");
			}
			nodes = indxnodes;
		}
		else if(which == 2)
		{
			if(level == 0)
			{
				doc.write("<A class=\"TocEmptyNode\" HREF=\"#\" onClick=\"indx_doclick(event, " + node.indx + "); return false\"");
			}
			else
			{
				doc.write("<A class=\"TocLeaf\" HREF=\"#\" onClick=\"topc_doclick(event, " + node.indx + "); return false\"");
			}
			nodes = topcnodes;
		}
		else
		{
			return;
		}
		if(node.synopsis != "")
		{
			doc.write(" onMouseOver=\"window.top.defaultStatus = self.status = \'" + node.synopsis + "\'; return true\" alt=\"" + node.synopsis + "\"><SPAN TITLE=\'" + node.synopsis + "\'>");
		}
		else
		{
			doc.write(">");
		}
	}
	else
	{
		if(which == 0)
		{
			doc.write("<A class=\"TocNode\" HREF=\"#\" onClick=\"toc_doclick(event, " + node.indx + "); return false\"");
			nodes = tocnodes;
		}
		else if(which == 1)
		{
			doc.write("<A class=\"TocNode\" HREF=\"#\" onClick=\"indx_doclick(event, " + node.indx + "); return false\"");
			nodes = indxnodes;
		}
		else if(which == 2)
		{
			doc.write("<A class=\"TocNode\" HREF=\"#\" onClick=\"topc_doclick(event, " + node.indx + "); return false\"");
			nodes = topcnodes;
		}
		else
		{
			return;
		}
		doc.write(">");
	}
	if(node.type == typeNode)
	{
//alert("type is Node");
		if(node.state != 0)
		{
//alert("state is On");
//alert("node.numChildren");
//alert(node.numChildren);
			doc.write("<IMG SRC=\"image/book_open.gif\" border=0>&nbsp;&nbsp;" + node.title + "</A></P>");
			for(i = 0; i < node.numChildren; i++)
			{
//alert("i");
//alert(i);
				x = node.children[i];
//alert("x");
//alert(x);
				DrawNode(nodes[x], which, level+1, doc);
			}
		}
		else
		{
			doc.write("<IMG SRC=\"image/book_closed.gif\" border=0>&nbsp;&nbsp;" + node.title + "</A></P>");
		}
	}
	else if(node.type == typeLeaf)
	{
		if(node.image == "")
		{
			if(node.synopsis != "")
				doc.write("<IMG SRC=\"image/page.gif\" border=0>&nbsp;&nbsp;" + node.title + "</SPAN></A></P>");
			else
				doc.write("<IMG SRC=\"image/page.gif\" border=0>&nbsp;&nbsp;" + node.title + "</A></P>");
		}
		else
		{
			if(node.synopsis != "")
				doc.write("<IMG SRC=\"image/page.gif\" border=0>&nbsp;&nbsp;" + node.title + "</SPAN></A><IMG SRC=\"" + node.image + "\"></P>");
			else
				doc.write("<IMG SRC=\"image/page.gif\" border=0>&nbsp;&nbsp;" + node.title + "</A><IMG SRC=\"" + node.image + "\"></P>");
		}
	}
	else if(node.type == typeIndxNode)
	{
		doc.write(node.title + "</A></P>");
		if(node.state != 0)
		{
			for(i = 0; i < node.numChildren; i++)
			{
				x = node.children[i];
				DrawNode(nodes[x], which, level+1, doc);
			}
		}
	}
	else if(node.type == typeIndxLeaf)
	{
		if(node.synopsis != "")
			doc.write(node.title + "</SPAN></A></P>");
		else
			doc.write(node.title + "</A></P>");
	}
	doc.write("\r\n");
}

function DrawTocAll(doc)
{
//	alert("in DrawTocAll");
//	alert(numNodes);
//	s = doc.URL;
//	alert(s);
	doc.open();
//	doc.writeln("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"");
//	doc.writeln("   \"http://www.w3.org/TR/html4/frameset.dtd\">");
	doc.writeln("<HTML>");
	doc.writeln("<HEAD>");

	doc.writeln("<title>Table of contents</title><!-- BSSCMARK_POS TITLE -->");
	doc.writeln("<LINK REL=stylesheet HREF=\"formZApi.css\" TYPE=\"text/css\">");

	doc.writeln("</HEAD>");
	doc.writeln("<BODY bgcolor=white scroll=yes>");
	doc.writeln("<SCRIPT LANGUAGE=\"JavaScript\" SRC=\"globals.js\">");
	doc.writeln("</SCRIPT>");
	doc.writeln("<SCRIPT LANGUAGE=\"JavaScript\" SRC=\"tocfrm.js\">");
	doc.writeln("</SCRIPT>");
	doc.writeln("<NOBR>");

	DrawNode(tocnodes[0], 0, 0, doc);

	doc.writeln("</NOBR>");
	doc.writeln("</BODY>");
	doc.writeln("</HTML>");
	doc.close();
}

function DrawIndxAll(doc)
{
//	alert("in Drawall");
//	alert(numNodes);
//	s = doc.URL;
//	alert(s);
	doc.open();
//	doc.writeln("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"");
//	doc.writeln("   \"http://www.w3.org/TR/html4/frameset.dtd\">");
	doc.writeln("<HTML>");
	doc.writeln("<HEAD>");

	doc.writeln("<title>Table of contents</title><!-- BSSCMARK_POS TITLE -->");
	doc.writeln("<LINK REL=stylesheet HREF=\"formZApi.css\" TYPE=\"text/css\">");

	doc.writeln("</HEAD>");
	doc.writeln("<BODY bgcolor=white scroll=yes>");
	doc.writeln("<SCRIPT LANGUAGE=\"JavaScript\" SRC=\"globals.js\">");
	doc.writeln("</SCRIPT>");
	doc.writeln("<SCRIPT LANGUAGE=\"JavaScript\" SRC=\"indxbotmfrm.js\">");
	doc.writeln("</SCRIPT>");
	doc.writeln("<NOBR>");

	for(j = 0; j < numIndxTopNodes; j++)
	{
		DrawNode(indxnodes[j], 1, 0, doc);
	}

	doc.writeln("</NOBR>");
	doc.writeln("</BODY>");
	doc.writeln("</HTML>");
	doc.close();
}

function DrawTopcAll(doc)
{
//	alert("in Drawall");
//	alert(numNodes);
//	s = doc.URL;
//	alert(s);
	doc.open();
//	doc.writeln("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"");
//	doc.writeln("   \"http://www.w3.org/TR/html4/frameset.dtd\">");
	doc.writeln("<HTML>");
	doc.writeln("<HEAD>");

	doc.writeln("<title>Table of contents</title><!-- BSSCMARK_POS TITLE -->");
	doc.writeln("<LINK REL=stylesheet HREF=\"formZApi.css\" TYPE=\"text/css\">");

	doc.writeln("</HEAD>");
	doc.writeln("<BODY bgcolor=white scroll=yes>");
	doc.writeln("<SCRIPT LANGUAGE=\"JavaScript\" SRC=\"globals.js\">");
	doc.writeln("</SCRIPT>");
	doc.writeln("<SCRIPT LANGUAGE=\"JavaScript\" SRC=\"topcbotmfrm.js\">");
	doc.writeln("</SCRIPT>");
	doc.writeln("<NOBR>");

	for(j = 0; j < numTopcTopNodes; j++)
	{
		DrawNode(topcnodes[j], 2, 0, doc);
	}

	doc.writeln("</NOBR>");
	doc.writeln("</BODY>");
	doc.writeln("</HTML>");
	doc.close();
}

var gtoc_scrollval = 0;
var gtoc_win;

function do_toc_scroll()
{
//	alert(gtoc_scrollval);
	gtoc_win.scrollTo(0, gtoc_scrollval);
//	alert(gtoc_win.document.body.scrollTop);
//	alert(gtoc_win.pageYOffset)
}

function set_toc_scroll(win, sv)
{
	gtoc_win = win
	gtoc_scrollval = sv;
}

var gindx_scrollval = 0;
var gindx_win;

function do_indx_scroll()
{
//	alert(gindx_scrollval);
	gindx_win.scrollTo(0, gindx_scrollval);
//	alert(gindx_win.document.body.scrollTop);
//	alert(gindx_win.pageYOffset)
}

function set_indx_scroll(win, sv)
{
	gindx_win = win
	gindx_scrollval = sv;
}

var gtopc_scrollval = 0;
var gtopc_win;

function do_topc_scroll()
{
//	alert(gtopc_scrollval);
	gtopc_win.scrollTo(0, gtopc_scrollval);
//	alert(gtopc_win.document.body.scrollTop);
//	alert(gtopc_win.pageYOffset)
}

function set_topc_scroll(win, sv)
{
	gtopc_win = win
	gtopc_scrollval = sv;
}


