
/* expands nodes of the tree
	n_index - zero based index of the tree on the pate
                  if omitomittedn applied to first tree (n_index==0)
	n_depth - zero based level to which the tree with be expanded
	          if omitted the tree will be fully expanded
 */
function expand_all (n_index, n_depth) {
	var o_tree = trees[n_index ? n_index : 0];
	if (!o_tree)
		alert("Tree is not initialized yet");
	var a_index = o_tree.a_index;
//alert("start i loop");	
	for (var i = 0; i < a_index.length; i++) {
//alert("i loop ...");			
		if (n_depth == null || a_index[i].n_depth <= n_depth)
			a_index[i].open(0, 1);
	}
//	o_tree.ndom_refresh();
}

/* collapses nodes of the tree
	n_index - zero based index of the tree on the pate
                  if omited then applied to first tree (n_index==0)
	n_depth - zero based level to which the tree with be collapsed
	          if omitted the tree will collapsed to second level (n_depth==1)
 */
function collapse_all (n_index, n_depth) {
	var o_tree = trees[n_index ? n_index : 0];
	if (!n_depth) n_depth = 1;
	if (!o_tree)
		alert("Tree is not initialized yet");
	var a_index = o_tree.a_index;
	for (var i = a_index.length - 1; i >= 0; i--)
		if (a_index[i].n_depth >= n_depth && a_index[i].open)
			a_index[i].open(1, 1);
//	o_tree.ndom_refresh();
}
