/******************
Funciones para scroll
*******************/

var SCROLLING_TEXT_ID = "scrolling_text";

var scroller;

function scrollsetup(texto) {
    //The controls should all be input elements (type="button") so that they can be disabled
    scroller = new Scroller(SCROLLING_TEXT_ID, texto);
}

//Scroller class
function Scroller(id, texto) {

    this.scrolling_text = document.getElementById(id);
    this.texto = texto;
    this.max_length = 110;
    if(this.texto.length > this.max_length){
        this.visible_length = this.max_length;
    }else{
        this.visible_length = this.texto.length;
    }

    this.contador = 0;
    var obj = this;

    this.timer = null;
    this.speed = 150; //1000 = 1 second
    this.right_to_left = true;

    this.scrolling_text.firstChild.nodeValue = texto;

    this.scroll();
}

Scroller.prototype.scroll = function () {
    this.texto = this.texto.substring(1, this.texto.length) + this.texto.substring(0, 1);
    text = this.texto.substring(0, this.visible_length);
    this.scrolling_text.firstChild.nodeValue = text;
    var obj = this;
    this.timer = setTimeout(function () { obj.scroll(); }, this.speed);

}

/******************
Fin funciones para scroll
*******************/
