﻿// JScript File

function cycler(id, size)
{
    var end = 30;
    if (size == '800')
        end = 20;
    
    //Wipe off
    wa=setTimeout("wipe('"+id+"', 200, "+end+", 5, 30, wa)", 6000);
    
    //Set new, scroll on, wipe off
    na=setTimeout("newtext('"+id+"', '01', '02', -200, na)", 7500);
    sa=setTimeout("wipe('"+id+"', "+end+", -150, 5, 30, sa)", 7550);
    wb=setTimeout("wipe('"+id+"', 200, "+end+", 5, 30, wb)", 16000);
    
    //Set new, scroll on, wipe off
    nb=setTimeout("newtext('"+id+"', '02', '03', -200, nb)", 17500);
    sb=setTimeout("wipe('"+id+"', "+end+", -150, 5, 30, sb)", 17550);
    wc=setTimeout("wipe('"+id+"', 200, "+end+", 5, 30, wc)", 26000);
    
    //Set new, scroll on
    nc=setTimeout("newtext('"+id+"', '03', '01', -200, nc)", 27500);
    sc=setTimeout("wipe('"+id+"', "+end+", -150, 5, 30, sc)", 27550);
    
    //Repeat
    ca=setTimeout("cycler('"+id+"')", 30000);

}

function wipe(id, e, s, step, rate, timeout)
{
    if ((s+step) >= e) // The text is in position.
    {
        if (timeout != null)
        {
            returnObjById(id).style.marginTop = e + "px";
            clearTimeout(timeout);
        }
        return;
    }
    var s1 = s + step;
    returnObjById(id).style.marginTop = s1 + "px";
    timeout=setTimeout("wipe('"+id+"', "+e+", "+s1+", "+step+", "+rate+", "+timeout+")", rate);
}

function newtext (id, oldText, newText, begin, timeout)
{
    returnObjById(id + "_" + oldText).style.display = "none";
    returnObjById(id + "_" + newText).style.display = "block";
    returnObjById(id).style.marginTop = begin + "px";
    if (timeout != null)
    {
        clearTimeout(timeout);
    }
    return;
}
