	var open_image = "/products/images/btn_open.gif";
	var closed_image = "/products/images/btn_close.gif";

	var first_only = "yes";
	var level=0;

	var expanduser_tracking = new Array();
	var original_out_bgcolors = new Array();
	var original_out_text_colors = new Array();

	var original_down_bgcolors = new Array();
	var original_down_text_colors = new Array();
	var current_node = "";
	var current_node_array = new Array();
	var mouse_over_colors = new Array();
	var mouse_down_colors = new Array();
	var mouse_out_colors = new Array();
	

	function byid(id) {
		if (document.getElementById(id)){
		  return document.getElementById(id);
		}
			}
	function tree_mouse_over(item, bgcolor, text_color) {
		if (mouse_over_colors[level].length == 2) {
			bgcolor = mouse_over_colors[level][0];
			text_color = mouse_over_colors[level][1];
		}
		byid("main"+item).style.backgroundColor=bgcolor;
		byid("href"+item).style.color=text_color;
		if (byid("nav"+item)) {
			byid("nav"+item).style.color=text_color;
		}
	}
	function tree_mouse_out(id, bgcolor, text_color) {
		id_list = id.split(":");
		level = id_list.length-1;
		if (mouse_out_colors[level].length == 2) {
			bgcolor = mouse_out_colors[level][0];
			text_color = mouse_out_colors[level][1];
		}
		if ((id == current_node_array[level])) {
			if (mouse_down_colors[level]) {
				bgcolor = mouse_down_colors[level][0];
				text_color = mouse_down_colors[level][1];
			}
			else {
				bgcolor = "";
				text_color = "";
			}
		}
		byid("main"+id).style.backgroundColor=bgcolor;
		byid("href"+id).style.color=text_color;
		if (byid("nav"+id)) {
			byid("nav"+id).style.color=text_color;
		}
	}
	function tree_mouse_down(id, bgcolor, text_color) {
		id_list = id.split(":");
		level = id_list.length -1;
		if (mouse_down_colors[level].length == 2) {
			bgcolor = mouse_down_colors[level][0];
			text_color = mouse_down_colors[level][1];
		}
		mouse_down_colors[level] = Array(bgcolor, text_color);
		byid("main"+id).style.backgroundColor=bgcolor;
		byid("href"+id).style.color=text_color;
		if (byid("nav"+id)) {
			byid("nav"+id).style.color=text_color;
		}
	}

	//This function set all colors of node array to none
	function clear_nodes() {
		current_node_array = new Array();
		for ( level in expanduser_tracking ) {
			node_id = expanduser_tracking[level][0];
			if (mouse_out_colors[level]) {
				bgcolor = mouse_out_colors[level][0];
				text_color = mouse_out_colors[level][1];
			}
			else {
				bgcolor = "";
				text_color = "";
			}
			if (byid("main"+node_id)) {
				byid("main"+node_id).style.backgroundColor=bgcolor;
			}
			if (byid("href"+node_id)) {
				byid("href"+node_id).style.color= text_color;
			}
			if (byid("nav"+node_id)) {
				byid("nav"+node_id).style.color= text_color;
			}
			if (byid(node_id))
				byid(node_id).style.display="none";

			if (byid("img"+node_id)) {
				byid("img"+node_id).src=closed_image;
			}
		}
	}

	//This function will open or close a branch on the tree
	function expand_contract(id, node) {
		current_node = id;
		id_list = id.split(":");
						if (node == "child") {
			if (byid("table"+id)) {
				clear_nodes();
				expand_parents(id, "child");
				if (byid("node_id")) {
					byid("node_id").value = id;
				}
			}
			first_only = "";
		}
		//if parent 
		else { 
			current_id = id;
			if (byid(current_id)) {
				if (byid(current_id).style.display == "none") { // If we are expanding a node
					clear_nodes();
					if (byid(id)) {
						expand_parents(id, "parent");
					}
					id_string = "";
				}
				else { //If we are closing a node
					//Here we get the parent id so that we can expand it
					clear_nodes();
					level = id_list.length -1;
					if (level > 0) { //If level is 0 there is no parent id
						id_list.pop();
						parent_id = "";
						for (x=0; x<id_list.length; x++) {
							if (parent_id != "") {
								parent_id += ":";
							}
							parent_id += id_list[x];
						}
						expand_parents(parent_id, "parent");
					}
				}
			first_only = "";
			}
		}
	}

	//This function expands a node and parents above it
	function expand_parents(id, type) {
		id_list = id.split(":");
		level = id.length -1;
		id_string = "";
		temp_color_array = new Array();
		current_node_array = new Array();
		for (x=0; x<id_list.length; x++) {
			if (id_string == "") {
				id_string = id_string + id_list[x];
			}
			else {
				id_string = id_string + ":" + id_list[x];
			}
			temp_id_list = id_string.split(":");
			level = temp_id_list.length -1;
			if (byid("main"+id_string)) {
				if (mouse_down_colors[level]) {
					byid("main"+id_string).style.backgroundColor=mouse_down_colors[level][0];
					byid("href"+id_string).style.color=mouse_down_colors[level][1];
					if (byid("nav"+id_string)) {
						byid("nav"+id_string).style.color=mouse_down_colors[level][1];
					}
				}
				else {
					byid("main"+id_string).style.backgroundColor="";
					byid("href"+id_string).style.color="";
					if (byid("nav"+id_string)) {
						byid("nav"+id_string).style.color="";
					}
				}
			}
			if (byid(id_string)) {
				byid(id_string).style.display = "block";
				if (byid("img"+id_string)) {
					byid("img"+id_string).src=open_image;
				}
			}
			current_node_array[level] = id_string;
			expanduser_tracking[level] = Array(id_string, type);
		}
	}

	

	//This function takes the user variable and makes the links in the tree link to the link location or just expand
	function linking_disabled(node_ids, type) {
		if (byid("disable_linking")) {
			if (byid("disable_linking").value != "yes") {
				expand_contract(node_ids, type);
			}
			return false;
		}
		else {
			return true;
		}
	}

	