<!--
// Use the following variable to 
// specify the number of messages
var NumberOfMessages = 6

var messages = new BuildArray(NumberOfMessages)

// Use the following variables to 
// define your messages:
messages[1] = "Welcome to the James A. Cannavino Library"
messages[2] = "800 number: 1-866-880-3682"
messages[3] = "General Information: 845-575-3292"
messages[4] = "Circulation Desk: 845-575-2029"
messages[5] = "See New Books List in the Library Catalog"
messages[6] = "Need Help?  Call 845-575-3292"

var delay = 50
var startPos = 100

// Don't touch these variables:
var timerID = null
var timerRunning = false
var pos = 0

// Crank it up!
StartScrolling()

function StartScrolling(){
    // Make sure the clock is stopped
    StopTheClock()

    // Pick the first message at random
    PickRandomMessage()

    // Off we go...
    DoTheScroll()
}

function StopTheClock(){
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function DoTheScroll(){
    if (pos <= msg.length)
        self.status = msg.substring(pos, msg.length);
    else{
        PickRandomMessage()
        pos=-1
    }
    ++pos
    timerRunning = true
    timerID = self.setTimeout("DoTheScroll()", delay)
}

function PickRandomMessage(){
    // Use the time (i.e., seconds) to get a random number
    var d = new Date()
    var secs = d.getSeconds()
    var rnd = (secs % messages.length) + 1
    msg = messages[rnd]

    // Pad the message with spaces 
    // to get the "start" position
    for (var i = 0; i < startPos; i++) msg = " " + msg
}

function BuildArray(size){
    this.length = size
    for (var i = 1; i <= size; i++){
        this[i] = null}
    return this
}
//-->



