repositioner = function() {
   var d, h, s, c, z;

   return {
      init: function() {
         h=document.getElementById('header');
         s=document.getElementById('sidebar');
         c=document.getElementById('content');

         h.style.display = '';
         s.style.display = 'inline';

         if (!d) {
            repositioner.position();
            d = window.setInterval('repositioner.position()', 500);
         }
      },

      position: function() {
         if (h.offsetHeight != z) {
            if ((h.offsetHeight + s.offsetHeight) < window.innerHeight) {
               s.style.position = h.style.position = 'fixed';
               c.style.position = 'absolute';
            } else {
               c.style.position = s.style.position = h.style.position = 'absolute';
            }

            c.style.top = s.style.top = h.offsetHeight + 'px';
            c.style.left = s.offsetWidth + 'px';
            c.style.right = '0px';

            z = h.offsetHeight;
         }
      }
   };
}();
