function createWekaExtendedSearchTree(div, rpcUrl, treeName, insertValueTo,imagePath) {
		
	if(!imagePath) imagePath=contextPath+"/portlets/ps/core/res/images/tree/";

	var tree = new DynamicTree(div);
	tree.load = function(u,o){
		var r=(window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"));
		r.open('GET',u,true);
		r.setRequestHeader("Content-Type","text/xml");
		r.setRequestHeader("Accept-Language","nl, en, ru, uk");
		r.setRequestHeader("Accept-Charset",this.getCharset());
		r.onreadystatechange=function(){if(r.readyState==4){
			//var n=o.tagName;
			//if(n=="A"||n=="IMG")o=this.getLastChild(o.parentNode);
			//if(n=="A")o=o.parentNode.appendChild(d.createElement("UL"));
			var html=r.responseText.replace(/\{(pl|min)\}/g, imagePath+"$1us-c.gif");
			o.innerHTML=html;
		}
		};
		r.send(null);
	};
		
	tree.getLoadURL=function(img,config){
		var itemId = img.getAttribute("name");
		var rpUrl = rpcUrl + "?treeId="+treeName+"&nodeId={parent}&nocache="+(new Date().getTime());
		return rpUrl.replace("{parent}", encodeURIComponent(itemId));
	}

	tree.itemClick=function(a){
		var href = a.getAttribute("href");
		insertValueTo.value=a.innerHTML;
 		Global.getObject(div).style.display = "none";
		return false;
	}
	
	tree.imgClick=function(img,config){
		var children = img.getAttribute("children");
		var result = !children || children != "false";
		if (result) {
			var openIcon = img.getAttribute("op");  //openIcon
			var closeIcon = img.getAttribute("cl"); //closeIcon
			if (openIcon) {
				img.setAttribute("cl", img.src);
				img.removeAttribute("op");
				img.src = openIcon;
			}else if (closeIcon) {
				img.setAttribute("op", img.src);
				img.removeAttribute("cl");
				img.src = closeIcon;
			}
		} else {
			var a = this.findA(img.parentNode);
			this.internalItemClick(a);
		}
		return result;
	}
		
		
	tree.resizeTreeContainer=function(){
		var d = document;
		var treeDiv = d.getElementById(div);
		if(treeDiv){
			var divs = d.getElementsByTagName("DIV");
			for(var i = 0; i < divs.length; i++) {
				if(divs[i].className == "secondColumn2"){
					var leftDiv = divs[i];
					if(treeDiv.offsetHeight <= leftDiv.offsetHeight){
						treeDiv.style.height = leftDiv.offsetHeight + "px";
					}
				}
			}
		}
	}

	tree.registerResizeEvent = function(e) {
		var w=window;
		if (w.attachEvent){
			w.attachEvent("onload",e);
		} else {
			w.addEventListener("load",e,false);
		}
	}
 	
 	
 	return tree;
}