il primo con le funzioni MakeNode che sono scritte sopra:
var Ccounter = 0;
var Mcounter = 1;
var firstNode = 0;
var lastNode = 0;


function beginDownload(newlocation) {
idl = 1;
if (location.search) {
idl = -location.search.indexOf("idl=n");
}
if (idl > 0) {
window.location = newlocation;
}
}


function openTree(caption)
{
document.write('<font face="Tahoma,Arial,Helvetica,Sans Serif" size="2">');
document.write('<div style="margin-left:0; display:;">');
document.write('<table cellpadding=0 cellspacing=0 border="0"><tr>');
document.write('<td valign=top>[img]images/tree_view/ftv2plastnode.gif[/img]');
document.write('</td>');
document.write('<td valign=top><span ID="MT-1">[img]images/epbulletsml.gif[/img]<font size="-1">');
document.write(caption);
document.write('
</font></span></td>');
document.writeln('</tr></table>');
}

function closeTree()
{
document.writeln ('</DIV>\n</FONT>');
}

// This function handles to onClick event for expanding/closing
// nodes of the tree.
function expandCollapseClick ()
{
var parentID;
var child;
var parentImage;

parentID = window.event.srcElement.id;

if (parentID.charAt (0) == 'M')
{
child = document.all ('C' + parentID.substr (2));
parentImage = document.all ('MI' + parentID.substr (2));
if (child.style.display == 'none') // hidden
{
child.style.display = '';
/* use last minus sign when appropiate */
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2mlastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2mnode.gif';
}
else
{
child.style.display = 'none';
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2plastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2pnode.gif';
}
}
}

// This function gets called from a script tag at the bottom of
// your html to expand the menu upon page opening.
function expandMenu(cat)
{
var parentID;
var child;
var parentImage;

// Get First level desired to expand. You want to specify
// Top level (MI-1) when calling this function.
parentID = cat.substr(0);

if (parentID.charAt(0) == 'M')
{
child = document.all ('C' + parentID.substr (2));
parentImage = document.all ('MI' + parentID.substr (2));
if (child.style.display == 'none') // hidden
{
child.style.display = '';
/* use last minus sign when appropiate */
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2mlastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2mnode.gif';
}
else
{
child.style.display = 'none';
if(parentID == 'MI-1' || parentID == 'MI-' + Mcounter)
parentImage.src = 'images/tree_view/ftv2plastnode.gif';
else
parentImage.src = 'images/tree_view/ftv2pnode.gif';
}
}
}

// This function creates the link.
function makeLink (category, urlDir, targetc)
{
var categoryToDisplay, targetstr;

/*if (category.length > 12)
{
categoryToDisplay = category.substring (0, 50);
}
else
{
categoryToDisplay = category;
}
*/

HTMLstr='<font size="-1">' + category + '<input type="checkbox" name="' + urlDir + '" value="">';

return HTMLstr;
}

// This function creates the end nodes under any given category.
function makeNode (name, URLpath, targeta, checked)
{

++lastNode; // increment to track last node of node division.
if (checked == true)
{
document.writeln ('<table border="0" width="180" CELLPADDING=0 CELLSPACING=0><tr><td valign=top width=32>[img]images/tree_view/ftv2vertline.gif[/img][img]images/tree_view/ftv2node.gif[/img]</td><td valign=top style="font-size:11px;width:128px;">' + name + '</td><td valign=top width="20"><input type="checkbox" checked name="' + URLpath + '" value="" onClick="RM_deptcheck('+ targeta + ');"></td></tr></table>');
}
else
{
document.writeln ('<table border="0" width="180" CELLPADDING=0 CELLSPACING=0><tr><td valign=top width=32>[img]images/tree_view/ftv2vertline.gif[/img][img]images/tree_view/ftv2node.gif[/img]</td><td valign=top style="font-size:11px;width:128px;">' + name + '</td><td valign=top width="20"><input type="checkbox" name="' + URLpath + '" value="" onClick="RM_deptcheck(' + targeta + ');"></td></tr></table>');
}

}

// This function creates the category.
function makeCategory (name, URLpath, targetb)
{
Mcounter++;
document.writeln ('<table width="400" CELLPADDING=0 CELLSPACING=0><tr style="color:#FFFFFF;font-weight:bold;"><td valign=top width=16>[img]images/tree_view/ftv2pnode.gif[/img]</td><td style="font-size:12px;width:364px;background:#666666;padding-left:3px;" id="cat' + targetb + '"><SPAN ID=MT-' + Mcounter + '>' + name + '</SPAN></td><td valign="top" width="20" style="background:#666666;"><input type="checkbox" name="' + URLpath + '" value="" onClick="window.RM_SelectDept(' + targetb + ');window.RM_toggBg(' + targetb + ');"></td></tr></table>');
}

// This function creates the opening div tag for hiding and
// showing with the expandCollapseClick function.
function openDiv ()
{
Ccounter++;
document.writeln ('<DIV ID=C-' + Ccounter + ' STYLE="margin-left:15; display:None;">');
}
function openNodeDiv ()
{
firstNode = lastNode + 1; // remember first node of node division.
++Ccounter;
document.writeln ('<DIV ID=C-' + Ccounter + ' STYLE="margin-left:0; display:None;">');
}

// This function closes the div tag.
function closeDiv ()
{
var image;

document.writeln ('</DIV>');

image = document.all('MI-' + Mcounter);
image.src = 'images/tree_view/ftv2plastnode.gif';

// blank last catagory's node's first image(vertical line).
for(i = firstNode; i <= lastNode; ++i)
{
image = document.all('img1-' + i);
image.src = 'images/tree_view/ftv2blank.gif';
}
}
function closeNodeDiv ()
{
var image;

document.writeln('</DIV>');

image = document.all('img2-' + lastNode);
image.src = 'images/tree_view/ftv2lastnode.gif';
}

// This command calls the function created in the head of your
// document. If you do not want users to see your directory
// structure, you will need to put that function here. I moved
// it outside this file and into the head of the html file
// to manipulate the tree using ASP.
// showDirectoryTree();