
var tot= new Object();

tot.aTools= new Array();

tot.quickenToolbox= function() {
        var tools=document.getElementsByTagName('DD');
        for (var i=0;i<tools.length;i++) {
            if (tools[i].className.search('tool')) {
                var thisTitle= tot.getMyDT(tools[i]);
                thisTitle.onclick=tot.toggleTool;
                tot.aTools.push({title:thisTitle,tool:tools[i]});
                tools[i].alt= tools[i].offsetHeight +'px';
            }
        }
}

if (window.addEventListener) window.addEventListener('load', tot.quickenToolbox, false);
else if (window.attachEvent) window.attachEvent('onload', tot.quickenToolbox);

tot.getMyDT= function(dd) {
    var myDT=dd.previousSibling;
    while (myDT.nodeType !=1) myDT = myDT.previousSibling;
     if (myDT.tagName!="DT") alert('wow, that\'s bad!\n'+ myDT);
    return myDT;
}

tot.getMyDD= function(dt) {
    var myDD=dt.nextSibling;
    while (myDD.nodeType !=1) myDD = myDD.nextSibling;
    if (myDD.tagName!="DD") alert('wow, that\'s bad!');
    return myDD;
}

tot.toggleTool= function() {
    var myDD=tot.getMyDD(this);
    switch (myDD.className){
        case "tool":
            this.className= 'toolTitle opened';
            myDD.className= 'home tool';
            break;
        case "home tool":
            this.className= 'toolTitle closed';
            myDD.className= 'hidden tool';
            tot.fastShorten(myDD);
            break;
        case "hidden tool":
            this.className= 'toolTitle opened';
            myDD.className= 'home tool';
            tot.fastLengthen(myDD, parseInt(myDD.alt));//firstkid.offsetHeight);
            break;
        default:
            this.className= 'toolTitle closed';
            myDD.className= 'hidden tool';
    }
}

tot.rt= function(tool,h){
    return function(){if(typeof(h)=='number'){tool.style.height=h+'px'}else{tool.style.height=h}}
}

tot.fastShorten= function(tool){
    var h = Math.min(20,tool.offsetHeight);
    for (var i=1;i<h;i++){
        setTimeout( tot.rt(tool,h-i), 10*i);
    }
    setTimeout( tot.rt(tool,1), 10*i);
}

tot.fastLengthen= function(tool, h){
    for (var i=0;i<h;i++){
        setTimeout( tot.rt(tool,i+1), 10*i);
    }
    setTimeout( tot.rt(tool,'auto'), 10*i);
}
