//载入左边树
function loadTree(treeId){
	var p = new HttpRequestParams();
	p.method = "POST";
	p.async = false;
	p.url="info!getSortNameTree.action";
	//p.url="data/tree.xml";
	var xmlHttp = new HttpRequest(p);
	//getResponseXml
	xmlHttp.onresult = function(){
		var responseXMl = this.getResponseXml();
		var treeData = this.getNodeValue("treeData");
		var node = treeData.selectNodes("./treeNode");
		var treeName = [];
		var juDatas = [];
		for (i=0;i<node.length ;i++ ){
			var treeID = node[i].getAttribute("bm");
			var isLeaf = node[i].getAttribute("isLeaf");
			var nextSiblings = node[i].selectNodes("./treeNode").length
			var hasUnit = node[i].getAttribute("hasUnit");
			if(treeId==treeID){
				treeName[treeName.length] = "<div style=clear:both;line-height:20px;margin-left:30px;cursor:hand; id='"+ treeID+"' onclick=openDiv('"+treeID+"','"+isLeaf+"',this,'"+nextSiblings+"','"+hasUnit+"')><font color=#FFD50D><strong>+ "+ node[i].getAttribute("name") + "</strong></font></div>" ;
			}else{
				treeName[treeName.length] = "<div style=clear:both;line-height:20px;margin-left:30px;cursor:hand; id='"+ treeID+"' onclick=openDiv('"+treeID+"','"+isLeaf+"',this,'"+nextSiblings+"','"+hasUnit+"')>+ "+ node[i].getAttribute("name") + "</div>" ;
			}
			for (j=0;j<nextSiblings;j++){
				var zbm = node[i].selectNodes("./treeNode")[j].getAttribute("bm");
				var name = node[i].selectNodes("./treeNode")[j].getAttribute("name");
				if(treeId==""){		//刷新时为空字符串
					if(treeID == '01'){	//默认展示机构设置的子类别
						if(zbm=="0101"){	//默认领导简历选中
							treeName[treeName.length] = "<div style=clear:both;line-height:20px;margin-left:40px;cursor:hand; id='"+zbm+"' onclick=openDiv('"+zbm+"','1',this,'"+nextSiblings+"','"+hasUnit+"')><font color=#FFD50D><strong>&nbsp;&nbsp;&nbsp;"+ name + "</strong></font></div>" ;
						}else{
							treeName[treeName.length] = "<div style=clear:both;line-height:20px;margin-left:40px;cursor:hand; id='"+zbm+"' onclick=openDiv('"+zbm+"','1',this,'"+nextSiblings+"','"+hasUnit+"')>&nbsp;&nbsp;&nbsp;"+ name + "</div>" ;
						}	
					}else{
						treeName[treeName.length] = "<div style=display:none;clear:both;line-height:20px;margin-left:40px;cursor:hand; id='"+zbm+"' onclick=openDiv('"+zbm+"','1',this,'"+nextSiblings+"','"+hasUnit+"')>&nbsp;&nbsp;&nbsp;"+ name + "</div>" ;
					}
				}else{	//有树结点传值的情况
					var len = treeId.length;
					if(len==4){	//展示的是子类别
						var parentId = treeId.substring(0,treeId.length-2);
						if(treeID == parentId){	// 选中子类别的父类别
							if(zbm==treeId){	//选中
								treeName[treeName.length] = "<div style=clear:both;line-height:20px;margin-left:40px;cursor:hand; id='"+zbm+"' onclick=openDiv('"+zbm+"','1',this,'"+nextSiblings+"','"+hasUnit+"')><font color=#FFD50D><strong>&nbsp;&nbsp;&nbsp;"+ name + "</strong></font></div>" ;
							}else{
								treeName[treeName.length] = "<div style=clear:both;line-height:20px;margin-left:40px;cursor:hand; id='"+zbm+"' onclick=openDiv('"+zbm+"','1',this,'"+nextSiblings+"','"+hasUnit+"')>&nbsp;&nbsp;&nbsp;"+ name + "</div>" ;
							}	
						}else{
							treeName[treeName.length] = "<div style=display:none;clear:both;line-height:20px;margin-left:40px;cursor:hand; id='"+zbm+"' onclick=openDiv('"+zbm+"','1',this,'"+nextSiblings+"','"+hasUnit+"')>&nbsp;&nbsp;&nbsp;"+ name + "</div>" ;
						}
					}else{
						treeName[treeName.length] = "<div style=display:none;clear:both;line-height:20px;margin-left:40px;cursor:hand; id='"+zbm+"' onclick=openDiv('"+zbm+"','1',this,'"+nextSiblings+"','"+hasUnit+"')>&nbsp;&nbsp;&nbsp;"+ name + "</div>" ;
					}
				}
			}
		}
		var treehtmlData = document.getElementById("treehtmlData");
		treehtmlData.innerHTML = treeName.join("");
	}
	xmlHttp.send();
}
//点树节点控制
function openDiv(treeId,isLeaf,obj,nextSiblings,hasUnit){
	if (hasUnit == 1){
		var treeName = (obj.innerText.charAt(0)=="+")?obj.innerText.substr(2):obj.innerText;
		location.href="cmulu_chushi.htm?treeId=" + treeId + "&treeName=" + treeName;
	}else{
		if (isLeaf == 1){
			var treeName = (obj.innerText.charAt(0)=="+")?obj.innerText.substr(2):obj.innerText;
			location.href="cmulu_title.htm?treeId=" + treeId + "&treeName=" + treeName;
		}else{
			for (i=0;i<nextSiblings;i++){
				if (obj.nextSibling.style.display == ""){
					obj.nextSibling.style.display = "none";
				}else{
					obj.nextSibling.style.display = "";
				}
				obj = obj.nextSibling;
			}
		}
	}
}