
   var ns = false;
   if (document.layers) ns=true;
   var ie = false;
   if (document.all)    ie=true;
   var scrollMargin    = 15;
   var scrollPos       = 0;        // Current position of scroll
   var scrollStep      = 1;        // Size of scrolling step
   var scrollSpeedStep = 100;      // Size of jump
   var currentScroll   = null;     // Is the panel currently scrolling?
   var continueFlag    = false;
   var scrollEnable    = false;
   var continuous      = false;


   // Initialise all variables / layer positioning etc. A call to this function should be placed
   // in the 'onLoad' event of the body tag in the page which contains the scrolling panel.
   function initialiseScroller(scrollType,scrollStart,scrollSpeed)
   {
      continuous = (scrollType=="continuous");
      document.onmouseup = toggleScroll;
      if (ns) document.captureEvents(Event.MOUSEUP);

      if (ie)
      {
         scrolldiff = ScrollArea.scrollHeight-BoxArea.offsetHeight;
         boxheight  = BoxArea.offsetHeight;
         if (continuous)
         {
            maxscroll = ScrollArea.scrollHeight;
            minscroll = 0 - boxheight;
         }
         else
         {
            maxscroll = ScrollArea.scrollHeight-boxheight+100;
            minscroll = 0;
         }

      }
      if (ns)
      {
         scrolldiff = document.layers['BoxArea'].document.layers['ScrollArea'].document.height-document.layers['BoxArea'].clip.height;
         boxheight  = document.layers['BoxArea'].clip.height;
         if (continuous)
         {
            maxscroll = document.layers['BoxArea'].document.layers['ScrollArea'].document.height;
            minscroll = 0 - boxheight;
         }
         else
         {
            maxscroll = document.layers['BoxArea'].document.layers['ScrollArea'].document.height-boxheight+100;
            minscroll = 0;
         }
      }

      positionScroller();

      // Work out if we need to display the navigation buttons...
      if (scrolldiff > 0)
      {
         scrollEnable=true;
         // Set the scroller so that it starts scrolling straight away
         if (scrollStart > 0)
            setTimeout("movePanel('down','slide');",scrollStart);
      }
      else
      {
         movePanel('down','slide');
      }
   }

   function toggleScroll()
   {
      if (!continueFlag) currentScroll=false;
      continueFlag=false;
      setTimeout("scrollFlag=false;", 100);
   }

   function movePanel(direction, type)
   {
      if (scrollEnable)
      {
         continueFlag=true;
         if ((currentScroll==direction) && (type=="slide"))
         {
            currentScroll=null;
         }
         else
         {
            currentScroll=direction;
            scrollExec(direction, type);
         }
      }
   }

   function scrollExec(direction, type)
   {
      if (currentScroll==direction)
      {
         if ((type=="slide") && (currentScroll))
         {
            setTimeout("scrollExec('"+direction+"', '"+type+"');", scrollSpeedStep);
         }
         else currentScroll=null;

         if (type=="jump") delta=boxheight-scrollMargin;
         else delta=scrollStep;
         if (direction=="up") delta=-delta;
         scrollPos+=delta;
         //if (scrollPos < 0) scrollPos=0;
         if (scrollPos < minscroll)
         {
            if (continuous)
               scrollPos=maxscroll;
            else
               scrollPos=minscroll;
         }


         if (scrollPos > maxscroll)
         {
            if (continuous)
               scrollPos = minscroll;
            else
               scrollPos = maxscroll;
         }
         if (ie) ScrollArea.style.top=-scrollPos;
         if (ns) document.layers['BoxArea'].document.layers['ScrollArea'].top=-scrollPos;
      }
   }

   function positionScroller()
   {
      if (document.layers)
      {
         if (window.scrollbars.visible)
            scrollWidth = 20
         else
            scrollWidth = 0;

         document.layers.BoxArea.left = (window.innerWidth - document.layers.BoxArea.clip.width) - 9 - scrollWidth;
         document.layers.BoxArea.visibility = "visible";
      }
      else if (document.all)
      {
         boxWidth = BoxArea.clientWidth;
         if (!boxWidth) boxWidth = BoxArea.style.width;
         BoxArea.style.left = document.body.clientWidth - boxWidth - 9;
         BoxArea.style.visibility = "visible";
      }
   }

