var nodes = Array(); // nodes[][Array(level,  Array(id, id, id .. id) )]
var level = Array(); // level[level][setting]

function switchDisplay(rootId, tLevel) {
	divObj  = document.getElementById("div_" + rootId + "no");
	itemObj = document.getElementById("table_" + rootId + "no");
	
	if (divObj.style.display == "block") {
		divObj.style.display = "none";
		itemObj.className = level[tLevel]['classNormal'];
		if (level[tLevel]['rightIcon']) {
			imgObj = document.getElementById("image_" + rootId + "no");
			imgObj.src = level[tLevel]['iconPlus'];
		}
		if ((level[tLevel]['classLinkActive'] != "") && (level[tLevel]['classLink'] != level[tLevel]['classLinkActive'])) {
			hrefObj = document.getElementById("href_" + rootId + "no");
			hrefObj.className = level[tLevel]['classLink'];
		}
	} else {
		divObj.style.display = "block";
		itemObj.className = level[tLevel]['classActive'];
		if (level[tLevel]['rightIcon']) {
			imgObj = document.getElementById("image_" + rootId + "no");
			imgObj.src = level[tLevel]['iconMinus'];
		}
		if ((level[tLevel]['classLinkActive'] != "") && (level[tLevel]['classLink'] != level[tLevel]['classLinkActive'])) {
			hrefObj = document.getElementById("href_" + rootId + "no");
			hrefObj.className = level[tLevel]['classLinkActive'];
		}
		
		collapseNodes(rootId, tLevel);
	}	
}

function collapseNodes(rootId, tLevel) {
	founded = false;
	pos 	= 0;
	while ((pos < nodes.length) && (!founded))
		if (nodes[pos][0] == tLevel) founded = true;
		else pos++;
	
	if (founded) {
		for (f = 0; f < nodes[pos][1].length; f++) {
			if (nodes[pos][1][f] != rootId) {
				if (document.getElementById("div_" + nodes[pos][1][f] + "no").style.display == "block") 
					switchDisplay(nodes[pos][1][f], tLevel);
			}
		}
	}
}
