
function TDClick(e)
{
	e = (e) ? e : window.event;
	var cell = (e.srcElement) ? e.srcElement : (e.target) ? e.target : null;
	var row = (cell) ? cell.parentNode : null;
	if (row && row.className == 'topic')
	{
		var tr, CSSdisplay = 'none', s = 0;
		for (s; s < TDClick.topics.length; ++s)
		{
			tr = TDClick.topics[s];
			if (tr.className == 'topic')
			{
				if (row == tr)
					CSSdisplay = (row.style.display != 'inline') ? 'inline' : 'none';
				else CSSdisplay = 'none';
			}
			else if (tr.className == 'subtopic')
				tr.style.display = (tr.style.display != 'inline') ? CSSdisplay : 'none';
		}
	}	
}




function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

addLoadEvent(function() {

	TDClick.topics = new Array();
	var tr, i = 0, trs = document.getElementById('alltopics').getElementsByTagName('tr');
	while (tr = trs.item(i++))
		if (tr.className.match(/(sub)?topic/))
			TDClick.topics[TDClick.topics.length] = tr;

	var obj = document.getElementsByTagName('body').item(0);
	if (obj.addEventListener)
		obj.addEventListener('click', function(e) { return TDClick(e); }, true);
	else if (obj.attachEvent)
		obj.attachEvent('onclick', function(e) { return TDClick(e); });
	else
	{
		var oldhandler = obj.onclick;
		if (null != oldhandler)
			obj.onclick = function(e) { oldhandler(e); TDClick(e); }; 
		else obj.onclick = function(e) { return TDClick(e) };
	}
})


