// File locations in the DHTML are relative to the current file.
// directoryChain specifies the directory enclosing this file, as a
// sequence of directory names.  An empty sequence denotes that the file is in
// the top directory of the web site.

var directoryChain = new Array();

// aHref is the address of the node, relative to the top
// directory of the web site.
function makeTopicNode(aHref,aId,aClass,aContents)
{
	var path = (aHref.substr(0,7)=="mailto:")?aHref:pathTo(aHref);
	//window.alert("makeTopicNode,href= " + path);
	var node=document.createElement("a");
	node.setAttribute("href",pathTo(aHref));
	node.setAttribute("id",aId);
	node.setAttribute("class",aClass);
	var textNode=document.createTextNode("\u2022 " + aContents);
	node.appendChild(textNode);
	return node;
}

function debugLine(s)
{
	var tell = document.getElementById("telltale");
	if(tell != null)tell.innerHTML = s;
}

function ibidize(topId)
{
	var thisOne = document.getElementById(topId);
	//debugLine("line 1 " + topId);
	var thisClass = thisOne.getAttribute("class");
	thisOne.setAttribute("class", thisClass + " ibidem");
}

// Given the relative path of the enclosing directory, set
// the value of directoryChain.
function setDirectoryChain(dirPath)
{
	directoryChain = dirPath.split("/");
}

// Find a path to the named file, which is specified
// by its location relative to the top directory of the web site.
function pathTo(filePath)
{
	fileChain = filePath.split("/");
	var common = 0;
	while((common < directoryChain.length) && (common < fileChain.length) &&
		directoryChain[common].valueOf() == fileChain[common].valueOf())
			common++;
	var result = "";
	for(var i=0; i<directoryChain.length - common; i++){
		result += "../";
	}
	for(var i=common; i<fileChain.length; i++){
		if(i>common)result += "/";
		result += fileChain[i];
	}
	return result;
}

