  var scrollBarStep = 1;
  var bodyStep = 0;
  var barPosition = 0;
  var bodyPosition = 0;

  function sizeScroller()
  {
    var scrollBar = $("scrollBar");
    var clientText = $("clientText");
    var textScroller=$("textScroller");

    //Reset position tracking variables
    barPosition=0;
    bodyPosition=0;
    scrollBar.style.marginTop = barPosition + "px";
    clientText.style.marginTop = bodyPosition + "px";

    //Resize the text area so we can see the scroll bar
    var scrollContainerWidth = $("scrollContainer").offsetWidth;
   // clientText.style.width = (scrollContainerWidth - 17) + "px";

    var ScrollerOutsideHeight = $("scrollBarOutside").offsetHeight;

    //Calculate how many "pages" are in the textarea
    var Pages = clientText.offsetHeight / $("scrollContainer").offsetHeight;
       if (Pages < 1) {Pages=1;  textScroller.style.display="none";} else {textScroller.style.display="block";}
//alert(  clientText.offsetHeight );
    //Set the height of the scroller
    var ScrollerInsideHeight = ScrollerOutsideHeight / Pages;
    scrollBar.style.height = ScrollerInsideHeight + "px";

    //The number of pixels we move the body down is relative to number of pixels the scroller moves
    //Figure out the ratio between scrollbar height and body height
    //Use this ratio to make the body step size
    var ratio = (clientText.offsetHeight / ScrollerOutsideHeight);

    bodyStep = ratio * scrollBarStep;

  }

  var downStop = false;

  function startDown()
  {
    downStop = false;
    scrollDown();
  }

  function stopDown()
  {
    downStop = true;
  }

  function scrollDown()
  {
    var scrollBar = $("scrollBar");
    var clientText = $("clientText");

    if (downStop || ((barPosition + scrollBar.offsetHeight) >= $("scrollBarOutside").offsetHeight)) return;
    barPosition+=scrollBarStep;
    bodyPosition-=bodyStep;
    scrollBar.style.marginTop = barPosition + "px";
    clientText.style.marginTop = bodyPosition + "px";

    if ((barPosition + scrollBar.offsetHeight) >= $("scrollBarOutside").offsetHeight)
    {
      return;
    }

    setTimeout("scrollDown();", 50);
  }

  var upStop = false;

  function startUp()
  {
    upStop = false;
    scrollUp();
  }

  function stopUp()
  {
    upStop = true;
  }

  function scrollUp()
  {
    var scrollBar = $("scrollBar");
    var clientText = $("clientText");

    if (upStop || (barPosition <= 0)) return;
    barPosition-=scrollBarStep;
    bodyPosition+=bodyStep;
    scrollBar.style.marginTop = barPosition + "px";
    clientText.style.marginTop = bodyPosition + "px";

    if (barPosition <= 0)
    {
      barPosition = 0;
      bodyPosition = 0;
      scrollBar.style.marginTop = barPosition + "px";
      clientText.style.marginTop = bodyPosition + "px";
      return;
    }

    setTimeout("scrollUp();", 50);
  }

      var mouseDown = false;

      var startY=0;

      function parentMouseDown(e)
      {
        if (window.ActiveXObject)
        {
          startY = event.clientY;
        }
        // code for Mozilla, etc.
        else if (document.implementation &&
          document.implementation.createDocument)
        {
          startY = e.pageY;
        }
        mouseDown = true;
      }

      function parentMouseUp()
      {
        mouseDown = false;
      }

      function parentMouseMove(e)
      {
        if (mouseDown)
        {
          var Y=0;
          // code for IE
          if (window.ActiveXObject)
          {
            Y = event.clientY;
          }
          // code for Mozilla, etc.
          else if (document.implementation &&
            document.implementation.createDocument)
          {
            Y = e.pageY;
          }
          else
          {
            alert('Your browser cannot handle this script');
          }

          var scrollBar = $("scrollBar");
          var clientText = $("clientText");

          var yDiff = (startY - Y)/1;

          if ((barPosition-yDiff) >= 0 && ((barPosition-yDiff) + scrollBar.offsetHeight) <= $("scrollBarOutside").offsetHeight)
          {
            barPosition-=yDiff;
            bodyPosition+=(yDiff*bodyStep);
            scrollBar.style.marginTop = barPosition + "px";
            clientText.style.marginTop = bodyPosition + "px";
          }
          startY = Y;
        }
      }
