var dom=document.getElementById;
var iex=document.all;

  function eeSaddEvent(a,b){
    this[a]=b
  }

  function eeSremoveEvent(a){
    this[a]=null
  }

  function eeSgetElement(a,c){
    c=c?"document."+c+".":"";var b=dom?document.getElementById(a):iex?document.all[a]:false;b.css=b.style;b.getTop=function(){return parseInt(b.css.top,10)||0};b.setTop=function(d){b.css.top=d+"px"};b.getHeight=function(){return b.offsetHeight};b.getClipHeight=function(){return b.offsetHeight};b.hideVis=function(){b.css.visibility="hidden"};b.eeSaddEvent=eeSaddEvent;b.eeSremoveEvent=eeSremoveEvent;return b
  }

  function getYMouse(a){
    if(!a){var a=window.event}
    if(a.PageY){return a.pageY}
    else{if(a.clientY){return a.clientY+document.body.scrollTop}}
  }

  document.eeSaddEvent=eeSaddEvent;
  document.eeSremoveEvent=eeSremoveEvent;

  ScrollObj=function(speed,dragHeight,trackHeight,trackObj,upObj,downObj,dragObj,contentMaskObj,contentObj){
    this.speed=speed;
    this.dragHeight=dragHeight;
    this.trackHeight=trackHeight;
    this.trackObj=eeSgetElement(trackObj);
    this.upObj=eeSgetElement(upObj);
    this.downObj=eeSgetElement(downObj);
    this.dragObj=eeSgetElement(dragObj);
    this.contentMaskObj=eeSgetElement(contentMaskObj);
    this.contentObj=eeSgetElement(contentObj,contentMaskObj);
    this.obj=contentObj+"Object";eval(this.obj+"=this");
    var mouseChange=function(e){if(!e){e=window.event}if(e.preventDefault){e.preventDefault()}if(e.wheelDelta){delta=e.wheelDelta/120;if(window.opera){delta=-delta}}else{if(e.detail){delta=-e.detail/3}}if(delta>0){self.scroll(speed)}else{if(delta<0){self.scroll(-speed)}}e.returnValue=false};

    if(this.contentObj.addEventListener){
      //window.alert("noEventListener");
      this.contentObj.eeSaddEvent("onmousewheel",mouseChange);
      this.contentObj.addEventListener("DOMMouseScroll",mouseChange,false)
    } else{
      //window.alert("noEventListener");
      this.contentObj.eeSaddEvent("onmousewheel",mouseChange)
    }

    this.trackTop=this.dragObj.getTop();
    this.trackLength=this.trackHeight-this.dragHeight;
    this.trackBottom=this.trackTop+this.trackLength;
    this.contentMaskHeight=this.contentMaskObj.getClipHeight();
    this.contentHeight=this.contentObj.getHeight();
    this.contentLength=this.contentHeight-this.contentMaskHeight;
    this.scrollLength=this.trackLength/this.contentLength;
    this.scrollTimer=null;

    if(this.contentHeight<=this.contentMaskHeight){
      this.dragObj.hideVis();
      this.upObj.hideVis();
      this.downObj.hideVis();
      this.trackObj.hideVis()
    } else {
      var self=this;
      this.trackObj.eeSaddEvent("onmousedown",function(e){self.scrollJump(e);return false});
      this.upObj.eeSaddEvent("onmousedown",function(){self.scroll(self.speed,true);return false});
      this.upObj.eeSaddEvent("onmouseup",function(){self.stopScroll()});
      this.upObj.eeSaddEvent("onmouseout",function(){self.stopScroll()});
      this.downObj.eeSaddEvent("onmousedown",function(){self.scroll(-self.speed,true);return false});
      this.downObj.eeSaddEvent("onmouseup",function(){self.stopScroll()});
      this.downObj.eeSaddEvent("onmouseout",function(){self.stopScroll()});
      this.dragObj.eeSaddEvent("onmousedown",function(e){self.startDrag(e);return false});
      if(iex){this.dragObj.eeSaddEvent("ondragstart",function(){return false})}
    }
  };

  ScrollObj.prototype.startDrag=function(b){
    this.dragStartMouse=getYMouse(b);
    this.dragStartOffset=this.dragObj.getTop();
    var a=this;document.eeSaddEvent("onmousemove",function(c){a.drag(c)});
    document.eeSaddEvent("onmouseup",function(){a.stopDrag()})
  };

  ScrollObj.prototype.stopDrag=function(){document.eeSremoveEvent("onmousemove");document.eeSremoveEvent("onmouseup")};

  ScrollObj.prototype.drag=function(g){var a=getYMouse(g);var c=a-this.dragStartMouse;var f=this.dragStartOffset+c;var b=(f<this.trackTop)?this.trackTop:(f>this.trackBottom)?this.trackBottom:f;this.dragObj.setTop(b);var d=-(b-this.trackTop)*(1/this.scrollLength);this.contentObj.setTop(d)};

  ScrollObj.prototype.scroll=function(d,b){var c=this.contentObj.getTop()+d;var a=this.trackTop-Math.round(this.contentObj.getTop()*(this.trackLength/this.contentLength));if(c>0){c=0}else{if(c<-this.contentLength){c=-this.contentLength}}if(a<this.trackTop){a=this.trackTop}else{if(a>this.trackBottom){a=this.trackBottom}}this.contentObj.setTop(c);this.dragObj.setTop(a);if(b){this.scrollTimer=window.setTimeout(this.obj+".scroll("+d+","+b+")",25)}};

  ScrollObj.prototype.stopScroll=function(){if(this.scrollTimer){window.clearTimeout(this.scrollTimer);this.scrollTimer=null}};

  ScrollObj.prototype.scrollJump=function(f){var a=getYMouse(f);var d=a-findPosY(this.trackObj);var b=(d<this.trackTop)?this.trackTop:(d>this.trackBottom)?this.trackBottom:d;this.dragObj.setTop(b);var c=-(b-this.trackTop)*(1/this.scrollLength);this.contentObj.setTop(c)};

  ScrollObj.prototype.syncBarPosToContent=function(b){var a;if(b){a=this.trackTop-Math.round(b*(this.trackLength/this.contentLength))}else{a=this.trackTop-Math.round(this.contentObj.getTop()*(this.trackLength/this.contentLength))}this.dragObj.setTop(a)};

  function findPosY(b){
    var a=0;
    if(b.offsetParent){
      while(b.offsetParent){a+=b.offsetTop;b=b.offsetParent}
    }else{if(b.y){a+=b.y}}return a
  };

