var globalRootPath;
var subsites;

function TocManager(subsites, globalRootPath)
{
	this.tocs = new Array();
}

TocManager.prototype.load = function(subsites, rootPath)
{
	if(rootPath == null) rootPath = "./";
	if(subsites == null) subsites = new Array();
	var name;
	for(name in subsites) {
		var path = subsites[name];
		if(path == "") continue;
		if(path == ".") path = rootPath;
		else if(rootPath != ".") path = rootPath + path + "/";
		path += "iso_resource/toc.js";
		var scr = "<scr" + "ipt type='text/javascript' src='" + path + "'></scr" + "ipt>";
		document.write(scr);
	}
}

TocManager.prototype.getTocBlock = function(tocName, gid)
{
	var toc = this.tocs[tocName];
	if(toc == null) return;
	return toc.gids[gid];
}

TocManager.prototype.getSubsiteToc = function(tocName, lang, sid)
{
	var toc = this.tocs[tocName];
	if(toc == null) return;
	var array = toc[lang];
	if(array == null) return;
	return array[sid];
}

var tocManager = new TocManager(subsites, globalRootPath);
tocManager.load(subsites, globalRootPath);
