﻿<!--
/*---------------------------------------------------------------------------*\
|  Subject:       EpointTreeView Class                                   |
|  Version:       0.1                                                         |
|  Author:        袁勋 （参考“梅花雪”的MzTreeView1.0）                      |
|  FileName:      EpointTreeView.js                                               |
|  Created:       2007-02-28                                                  |
|  LastModified:                                                              |
\*---------------------------------------------------------------------------*/
        
    /* 实现了中英文混合字符串取长度*/
    /* 取得字符串的字节长度        */
    function strLen(str)
    {
	    if(str==null) return 0;
	    var i;
	    var len;
	    var strTmp;
	    strTmp=str;
	    len = 0;
	    for (i=0;i<strTmp.length;i++)
	    {
		    if (strTmp.charCodeAt(i)>255) len+=2; 
		    else len++;
	    }
	    return len;
    }

    function array_has(val)
    {
        var i;
        for(i = 0; i < this.length; i++)
        {
            if(this[i] == val)
            {
                return true;
            }
        }
        return false;
    }
    Array.prototype.has = array_has;
 
    function nocontextmenu() 
    {
        event.cancelBubble = true
        event.returnValue = false;

        return false;
    }


    //document.oncontextmenu = nocontextmenu; 
 
    function array_remove(val)
    {
        var i;
        var j;
        for(i = 0; i < this.length; i++)
        {
            if(this[i] == val)
            {
                for(j = i; j < this.length - 1; j++)
                {
                    this[j] = this[j + 1];
                }
                this.length = this.length - 1;
            }
        }
    }
    Array.prototype.remove = array_remove;
 
    function array_removeAt(index)
    {
        var i;
        if(index < this.length)
        {
            for(i = index; i < this.length - 1; i++)
            {
                this[i] = this[i + 1];
            }
            this.length = this.length - 1;
        }
    }
    Array.prototype.removeAt = array_removeAt;
    
    if(typeof(Epoint_IE) != "boolean")
	var Epoint_IE = (document.all) ? true : false;
	
	if(typeof(Epoint_TextTreeView) != "object")
	var Epoint_TextTreeView=[];
	
	if(typeof(Epoint_TreeViewExpand) != "object")
	var Epoint_TreeViewExpand=[];
	
    var RootNodeId = "RootNode";
    function Epoint_getSrcElement(evnt)
    {
	    if(Epoint_IE)
		    return evnt.srcElement;
	    else
		    return evnt.target;
    }

    function Epoint_getElementById(id)
    {
        
	    var el;
	    if(Epoint_IE)
		    el = document.all[id];
	    else 
		    el = document.getElementById(id);
	    return el;
    }
	
    var _d = "\x0f";//tree.names中的节点sourceindex分割符
	//从节点信息数组tree.nodes中获取节点信息
	String.prototype.getParam = function(name) 
	{
		var reg = new RegExp("(^|;|\\s)"+name+"\\s*:\\s*([^;]*)(\\s|;|$)", "i");
		var str = this.replace(/(;[^:]+)(;|$)/g, function(a,b,c){return b.replace(/;/g, "\x0f")+c;});
		var r = str.match(reg); 
		if (r!=null) 
		return unescape(r[2].replace(/[\x0f]/g, ";")); 
		return "";
	}

    String.prototype.remove=function(str)
    {
        if(this == str) return "";
        var s='';
        var len = str.length;
        var index = this.indexOf(str);
        if(index>-1)
        {
            if(index==0)
                s=this.substring(len,this.length);  
            else
            {
                index = this.indexOf(";" + str);
                s=this.substring(0,index + 1);
                if(index + len + 1<=this.length) 
                    s+=this.substring(index + len + 1,this.length);                
            }
            return s;
            
        }
        else
            return this;
    };
    
    String.prototype.EpointAddStr=function(str,div)
    {
        var index = this.indexOf(str);
        
        if(index==-1)
           return this + str;
        
        if(index==0)
            return this;
        else
        {
            if(div==null)
                return this + str;
            else
            {
                if(this.indexOf(div + str) > -1)
                    return this;
                else
                    return this + str;
            }                   
        }        
    };
    
	function getObjectById(id)
	{
		if (typeof(id) != "string" || id == "") return null;
		if (document.all) return document.all(id);
		if (document.getElementById) return document.getElementById(id);
		try {return eval(id);} catch(e){ return null;}
	}

	//MzTreeView类
	//Tname: 树的name
	//ListBoxID:表单的name， 用来调用ajax
	function MzTreeView(Tname,TID,_sript,bTextTreeView,divID,bCheckChildCheckBox,bRunClickEvtWhenCheckChild)
	{
	
	    //targetListBoxID = ListBoxID;
	    
		if(typeof(Tname) != "string" || Tname == "")
			throw(new Error(-1, 'no Class Name'));
	  
		this.divider  = "\b";
		this.url      = "#";
		this.target   = "_self";
		this.name     = Tname;
		this.id       = TID;
		this.index    = 0;
		this.nodes    = {};
		this.currentNode = null;
        this.script = _sript;
        this.IsTextTreeView = bTextTreeView;
        this.divID = divID;
        this.CheckChildCheckBox = bCheckChildCheckBox;
        this.RunClickEvtWhenCheckChild = bRunClickEvtWhenCheckChild;
        this.HidSelectValue = null;
		var highLight = "#0A246A";
		var highLightText   = "#FFFFFF";
		var mouseOverBgColor= "#D4D0C8";

		this.createHTML = function(node, AtEnd)
		{
			var data = node.data; 
			var id   = node.id; 
			var url =  node.url; 
			if(!url) url = this.url;
			if(data) url += (url.indexOf("\?")==-1?"\?":"&") + data;
			var HCN  = node.hasChild, isRoot = node.parentId=="0";
			if(isRoot && node.icon=="") node.icon = "root";
			if(node.icon=="") node.icon = HCN ? "folder" : "file";
			
			node.iconExpand  = HCN ? AtEnd ? "PM2" : "PM1" : AtEnd ? "L2" : "L1";

			if(node.id!="0" && !isRoot)  
			    node.childAppend = node.parentNode.childAppend + "<IMG border='0' align='absmiddle' src='"+this.icons[(AtEnd?"empty":"L4")].src+"'>";
			var nodeHTML = "<DIV noWrap id='" + Tname +"_Node_"+ id  + "' divType='Node'>";
				
			if(!isRoot)
		    {
			    nodeHTML += node.parentNode.childAppend +
				"<IMG border='0' align='absmiddle' id='"+ Tname +"_expand_"+ id +"' ";
				if(HCN)
				    nodeHTML += "onclick=\""+ Tname +".expand('"+ id +"')\" ";
				nodeHTML += "src='"+ this.icons[node.iconExpand].src +"' style='cursor: hand'>";
			}
			nodeHTML += "<SPAN oncontextmenu='return "+ Tname +".popupmenu(\""+ id +"\")' "
				+ " onclick =\""+ Tname +".focus('"+ id +"', true);\" "
				+">";	
										
		    if(node.ShowImage!="false")
		    {
		        nodeHTML += "<IMG border='0' align='absmiddle' id='"+ Tname +"_icon_"+ id +"' ";
		        if(node.ImageUrl=="")    
		            nodeHTML += "src='"+ this.icons[node.icon].src +"'";	
		        else
		            nodeHTML += "src='"+ node.ImageUrl +"'";
		       
		        if(node.ImageToolTip != "")
		            nodeHTML += "title='"+ node.ImageToolTip +"'";
		            
		       nodeHTML += ">";
		    }    			
  			if(node.ctrl) //add by yx 2007-2-28 如果发现ctrl属性=true，则根据ctrlType加上checkbox或radio
			{
				nodeHTML += "<input type='"+ node.ctrlType +"' name='"+ node.ctrlName  +
  				"' id='"+ this.name +"_checbox_"+ id +"' style='height:15px;'";	  				  			
	  			
	  			if(node.ctrlenable == "false")
	  			{
	  			    nodeHTML += " disabled";
	  			}
	  			
  				if(node.hasChild && node.ctrlType=='checkbox') //add by yx 2007-2-28 如果当前有checkbox，且有子节点，增加全选事件处理
  				{
                    nodeHTML+=" onclick=\""+ this.name +".CheckChildNode('"+ id +"',this.checked,'" + this.CheckChildCheckBox + "');";  
	  				nodeHTML+=node.ctrlClick;
	  			}	
	  			else
  					nodeHTML+=" onclick=\""+node.ctrlClick;
  				
  				if(node.ExpandOnCheckedChanged=="true")
  				    nodeHTML+="; " + this.name +".expand_forSelect('"+ id +"',true,this.checked);"; 
  				
  			    nodeHTML += "\" ";
  				if(node.ctrlChecked=="true")
  				    nodeHTML+="checked=true>";	
  				else
  				{
  				    if(this.IsTextTreeView && this.HidSelectValue!=null && CheckIsSelect(this.HidSelectValue,node.id))
  				        nodeHTML+="checked=true>";	
  				    else
  				        nodeHTML+=">";
  				}
			}	
  			nodeHTML+=	"<SPAN onmouseover='this.style.backgroundColor=\""+
				mouseOverBgColor +"\"' onmouseout='this.style.backgroundColor=\"\"'><NOBR><A class='MzTreeview' id='"+ Tname +"_link_"+ id +"' ";
			
			if(url.toLowerCase().indexOf("javascript:") > -1)
			{
			    //nodeHTML +=	" target='_self' ";
			    //nodeHTML +=	" href=\"javascript:void(0);\" ";
			    nodeHTML +=	" href=\"#;\" ";
			    nodeHTML +=	" onclick=\"" + url + "\" ";
			}
			else
			{
			    if(url!="#")
			    {
			        nodeHTML +=	" target='"+ this.target + "' ";
			        nodeHTML +=	" href=\""+ url + "\" ";
			    }
			    else
			    {
			        nodeHTML +=	" target='_self' ";
			        //nodeHTML +=	" href=\"javascript:void(0);\"";
			        nodeHTML +=	" href=\"#;\" ";
			    }
			}
			///upd by xgc 点击节点不展开节点
            nodeHTML +=	"title='"+ node.hint +"' onmouseup=\"" + Tname + ".ShowRightButton('" + node.id + "');\" >"+ node.text +"</A>"+
				"</SPAN></NOBR></SPAN>\r\n"; 
			
			nodeHTML += "<DIV id='"+ Tname +"_tree_"+ id +"' style='DISPLAY: none' divType = 'Nodes'></DIV></DIV>";

			if(isRoot && node.text=="") 
			    nodeHTML = "";
			
			return nodeHTML;
		};
		
		
		this.node = [];
		this.node["0"] =
		{
			"id": "0",//node编号，以按节点显示顺序依次加1
			"path": "0",//某个节点的id路径，格式为“……祖节点id-父节点id-当前节点id”
			"isLoad": false,//指示某个节点是否已近装载
			"childNodes": new Array(),//节点的子节点信息，在this.load方法中赋值
			"childAppend": "",//暂时没有用到
			"sourceIndex": "0",//原始节点信息数组中的下标
			"hasChild" : ""//是否有子节点
		};

	   
		//载入新节点
		//sign是用来控制显示“加载中...”的变量
		this.load = function(id,sign)
		{
		    //alert("load id is " + id);
			var me  = this, node = this.node[id];
//			alert(id);
			if(sign && (id != "0"))
			{
//			    alert('ppp');
                if(id=="RootNode" && node.childNodes==null)
                {}
                else
                {
				    setTimeout(me.name +".load('"+ id +"',false)", 1);
				    getObjectById(me.name +"_tree_"+ id).innerHTML = node.childAppend +
				    "<IMG border='0' align='absmiddle' src='"+this.icons["L2"].src+"'>"+
				    "<IMG border='0' align='absmiddle' src='"+this.icons["file"].src+"'>"+
				    "<span style='background-Color: "+ highLight +"; color: "+ highLightText +
				    "; font-size: 9pt'>"+ unescape("%u52A0%u8F7D%u4E2D") +"...</span>";
				    return;
				}
			}
			node.hasComplete = false;
			if(!node.isLoad && node.PopulateOnDemand)
			{
			    //alert(node.childNodesFileName)
			    //alert(node.childNodesFileName.length);
				if((node.childNodesFileName)&&(node.childNodesFileName != "undefined")&&(node.childNodesFileName.length > 0))
				{	
				    //alert('222');
					var parentNodeChecked=false;
					try//显示一个节点是判断是否是选中的checkbox ，加try-catch是为了防止该节点没有checkbox
					{
						var pckboxID = this.name +"_checbox_"+ id;
						var pckbox  = getObjectById(pckboxID);
						parentNodeChecked=pckbox.checked;
					}
					catch(e){}
					this.LoadSubNodeInfo(id,node.text,node.sourceIndex,parentNodeChecked,'1');
				}
				else
				{
				    //alert("test222");
				    this.Compelete(id,'1');
				}
			}
			else
            {
                //alert("test11");
                this.Compelete(id,'1');
            }
		};
		
		// UPD BY XGC 2007-3-28 
		// sourceIndex ：当前节点的下标
		// parentNodeChecked：当前节点点是否选中
		this.LoadSubNodeInfo = function(id,text,sourceIndex,parentNodeChecked,context) 
		{
		    
			if(context == null) 
			    context = '1';
			var args = context + '|' + sourceIndex + '|' + id + '|' + escape(text) + '|' + parentNodeChecked;
			eval(this.script);
		}

		this.nodeInit = function(sourceIndex, parentId)
		{
			this.index++;
			var param = this.nodes[sourceIndex];
			var id = param.getParam("id") == "" ? "0":param.getParam("id");
			this.node[id] = new EpointTree_InitNode(this,param,sourceIndex,this.divider,parentId);
			if(this.node[id].hasChild)  
				this.node[id].childNodes = new Array();
			this.nodes[sourceIndex] = id;
			return this.node[id];
		};
		
		this.RemoveNode = function(value,pValue,bHasChild)
		{
		    var node = this.node[value];
		    var pNode;
		    if(node == null)
		    {
		        pNode = this.node[pValue];
		        if(pNode != null)
		        {
		            pNode.hasChild = bHasChild;
		            pNode.resetLinkImage();
		        }		        
		        return;
		    }
		    var preNode = node.getPrevNode();
            pNode = node.parentNode;
		    var parentId = node.parentId;
		    var elem = getObjectById(this.name + "_Node_" + value);
		    var pelem = elem.parentNode;
		    if(elem)
		    {
		        pelem.removeChild(elem);
		    }
		    pNode.childNodes.remove(node);
		    this.nodes[node.sourceIndex] = null;
		    this.node[value] = null;
		    node = null;
		    if(parentId ==RootNodeId)
		        this.names = this.names.replace("\x0f" + this.id + "\b" + value + "\x0f","");
		    else
		    {
		        this.names = this.names.replace("\x0f" + parentId + "\b" + value + "\x0f","");
		        if(pNode)
                {
                    if(pNode.childNodes.length==0)
                    {
                        pelem.outerHTML ="<DIV id='"+ this.name +"_tree_"+ parentId + "' style='DISPLAY: none' divType = 'Nodes'></DIV>";
                        pNode.hasChild = false;
                        pNode.isExpand = false;
                        pNode.isLoad = false;
                        pNode.icon = pNode.hasChild ? "folder" : "file";
			
//			            pNode.iconExpand  = pNode.hasChild ? AtEnd ? "PM2" : "PM1" : AtEnd ? "L2" : "L1";
                    }
                    pNode.resetLinkImage();
                }
            }
		    if(preNode)
            {
                preNode.resetLinkImage();   
                if(preNode.isEndNode())
                    preNode.resetChildLinkImage(0);      
            }
            
		};
		
        this.InsertRootNode = function(value,
				text,
				hint,
				ImageUrl,
				ImageToolTip,
				hasChild,
				url,
				data,
				ctrl,
				ctrlClick,
				ctrlChecked,
				ctrlType,
				bShowImage,
				bRunClickEvtOnInit,
				bExpandOnCheckedChanged,
				sOnmouseup,
				bPopulateOnDemand,
				bCheckChildCheckBox)
	    {
	        this.InsertChildNode(value,
				text,
				hint,
				ImageUrl,
				ImageToolTip,
				RootNodeId,				
				hasChild,
				url,
				data,
				ctrl,
				ctrlClick,
				ctrlChecked,
				ctrlType,
				bShowImage,
				bRunClickEvtOnInit,
				bExpandOnCheckedChanged,
				sOnmouseup,
				bPopulateOnDemand,
				bCheckChildCheckBox);
        };
        
        this.InsertChildNode = function(value,
				text,
				hint,
				ImageUrl,
				ImageToolTip,
				parentValue,
				hasChild,
				url,
				data,
				ctrl,
				ctrlClick,
				ctrlChecked,
				ctrlType,
				bShowImage,
				bRunClickEvtOnInit,
				bExpandOnCheckedChanged,
				sOnmouseup,
				bPopulateOnDemand,
				bCheckChildCheckBox)
	    {
	        if(this.node[value])
	        {
	            alert("您添加的节点“" + value + "”已经在树中存在！")
	            return;
	        }
	        
	        if(parentValue==RootNodeId)
	            this.names += "\x0f" + this.id + "\b" + value + "\x0f";
	        else
	            this.names += "\x0f" + parentValue + "\b" + value + "\x0f";
	        var js = "id:" + value + ";url:" + url + ";text:" + text
                     + ";hasChild:" + hasChild + ";";
            if(ctrl==true)
            {
                js +=  "ctrl:true;";
                if(ctrlType.toLowerCase() == "checkbox")
                    js += "ctrlName:" + this.name + "_" + value + "_CheckBox;ctrlType:checkbox;";
                else
                    js +=  "ctrlName:" + this.name + "_Radio;ctrlType:radio;";
                js +=  "ctrlChecked:" + ctrlChecked + ";";
            }
            if(ctrlClick!= "")
                js += "ctrlClick:" + ctrlClick + ";";
            if(hint!= "")
                js += "hint:" + hint + ";";
                
            if(!bShowImage)
                js += "ShowImage:false;";
            
            if(bRunClickEvtOnInit)
                js += "RunClickEvtOnInit:true;";
            if(bExpandOnCheckedChanged)
                js += "ExpandOnCheckedChanged:true;";
            if(ImageUrl!="")
                js += "ImageUrl:" + ImageUrl + ";";
            if(ImageToolTip!="")
                js += "ImageToolTip:" + ImageToolTip + ";";
            if(sOnmouseup!="")
            {
                if(sOnmouseup.toLowerCase().indexOf("javascript:") > -1)
                    js += "onmouseup:" + sOnmouseup.substring(11) + ";";
                else
                    js += "onmouseup:" + sOnmouseup + ";";
            }
            if(bPopulateOnDemand)
                js += "PopulateOnDemand:true;";
            else
                js += "PopulateOnDemand:false;";
			//js += "CheckChildCheckBox:" + bCheckChildCheckBox.toString().toLowerCase() + ";";
            var pnode = this.node[parentValue];
	        if(parentValue == RootNodeId)
            {
                this.nodes[this.id + this.divider + value] =  js;
                var node = this.nodeInit(this.id + this.divider + value, parentValue);
                var tcn = pnode.childNodes;
                if(tcn==null)
                {
                    tcn = pnode.childNodes = new Array();
                    getObjectById(Tname + "_tree_" + RootNodeId).innerHTML ="";
                }
                
                tcn[tcn.length] = node;
                getObjectById(Tname + "_tree_" + RootNodeId).insertAdjacentHTML("beforeEnd",this.createHTML(tcn[tcn.length - 1], true));
                var preNode = node.getPrevNode();
                
                if(preNode)
                    preNode.resetLinkImage();
            }
            else
            {
                this.nodes[parentValue + this.divider + value] =  js;
                
                if(!pnode.hasChild)
                {
                    pnode.hasChild = true;
                    pnode.childNodes = new Array();
                }
                pnode.resetLinkImage();                
                if(!pnode.isExpand)
                {                   
                    this.expand(parentValue);
                }
                else
                {
                    var tcn = this.node[parentValue].childNodes;
                    var node = this.nodeInit(parentValue + this.divider + value, parentValue);
                    tcn[tcn.length] = node;
                    getObjectById(Tname + "_tree_" + parentValue).insertAdjacentHTML("beforeEnd",this.createHTML(tcn[tcn.length - 1], true));
                    var preNode = node.getPrevNode();
                    if(preNode)
                        preNode.resetLinkImage();
                }
            }
        };
        
        
        
		this.drawNode = function(id,type)
		{		   
			var tcn     = this.node[id].childNodes, str = "";
			for (var i=0; i<tcn.length; i++) 
			{
			    str += this.createHTML(tcn[i], i==tcn.length-1);
			}
			getObjectById(Tname +"_tree_"+ id).innerHTML = str;
			if(type=='2')
			{
			    this.expand(id);
			    setTimeout(this.name + ".drawChildNode('" + id + "')",1);
			}
			
			if(this.IsTextTreeView)
                setTimeout("reComputeIFrameWidth('" + this.divID + "')",10);
		};

        this.drawChildNode = function(id,type)
        {
            var tcn     = this.node[id].childNodes
            for (var i=0; i<tcn.length; i++) 
                if(tcn[i].RunClickEvtOnInit == "true")
                    getObjectById(tcn[i].ctrlName).onclick();
        };

		this.getPath= function(id)
		{
			var A = new Array(); A[0] = id, pid=id;
			while(id!="0" && id!="")
			{
				var str = "(^|"+_d+")([^"+_d+ this.divider +"]+"+ this.divider + id +")("+_d+"|$)";
				var ids = this.names.match(new RegExp(str, "g"));
				if(ids)
				{
					id = ids[0].replace(_d, "").split(this.divider)[0];
					A[A.length] = id;
				} else break;
			}
			return A.reverse();
		};

		this.focus      = function(id, onlySimpleFocus)
		{
			if(!this.currentNode) this.currentNode=this.node["0"]; if(!onlySimpleFocus){
			if(typeof(this.node[id])=="undefined") var apid = this.getPath(id);
			else var apid = this.node[id].path.split(this.divider);
			for(var i=0; i<apid.length-1; i++) this.expand(apid[i], true);}

			var a = getObjectById(Tname +"_link_"+ id); 
			if (a) 
			{ 
			    try
			    {
			        a.focus();// //alert("focus "+ id);
			    }
			    catch(e)
			    {
			        return;   
			    }
			    var link = getObjectById(Tname +"_link_"+ this.currentNode.id);
			    if(link)with(link.style)
			    {
			        color="";
			        backgroundColor="";
			    }
			    with(a.style)
			    {
			        color = highLightText; 
			        backgroundColor = highLight;
			    }
			    this.currentNode= this.node[id];
			}			
		};
	  
		this.expand   = function(id, sureExpand)
		{
			var node  = this.node[id];
			if (sureExpand && node.isExpand) return;
			var area    = getObjectById(Tname +"_tree_"+ id);
			Epoint_TreeViewExpand[id] = 0;
			if (area)
			{
			    Epoint_TreeViewExpand[id] = -1;
				var icon  = this.icons[node.icon];
				var iconE = this.iconsExpand[node.icon];
				var exp   = this.icons[node.iconExpand];
				var expE  = this.iconsExpand[node.iconExpand];
				var Bool  = node.isExpand = sureExpand || area.style.display == "none";
                //alert("node.ImageUrl:" + node.ImageUrl);
                if(node.ImageUrl=="")
				{
				    var img   = getObjectById(Tname +"_icon_"+ id);
				    if (img)  img.src = !Bool ? icon.src :typeof(iconE)=="undefined" ? icon.src : iconE.src;
				}
				
				var img   = getObjectById(Tname +"_expand_"+ id);
				if (img)  img.src = !Bool ? exp.src : typeof(expE) =="undefined" ? exp.src  : expE.src;
				
				if(!Bool && this.currentNode.path.indexOf(node.path)==0)
				{
					this.focus(id, true); 
					this.click(id);
				}
				area.style.display = Bool ? "block" : "none";
				if(!node.isLoad) 
				{
					this.load(id,true);
				}
				if(this.IsTextTreeView)
                    reComputeIFrameWidth(this.divID);
			}
			else
			{
			    if (sureExpand) return;
			    var time = parseInt(Epoint_TreeViewExpand[id]);
			    time++;
			    Epoint_TreeViewExpand[id] = time;
			    if(Epoint_TreeViewExpand[id] != -1 && Epoint_TreeViewExpand[id] < 10)
			        setTimeout(this.name + ".expand('" + id + "')",100); 
			}
		};
		
	  
		this.toString = function()
		{
			var a = new Array(); 
			for (id in this.nodes) 
			    a[a.length] = id;
			this.names = a.join(_d + _d); 
			this.load("0",true);
			var rootCN = this.node["0"].childNodes;
			var str = "<A id='"+ Tname +"_RootLink' href='#' style='DISPLAY: none'></A>";
			if(rootCN.length>0)
			{
				for(var i=0; i<rootCN.length; i++) 
				    str += this.createHTML(rootCN[i], i==rootCN.length-1);
				setTimeout(Tname +".expand('"+ rootCN[0].id +"', true); "+ 
					Tname +".focus('"+ rootCN[0].id +"'); "+ Tname +".atRootIsEmpty()",10);				
			}
//			alert(str);
			return str;
		};
		
		   //========新增的函数  add by yx 2007-2-28 =============
  
		//针对checkbox的选择处理方法，注意，本函数和ctrlChecked无关。
  		this.expand_forSelect   = function(id, sureExpand,parentNodeChecked)
		{		   		   
			var node  = this.node[id];
			var area    = getObjectById(Tname +"_tree_"+ id);
			if (area)
			{
			    if(node.isExpand && node.hasChild && node.childNodes.length>0 && node.ExpandOnCheckedChanged!="true")
			    {
			        this.CheckChildNode(id,parentNodeChecked,this.CheckChildCheckBox);
			        return;
			    }
			    else
			    {
				    var Bool  = node.isExpand = sureExpand || area.style.display == "none";
				    if(!Bool && this.currentNode.path.indexOf(node.path)==0)
				    {
					    this.focus(id, true); 
					    this.click(id);
				    }
				    this.load_forSelect(id,true,parentNodeChecked,'2');	
				}
			}
		};
		
		//针对checkbox选择的加载处理方法
		//点击一个checkbox后重新加载该节点。加载前需要将本节点的所有子节点（包括子节点的子节点）信息从tree.names中删除
		this.load_forSelect = function(id,sign,parentNodeChecked,type)
		{
		    if(type == null) type = '1';
			var me  = this, node = this.node[id];
	        if(!node.isLoad && node.PopulateOnDemand)
			{
                if(sign && (id > 0))
			    {
				    setTimeout(me.name +".load_forSelect('"+ id +"',false,"+parentNodeChecked+",'" + type + "')", 1);
				    getObjectById(me.name +"_tree_"+ id).innerHTML = node.childAppend +
				    "<IMG border='0' align='absmiddle' src='"+this.icons["L2"].src+"'>"+
				    "<IMG border='0' align='absmiddle' src='"+this.icons["file"].src+"'>"+
				    "<span style='background-Color: "+ highLight +"; color: "+ highLightText +
				    "; font-size: 9pt'>"+ unescape("%u52A0%u8F7D%u4E2D") +"...</span>";
				    return;
			    }
			    
			    node.hasComplete = false;
			    
			    if((node.childNodesFileName)&&(node.childNodesFileName != "undefined")&&(node.childNodesFileName.length > 0))
			    {    			
				    this.LoadSubNodeInfo (id,node.text,node.sourceIndex,parentNodeChecked,type);
			    }
                else
                    this.Compelete(id,type);
            }            
		};
		
		this.Compelete = function(id,type)
		{
		    node = this.node[id];
		    node.isLoad = true;
		    if(node.id=="0" || node.hasChild)
		    {
		        var sid = node.sourceIndex.substr(node.sourceIndex.indexOf(this.divider) + this.divider.length);
			    var str = "(^|"+ _d +")"+ sid + this.divider +"[^"+ _d + this.divider +"]+("+ _d +"|$)";
			    var reg = new RegExp(str, "g"), cns = this.names.match(reg);
    			
			    tcn = this.node[id].childNodes;
			    //清除子节点数组childNodes
			    tcn.length=0;
			    if (cns){ 
				    reg = new RegExp(_d, "g");
				    for(var i=0; i<cns.length; i++) 
				    {
					    var tmp = cns[i].replace(reg, "");
					    tcn[tcn.length] = this.nodeInit(tmp, id);
				    }
			    }
			    node.isLoad = true; 
			    this.node[id].childNodes = tcn;
		        if(node.id=="0") 
		        {
		            node.hasComplete = true;
		            return;
		        }
		        this.drawNode(id,type);
		        node.hasComplete = true;		        		        
			}	
		}
		
		//用嵌套的方式清除节点数组childNodes
		this.RemodeNodeNames=function(parentSID)
		{
			var str = "(^|"+ _d +")"+ parentSID + this.divider +"[^"+ _d + this.divider +"]+("+ _d +"|$)";
			var reg = new RegExp(str, "g");//获取子节点，类似\x0f\x0f9009_56\x0f
			var cnsnew = this.names.match(reg);
			if (cnsnew)
			{
				var	regGet = new RegExp(_d, "g");//获取子节点sourceIndex,就是去掉分隔符\x0f
				for(var i=0; i<cnsnew.length; i++) 
				{
					var tmp = cnsnew[i].replace(regGet, "");
					this.RemodeNodeNames(tmp.split('_')[1]);  
					var strCNS=cnsnew[i];
					var regRemoveFormNames = new RegExp(strCNS, "g"); // this.names中去掉获取子节点
					this.names=this.names.replace(regRemoveFormNames, "");
				}
			}
		}
		
		this.CheckChildNode=function(id,bChecked,bExec)
		{
		    //由前台设置是否CheckChildNode
		    if(bExec == "false") return;
		    var node=this.node[id];		    
		    var child;
		    if(typeof(node.childNodes)=="undefined") return;
		    for(var i=0;i<node.childNodes.length;i++)
		    {
		        
		        child = this.node[node.childNodes[i].id];
		        if(child.ctrl == "" || child.ctrlType.toLowerCase() != "checkbox")
		        {
		            continue;
		        }
		        if(getObjectById(child.ctrlName))
		        {
		            getObjectById(child.ctrlName).checked = bChecked;
		            child.ctrlChecked = bChecked;
		            if(this.RunClickEvtWhenCheckChild)
		                getObjectById(child.ctrlName).onclick();
		            else
		                this.CheckChildNode(child.id,bChecked,bExec);
		        }
		    }   
		};
		this.CheckNode=function(id,bChecked,bCheckChild)
		{
		    var node = this.node[id];
		    if(node.ctrl == "" || node.ctrlType.toLowerCase() != "checkbox")
	        {
	            return;
	        }
	        if(getObjectById(node.ctrlName))
	        {
	            getObjectById(node.ctrlName).checked = bChecked;
	            node.ctrlChecked = bChecked;
	            if(bCheckChild)
	                this.CheckChildNode(id,bChecked,true);
	        }
	        
		}
		this.ShowRightButton=function(id)
        {
            if(window.event.button == 2)
            {
                var node = this.node[id];
                eval(node.onmouseup)
            }
        };
	}

	MzTreeView.prototype.setIconPath  = function(path)
	{
		this.icons    = {
			L0        : 'L0.gif',  //┏
			L1        : 'L1.gif',  //┣
			L2        : 'L2.gif',  //┗
			L3        : 'L3.gif',  //━
			L4        : 'L4.gif',  //┃
			PM0       : 'P0.gif',  //＋┏
			PM1       : 'P1.gif',  //＋┣
			PM2       : 'P2.gif',  //＋┗
			PM3       : 'P3.gif',  //＋━
			empty     : 'L5.gif',     //blank
			root      : 'root.gif',   // root
			folder    : 'folder.gif', // folder 
			file      : 'file.gif',   // file 

			event     : 'event.gif',
			object    : 'object.gif',
			behavior  : 'behavior.gif',
			property  : 'property.gif',
			method    : 'method.gif',
			collection: 'collection.gif',

			exit      : 'exit.gif'
		};

	this.iconsExpand = { 
		PM0       : 'M0.gif',     //－┏
		PM1       : 'M1.gif',     //－┣
		PM2       : 'M2.gif',     //－┗
		PM3       : 'M3.gif',     //－━
		folder    : 'folderopen.gif',

		exit      : 'exit.gif'
	};
	for(var i in this.icons)
	{
		var tmp = this.icons[i];
		this.icons[i] = new Image();
		this.icons[i].src = path + tmp;
	}
	for(var i in this.iconsExpand)
	{
		var tmp = this.iconsExpand[i];
		this.iconsExpand[i]=new Image();
		this.iconsExpand[i].src = path + tmp;
	}
	}

	MzTreeView.prototype.atRootIsEmpty = function()
	{
	    var RCN = this.node["0"].childNodes;
	    for(var i=0; i<RCN.length; i++)
	    {
		    if(RCN[i].text=="")
		    {
		    var node = RCN[i].childNodes[0], HCN  = node.hasChild;
		    node.iconExpand  =  RCN[i].childNodes.length>1 ? HCN ? "PM0" : "L0" : HCN ? "PM3" : "L3"
		    getObjectById(this.name +"_expand_"+ node.id).src = this.icons[node.iconExpand].src;
		    }
	    }
	};

	MzTreeView.prototype.popupmenu  = function(id)
	{
	try
	{
		if(this.popupMenu)
		{
		if(id)
		{
			this.popupMenu.data = this.node[id].data;
			this.popupMenu.treeviewitem = this.node[id];
		}
		for(var i=0; i<this.popupMenu.items.length; i++)
		{
			if(this.popupMenu.items[i].bind != "")
			this.popupMenu.items[i].bind = Tname +"_tree_"+ Tname;
		}
		this.popupMenu.show(window.event, window.event.srcElement);
		return false;
		}
		else return true;
	}catch(e){}
	};

	MzTreeView.prototype.click    = function(id)
	{
	if( (this.node[id].url == this.url) || ((this.node[id].url == "")&&(this.node[id].data == ""))) return false; 
	return true;
	};

 
    function EpointTree_ReceiveServerData(result,context)
    {       
        if(context == '2')
        {
            var s1 = result.split("|")[0];
            var s2 = result.split("|")[1];
            eval(s1);
        }
        else
        {
            eval(result);    
        }    
    }
    
    function OnError()
    {
        alert('动态加载失败！');
    }
  
    function ChangeOption(OptionsInfo,mode)
	{
	    var list = getObjectById(targetListBoxID);
		if(list == null) return;
		var Options=OptionsInfo.split('\x0f');
		var ItemText,ItemValue;
		var rawOuterHTML=list.outerHTML;
		var newOuterHTML=list.outerHTML;

		if(Options.length>1)
		{
			if(mode=="add")
				for(i=1;i<Options.length;i++)
				{
					
					ItemText=Options[i].split('\x0e')[0];
					ItemValue=Options[i].split('\x0e')[1];
					
					var strCNS="";
					strCNS="<[ ]*OPTION[ ]*value[ ]*=[ ]*"+ItemValue+"[ ]*>[ ]*"+ItemText+"[ ]*</[ ]*OPTION[ ]*>";
					var regRemove = new RegExp(strCNS, "gi"); 
					var cnsnew = rawOuterHTML.match(regRemove);
					if(cnsnew)
						continue;
					else
					{
						
						var strCNS="";
						strCNS="</[ ]*SELECT[ ]*>";
						var regAdd = new RegExp(strCNS, "gi"); 
						newOuterHTML=newOuterHTML.replace(regAdd,"<OPTION  value="+ItemValue+">"+ItemText+"</OPTION></SELECT>");

					}
				}
			else if(mode=="del")
				for(i=1;i<Options.length;i++)
				{
					ItemText=Options[i].split('\x0e')[0];
					ItemValue=Options[i].split('\x0e')[1];
					
					var strCNS="";
					strCNS="<[ ]*OPTION[ ]*value[ ]*=[ ]*"+ItemValue+"[ ]*>[ ]*"+ItemText+"[ ]*</[ ]*OPTION[ ]*>";
					var regRemove = new RegExp(strCNS, "gi"); 
					
					newOuterHTML=newOuterHTML.replace(regRemove,"");
				}
			else
				{ alert(" error mode:"+mode);return; }
			
			list.outerHTML=newOuterHTML;
			
		}
	}
	
	function addOneOption(ItemText,ItemValue)
	{
	    var list = getObjectById(targetListBoxID);
	    if(list == null) return;
		var strCNS="";
		strCNS="<[ ]*OPTION[ ]*value[ ]*=[ ]*"+ItemValue+"[ ]*>[ ]*"+ItemText+"[ ]*</[ ]*OPTION[ ]*>";
		var regRemove = new RegExp(strCNS, "gi"); 
		var cnsnew = list.outerHTML.match(regRemove);
		if(cnsnew)
			return;
		else
		{
			var strCNS="";
			strCNS="</[ ]*SELECT[ ]*>";
			var regAdd = new RegExp(strCNS, "gi"); 
			list.outerHTML=list.outerHTML.replace(regAdd,"<OPTION  value="+ItemValue+">"+ItemText+"</OPTION></SELECT>");
		}
	}
	
	
	function delOneOption(ItemText,ItemValue)
	{
	    var list = getObjectById(targetListBoxID);
	    if(list == null) return;
		var strCNS="";
		strCNS="<[ ]*OPTION[ ]*value[ ]*=[ ]*"+ItemValue+"[ ]*>[ ]*"+ItemText+"[ ]*</[ ]*OPTION[ ]*>";
		var regRemove = new RegExp(strCNS, "gi"); 
		list.outerHTML=list.outerHTML.replace(regRemove,"");
	}
	
	function Init_TextTreeView(id,textID,hidValueID,btnConfirmID,treeid,objTreeID,IsCreate,MaxItem,jsFunAfterSelect,eSelectAreaPosition)
	{
	    
	    Epoint_TextTreeView[id] = new TextTreeView(id,textID,hidValueID,btnConfirmID,treeid,objTreeID,IsCreate,MaxItem,jsFunAfterSelect,eSelectAreaPosition);
	}
	
	function TextTreeView(id,textID,hidValueID,btnConfirmID,treeid,objTreeID,IsCreate,MaxItem,jsFunAfterSelect,eSelectAreaPosition)
	{
	    this.id = id;
	    this.Element = Epoint_getElementById(id);
	    try
	    {
	        this.SelectImageTD = this.Element.childNodes[0].childNodes[0].childNodes[0].childNodes[2];
	    }
	    catch(ex)
	    {
	        this.SelectImageTD = null;
	    }
	    try
	    {	        
	        this.ClearImageTD = this.SelectImageTD.nextSibling;
	    }
	    catch(ex)
	    {
	        this.ClearImageTD = null;
	    }
	    this.textID = textID;
	    this.hidValueID = hidValueID;
	    this.btnConfirmID = btnConfirmID;	    
	    this.TreeId = treeid;
	    this.TreeDiv = Epoint_getElementById(treeid);
	    this.objTreeID = objTreeID;
	    this.IsCreate = IsCreate;
	    var hidselect = getObjectById(hidValueID);
	    eval("obj" + objTreeID + ".HidSelectValue=hidselect");
	    this.JSFunAfterSelect = jsFunAfterSelect;
	    this.IFrame = Epoint_getElementById("iframe" + id);
	    this.MaxItem = MaxItem;
	    this.SelectAreaPosition = eSelectAreaPosition;
	}
	
	function ShowHideTree(obj)
    {
        var texttreeview = Epoint_TextTreeView[obj.parentNode.parentNode.parentNode.parentNode.id];
        if(!texttreeview.IsCreate)
        {            
            eval("document.getElementById(\"" + texttreeview.TreeId + "\").innerHTML = obj" + texttreeview.objTreeID + ".toString()");
            texttreeview.IsCreate = true;
        }
        var div = obj.parentNode.parentNode.parentNode.nextSibling;
        var txt = obj.previousSibling.previousSibling.childNodes[0];
        var table = div.childNodes[0];
        if(div.style.display == "")
        {
            div.style.display = "none";    
            table.style.display = "none";
            texttreeview.IFrame.style.display   =   "none";
        }
        else
        {     
            div.style.display = "";
	        table.style.display = "";
            var opp = EpointGetAbsoluteLocation(txt);
            var opp1 = EpointGetAbsoluteLocation(div);
            if(texttreeview.SelectAreaPosition=="Left")
            {
                div.style.left =opp.absoluteLeft + 10;
            }
            else
            {
                div.style.left =opp.absoluteLeft + opp.offsetWidth - opp1.offsetWidth + 10;
            }
            //div.style.top =opp.absoluteTop + opp.offsetHeight;
            div.style.width = texttreeview.TreeDiv.offsetWidth + 20;
            texttreeview.IFrame.style.width   =   div.offsetWidth;   
            texttreeview.IFrame.style.height   =   div.offsetHeight;   
            texttreeview.IFrame.style.top   =   div.style.top;   
            texttreeview.IFrame.style.left   =   div.style.left;   
            texttreeview.IFrame.style.zIndex   =   div.style.zIndex   -   1;   
            texttreeview.IFrame.style.display   =   "";
	    }
    }
    
    function reComputeIFrameWidth(treeID)
    {
        var treediv = getObjectById(treeID);
        var parent = treediv.parentNode;
	    while(parent != null) {
	        if(parent.tagName=="DIV" && parent.DivType=="MainDiv")
	            break;
	        parent = parent.parentNode;
	    }
        var div = parent.childNodes[1];
        var texttreeview = Epoint_TextTreeView[parent.id];
        div.style.width = texttreeview.TreeDiv.offsetWidth + 20;
        texttreeview.IFrame.style.width   =   div.offsetWidth;   
        texttreeview.IFrame.style.height   =   div.offsetHeight;   
        texttreeview.IFrame.style.top   =   div.style.top;   
        texttreeview.IFrame.style.left   =   div.style.left;   
    }
    
    
    function ClearTreeValueObj(obj)
    {
        var texttreeview = Epoint_TextTreeView[obj.parentNode.parentNode.parentNode.parentNode.id];
        getObjectById(texttreeview.textID).value = "";
        getObjectById(texttreeview.hidValueID).value = "";
        
        //清除选择的节点
        var input = texttreeview.TreeDiv.getElementsByTagName('INPUT');
        for(var i=0;i<input.length;i++){
            if(input[i].checked)
                input[i].checked = false;
        }
    }
    
    function ClearTreeValue(id)
    {
        var texttreeview = Epoint_TextTreeView[id];
        getObjectById(texttreeview.textID).value = "";
        getObjectById(texttreeview.hidValueID).value = "";
        
        //清除选择的节点
        var input = texttreeview.TreeDiv.getElementsByTagName('INPUT');
        for(var i=0;i<input.length;i++){
            if(input[i].checked)
                input[i].checked = false;
        }
    }
    
    function HideTreeForImageTD(obj)
    {
        
        var table = obj.parentNode.parentNode.parentNode;
        var div = table.parentNode;
        var parent = div.parentNode;
	    while(parent != null) {
	        if(parent.tagName=="DIV" && parent.DivType=="MainDiv")
	            break;
	        parent = parent.parentNode;
	    }
	    var texttreeview = Epoint_TextTreeView[parent.id];
        if(div.style.display == "")
        {
            div.style.display = "none";    
            table.style.display = "none";
            texttreeview.IFrame.style.display = "none";
        }
    }
    
    
    function SetValueForTextTreeView(treeElementID,treeID,chk,retvalue,rettext)
    {
        var div = getObjectById(treeElementID);
        var parent = div.parentNode;
	    while(parent != null) {
	        if(parent.tagName=="DIV" && parent.DivType=="MainDiv")
	            break;
	        parent = parent.parentNode;
	    }
        var texttreeviewid = parent.id;
        var texttreeview = Epoint_TextTreeView[texttreeviewid];
        var node;
        eval("node = " + treeID + ".node[retvalue]");
        if(chk.checked)
        {
            if(getObjectById(Epoint_TextTreeView[texttreeviewid].textID).value.split(";").length > texttreeview.MaxItem)
            {
                chk.checked = false;
                alert("您最多只能选择" + texttreeview.MaxItem + "项");
                return false;
            }
            //getObjectById(Epoint_TextTreeView[texttreeviewid].textID).value = getObjectById(Epoint_TextTreeView[texttreeviewid].textID).value.EpointAddStr(rettext + ";",";");
            getObjectById(Epoint_TextTreeView[texttreeviewid].textID).value = getObjectById(Epoint_TextTreeView[texttreeviewid].textID).value.EpointAddStr(getFullPathText(texttreeview,node) + ";",";");
            
            getObjectById(Epoint_TextTreeView[texttreeviewid].hidValueID).value = getObjectById(Epoint_TextTreeView[texttreeviewid].hidValueID).value.EpointAddStr(retvalue + ";",";");
        }
        else
        {
            //getObjectById(Epoint_TextTreeView[texttreeviewid].textID).value = getObjectById(Epoint_TextTreeView[texttreeviewid].textID).value.remove(rettext + ";");
            getObjectById(Epoint_TextTreeView[texttreeviewid].textID).value = getObjectById(Epoint_TextTreeView[texttreeviewid].textID).value.remove(getFullPathText(texttreeview,node) + ";");
            getObjectById(Epoint_TextTreeView[texttreeviewid].hidValueID).value = getObjectById(Epoint_TextTreeView[texttreeviewid].hidValueID).value.remove(retvalue + ";");
        }
    }
    
    function ReturnValueByButton(input)
    {
        var parent = input.parentNode;
	    while(parent != null) {
	        if(parent.tagName=="DIV" && parent.DivType=="MainDiv")
	            break;
	        parent = parent.parentNode;
	    }
	    var texttreeviewid = parent.id;
        var div = parent.childNodes[1];
        div.style.display = "none";  
        div.childNodes[0].style.display = "none";
        var texttreeview = Epoint_TextTreeView[texttreeviewid];
        texttreeview.IFrame.style.display = "none";
        if(texttreeview.JSFunAfterSelect!="")
            eval(texttreeview.JSFunAfterSelect);
    }
    
    function ReturnValue(treeElementID,treeID,retvalue,rettext)
    {
        var treediv = getObjectById(treeElementID);
        var parent = treediv.parentNode;
	    while(parent != null) {
	        if(parent.tagName=="DIV" && parent.DivType=="MainDiv")
	            break;
	        parent = parent.parentNode;
	    }
	    var texttreeviewid = parent.id;
	    var texttreeview = Epoint_TextTreeView[texttreeviewid];
        var node;
        eval("node = " + treeID + ".node[retvalue]");

        //getObjectById(Epoint_TextTreeView[texttreeviewid].textID).value = rettext;
        getObjectById(Epoint_TextTreeView[texttreeviewid].textID).value = getFullPathText(texttreeview,node);
        getObjectById(Epoint_TextTreeView[texttreeviewid].hidValueID).value = retvalue;
        var div = parent.childNodes[1];
        //alert(div.innerHTML);
        div.style.display = "none";  
        div.childNodes[0].style.display = "none"; 
        texttreeview.IFrame.style.display = "none";
        if(texttreeview.JSFunAfterSelect!="")
            eval(texttreeview.JSFunAfterSelect);

    }   
    
    function getFullPathText(tree,node)
    {
        var rettext = node.text;
        if(node.ReturnFullPath)
        {
            node = node.parentNode;
            while(node.parentId!="0")
            {
                rettext = node.text + "·" + rettext;
                node = node.parentNode
            }
        }
       
        return rettext;
    }
    
    
    function EpointTree_InitNode(tree,param,sourceIndex,divider,parentId)
    {
        this.Tree = tree;
		this.id = param.getParam("id");//节点的value值
		this.text = param.getParam("text");//显示的文本
		this.hint  = param.getParam("hint") ? param.getParam("hint") : this.text;//提示信息title
		this.icon = param.getParam("icon");
		this.ImageUrl =  param.getParam("ImageUrl");
		this.ImageToolTip =  param.getParam("ImageToolTip");
		this.divider = divider;
		this.path = tree.node[parentId].path + this.divider + this.id;
		this.isLoad = false;
		this.isExpand = false;
		this.parentId = parentId;
		this.parentNode = tree.node[parentId];
		this.sourceIndex = sourceIndex;
		this.childAppend = "";
		this.childNodesFileName = param.getParam("hasChild")
		this.url = param.getParam("url").replace("\x0e",";");;
		this.data = param.getParam("data");
		this.sid   = sourceIndex.substr(sourceIndex.indexOf(this.divider) + this.divider.length);
		this.ctrl =			param.getParam("ctrl");		   //是否是checkbox或redio控件  add by yx 2007-2-29
		this.ctrlClick =		param.getParam("ctrlClick").replace("\x0e",";");   //单击控件的处理方法  add by yx 2007-2-29
		this.ctrlName =		param.getParam("ctrlName");    //控件名称，主要用来控制raido的单选 add by yx 2007-2-29
		this.ctrlChecked =	param.getParam("ctrlChecked"); // 控件是否已经选中  add by yx 2007-2-29
		this.ctrlType  =		param.getParam("ctrlType");    // 控件类型，值是checkbox或redio   add by yx 2007-2-29
		this.ctrlenable =		param.getParam("ctrlenable"); 
		this.ShowImage  =		param.getParam("ShowImage");     // 是否显示图标 Add by XGC 2007-4-18火车大提速之日
		this.RunClickEvtOnInit = param.getParam("RunClickEvtOnInit");      // 是否在节点初始化时运行节点的click事件
		
		this.ExpandOnCheckedChanged = param.getParam("ExpandOnCheckedChanged");     //是否在inputCheckedChanged事件时展开节点
		this.hasComplete = true;
		this.PopulateOnDemand = param.getParam("PopulateOnDemand") == "true";
		//this.CheckChildCheckBox = param.getParam("CheckChildCheckBox");   //是否在Check父节点的时候Check子节点 Add By XGC
		this.ReturnFullPath = param.getParam("ReturnFullPath")=="true";
		this.onmouseup = param.getParam("onmouseup");                               //节点的右键函数
		if(this.ctrlType == "") 
		    this.ctrlType = "checkbox";		   //add by yx 2007-2-29
		    		    
		if(param.getParam("hasChild").toLowerCase()=="true")
			this.hasChild = true;
		else
			this.hasChild = tree.names.indexOf(_d + this.sid + divider)>-1;		
		this.isEndNode = isEndNode;
		this.getNodeElement = getNodeElement;
	    this.resetLinkImage = resetLinkImage;
	    this.resetChildLinkImage = resetChildLinkImage;
	    this.getPrevNode = getPrevNode;
	    this.getNextNode = getNextNode;
	    this.getNodeText = function()
	    {
	        var a = getObjectById(this.Tree.name +"_link_"+ this.id);
	        if (a)  
			    return a.innerText;
	    };
	    this.setNodeText = function(txt)
	    {
	        var a = getObjectById(this.Tree.name +"_link_"+ this.id);
	        if (a)  
			    a.innerText = txt;
	    };
	    this.getImageUrl = function()
	    {
	        if(!this.ShowImage)
	            return "";
	        var img = getObjectById(this.Tree.name +"_icon_"+ this.id);
	        if (img)  
			    return img.src;
	    };
	    this.setImageUrl = function(url)
	    {
	        if(!this.ShowImage)
	            return "";
	        var img = getObjectById(this.Tree.name +"_icon_"+ this.id);
	        if (img)
			    img.src = url;
	    };
	    
	    this.HasCreateChild = function()
	    {
	        if(!this.isLoad && this.PopulateOnDemand && (this.childNodesFileName)&&(this.childNodesFileName != "undefined")&&(this.childNodesFileName.length > 0))
	            return false;
	        else
	            return true;
	    };
    }
    
    function isEndNode()
    {
        if(this.getNextNode() == null) 
            return true;
        else
            return false;
    }
    
    function getNodeElement()
    {
        return getObjectById(this.Tree.name +"_Node_"+ this.id);
    }
    
    function resetLinkImage()
    {
		var area    = getObjectById(this.Tree.name +"_tree_"+ this.id);
		var AtEnd = this.isEndNode();
		if (area)
		{
			var id   = this.id; 
			var HCN  = this.hasChild
			if(HCN)
			    if(AtEnd)
			        this.iconExpand = "PM2";
			    else
			        this.iconExpand = "PM1";
			else
			    if(AtEnd)
			        this.iconExpand = "L2";
			    else
			        this.iconExpand = "L1";
			node.icon = HCN ? "folder" : "file";			
			var isRoot = this.parentId=="0";
			var img   = getObjectById(this.Tree.name +"_expand_"+ this.id);
			var img1   = getObjectById(this.Tree.name +"_icon_"+ this.id);
			var exp   = this.Tree.icons[this.iconExpand];
			var expE  = this.Tree.iconsExpand[this.iconExpand];
			if (img)  
			{
				if(HCN)
				{
				    if(!this.isExpand)
				        img.src=exp.src;
				    else
				    {
				        if(typeof(expE) =="undefined")
				            img.src=exp.src;
				        else
				            img.src=expE.src;
			        }
			        img.onclick= (function (Tname,id) { return function(){eval(Tname + ".expand('" + id + "')");}; })(this.Tree.name,id)
			    }
			    else
			    {
			        img.src=exp.src;
			        img.onclick="";
			    }
			}
			if(img1)
			{
			    if(this.ImageUrl=="" && !HCN)    
		            img1.src=this.Tree.icons[node.icon].src ;	
			}
			
			if(this.id!="0" && !isRoot)  
			{   
			    this.childAppend = this.parentNode.childAppend +
				"<IMG border='0' align='absmiddle' src='"+this.Tree.icons[(AtEnd?"empty":"L4")].src+"'>";
            }                        
		}					
    }
    
    function resetChildLinkImage(level)
    {
        
        var curLevel = level + 1;
        var img   = getObjectById(this.Tree.name +"_expand_"+ this.id);
        var pNode=this.parentNode;
        while(level>0 && img)
        {
            var imgLink = img.previousSibling;
            if(pNode.isEndNode())
                imgLink.src= this.Tree.icons["empty"].src
            img = imgLink;
            level--;
            pNode = pNode.parentNode;
        }
        var tcn     = this.childNodes;
        if(tcn==null) return;
        for (var i=0; i<tcn.length; i++) 
        {
            tcn[i].resetLinkImage();
            tcn[i].resetChildLinkImage(curLevel);
        }
    }
    
    function getPrevNode()
    {
        var elem = this.getNodeElement();
        var pre = elem.previousSibling;
		while(pre)
		{
		
	        if(pre.tagName=="DIV" && pre.getAttribute("divType") == "Node")
	            break;
	        else
	            pre=pre.previousSibling;
	    }
	    
	    if(!pre) 
	        return null;
	    return this.Tree.node[pre.id.split('_')[2]];
    }
    
    function getNextNode()
    {
        var elem = this.getNodeElement();
        var next = elem.nextSibling;
		while(next)
		{
		    if(next.tagName=="DIV" && next.getAttribute("divType") == "Nodes")
		        return null;
		        
	        if(next.tagName=="DIV" && next.getAttribute("divType") == "Node")
	            break;
	        else
	            next=next.nextSibling;
	    }
	    if(!next) 
	        return null;
	    return this.Tree.node[next.id.split('_')[2]];
    }
    
    function CheckIsSelect(obj,str)
    {
        var strSelectID = ";" + obj.value;
        if(strSelectID.indexOf(";" + str + ";") > -1)
            return true;
        return false;
    }        
    
    var myTree_x,myTree_y

    function Epoint_TreeView_Move_Init(obj,pNode)
    { 
        var pos = EpointGetAbsoluteLocation(pNode);
        myTree_x=event.x-pos.absoluteLeft;
        myTree_y=event.y-pos.absoluteTop;
        obj.setCapture();
    } 

    function Epoint_TreeView_Move_Stopdrag(obj){ 
        obj.releaseCapture(); //释放当前对象的鼠标捕捉 
    } 


    function Epoint_TreeView_Move(obj,id)
    {
        if(event.button==1)
        {
            var X = obj.clientLeft;
            var Y = obj.clientTop;
            obj.style.pixelLeft= X+(event.x-myTree_x);
            obj.style.pixelTop= Y+(event.y-myTree_y);
            var texttreeview = Epoint_TextTreeView[id];
//            datetext.HideMonth();
            texttreeview.IFrame.style.pixelLeft= X+(event.x-myTree_x);
            texttreeview.IFrame.style.pixelTop= Y+(event.y-myTree_y);
        }
    }
    
    var w3c=(document.getElementById)? true:false;
var agt=navigator.userAgent.toLowerCase();
var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1) && (agt.indexOf("omniweb") == -1));
var ie5=(w3c && ie)? true : false;
var ns6=(w3c && (navigator.appName=="Netscape"))? true: false;

function EpointGetAbsoluteLocation(o)
{
    var nLt=0;
    var nTp=0;
    var offsetParent = o;
    while (offsetParent!=null && offsetParent!=document.body) 
    {
        nLt+=offsetParent.offsetLeft;
        nTp+=offsetParent.offsetTop;
        if(!ns6)
        {
            parseInt(offsetParent.currentStyle.borderLeftWidth)>0?nLt+=parseInt(offsetParent.currentStyle.borderLeftWidth):"";
            parseInt(offsetParent.currentStyle.borderTopWidth)>0?nTp+=parseInt(offsetParent.currentStyle.borderTopWidth):"";
        }
        offsetParent=offsetParent.offsetParent;
    //alert(offsetParent.tagName);
    }
    return { absoluteTop: nTp, absoluteLeft: nLt, 
        offsetWidth: o.offsetWidth, offsetHeight: o.offsetHeight }; 
}
// -->