﻿// inputarray is the array of rotated text
// outputdiv is the ID of the div containign the rotated data
// leftbutton is the ID of the left button (prior)
// rightbutton is the ID of the right button
function TextRotater(inputarray, outputdiv, leftbutton, rightbutton)
{
    this.RotateRight = fRotateRight;
    this.RotateLeft = fRotateLeft;
    this.inputarray = inputarray;
       
    // Calculate initial value
    this.CurrentTextBlock = Math.floor(Math.random() * inputarray.length);
    
}

function fRotateRight()
{
    var rot = this.rotater;
    rot.CurrentTextBlock +=1;
    if(rot.CurrentTextBlock >= rot.inputarray.length) rot.CurrentTextBlock = 0;
    rot.outputdiv.innerHTML = rot.inputarray[rot.CurrentTextBlock];
}

function fRotateLeft()
{
    var rot = this.rotater;
    rot.CurrentTextBlock -=1;
    if(rot.CurrentTextBlock < 0) rot.CurrentTextBlock = rot.inputarray.length - 1;
    rot.outputdiv.innerHTML = rot.inputarray[rot.CurrentTextBlock];
}
