function VScrollBar(name,scrollBarId,scrollCursorId,clipId,contentId,btScrollUpId,btScrollDownId)
 {
  this.name=name;
  this.scrollBar=new getObject(scrollBarId);
  this.scrollCursor=new getObject(scrollCursorId);
  this.clip=new getObject(clipId);
  this.content=new getObject(contentId);
  this.btScrollUp=(btScrollUpId)?new getObject(btScrollUpId):false;
  this.btScrollDown=(btScrollDownId)?new getObject(btScrollDownId):false;
  this.cursorScrollHeight=false;
  this.contentScrollHeight=false;
  this.baseScrollPos=false;
  this.contentPos=false;
  this.cursorPos=false;
  this.scrollTimer=false;
  this.dragCursor=false;
  mouseMoveEvent.add(name+".dragCursorEvent()");
  mouseUpEvent.add(name+".stopDragCursor()");
 }

VScrollBar.prototype.init=function(borderSize)
 {
  if(!borderSize) borderSize=0;
  this.baseScrollPos=parseInt(this.scrollBar.yPos())+parseInt(parseInt(this.scrollCursor.height())/2);
  this.cursorScrollHeight=parseInt(this.scrollBar.height())-parseInt(this.scrollCursor.height())-((isMOZ)?0:2*borderSize);
  this.contentScrollHeight=parseInt(this.content.scrollHeight())-parseInt(this.clip.height());
  if(!isMOZ) this.scrollBar.width(2*borderSize+parseInt(this.scrollCursor.width()));
  this.scrollCursor.yPos("0px");
  this.content.yPos("0px");
  this.contentPos=0;
  if(this.contentScrollHeight>0)
   {
    this.scrollBar.show();
    if(this.btScrollUp) this.btScrollUp.show();
    if(this.btScrollDown) this.btScrollDown.show();
   }
  else
   {
    this.scrollBar.hide();
    if(this.btScrollUp) this.btScrollUp.hide();
    if(this.btScrollDown) this.btScrollDown.hide();
   }
  return (this.contentScrollHeight>0);
 }

VScrollBar.prototype.startDragCursor=function()
 {
  this.dragCursor=true;
  this.dragCursorEvent();
 }

VScrollBar.prototype.stopDragCursor=function()
 {
  this.dragCursor=false;
  if(this.scrollTimer)
   {
    clearInterval(this.scrollTimer);
    this.scrollTimer=false;
   }
 }

VScrollBar.prototype.dragCursorEvent=function()
 {
  if(this.dragCursor)  
   {
    this.cursorPos=yMouse-this.baseScrollPos;
    if(this.cursorPos<0) this.cursorPos=0;
    if(this.cursorPos>this.cursorScrollHeight) this.cursorPos=this.cursorScrollHeight;
    this.contentPos=parseInt(this.cursorPos*this.contentScrollHeight/this.cursorScrollHeight);
    this.scrollCursor.yPos(this.cursorPos+"px");
    this.content.yPos(-this.contentPos+"px");
    if(isIE) document.selection.empty();
   }
 }

VScrollBar.prototype.scrollUp=function(step)
 {
  if(!step) step=8;
  if(this.contentScrollHeight>0)
   {
    this.contentPos-=step;
    if(this.contentPos<0) this.contentPos=0;
    this.cursorPos=parseInt(this.contentPos*this.cursorScrollHeight/this.contentScrollHeight);
    this.scrollCursor.yPos(this.cursorPos+"px");
    this.content.yPos(-this.contentPos+"px");
    if(!this.scrollTimer) this.scrollTimer=setInterval(this.name+".scrollUp("+step+")",40);
   }
 }

VScrollBar.prototype.scrollDown=function(step)
 {
  if(!step) step=8;
  if(this.contentScrollHeight>0)
   {
    this.contentPos+=step;
    if(this.contentPos>this.contentScrollHeight) this.contentPos=this.contentScrollHeight;
    this.cursorPos=parseInt(this.contentPos*this.cursorScrollHeight/this.contentScrollHeight);
    this.scrollCursor.yPos(this.cursorPos+"px");
    this.content.yPos(-this.contentPos+"px");
    if(!this.scrollTimer) this.scrollTimer=setInterval(this.name+".scrollDown("+step+")",40);
   }
 }

function HScrollBar(name,scrollBarId,scrollCursorId,clipId,contentId,btScrollLeftId,btScrollRightId)
 {
  this.name=name;
  this.scrollBar=new getObject(scrollBarId);
  this.scrollCursor=new getObject(scrollCursorId);
  this.clip=new getObject(clipId);
  this.content=new getObject(contentId);
  this.btScrollLeft=(btScrollLeftId)?new getObject(btScrollLeftId):false;
  this.btScrollRight=(btScrollRightId)?new getObject(btScrollRightId):false;
  this.cursorScrollWidth=false;
  this.contentScrollWidth=false;
  this.baseScrollPos=false;
  this.contentPos=false;
  this.cursorPos=false;
  this.scrollTimer=false;
  this.dragCursor=false;
  mouseMoveEvent.add(name+".dragCursorEvent()");
  mouseUpEvent.add(name+".stopDragCursor()");
 }

HScrollBar.prototype.init=function(borderSize)
 {
  if(!borderSize) borderSize=0;
  this.baseScrollPos=parseInt(this.scrollBar.xPos())+parseInt(parseInt(this.scrollCursor.width())/2);
  this.cursorScrollWidth=parseInt(this.scrollBar.width())-parseInt(this.scrollCursor.width())-((isMOZ)?0:2*borderSize);
  this.contentScrollWidth=parseInt(this.content.scrollWidth())-parseInt(this.clip.width());
  if(!isMOZ) this.scrollBar.height(2*borderSize+parseInt(this.scrollCursor.height()));
  this.scrollCursor.xPos("0px");
  this.content.xPos("0px");
  this.contentPos=0;
  if(this.contentScrollWidth>0)
   {
    this.scrollBar.show();
    if(this.btScrollLeft) this.btScrollLeft.show();
    if(this.btScrollRight) this.btScrollRight.show();
   }
  else
   {
    this.scrollBar.hide();
    if(this.btScrollLeft) this.btScrollLeft.hide();
    if(this.btScrollRight) this.btScrollRight.hide();
   }
  return (this.contentScrollWidth>0);
 }

HScrollBar.prototype.startDragCursor=function()
 {
  this.dragCursor=true;
  this.dragCursorEvent();
 }

HScrollBar.prototype.stopDragCursor=function()
 {
  this.dragCursor=false;
  if(this.scrollTimer)
   {
    clearInterval(this.scrollTimer);
    this.scrollTimer=false;
   }
 }

HScrollBar.prototype.dragCursorEvent=function()
 {
  if(this.dragCursor)  
   {
    this.cursorPos=xMouse-this.baseScrollPos;
    if(this.cursorPos<0) this.cursorPos=0;
    if(this.cursorPos>this.cursorScrollWidth) this.cursorPos=this.cursorScrollWidth;
    this.contentPos=parseInt(this.cursorPos*this.contentScrollWidth/this.cursorScrollWidth);
    this.scrollCursor.xPos(this.cursorPos+"px");
    this.content.xPos(-this.contentPos+"px");
    if(isIE) document.selection.empty();
   }
 }

HScrollBar.prototype.scrollLeft=function(step)
 {
  if(!step) step=8;
  if(this.contentScrollWidth>0)
   {
    this.contentPos-=step;
    if(this.contentPos<0) this.contentPos=0;
    this.cursorPos=parseInt(this.contentPos*this.cursorScrollWidth/this.contentScrollWidth);
    this.scrollCursor.xPos(this.cursorPos+"px");
    this.content.xPos(-this.contentPos+"px");
    if(!this.scrollTimer) this.scrollTimer=setInterval(this.name+".scrollLeft("+step+")",40);
   }
 }

HScrollBar.prototype.scrollRight=function(step)
 {
  if(!step) step=8;
  if(this.contentScrollWidth>0)
   {
    this.contentPos+=step;
    if(this.contentPos>this.contentScrollWidth) this.contentPos=this.contentScrollWidth;
    this.cursorPos=parseInt(this.contentPos*this.cursorScrollWidth/this.contentScrollWidth);
    this.scrollCursor.xPos(this.cursorPos+"px");
    this.content.xPos(-this.contentPos+"px");
    if(!this.scrollTimer) this.scrollTimer=setInterval(this.name+".scrollRight("+step+")",40);
   }
 }
