var tree_tpl = {
		
	'target'  : '_self',	// name of the frame links will be opened in
							// other possible values are: _blank, _parent, _search, _self and _top

	'icon_e'  : 'images/empty.gif', // empty image
	'icon_l'  : 'images/line.gif',  // vertical line

    'icon_32' : 'images/base.gif',   // root leaf icon normal
    'icon_36' : 'images/base.gif',   // root leaf icon selected

	'icon_48' : 'images/base.gif',   // root icon normal
	'icon_52' : 'images/base.gif',   // root icon selected
	'icon_56' : 'images/base.gif',   // root icon opened
	'icon_60' : 'images/base.gif',   // root icon selected
	
	'icon_16' : 'images/folder.gif', // node icon normal
	'icon_20' : 'images/folderopen.gif', // node icon selected
	'icon_24' : 'images/folderopen.gif', // node icon opened
	'icon_28' : 'images/folderopen.gif', // node icon selected opened

	'icon_0'  : 'images/page.gif', // leaf icon normal
	'icon_4'  : 'images/page.gif', // leaf icon selected
	
	'icon_2'  : 'images/joinbottom.gif', // junction for leaf
	'icon_3'  : 'images/join.gif',       // junction for last leaf
	'icon_18' : 'images/plusbottom.gif', // junction for closed node
	'icon_19' : 'images/plus.gif',       // junctioin for last closed node
	'icon_26' : 'images/minusbottom.gif',// junction for opened node
	'icon_27' : 'images/minus.gif'       // junctioin for last opended node
	
	//'onItemOpen':'onItemOpenHandler'        // on item open event handler
	// make sure there is no comma after the last key-value pair
};

function onItemOpenHandler(o_item) {
	// get current block
	var a_curblock = o_item.o_parent.a_children;
	// close all nodes except current
	for (var i = 0; i < a_curblock.length; i++)
		if (a_curblock[i].n_state & 48 && a_curblock[i] != o_item)
			a_curblock[i].open(true);
	return true;
}

function closeParents(item) {
	item.open(true);
	item = item.o_parent;
	if (item) {closeParents(item);}
	return true;
}

function onItemOpenHandler2(o_item) {
	if (o_item != o_selected) {closeParents(o_selected);}
	return true;
}

function openItemById(n_uid, o_tree) {
	// set to true when debugging the application
	var B_DEBUG = false;
		
	// find item with specified caption
	var o_item = o_tree.find_item_by_id(n_uid);
	if (!o_item)
		return (B_DEBUG
			? alert("Item with ID '" + n_uid + "' can't be found in the tree hierarchy")
			: false
		);
	
	// check if node/root or leaf
	var a_parents = [];
	if (o_item.n_node_id)
		a_parents[0] = o_item;
	else if (B_DEBUG)
		alert("Item with ID '" + o_item.n_uid + "' is leaf.\nHierarchy will be opened to its parent node only.");
	
	// collect info about all item's parents
	var n_id = o_item.n_id,
		n_depth = o_item.n_depth,
		a_index = o_item.o_root.a_index;
	while (n_depth) {
		if (a_index[n_id].n_depth < n_depth) {
			a_parents[a_parents.length] = a_index[n_id];
			n_depth--;
		}
		n_id--;
	}
	
	// open all parents starting from root
	if (B_DOM) 
		// new browsers version
		for (var i = a_parents.length-1; i >= 0; i--) {
			if(a_parents[i].o_parent == o_tree) continue;
			a_parents[i].n_state |= 4;
			a_parents[i].b_path = true;
			a_parents[i].open();
			a_parents[i].state_lookup();
		}
	else {
		// old browsers version
		for (var i = a_parents.length-1; i >= 0; i--)
			a_parents[i].n_state |= 8;
		a_index[0].o_item.save();
		window.location = window.location;
	}
	
	o_item.b_path = true;
	o_item.n_state |= 4;
	// update styles and images
	o_item.state_lookup();
	
	return 0;
}