function setScrollbar()
{
  this.scroll = function(delta)
  {
    var contentTop = parseInt($('#content').css('top').replace(/^(\d+)px$/, '$1'));
    if (isNaN(contentTop)) contentTop = 0;
    var sctop = contentTop + delta * 15;


    sctop = Math.min(0, sctop);
    sctop = Math.max(sizes.scrollBarHeight - sizes.contentHeight, sctop);
    $('#content').css('top', sctop + 'px');


    var scrollerTop = -(sctop);
    scrollerTop = Math.max(0, scrollerTop);
    scrollerTop = Math.min(sizes.scrollBarHeight-sizes.scrollerHeight, scrollerTop);

    return false;
  };

  var sizes = {
      scrollBarHeight: $('#contentHider').height(),
      contentHeight: $('#content').height()
    }
    
  if (sizes.contentHeight <= sizes.scrollBarHeight)
    return;
    
  $('#contentRollUp, #contentRollDown').css('display', 'block');
  
  var _this = this;
  $('#contentHider').mousewheel(function(event, delta)
  {
    return _this.scroll(delta);
  }, null, true);
  
  $('#contentRollUp').bind('mousedown', function()
  {
    timer = setInterval(function()
    {
      scroll(1);
    }, 60);
  });
  
  $('#contentRollUp').bind('mouseup', function()
  {
     clearTimeout(timer);
  });
  
  $('#contentRollDown').bind('mousedown', function()
  {
    timer = setInterval(function()
    {
      scroll(-1);
    }, 60);
  });
  
  $('#contentRollDown').bind('mouseup', function()
  {
     clearTimeout(timer);
  });

}

$(function()
{
  $(window).load(function()
  {
    setScrollbar();
  });
  
});

