/*========= create collapsed topics for contents in these page ========*/

function createTOC() {
	if (top.bugRiddenCrashPronePieceOfJunk) return;
	toBeTOCced = getElementsByTagClass("div", "topics", "main");
	if (toBeTOCced.length < 1) return;
	for (var i=0;i<toBeTOCced.length;i++) {
		var contentId = toBeTOCced[i].id.replace(/T/,'C');
		var contentnode = document.getElementById(contentId);
		if (contentnode == null) return;
		contentnode.TOCstate = 'none';
		contentnode.style.display = contentnode.TOCstate;
		toBeTOCced[i].onclick = showhideTOCmy;
		contentnode.onclick = showhideTOCmy;
	}
}

function hideall() {
	if (top.bugRiddenCrashPronePieceOfJunk) return;
	for (var i=0;i<toBeTOCced.length;i++) {
		var contentId = toBeTOCced[i].id.replace(/T/,'C');
		var contentnode = document.getElementById(contentId);
		if (contentnode == null) return;
		contentnode.TOCstate = 'none';
		contentnode.style.display = contentnode.TOCstate;
	}
}

function showall() {
	if (top.bugRiddenCrashPronePieceOfJunk) return;
	for (var i=0;i<toBeTOCced.length;i++) {
		var contentId = toBeTOCced[i].id.replace(/T/,'C');
		var contentnode = document.getElementById(contentId);
		if (contentnode == null) return;
		contentnode.TOCstate = 'block';
		contentnode.style.display = contentnode.TOCstate;
	}
}

function showhideTOCmy() {
	 var clickedObj = this;	
   if ((navigator.userAgent.indexOf('MSIE 5') > 0) || (navigator.userAgent.indexOf('MSIE 6') > 0)) {
        clickedObj = event.srcElement;
        while(clickedObj.className != 'topics' && clickedObj.className != 'contents'  && clickedObj.parentElement != null) {
        clickedObj = clickedObj.parentElement;
    		}
    }
		var contentId = clickedObj.id.replace(/T/,'C');
		var contentnode = document.getElementById(contentId);
		var topicId = clickedObj.id.replace(/C/,'T');
		var topicnode = document.getElementById(topicId);
		if (topicnode == null) return false;
		var imagenodes = topicnode.getElementsByTagName("img");
		var imagenode = imagenodes[0];
		contentnode.TOCstate = (contentnode.TOCstate == 'none') ? 'block' : 'none';
/*		if (imagenode && contentnode.TOCstate == 'none') {
			 imagenode.src = "images/general/yellow_arrow_sub.gif";
		}
		else if (imagenode) {
			 imagenode.src = "images/general/yellow_arrow_down.gif";
		}
*/		
		contentnode.style.display = contentnode.TOCstate;
}

window.onload=function()
{
 	var toBeTOCced = new Array();
	createTOC();
}