function Tree_getSelectedIndex(id) {
	var tree = document.getElementById(id);
	if (tree != null) {
		var selIndex = tree.getAttribute("selIndex");
		if (selIndex == null) {
			tree.setAttribute("selIndex", -1);
			selIndex = -1;
		}
		return parseInt(selIndex);
	} else {
		return -1;
	}
}

function Tree_setSelectedIndex(id, index) {
	var tree = document.getElementById(id);
	if (tree != null) {
		var oldIndex = Tree_getSelectedIndex(id);
		tree.setAttribute("selIndex", index);
		var statePostfix = getPostfixForState(getElementState(tree));
		var newClassName = id + statePostfix;
		if (index != 0) {
			newClassName = newClassName + "_" + index;
		}
		if (statePostfix == "_Disabled") {
			newClassName = id + "_Disabled";
		}
		if (tree.className != newClassName) {
			tree.className = newClassName;
		}
		if (oldIndex != index) {
			try {
				eval(id + "_onSelectionChanged(" + index + ");");
			} catch (err) {}
		}
	}
}
