function Scroller(pWidth, pHeight, pInterval, pSpeed, pAmount, pFrameCount, pMode, pDirection, pLayerPrefix) {
    this.width = pWidth;
    this.height = pHeight;  
    this.interval = pInterval;  
    this.speed = pSpeed;  
    this.amount = pAmount;  
    this.frameCount = pFrameCount;  
    this.mode = pMode;
    this.direction = pDirection;
    this.layerPrefix = pLayerPrefix;
    this.frames = new Array();
    this.scrollEnabled = true;

    function initialize() {
        for (var i = 0 ; i < this.frameCount; i++) {
            this.frames[i] = eval(this.layerPrefix + i + ".innerHTML") ;
        }    

        this.firstScreen = new Screen(0, 0, this.width, this.height, this.mode, this.direction, eval("document.all." + this.layerPrefix + "Screen1"));
        this.secondScreen = new Screen(0, 0, this.width, this.height, this.mode, this.direction, eval("document.all." + this.layerPrefix + "Screen2"));

        if (this.frameCount > 1) {
            this.nextFrameIndex = 1;
        } else {
            this.nextFrameIndex = 0;
        }        

        this.firstScreen.setHtml(this.frames[0]);
        this.prepareScreen(this.secondScreen);        
    }

    function prepareScreen(pScreen) {
        if (this.mode == "v" && this.direction == "up") {
            pScreen.top = this.height;
        } else if (this.mode == "v" && this.direction == "down") {
            pScreen.top = this.height * -1;
        } else if (this.mode == "h" && this.direction == "left") {
            pScreen.left = this.width;
        } else if (this.mode == "h" && this.direction == "right") {
            pScreen.left = this.width * -1;
        }
        
        pScreen.setHtml(this.frames[this.nextFrameIndex]);

        if (this.nextFrameIndex == this.frames.length - 1) {
            this.nextFrameIndex = 0;
        } else {
            this.nextFrameIndex++;
        }
    }

    function setScroll(pFlag){
        this.scrollEnabled = pFlag;
    }    

    function scroll() {
        if (this.firstScreen.reachEnd()) {
            this.prepareScreen(this.firstScreen);
            this.firstScreen.reset();
            this.secondScreen.reset();
            setTimeout(this.layerPrefix + "Scroller.scroll()", this.interval);
        } else if (this.secondScreen.reachEnd()) {
            this.prepareScreen(this.secondScreen);
            this.firstScreen.reset();
            this.secondScreen.reset();
            setTimeout("Change_Div()", 7000);
            //setTimeout(this.layerPrefix + "Scroller.scroll()", this.interval);
        } else {
            if (this.scrollEnabled) {
                this.firstScreen.proceed(this.amount);
                this.secondScreen.proceed(this.amount);
            }
            setTimeout(this.layerPrefix + "Scroller.scroll()", this.speed);
        }
    }

    function start() {
      setTimeout(this.layerPrefix + "Scroller.scroll()", this.interval);
    }

    this.initialize = initialize;
    this.prepareScreen = prepareScreen;
    this.setScroll = setScroll;
    this.scroll = scroll;
    this.start = start;
}
