js调用本函数里另一个函数里的变量解决方案

js调用本函数里另一个函数里的变量
dTree.prototype.node = function (node, nodeId)
{
    
    var divSelected = "onmouseover = \"this.style.backgroundColor='#FFF250';\" onmouseout = \"this.style.backgroundColor='#FFFFFF';\"";
    var str = "<div  "+divSelected+"  class=\"dTreeNode\">" + this.indent(node, nodeId);
    
    if (this.config.useIcons)
    { 
        if (!node.icon)
        {
            node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
        }
        if (!node.iconOpen)
        {
            node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
        }
        if (this.root.id == node.pid)
        {
            node.icon = this.icon.root;
            node.iconOpen = this.icon.root;
            
        }
        str += "<span style=\"width:300px;overflow:hidden; text-overflow:ellipsis; white-space:nowrap;\"><img id=\"i" + this.obj + nodeId + "\" src=\"" + ((node._io) ? node.iconOpen : node.icon) + "\" alt=\"\" />";
    //添加上复选框
       
        if (this.config.check == true) {
        
             str += '<input value="  " name="xyz" type="checkbox" id="c' + this.obj + node.id
                    + '" onclick="javascript:' + this.obj + '.cc(' + node.id
                    + ',' + node.pid + ')"/>';
        } 
    }
    //alert(xyz);
    //style="background: b4b4b4;border:0px"
    //最后要为点中复选框的事件添加cc方法

//点击复选框onclick事件
  
dTree.prototype.cc=function(nodeId, nodePid){
    
    //首先获取这个多选框的id 
    var cs = document.getElementById("c" + this.obj + nodeId).checked;
    //alert(nodeId+"==");
    var n,node = this.aNodes[nodeId];
    var len = this.aNodes.length;
    for (n=0; n<len; n++) { //如果循环每一个节点 
        if (this.aNodes[n].pid == nodeId) { //如果选中的是非叶子节点,则要将所有的子节点选择和父节点一样 
            document.getElementById("c" + this.obj + this.aNodes[n].id).checked = cs;           
            this.cc(this.aNodes[n].id, nodeId);   
        }         
    }  
    
     if(cs==true){  //当前是选中状态
        var pid=nodePid;  
        
         
        var bSearch;  
        do{  
            bSearch=false;  
            for(n=0;n<len;n++){  //循环每一个节点 
                if(this.aNodes[n].id==pid){  //如果循环的节点的id等于PID 
                    document.getElementById("c"+this.obj+pid).checked=true; //那么这个循环的节点应该被选中  
                    pid=this.aNodes[n].pid;