onContent("treeSetup()");

function treeSetup ()
{
	var uls = document.getElementsByTagName('ul');
	for (var x = 0; x < uls.length; x++)
	{
		if (uls[x].className.indexOf('subCategories') != -1)
		{
			var childLis = collectChildren(uls[x], 'li');
			for (var y = 0; y < childLis.length; y++)
				checkForChildren(childLis[y]);
		}
	}
};

function collectChildren (element, tagName)
{
	var aChildren = [];
	child = element.firstChild;
	if (child.tagName == tagName.toUpperCase()) aChildren.push(child);
	while ((child = child.nextSibling) != null)
	{
		if (child.tagName == tagName.toUpperCase()) aChildren.push(child);
	}
	return aChildren;
};

function checkForChildren (liElement)
{
	var children = collectChildren(liElement,'ul');
	if (children.length > 0)
	{
		var shield = document.createElement('div');
		shield.className = 'shield seemore';
		shield.style.height = '0px';
		shield.appendChild(document.createElement('div'));

		var child = liElement.firstChild;
		var bStarted = false;
		while ((child = child.nextSibling) != null)
		{
			if (child.tagName == 'UL') bStarted = true;
			if (bStarted)
			{
				var tempChild = child.previousSibling;
				shield.firstChild.appendChild(child.cloneNode(true));
				liElement.removeChild(child);
				child = tempChild;
			}
		}
		liElement.appendChild(shield);
		var div = document.createElement('div');
		div.className = 'expandMe';
		div.title = 'Click to expand.';
		liElement.insertBefore(div, liElement.firstChild);
		var oExpando = new expando();
		oExpando.init(shield, 'shield', 'seemore', 'seeless', div, null, 'expandMe', null, 'contractMe');
		var uls = shield.getElementsByTagName('ul');
		for (var x = 0; x < uls.length; x++)
		{
			var childLis = collectChildren(uls[x], 'li');
			for (var y = 0; y < childLis.length; y++)
				checkForChildren(childLis[y]);
		}
	}
};

