title: I move this code into a separate function and it stops working, why?
body: <p>Here is an excerpt of my code.  You can ignore most of it: the bit of concern is with the refreshDimensions method, the call to said method inside zoomTo, and the block of code after that call.</p>
  
  <pre><code>function refreshDimensions(node) {
      _("refreshdimensions");
      t = $("#contents");
      var other = $(selectednode).parent().parent(":not(#contents)");
      if(!other.length) {
      other = selectednode || zoomednode || start;
      t.width("100%");
      } else {
      t.width("100%");
      t.width((t.width() + other.position().left));
      }
      t.height($(other).position().top);
  
      /* Begin animating */
  
      t.animate({ fontSize: zoom }, {duration: 0, queue: false });
  
  //    
  }
  
  function zoomTo(node, select) {
      var oldzoom, zoomdepth, t;
      oldzoom = zoomednode;
      if($(node)[0] != $(zoomednode)[0]) {
      savedepth = t = zoomdepth = $(node).parents("ul").length;
      if(!zoomednode)
          zoomednode = topChapter;
      $(zoomednode).toggleClass("zoomednode", false);
      if(!node)
          node = topChapter;
      /* capture values */
      var sz;
      var capp = cBaseSz.slice((zoom = zoomnum = sz = parseFloat(cBaseSz)+"").length);
      /* end capture */
      while(--t &gt; 0) {
              zoomnum = (zoom *= 1.15);
      }
      zoom  += capp;
      zoomdepth -= $(zoomednode).parents("ul").length;
      if(zoomdepth &lt; 0)
          zoomdepth *= -1;
      zoomednode = node;
      zoomednode.toggleClass("zoomednode", true);
      switch(select) {
      case 0:
      case false:
      default:
          break;
      case true:
      case 1:
          toggleNode(selectednode, false);
          toggleNode(node, true);
          break;
      case 2:
          toggleNode(zoomednode, false);
              zoomednode = 0;
      }
  
  
      /* Handle showing/hiding */
  
      //////////////////////////////
      //
      var showzoom = 1, showselect = 1, showidea = 1, seldepth, zdepth, showlist, hidelist = {};
      /* This is the 'brute force' way of doing it, horribly inefficient */
      if(zoomednode)
          zdepth = $(zoomednode).parents(".chapter").length;
      if(selectednode)
          seldepth = $(selectednode).parents(".chapter").length;
      else
          seldepth = zdepth;
      if(!seldepth)
          seldepth = zdepth = 0;
      showlist=$(".chapter, .idea").filter( function() {
          if($(this).parents("li").length &lt; (zdepth+showzoom))
          return true;
          else {
          hidelist = $(hidelist).add(this);
          return false;
          }
      });
  
  
      $(showlist).show()/*.not(hidelist)*/;
      if(hidelist &amp;&amp; hidelist.length) {
          $(hidelist).hide();
      }
      /* End showing/hiding */
  
      refreshDimensions(node);
  
      if(node) {
          _("top: " + $(zoomednode).position().top);
          $("html,body").stop().animate(
          { scrollTop: $(zoomednode).position().top - topAdjust }, {duration: 60+60*zoomdepth, queue: false }, 0);
      }
  
      }
      else {
      var dest;
      if($(zoomednode).parents(".chapter").length &gt; 1)
          dest = $(zoomednode).parent().parent().prevAll(".chapter:first .chapterheading:first");
      else {
      //    if($(zoomednode)[0] != $("#contents")[0]) {
          toggleNode(selectednode, false);
          dest = $("#contents");
      //    } else
      //  dest = $(start);
      }
      zoomTo(dest, 0);
      }
  }
  </code></pre>
  
  <p>So my problem is that when I move the bit of code after the call to refreshDimensions (the block beginning with 'if(node) {'), into refreshDimensions (at the end), the desired effect stops working.  I have dumped all the variables that the line uses into the console and they are consistent across both instances, yet when I move the code to refreshDimensions my page gets 'trapped' at the top of the screen and won't scroll at all.  This really has me stumped as everything points to that it should work exactly the same...</p>