var startY = 0;
function move_subnav(config)
{
  var subnav = $(config.el);
  if (subnav) {
    setTimeout("move_subnav(" + Object.toJSON(config) + ")", config.speed);
    
    if (subnav.down('div')) {
      if (!subnav.visible()) {
        subnav.show();
      }
      var mintop = config.mintop ? $(config.mintop.el).offsetTop + $(config.mintop.el).getHeight() + ( config.mintop.delta ? config.mintop.delta : 0): -1;
      var maxtop = config.maxtop ? $(config.maxtop.el).offsetTop - subnav.getHeight() - (config.maxtop.delta ? config.maxtop.delta : 0): -1;
      var targetY = document.viewport.getScrollOffsets().top + document.viewport.getDimensions().height - subnav.getHeight();
  
      if ((mintop > 0) && (targetY < mintop)) targetY = mintop;
      if ((maxtop > 0) && (targetY > maxtop)) targetY = maxtop;
      if (startY == 0) startY = targetY;
      
      var delta = (targetY - startY) / 8;
      startY += delta;
      
      subnav.style.top = Math.round(startY) + 'px';
    }
  }
  else {
    if (subnav && subnav.visible()) {
      subnav.hide();
    }
  }
}