function fontsize(size) {
  document.getElementById('body').style.fontSize = size+'px';
  document.cookie = 'fontSize='+size;
}

var ScrollBody = function() {
  this.x = 0;
  this.xCur = 0;
  this.ie = (document.all);
  this.sites;
  this.height = 349;
  this.refBar;
  this.refUp;
  this.refDown;
  this.fps = 30;
  this.ani;
  
  this.move = function(way) {
    if (way == 'up') this.x += this.height;
    else this.x -= this.height;
    if (this.x < 1) this.x = 0;
    if (this.x > (this.sites-1)*this.height) this.x = (this.sites-1)*this.height;
    this.setArrows();
    clearTimeout(this.ani);
    this.startMoving();
  }
  
  this.startMoving = function() {
    var play = true;
    if (this.x > this.xCur) {
      if (this.x - this.xCur > 60) this.xCur+=10;
      else this.xCur+= Math.floor((this.x - this.xCur)/6);
      this.xCur++;
    } else if (this.x < this.xCur) {
      if (this.xCur - this.x > 60) this.xCur-=10;
      else this.xCur-= Math.floor((this.xCur - this.x)/6);
      this.xCur--;
    } else {
      var play = false;
    }
    this.refBar.style.top = -(this.xCur)+'px';
    if (play) this.ani = setTimeout('scrollBody.startMoving();',this.fps);
  }
  
  this.setArrows = function() {
    if (this.x == 0) this.setOpacity(this.refDown,30);
    else this.setOpacity(this.refDown,100);
    if (this.x > (this.sites-2)*this.height) this.setOpacity(this.refUp,30);
    else this.setOpacity(this.refUp,100);
  }
  
  this.setOpacity = function(ref,val) {
    if (this.ie) ref.style.filter = 'alpha(opacity='+val+')';
    else ref.style.opacity = val/100;
  }
  
  this.init = function(sites) {
    this.refBar = document.getElementById('scrollInnerBody');
    this.refUp = document.getElementById('scrollUpArrow');
    this.refDown = document.getElementById('scrollDownArrow');
    this.sites = sites;
    this.setArrows();
  }
}

var scrollBody = new ScrollBody();
