// Copyright 17 Mar 1999, Cavalry Outpost Publications.

// This program loads and displays a keypad popup menu which controlls
// an associated HTML file that scrolls and/or searches the current page,

// *********************************************************************
// **********     Program Name = scroller.js Ver 03.11.13     **********
// *********************************************************************

// 1.0 DEFINE SCREEN and POP_UP WINDOW PARAMETERS
// A. Define Screen Coordinates

var ScrollbarWidth = 22;
var popUpWinFrameWidth = 6;
var xMax = screen.availWidth;

// B. Define Screen and popUpWinParameters

var popUpWinWidth = 305, popUpWinHeight = 135;
var xOffset = ((xMax - ScrollbarWidth) - (popUpWinWidth + 2*popUpWinFrameWidth))/2;
var popUpWinParameters = 'width='+popUpWinWidth+',height='+popUpWinHeight+',screenX='+xOffset+',left='+xOffset+',screenY=0,top=0';

// C. Define keypad popup window characteristics

function keypadWin() {
        keypad=window.open("scroller.html","WebSite_Scroller", popUpWinParameters);
}

// 2.0 DEFINE SCROLLING VARIABLES

timeout = 0;
var position = 0;
var index = 1;

// 3.0 ENABLE SCROLLING LOGIC

function scrollDown() {
        if (position < 0) {
                position=0;
        }
        window.self.scroll(0,position);
        position=position + index;
        timeout=setTimeout("scrollDown()",25);
}

function resetScroll() {
        index = 1;
        clearTimeout(timeout);
}

function scrollUp() {
        if (position >=0 ) {
                window.self.scroll(0,position);
                position = position - index;
        }
        timeout=setTimeout("scrollUp()",25);
}

function fastScroll() {
         index  = index * 2; 
}

function pauseScroll() {
        clearTimeout(timeout);
}

function slowScroll() {
        index = index/2 ; if (index <= 1) index = 1;
}

// 4.0 CLOSE PopUp WINDOW

function CloseKeypad() {
        var sLocType
        if (keypad) {
                if (!keypad.closed) {
                        sLocType = typeof keypad.location;
                        if (sLocType == 'object') {
                                keypad.close();
                        }
                }
        }
}

