// SE.
// Modified to be used with a later(non-standard) version of the DynAPI.
// ScrollTo Methods added back into the DynLayer object.
// 2007JAN26
// Based on the original code:

// MiniScroll Object
// gives controls to a set of 2 layers for scrolling
// 19990410

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

function MiniScroll(viewHeight, viewWidth, content) {
    this.window = window;
    this.viewHeight = viewHeight;
    this.viewWidth = viewWidth;
    this.content = content;
    this.inc = 4;
    this.speed = 1;
    this.topY = content.getY();
    this.contentHeight = content.getHeight(); 
    this.contentWidth = content.getWidth();

    
    this.up = MiniScrollUp;
    this.down = MiniScrollDown;
    this.stop = MiniScrollStop;
    this.top = MiniScrollTop;
    
    this.activate = MiniScrollActivate;
    this.activate(this.contentWidth, this.contentHeight);
}

function MiniScrollActivate() {
    this.offsetHeight = this.contentHeight-this.viewHeight;
    this.offsetWidth = this.contentWidth-this.viewWidth;
    this.enableVScroll = (this.offsetHeight > 0);
    this.enableHScroll = (this.offsetWidth > 0);               
}

function MiniScrollUp() {
    if (this.enableVScroll && this.content.getY() < this.topY) 
        this.content.slideTo(null,1,this.inc,this.speed);
}

function MiniScrollDown() {
    var downLimit = this.contentHeight - this.viewHeight; 
    var scroll = (this.enableVScroll && this.content.getY() > -downLimit);
    if (scroll) 
        this.content.slideTo(null,-downLimit,this.inc,this.speed);
}

function MiniScrollStop() {
    this.content.slideActive = false;
}

function MiniScrollTop() {
    this.content.moveTo(0, this.topY);        
}


