function foldersubentries() {
var i = 0;
var se = this.nchildren;
for(i = 0; i < this.nchildren; i++) {
if(this.children.children) //is a folder
se = se + this.children.subentries();
}
return(se)
}
// definition of class item (a document or link inside a folder)
function item(itemdescription, hreference, itemlink, itemimg,parentid) // constructor
{
// constant data
this.desc = itemdescription
this.link = itemlink
this.hreference = hreference;
this.id =index;
this.navobj = 0; //initialized in render()
this.iconimg = 0; //initialized in render()
// iconsrc俊 瘤沥登绰 捞固瘤 颇老阑 阿 酒捞袍俊 嘎霸 瘤沥且 荐 乐档废 茄促 (格钎)
this.iconsrc = itemimg;
// methods
this.initialize = initializeitem ;
this.createindex = createentryindex;
this.hide = hideitem;
this.display = display;
this.renderob = drawitem;
this.totalheight = totalheight;
this.parentid=parentid;
//alert(this.parent);
}
function createentryindex() {
indexofentries[nentries] = this;
nentries++;
}
// total height of subentries open
function totalheight() { //used with browserversion == 2
var h = this.navobj.clip.height;
var i = 0;
if(this.isopen) { // is a folder and _is_ open
for(i = 0 ; i < this.nchildren; i++)
h = h + this.children.totalheight();
}
return h
}
// events
function clickonfolder(folderid) {
var clicked = indexofentries[folderid];
if(!clicked.isopen)
clickonnode(folderid);
if(clicked.isselected)
return;
}
function clickonnode(folderid) {
var clickedfolder = 0;
var state = 0;
clickedfolder = indexofentries[folderid];
state = clickedfolder.isopen;
if (!state){
if(clickedfolder.target)clickedfolder.target.location=clickedfolder.hreference; //点击folder时显示相干链接页面
veiwfile(folderid);
}
clickedfolder.setstate(!state); //open<->close
}
function initializedocument() {
if(doc.all)
browserversion = 1; //ie4
else if(doc.layers)
browserversion = 2; //ns4
else
browserversion = 0; //other
folderstree.initialize(0, 1, "");
//folderstree.display();
if(browserversion > 0) {
doc.write("<layer top="+indexofentries[nentries-1].navobj.top+"> </layer>");
// close the whole tree
clickonnode(0);
// open the root folder
clickonnode(0);
}
}
// auxiliary functions for folder-treee backward compatibility
function gfldr(description, hreference,parentid,target) {
var des;
index++;
if(fentries==0){
selectfile[fentries]=description;
fentries++;
}
des=description;
folder = new folder(des, hreference,parentid,target);
return(folder);
}
function insfldr(parentfolder, childfolder,target,hreference) {
var child;
var desc;
parentid=parentfolder.id;
child=gfldr(childfolder,hreference,parentid,target);
return(parentfolder.addchild(child));
}