//******************************************************************************
//*                            List Class By Protocoder, v1.0                  *
//******************************************************************************

   function List(                
                 ListId,  //Id of list (string), example: "List12345"
                 URParam, //UserRequestParam in format "&Name=Val&Name=Val"...
                 XMLDataBuilder_url,
                 Container, //HTML object where list has been stored
                 ClickHandlerFunction, //ClickHandler function name, example: "MyClickHandler". If no needed =null

                 firstSelectedType, firstSelectedId, //Default selected item after list first time builded, example: "folder", 5. If no needed =null,=null

                 LoadingImage_sx, LoadingImage_sy, LoadingImage,


                 Images_sy,

                 TypeImages_sx,

                 FolderImage, SelectedFolderImage,
                 FolderClassName, SelectedFolderClassName,
                 DisabledFolderImage, DisabledSelectedFolderImage,
                 DisabledFolderClassName, DisabledSelectedFolderClassName,

                 FileImage, SelectedFileImage,
                 FileClassName, SelectedFileClassName,
                 DisabledFileImage, DisabledSelectedFileImage,
                 DisabledFileClassName, DisabledSelectedFileClassName,

                 UpImage,

                 PathClassName, PathLinkClassName, PathDLinkClassName,
                 HighlightLineClassName,
                 ParityLineClassName,
                 NParityLineClassName,

                 RootId,
                 RootLabel,

                 DirLabel,
                 DirWidth,
                 DirAlign,

                 DontOpenBranch,

                 IconViewState
                ) {
/* 
LOADED XML:

xml version="1.0" encoding="Windows-1251";

<XMLDATA VERSION="1">

 <PATH>
  <ELEMENT></ELEMENT>
 </PATH>

 <BRANCH ID="12345">
  <ELEMENT></ELEMENT>
 </BRANCH>

</XMLDATA>

Attributes of PATH ELEMENT tag:
ID - id of item
LABEL - name of item

Attributes of BRANCH ELEMENT tag:
ID - id of item, in prop - id
LABEL - name of item, in prop - label
FOLDER - is item is folder, if FOLDER=1, in prop["type"] = "folder" or "file"
DISABLED - if item disabled - DISABLED=1, in prop["disabled"]=1 or 0

----- Optional images -----
IMAGE, in prop Image
SIMAGE, in prop sImage
DIMAGE, in prop dImage

----- Optional classes -----
CLASS, in prop Class
SCLASS, in prop sClass
DICLASS, in prop dClass




CLICKHANDLER:
function ClickHandler(TreeId,ClickType,Id,Type) {}
ClickType can be link/icon/label
*/

    this.ListId    = ListId;

    this.URParam   =URParam;

    this.XMLDataBuilder_url=XMLDataBuilder_url;
    
    this.Container = Container;
    this.ClickHandlerFunction=ClickHandlerFunction;

    this.LoadingImage_sx = LoadingImage_sx;
    this.LoadingImage_sy = LoadingImage_sy;
    this.LoadingImage    = LoadingImage;

    this.Images_sy = Images_sy;

    this.TypeImages_sx = TypeImages_sx;

    this.FolderImage             = FolderImage;
    this.SelectedFolderImage     = SelectedFolderImage;

    this.FolderClassName             = FolderClassName;
    this.SelectedFolderClassName     = SelectedFolderClassName;

    this.DisabledFolderImage             = DisabledFolderImage;
    this.DisabledSelectedFolderImage     = DisabledSelectedFolderImage;

    this.DisabledFolderClassName             = DisabledFolderClassName;
    this.DisabledSelectedFolderClassName     = DisabledSelectedFolderClassName;

    this.FileImage         = FileImage;
    this.SelectedFileImage = SelectedFileImage;

    this.FileClassName         = FileClassName;
    this.SelectedFileClassName = SelectedFileClassName;

    this.FileImage         = FileImage;
    this.SelectedFileImage = SelectedFileImage;

    this.FileClassName         = FileClassName;
    this.SelectedFileClassName = SelectedFileClassName;

    this.DisabledFileImage         = DisabledFileImage;
    this.DisabledSelectedFileImage = DisabledSelectedFileImage;

    this.DisabledFileClassName         = DisabledFileClassName;
    this.DisabledSelectedFileClassName = DisabledSelectedFileClassName;

    this.UpImage = UpImage;

    this.PathClassName = PathClassName;
    this.PathLinkClassName = PathLinkClassName;
    this.PathDLinkClassName = PathDLinkClassName;

    this.HighlightLineClassName = HighlightLineClassName;
    this.ParityLineClassName = ParityLineClassName;
    this.NParityLineClassName = NParityLineClassName;

    this.RootId = RootId;
    this.RootLabel = RootLabel;

    this.DirLabel = DirLabel;
    this.DirWidth = DirWidth;
    this.DirAlign = DirAlign;

    this.DontOpenBranch = DontOpenBranch;

    this.IconViewState = IconViewState;

    this.Selected = null;
    this.scrollTop = null;

    this.LastFolderId = null;

    this.RootObj = null;

    this.Highlighted = null;

    this.Columns=0;
    this.ColumnsAttr=new Array();

    this.curPage=0;

//    this.Build(null,firstSelectedType,firstSelectedId);
   }



   List.prototype.Build=function(parent_id,selected_type,selected_id,ipage) {
    var el,sel,ssel,sssel;

    while (this.Container.hasChildNodes()) this.Container.removeChild(this.Container.lastChild);

    this.ParentId=parent_id;
    this.firstSelectedType = selected_type;
    this.firstSelectedId = selected_id;
    this.Columns=0;
    this.ColumnsAttr=new Array();

    el=CrEl(this.Container,"table","width=95%; cellspacing=0; cellpadding=0; border=0;");
    el=CrEl(el,"tbody");
    sel=CrEl(el,"tr");
    sel=CrEl(sel,"td","class="+this.PathClassName+";");
    this.PathHTMLo=sel;
    CrEl(sel,"br");

    sel=CrEl(el,"tr");
    sel=CrEl(sel,"td");
    this.RootHTMLo=CrEl(sel,"table","width=100%; cellspacing=0; cellpadding=2; border=0;");
    this.RootHTMLo.onselectstart=function() {return false;}
    if(document.getElementById("PickContainer")) {
     this.RebuildList(parent_id,"&page="+ipage,function(list,picker,selected) {
      if(!list.Selected) list.SetSelected(list.RootObj);
      },this);
     }
    else
     this.RebuildList(parent_id,"&page="+ipage);
    }





   List.prototype.GetSelected=function() {
    if (this.Selected) {
        var rt=new Array();
        rt["type"]=this.Selected["type"];
        rt["id"]=this.Selected["id"];
        return rt;
    }
    var rt=new Array();
    rt["type"]=null;
    rt["id"]=null;
    return rt;
   }




   List.prototype.GetTypeImage=function(type, selected, prop) {
    if (prop["disabled"]) {
        if (type=="folder") return (selected ? ( prop["dsImage"] ? prop["dsImage"] : this.DisabledSelectedFolderImage ) : ( prop["dImage"] ? prop["dImage"] : this.DisabledFolderImage ));
            else if (type=="file") return (selected ? ( prop["dsImage"] ? prop["dsImage"] : this.DisabledSelectedFileImage ) : ( prop["dImage"] ? prop["dImage"] : this.DisabledFileImage ));
        return;
    }

    if (type=="folder") return (selected ? ( prop["sImage"] ? prop["sImage"] : this.SelectedFolderImage ) : ( prop["Image"] ? prop["Image"] : this.FolderImage ));
        else if (type=="file") return (selected ? ( prop["sImage"] ? prop["sImage"] : this.SelectedFileImage ) : ( prop["Image"] ? prop["Image"] : this.FileImage ));
                 else if (type=="levelup") return this.UpImage;
 
   }




   List.prototype.GetTypeClassName=function(type, selected, prop) {
    if (prop["disabled"]) {
        if (type=="folder") return (selected ? ( prop["dsClass"] ? prop["dsClass"] : this.DisabledSelectedFolderClassName ) : ( prop["dClass"] ? prop["dClass"] : this.DisabledFolderClassName ));
            else if (type=="file") return (selected ? ( prop["dsClass"] ? prop["dsClass"] : this.DisabledSelectedFileClassName ) : ( prop["dClass"] ? prop["dClass"] : this.DisabledFileClassName ));
        return;
    }

    if (type=="folder") return (selected ? ( prop["sClass"] ? prop["sClass"] : this.SelectedFolderClassName ) : ( prop["Class"] ? prop["Class"] : this.FolderClassName ));
        else if (type=="file") return (selected ? ( prop["sClass"] ? prop["sClass"] : this.SelectedFileClassName ) : ( prop["Class"] ? prop["Class"] : this.FileClassName ));
 
   }




   List.prototype.SetSelected=function(prop) {
    var o,t,tprop=this.Selected;
    this.Selected=prop;
    if (tprop!=null) {
        if (this.IconViewState) tprop["HTMLo"].firstChild.firstChild.src=this.GetTypeImage(tprop["type"], false, tprop);
        tprop["HTMLo"].className=(tprop["parity"] ? this.ParityLineClassName : this.NParityLineClassName);
        if (this.IconViewState) t=tprop["HTMLo"].firstChild.nextSibling.firstChild;
            else t=tprop["HTMLo"].firstChild.firstChild;
        t.className=this.GetTypeClassName(tprop["type"], false, tprop);
    };

    if (this.IconViewState) {
        prop["HTMLo"].firstChild.firstChild.src=this.GetTypeImage(prop["type"], true, prop);
        t=prop["HTMLo"].firstChild.nextSibling.firstChild;
    } else t=prop["HTMLo"].firstChild.firstChild;
    t.className=this.GetTypeClassName(prop["type"], true, prop);
    prop["HTMLo"].className=this.GetTypeClassName(prop["type"], true, prop);
    this.scrollTop=prop["HTMLo"].offsetTop;
   }



  
   List.prototype.Highlight=function(prop) {    
    var o,i;
    if (this.Highlighted==prop) return;

    if (this.Highlighted!=null) {
        o=this.Highlighted["HTMLo"].firstChild;
        i=0;
        while (o) {o.className=this.phClassName[i]; o=o.nextSibling; i++;}
        this.Highlighted=null;
    }

    if (prop) {
        this.Highlighted=prop;
        this.phClassName=new Array();
        o=this.Highlighted["HTMLo"].firstChild;
        i=0;
        while (o) {this.phClassName[i]=o.className; o.className=this.HighlightLineClassName; o=o.nextSibling; i++;}
    }
   }



   List.prototype.MakePage=function(dst,pxml_o,parity) {
    tel=CrEl(dst,"tr","class="+(parity ? this.ParityLineClassName : this.NParityLineClassName)+"; height="+27+"; valign=top;"); //this.Images_sy
    var pageso=tel;
    prop=new Array();
    prop["HTMLo"]=tel;
    prop["listClass"] = this;
    tel.getProp=function() {return this.prop;};
    tel.prop=prop;

    sel_tdi=CrEl(tel,"td","colspan="+(this.Columns+2)+"; align=center; valign=middle;");
    pxml_o=pxml_o.firstChild; 
    while (pxml_o) {
     t=pxml_o.tagName;
     if (t=="DOTS") CrEl(sel_tdi,"text","...");
         else if (t=="PREV_PAGE") {
                  sel_tdl=CrEl(sel_tdi,"A","CLASS=pageClass; href=#;");
                  sel_tdl.onclick=new Function('', "var lo=this.parentNode.parentNode.getProp()['listClass']; lo.RebuildList(lo.ParentId,'&page="+(this.curPage-1)+"'); return false;");
                  CrEl(sel_tdl,"text","<");
               } else if (t=="FIRST_PAGE") {
                          sel_tdl=CrEl(sel_tdi,"A","CLASS=pageClass; href=#;");
                          sel_tdl.onclick=new Function('', "var lo=this.parentNode.parentNode.getProp()['listClass']; lo.RebuildList(lo.ParentId,'&page=1'); return false;");
                          CrEl(sel_tdl,"text","<<");
                      } else if (t=="NEXT_PAGE") {
                                 sel_tdl=CrEl(sel_tdi,"A","CLASS=pageClass; href=#;");
                                 sel_tdl.onclick=new Function('', "var lo=this.parentNode.parentNode.getProp()['listClass']; lo.RebuildList(lo.ParentId,'&page="+(this.curPage+1)+"'); return false;");
                                 CrEl(sel_tdl,"text",">");
                              } else if (t=="LAST_PAGE") {
                                         sel_tdl=CrEl(sel_tdi,"A","CLASS=pageClass; href=#;");
                                         sel_tdl.onclick=new Function('', "var lo=this.parentNode.parentNode.getProp()['listClass']; lo.RebuildList(lo.ParentId,'&page="+(pxml_o.getAttribute("NUM"))+"'); return false;");
                                         CrEl(sel_tdl,"text",">>");
                                      } else if (t=="PAGE") {
                                                 sel_tdl=CrEl(sel_tdi,"A","CLASS="+((pxml_o.getAttribute("SELECTED")=="1") ? "pageSelectedClass": "pageClass")+"; href=#;");
                                                 sel_tdl.onclick=new Function('', "var lo=this.parentNode.parentNode.getProp()['listClass']; lo.RebuildList(lo.ParentId,'&page="+pxml_o.getAttribute("NUM")+"'); return false;");
                                                 CrEl(sel_tdl,"text",pxml_o.getAttribute("NUM"));
                                             }

     CrEl(sel_tdi,"text"," ");
     pxml_o=pxml_o.nextSibling;
    }
   }

   List.prototype.MakeList=function(xml_o,pxml_o) {
    var xml_co=xml_o;
    var tel,el,sel,attr;
    var sel_tdl,sel_tdi,sel_spn;
    var pprop=prop=null;
    var parity=0;
    var TBodyHTML=this.RootHTMLo.getElementsByTagName("TBODY")[0];
    var i,t;

    //BuildUpLvl
    if (this.ParentId!=0) {
        tel=CrEl(TBodyHTML,"tr","class="+(parity ? this.ParityLineClassName : this.NParityLineClassName)+"; height="+27+"; valign=top;"); //this.Images_sy

        prop=new Array();
        prop["HTMLo"]=tel;
        prop["listClass"] = this;
        prop["parity"]=parity;
        tel.getProp=function() {return this.prop;};
        tel.prop=prop;

        tel.onmouseover=function() { var prp=this.getProp(),lo=prp["listClass"]; lo.Highlight(prp);  }
        tel.onmouseout =function() { var prp=this.getProp(),lo=prp["listClass"]; lo.Highlight(); }

        sel_tdl=CrEl(tel,"td",(this.IconViewState ? "colspan=2;" : ""));       
        CrEl(sel_tdl,"img","src="+this.UpImage+";");
        CrEl(sel_tdl,"text",". .");
        sel_tdl.style.cursor=(navigator.appName == "Microsoft Internet Explorer")?"hand":"pointer";
/*        
        sel_tdl.onclick=function() {
                                    var prp=this.parentNode.getProp(),lo=prp["listClass"];
                                    if (lo.ClickHandlerFunction) lo.ClickHandlerFunction(lo.ListId,"icon",null,null);
                                    if (!lo.DontOpenBranch) lo.RebuildList(lo.ParentId,"&fparent=1"); 
                                   }
*/
        sel_tdl.ondblclick=function() {
                                       var prp=this.parentNode.getProp(),lo=prp["listClass"];
                                       if (!lo.DontOpenBranch) lo.RebuildList(lo.ParentId,"&fparent=1"); 
                                       if (lo.ClickHandlerFunction) lo.ClickHandlerFunction(lo.ListId,"label",null,null);
                                      }

        for (i=0;i<this.Columns;i++) {
             sel_tdi=CrEl(tel,"td","","paddingLeft:3; paddingRight:3;");
             sel_tdi.ondblclick=function() {this.parentNode.firstChild.nextSibling.ondblclick();}
             sel_tdi.style.cursor=(navigator.appName == "Microsoft Internet Explorer")?"hand":"pointer";
        }

        parity=parity^1;
    }

    if (pxml_o && pxml_o.firstChild) {
        this.MakePage(TBodyHTML,pxml_o,parity);
        parity=parity^1;
    }

    while (xml_co!=null) {
           prop=new Array();

           prop["id"] = xml_co.getAttribute("ID");
           prop["label"] = xml_co.getAttribute("LABEL");
           prop["type"] = ((xml_co.getAttribute("FOLDER")==1) ? "folder" : "file");
           prop["listClass"] = this;
           prop["disabled"] = ((xml_co.getAttribute("DISABLED")==1) ? 1 : 0);
           if (pprop==null) {this.RootObj=prop;}
               else {pprop["nextSibling"]=prop;}

           prop["nextSibling"]=null;
           prop["prevSibling"]=pprop;
           prop["parity"]=parity;

           //Optional images
           if (xml_co.getAttribute("IMAGE"))   prop["Image"]   = xml_co.getAttribute("IMAGE");
           if (xml_co.getAttribute("SIMAGE"))  prop["sImage"]  = xml_co.getAttribute("SIMAGE");
           if (xml_co.getAttribute("DIMAGE"))  prop["dImage"]  = xml_co.getAttribute("DIMAGE");

           //Optional classes
           if (xml_co.getAttribute("CLASS"))   prop["Class"]   = xml_co.getAttribute("CLASS");
           if (xml_co.getAttribute("SCLASS"))  prop["sClass"]  = xml_co.getAttribute("SCLASS");
           if (xml_co.getAttribute("DICLASS")) prop["dClass"]  = xml_co.getAttribute("DCLASS");
           cls=(parity ? this.ParityLineClassName : this.NParityLineClassName);
           tel=CrEl(TBodyHTML,"tr","class="+cls+"; height="+10+"; valign=middle;"); //this.Images_sy
           prop["HTMLo"]=tel;
           tel.getProp=function() {return this.prop;};
           tel.prop=prop;
 
           if (this.IconViewState) {
               sel_tdi=CrEl(tel,"td","width=32; align=center;");
               CrEl(sel_tdi,"img","src="+this.GetTypeImage(prop["type"], (this.Selected==prop), prop)+";");
           }

           sel_tdl=CrEl(tel,"td");

           sel_spn=CrEl(sel_tdl,"span","class="+this.GetTypeClassName(prop["type"], (this.Selected==prop), prop)+";");
           CrEl(sel_spn,"text",prop["label"]);

//           tel.onmouseover=function() { var prp=this.getProp(),lo=prp["listClass"]; lo.Highlight(prp);  }
//           tel.onmouseout =function() { var prp=this.getProp(),lo=prp["listClass"]; lo.Highlight(); }

           sel_tdl.style.cursor=(navigator.appName == "Microsoft Internet Explorer")?"hand":"pointer";

           if (this.IconViewState) {
               sel_tdi.style.cursor=(navigator.appName == "Microsoft Internet Explorer")?"hand":"pointer";
               sel_tdi.onclick=function() {
                                           var prp=this.parentNode.getProp(),lo=prp["listClass"];
                                           if (prp["type"]=="folder" && !lo.DontOpenBranch) lo.RebuildList(prp["id"]);
                                           if (lo.ClickHandlerFunction) lo.ClickHandlerFunction(lo.ListId,"icon",prp["id"],prp["type"]);
                                          }
           }
           sel_tdl.onclick=function() {
                                       var prp=this.parentNode.getProp(),lo=prp["listClass"];
                                       if (lo.Selected==prp) return;
/**/                                       lo.SetSelected(prp);
                                       if (lo.ClickHandlerFunction) lo.ClickHandlerFunction(lo.ListId,"label",prp["id"],prp["type"]);
                                      }

           if (prop["type"]=="folder")
               sel_tdl.ondblclick=function() {
                                              var prp=this.parentNode.getProp(),lo=prp["listClass"];
                                              if (!lo.DontOpenBranch) lo.RebuildList(prp["id"]); 
                                              if (lo.ClickHandlerFunction) lo.ClickHandlerFunction(lo.ListId,"label",prp["id"],prp["type"]);
                                             }

           for (i=0;i<this.Columns;i++) {
                sel_tdl=xml_co.getAttribute("COL_"+(i+1)+"_VAL");
		var wrap=(this.ColumnsAttr[i]["align"]=="right"?"nowrap=true;":"");
                sel_tdi=CrEl(tel,"td",wrap,"paddingLeft:3; paddingRight:3;");
                if (this.IconViewState) {
                    sel_tdi.onclick=function() {this.parentNode.firstChild.nextSibling.onclick();}
                    sel_tdi.ondblclick=function() {this.parentNode.firstChild.nextSibling.ondblclick();}
                } else {
                        sel_tdi.onclick=function() {this.parentNode.firstChild.onclick();}
                        sel_tdi.ondblclick=function() {this.parentNode.firstChild.ondblclick();}
                       }
                if (sel_tdl!=null) CrEl(CrEl(sel_tdi,"span","class="+this.GetTypeClassName(prop["type"], (this.Selected==prop), prop)+";"),"text",sel_tdl);
                sel_tdi.style.cursor=(navigator.appName == "Microsoft Internet Explorer")?"hand":"pointer";
           }
           if (prop["type"]==this.firstSelectedType && prop["id"]==this.firstSelectedId) this.SetSelected(prop);

           pprop=prop;
           xml_co=xml_co.nextSibling;
           parity=parity^1;

/*               if (this.firstSelectedType!="")
                   if (this.firstSelectedType==prop["type"] &&
                       this.firstSelectedId==prop["id"]) {
                                                          if (!prop["disabled"]) this.SetSelected(prop);
                                                          this.firstSelectedType="";
                                                         }
*/

    }

    if (pxml_o && pxml_o.firstChild) {
        this.MakePage(TBodyHTML,pxml_o,parity);
    }

    return tel;
   }





   List.prototype.RebuildList=function(parent_id,get,callback,picker,selected) {
    var el,sel,list=this,i;
    var xl=new XML_Load(this.XMLDataBuilder_url,"POST","list_id="+this.ListId+"&parent_id="+parent_id+this.URParam+(get ? get : ""),"XML",list);

    while (this.RootHTMLo.hasChildNodes()) this.RootHTMLo.removeChild(this.RootHTMLo.lastChild);
    tel=CrEl(this.RootHTMLo,"tr");
    sel_td=CrEl(tel,"td","colspan=2; align=center; valign=middle;");       
    CrEl(sel_td,"img","src="+this.LoadingImage+"; width="+this.LoadingImage_sx+"; height="+this.LoadingImage_sy+";");

    if (xl.IsReady()) {
        xl.OnReady=function(status,list,ldata) {
                            while (list.RootHTMLo.hasChildNodes()) list.RootHTMLo.removeChild(list.RootHTMLo.lastChild);
                            while (list.PathHTMLo.hasChildNodes()) list.PathHTMLo.removeChild(list.PathHTMLo.lastChild);

                            if (status!="" || !ldata) { // Error while loading
//                                prop["HTMLo"].parentNode.removeChild(prop["HTMLo"].nextSibling);
                                return;
                            } 

                            var cols=XML_FindSubRootSection(ldata,"COLUMNS");
                            if (cols && cols!=null) {
                                list.Columns=cols.getAttribute("COUNT");
                                list.ColumnsAttr=new Array();
                                cols=cols.firstChild;
                                for (i=0;i<list.Columns;i++) {
                                     list.ColumnsAttr[i]=new Array();
                                     list.ColumnsAttr[i]["width"]=cols.getAttribute("WIDTH");
                                     list.ColumnsAttr[i]["align"]=cols.getAttribute("ALIGN");
                                     list.ColumnsAttr[i]["label"]=cols.getAttribute("LABEL");
                                     list.ColumnsAttr[i]["field"]=cols.getAttribute("FIELD");
                                     cols=cols.nextSibling;
                                }
                            }

                            var path=XML_FindSubRootSection(ldata,"PATH");
                            if (path!=null) {
                                el=null;
                                path=path.firstChild;

                                if (path) {
                                    el=CrEl(list.PathHTMLo,"a","href=#; class="+list.PathLinkClassName+";");
                                    var prop=new Array();
                                    prop["list"]=list;
                                    prop["id"]=0;
                                    el.getProp=function() {return this.prop;};
                                    el.prop=prop;
                                    el.onclick=function() {var prp=this.getProp(); prp["list"].RebuildList(prp["id"]); return false;}
                                } else el=CrEl(list.PathHTMLo,"span","class="+(path ? list.PathLinkClassName : list.PathDLinkClassName)+";");
                                CrEl(el,"text",list.RootLabel);

                                if (path) {
                                         while (path) {
                                          CrEl(list.PathHTMLo,"text",' / ');
                                          var pid=path.getAttribute("ID");
                                          if (path.nextSibling) {
                                              el=CrEl(list.PathHTMLo,"a","href=#; class="+list.PathLinkClassName+";");
                                              prop=new Array();
                                              prop["list"]=list;
                                              prop["id"]=pid;
                                              el.getProp=function() {return this.prop;};
                                              el.prop=prop;
                                              el.onclick=function() {var prp=this.getProp(); prp["list"].RebuildList(prp["id"]); return false;}
                                          } else el=CrEl(list.PathHTMLo,"span","href=#; class="+list.PathDLinkClassName+";");
                                          CrEl(el,"text",path.getAttribute("LABEL"));
                                          path=path.nextSibling;                                        
                                         }
                                         list.LastFolderId=pid;
                                        }
                            }

                            var branch=XML_FindSubRootSection(ldata,"BRANCH");
                            if (branch!=null) {

                                el=CrEl(list.RootHTMLo,"colgroup");
                                if (list.IconViewState) CrEl(el,"col","width="+list.TypeImages_sx+";");
                                CrEl(el,"col","width="+list.DirWidth+"; align="+list.DirAlign+";");
                                for (i=0;i<list.Columns;i++) CrEl(el,"col",(list.ColumnsAttr[i]["width"] ? "width="+list.ColumnsAttr[i]["width"]+";" : "")+(list.ColumnsAttr[i]["align"] ? "align="+list.ColumnsAttr[i]["align"]+";" : ""));

                                el=CrEl(list.RootHTMLo,"tbody");
                                if (list.Columns>0) {
                                    sel=CrEl(el,"tr");

                                    if (list.IconViewState) CrEl(sel,"td"); //Icon
                                    var it=CrEl(sel,"td","class="+list.PathClassName+";");
                                    var ita=CrEl(it,"a","class="+list.PathClassName+";"); //Label;
                                    ita.onclick=new Function('','sort'+list.ListId+'("'+list.DirLabel+'")');
                                    CrEl(ita,"text",list.DirLabel);

                                    for (i=0;i<list.Columns;i++) {
                                         el=CrEl(sel,"td","class="+list.PathClassName+";","paddingLeft:3; paddingRight:3;");
                                         ita=CrEl(el,"a","class="+list.PathClassName+";"); //Label;
                                         ita.onclick=new Function('','sort'+list.ListId+'("'+list.ColumnsAttr[i]["label"]+'")');
                                         CrEl(ita,"text",list.ColumnsAttr[i]["label"]);
                                    }
                                }

                                list.ParentId=branch.getAttribute("PARENTID");
                                var pXMLo=XML_FindSubRootSection(ldata,"PAGES");

                                i=pXMLo.firstChild;
                                list.curPage=0;
                                while (i) {
                                 if (i.getAttribute("SELECTED")=="1") {
                                  list.curPage=parseInt(i.getAttribute("NUM"));
                                  // Обработка случая, если на странице есть форма редактирования элемента, на случай удаления.
                                  if(document.getElementById('propform')) {
                                   document.getElementById('propform').action=document.getElementById('propform').action.replace(/&page=[^&]*/ig,'');
                                   document.getElementById('propform').action+='&page='+list.curPage;
                                   }
                                  break;
                                  }
                                 i=i.nextSibling;
                                }
                                list.MakeList(branch.firstChild,pXMLo);
                            }  else list.RootObj=null;

                            if (callback) callback(list,picker,selected);

                   if (list.scrollTop>0) list.Container.scrollTop=list.scrollTop;
                   };
        xl.Load();
    }

   }

//******************************************************************************

