
function initTree() {
/* Original Code by sean@frontierit.com */

	if (!document.getElementById) return;
	
	var aTrees = document.getElementsByTagName('UL');
	
	if (aTrees.length > 0) {
		for (var i = 0; i < aTrees.length; i++) {
			if (aTrees[i].className == "ftm") {
				ftm(aTrees[i]);
			}
		}
	}
}

function ftm(menu) {

	var docs  = menu.getElementsByTagName('LI');

	for (var i = 0; i < docs.length; i++) {
        var oHref = document.createElement("IMG");
        oHref.src = "../images/x.gif";
        oHref.style.display = 'inline';
        oHref.style.marginRight = '5px';

		if (docs[i].getElementsByTagName('UL').length > 0 ) {

			oHref.src = "../images/plus.gif";
			oHref.style.cursor = 'hand';
			
			oHref.onmousedown = function() {
				if (this.parentNode.childNodes[2].style.display == '' || 
					this.parentNode.childNodes[2].style.display == 'none' ) {
					this.parentNode.childNodes[2].style.display = 'block';
					this.src = "../images/minus.gif";
				
				} else {
					this.parentNode.childNodes[2].style.display = 'none';
					this.src = "../images/plus.gif";
				}
			}
		}
		docs[i].insertBefore(oHref,docs[i].firstChild);
	}
	
	/* Expand Folding Tree Menu to current url if it exists in the tree */
	for (var i = 0; i < docs.length; i++) {

		if (docs[i].childNodes[1].nodeName == 'A' &&
			docs[i].childNodes[1].href == location ) {
			docs[i].firstChild.src = "../images/selected.gif";
			var q = docs[i].parentNode;
			
			while (q.className != 'ftm') {
				q.firstChild.src = "../images/minus.gif";
	          	q.style.display = 'block';
	          	q = q.parentNode;
    	    }
		} 
	}

}

window.onload = initTree;
