/*

	Feel free to use your custom icons for the tree. Make sure they are all of the same size.

	If you don't use some keys you can just remove them from this config

*/



var TREE_TPL={'target':'content','icon_48':'icons/base.gif','icon_52':'icons/base.gif','icon_56':'icons/down.gif','icon_60':'icons/down.gif','icon_16':'icons/folder.gif','icon_20':'icons/folderopen.gif','icon_24':'icons/folderopen.gif','icon_28':'icons/folderopen.gif','icon_80':'icons/folderopen.gif','icon_0':'icons/empty.gif','icon_4':'icons/empty.gif','icon_2':'icons/empty.gif','icon_3':'icons/empty.gif','icon_18':'icons/plusbottom.gif','icon_19':'icons/plus.gif','icon_26':'icons/minusbottom.gif','icon_27':'icons/minus.gif','icon_e':'icons/empty.gif','icon_l':'icons/line.gif','style_48':'mout','style_52':'mout','style_56':'mout','style_60':'mout','style_112':'mout','style_116':'mout','style_120':'mout','selstyle_124':'mout','style_16':'moutsel','style_20':'moutsel','style_24':'mout','style_28':'moutsel','style_80':'mout','style_84':'moutsel','style_88':'mout','style_92':'moutsel','style_0':'mout','style_4':'moutsel','style_64':'mout','style_68':'moutsel'};





/*

	This function opens first tree item which has caption specified

	There are a lot of verifications that will help you to debug your

	code. You can disable or remove those checks when finished.

*/

function openItemByCaption (s_caption, o_tree, o_menuitem) {

	// set to true when debugging the application

	var B_DEBUG = true;



	// exit if required parameter isn't specified

	if (!s_caption)

		return (B_DEBUG

			? alert("Required parameter to function openItemByCaption is missing")

			: false

		);



	// use first tree on the page if tree object isn't explicitly defined

	if (!o_tree)

		o_tree = (TREES[0]);

	if (!o_tree)

		return (B_DEBUG

			? alert("No Tigra Tree Menu PRO instances can be found on this page")

			: false

		);



	// find item with specified caption

	var o_item = o_tree.find_item(s_caption);

	if (!o_item)

		return (B_DEBUG

			? alert("Item with caption '" + s_caption

				+ "' can't be found in the tree hierarchy")

			: false

		);



	// 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,

		a_parents = [o_item];



	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

	for (var i = a_parents.length-1; i >= 0; i--)

		// check if node or root

		if (a_parents[i].n_state & 48)

			a_parents[i].open();

		else

			return (B_DEBUG

				? alert("Item with caption '" + a_parents[i].a_config[0]

					+ "' is leaf.\nHierarchy will be opened to its parent node only.")

				: false

			);

	

	// set select state of item

	var o_links = o_tree.find_item(s_caption);

	var o_linknumber=o_links.a_children[o_menuitem].n_id;

	o_tree.select(o_linknumber);

}

