function insertAfter(newElement, targetElement) {
	var parent = targetElement.parentNode;
	if(parent.lastChild == targetElement) {
		parent.appendChild(newElement);
	} else {
		parent.insertBefore(newElement, targetElement.nextSibling);
	}
}

function listLink(linkUrl, linkText)
{
	// fix Act 8.0.3 escaped ampersand (bug?)
	linkUrl = linkUrl.replace(/&amp;/g, '&');

	var a = document.createElement('a');
	a.setAttribute('href', linkUrl);
	linkText = linkText.replace(/&#39;/g, "'");
	linkText = linkText.replace(/&#40;/g, '(');
	linkText = linkText.replace(/&#41;/g, ')');
	var t = document.createTextNode(linkText);
	a.appendChild(t);
	var li = document.createElement('li');
	li.appendChild(a);
	return li;
}

function addMenu()
{
	if(!document.getElementById) { return; }
	var nav = document.getElementById('nav');
	if(!nav) { return; }

	for(var i=1; i<=section_tree.length; i++) {
		var li = listLink(section_tree[i].sURL, section_tree[i].sName);

		if(section_tree[i].pChild) {
			// subsections
			var sm_ul = document.createElement('ul');
			for(var j=1; j<=section_tree[i].pChild.length; j++) {
				if(section_tree[i].pChild[j].sURL != null) {
					sm_ul.appendChild(listLink(
						section_tree[i].pChild[j].sURL,
						section_tree[i].pChild[j].sName));
				}
			}
			li.appendChild(sm_ul);
		}
		nav.appendChild(li);
	}

}

function modifiedPopup(sUrl, nWidth, nHeight)
{
	window.open(sUrl, 'ActPopup', 'width=' + nWidth + ',height=' + nHeight + ',scrollbars, resizable');
}

window.onload = function() {
	addMenu();

	// remove "Click to activate this control" in IE
	objects = document.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++)
	{
		objects[i].outerHTML = objects[i].outerHTML;
	}

}