	var	mid = [1,2,3,4,5,6];
	
function Tree(seed){
	var Tree = this;
	this.seed = seed;
	this.root = document.getElementById(seed);
	this.branches = this.root.getElementsByTagName("LI");
	this.cookie = '';
	this.link = '';

	this.init=function(cookieTrail){
		/* GET INDEX FROM PASSED PARAMETER */
		this.cookie = cookieTrail;
		for(i=0;i<this.branches.length;i++){
		
			/* ADD INDEX TO EACH MENU ITEMS LINK */
			this.branches[i].index = i;
			this.link = this.branches[i].getElementsByTagName('A')[0];
			
			if (this.branches[i].getElementsByTagName('DIV')[0].className.indexOf("topMItem") < 0) {
				temp = this.link.href.split(this.link.search);
				querystring = this.link.search;
				if (this.link.href.indexOf('?') < 0)
					this.link.href += "?treeIndex=" + i + "&mid=" + mid[1];
				else if (this.link.href.indexOf('?') >= 0 && this.link.href.indexOf("treeIndex") < 0)
					this.link.href += "&treeIndex=" + i + "&mid=" + mid[1];
				else if (this.link.href.indexOf('?') >= 0 && this.link.href.indexOf("&mid") >= 0) {
					this.link.href = this.link.href.replace("mid","mid=" + mid[1] + "&cache")
					}
			} else {
				temp = this.link.href.split(this.link.search);
				querystring = this.link.search;
				if (querystring.length == 0 && querystring.indexOf('treeIndex') < 0)
					this.link.href = this.link.href.split('#')[0] + "?treeIndex=" + i;
				else if (querystring.length > 5 && querystring.indexOf('treeIndex') < 0)
					this.link.href = this.link.href.split('#')[0] + "&treeIndex=" + i;
				else if (querystring.length > 5 && querystring.indexOf('treeIndex') >= 0)
					this.link.href = this.link.href.split('treeIndex')[0] + "treeIndex=" + i;
			}

			/* INSERT ARROW IF CURRENT ITEM ON LOOP IS A PARENT BUT NOT TOP LEVEL */
			if (this.branches[i].getElementsByTagName("DIV")[0].className.indexOf("topMItem") < 0 && this.branches[i].getElementsByTagName("UL")[0] != undefined) {
				icon = document.createElement("img");
				icon.src = "/images/074/arrow-down.jpg";
				icon.setAttribute("width", 7);
				icon.setAttribute("index", i);
				icon.setAttribute("height", 7);
				icon.setAttribute("border", 0);
				icon.className = "arrows";
	
				branch = this.branches[i].getElementsByTagName("A")[0];
				branch.insertBefore(icon,branch.firstChild);
			}

			/* HIDE ALL SUBMENUS TO INITIALIZE SUBMENU STATE */
			subs = this.branches[i].getElementsByTagName("UL")[0];
			if (subs)
				subs.style.display = "none";
			
			/* LOOK FOR COOKIE ON THE NAV TREE AND SHOW IT */
			if (this.cookie == i) {
				this.branches[i].style.display = "block";
				parents = this.branches[i].parentNode;
				children = this.branches[i].getElementsByTagName("UL")[0];
				if (this.branches[i].getElementsByTagName('DIV')[0].className.indexOf('topMItem') < 0) {
					this.branches[i].getElementsByTagName('DIV')[0].className += " selected-category";
					while (parents.id != "treemenu") {
						parents.style.display = "block";
						if (children)
							children.style.display = "block";
						parents = parents.parentNode;
					}
				} else {
					parents.style.display = "block";
					if (children)
						children.style.display = "block";
				}
			}
		}
	}
}
