function treeviewFromList(id)
{
	try{
		if(this.CONTAINER = document.getElementById(id))
		{
			this.initialise();
		}
	}catch(e){
		alert(e);
	}
}
treeviewFromList.prototype.initialise = function()
{
	var uls = this.CONTAINER.getElementsByTagName('ul');
	for(var i=uls.length-1;i>=0;i--)
	{
		var lis = uls[i].getElementsByTagName('li');
		for(var j=0;j<lis.length;j++)
		{
			if(lis[j].getElementsByTagName('ul').length>0)
			{
				if(lis[j].firstChild.nodeType==3){lis[j].firstChild.parentNode.removeChild(lis[j].firstChild);}

				if(lis[j].firstChild.firstChild.nodeName.toLowerCase()!='a')
				{
					var a = document.createElement('A');
					a.href='javascript:void(0)';
					var sTxt = new String(lis[j].firstChild.firstChild.nodeValue);
					sTxt = sTxt.replace(/\s+$/,"");
					sTxt = sTxt.replace(/:$/,"");
					var txt = document.createTextNode(sTxt.replace(/:$/,""));
					a.appendChild(txt);
					lis[j].firstChild.insertBefore(a,lis[j].firstChild.firstChild);
					lis[j].firstChild.removeChild(lis[j].firstChild.childNodes[1]);
				}

				lis[j].firstChild.firstChild.onclick = function(){
					if(this.parentNode.parentNode.getElementsByTagName('ul')[0].style.display=='none')
					{
						this.parentNode.parentNode.getElementsByTagName('ul')[0].style.display = '';
						this.parentNode.parentNode.className = 'open';
					}
					else
					{
						this.parentNode.parentNode.getElementsByTagName('ul')[0].style.display = 'none';
						this.parentNode.parentNode.className = 'hasChildren';
					}
					return false;
				};

			}
		}
		//Hide all but the top level...
		if(uls[i].parentNode.nodeName.toLowerCase()!='div')
		{
			uls[i].style.display = 'none';
		}
		//
	}
}


function insertNodePath(sPath,sInputID)
{
	var criteriaPrompt = new String('[ENTER YOUR CRITERIA HERE]');
	try{
		var input = document.getElementById(sInputID);
		//if(input.value != '')
		//{
			document.getElementById(sInputID).value+=' +';
		//}
		document.getElementById(sInputID).value+=sPath+':';

		var startIndex = document.getElementById(sInputID).length+1;
		var endIndex = startIndex+criteriaPrompt.length;

		document.getElementById(sInputID).value+=criteriaPrompt;

		document.getElementById(sInputID).select();

	}catch(e){
		alert(e);
	}
}
