// container_toc.js

function buildContainerToc(tocElement, tocTitleStr, tocContainer) {
	if (!isContainerEmpty(tocContainer)) {
		var tocBox = document.createElement('div');
		tocBox.setAttribute("class", "TOCBox");
		
		var tocTitle = document.createElement('div');
		tocTitle.setAttribute("class", "TOCTitle");
		tocBox.appendChild(tocTitle);
		
		tocTitleText = document.createTextNode(tocTitleStr);
		tocTitle.appendChild(tocTitleText);

		if (document.importNode) {
			clonedContainer = document.importNode(tocContainer, true);
		}
		else {
			clonedContainer = importNode(tocContainer, true);
		}

		// can't do this, as style gets corrupted in IE
		//tocBox.appendChild(clonedContainer);

		appendNodeContent(tocBox, getNodeOuterHTML(clonedContainer));

		replaceElementContent(tocElement, getNodeOuterHTML(tocBox));
	}
}
