     getLabelNameFromButton = function(elem){
       myid = getNodeAttribute(elem, "id");
       return myid + "-label";
     }
     
     getIntegerFromButton = function(elem){
       myid = getNodeAttribute(elem, "id");
       return parseInt(myid.substr(3));
     }
     
     highlightAndShowLabel = function(event){
       unhighlightAllButtons();
       elem = getLabelNameFromButton(this);
       if(getElement(elem) != null){ 
           showElement(elem); 
           elempos = elementPosition(this);
           elempos.x += 44;
           elempos.y += 12;
           setElementPosition(getLabelNameFromButton(this), elempos);
       }
       addElementClass(this, "bordered"); 
     }
     
     unhighlightAllButtons = function(){
       buttons = getElementsByTagAndClassName("div", "button");
       for(b in buttons){
         elem = getLabelNameFromButton(buttons[b]);
         if(getElement(elem) != null){ hideElement(elem); }
         removeElementClass(buttons[b], "bordered");
       }
     }
  
  var unhighlightAllLater = function(call_no){
    if(call_no == btn_mostRecentCall && btn_hideNow){ unhighlightAllButtons(); }
  }
  
  var btn_falseHideNow = function(event){
    btn_hideNow = false;
  } 

  var btn_trueHideNow = function(event){
    btn_hideNow = true;
  } 

  var hideElementEvent = function(event){
    if(getNodeAttribute(event.relatedTarget(), 'class')){
        index = getNodeAttribute(event.relatedTarget(), 'class').indexOf('menu')
        btn_mostRecentCall++;
        callNoCopy = btn_mostRecentCall;
        setTimeout("unhighlightAllLater(" + callNoCopy + ")", 1200)
    } else {
      btn_mostRecentCall++;
      callNoCopy = btn_mostRecentCall;
      setTimeout("unhighlightAllLater(" + callNoCopy + ")", 1200)
    }
  }
     
  var moveButtonsDown = function(event){
    unhighlightAllButtons();
    var viewport_size = 0;
    var max_visible_id = 0;
    buttons = getElementsByTagAndClassName("div", "button");
    for(b in buttons){
      curr_id = getIntegerFromButton(buttons[b]);
      if(buttons[b].style.display != "none"){ viewport_size++; 
        if(max_visible_id < curr_id){  max_visible_id = curr_id; } 
      }
    }    
    max_visible_id ++;
    next_visible_id = max_visible_id;
    hideable_id = (next_visible_id - viewport_size);
    if(getElement("btn" + next_visible_id) != null){ showElement("btn" + next_visible_id); 
      if(getElement("btn" + hideable_id)     != null){ hideElement("btn" + hideable_id); }
    }
  }
  
  var moveButtonsUp = function(event){  
    unhighlightAllButtons();
    var viewport_size = 0;
    var visible_ids = new Array();
    var min_visible_id = 2;
    buttons = getElementsByTagAndClassName("div", "button");
    for(b in buttons){
      curr_id = getIntegerFromButton(buttons[b]);
      if(buttons[b].style.display != "none"){ 
        viewport_size++; 
        visible_ids.push(curr_id);
      }
    }    
    visible_ids;
    min_id_to_show = (listMin(visible_ids) - 1);
    max_id_to_hide = listMax(visible_ids);
    if(getElement("btn" + min_id_to_show) != null){ showElement("btn" + min_id_to_show); 
      if(getElement("btn" + max_id_to_hide) != null){ hideElement("btn" + max_id_to_hide); }
    }
  }
    
  var btn_mostRecentCall = 0;

     loadfunc_buttons = function(){
       buttons = getElementsByTagAndClassName("div", "button");
       for(b in buttons){
         connect(buttons[b], 'onmouseover', buttons[b], highlightAndShowLabel);
         connect(buttons[b], 'onmouseout', buttons[b], hideElementEvent);
         connect(buttons[b], 'onmouseout', buttons[b], btn_trueHideNow);
         connect(buttons[b], 'onmouseover', buttons[b], btn_falseHideNow);
       } 
       labels = getElementsByTagAndClassName("div", "button-label");
       for(l in labels){
         connect(labels[l], 'onmouseout', labels[l], hideElementEvent);
         connect(labels[l], 'onmouseout', labels[l], btn_trueHideNow);
         connect(labels[l], 'onmouseover', labels[l], btn_falseHideNow);
       }
       // internet explorer strikes again - can't use the word "up" as a keyword! WTF!
       b_up = getElement("up"); 
       connect(b_up,   'onclick', b_up,   moveButtonsUp);
       
       b_down = getElement("down"); 
       connect(b_down, 'onclick', b_down, moveButtonsDown);
       
       }
     
     addLoadEvent(loadfunc_buttons); 
