var newsText = new Array();
    newsText[0] = "Shaastra 2009 is over!";
    newsText[1] = "Thanks to our sponsors for the support and the team of coordinators and volunteers for the great show.";
    newsText[2] = "And thank you for coming. Hope to see you next year!";

var linkURL = new Array();
    linkURL[0]="http://www.shaastra.org/2009"; 
    linkURL[1]="http://www.shaastra.org/2009"; 
    linkURL[2]="http://www.shaastra.org/2009"; 

var ttloop = 0;    // Repeat forever? (1 = True; 0 = False)
var tspeed = 10;   // Typing speed in milliseconds (larger number = slower)
var tdelay = 5000; // Time delay between newsTexts in milliseconds

// ------------- NO EDITING AFTER THIS LINE ------------- \\
var dwAText="", mylink, cnews=-1, cchar=0, timeoutId = 0;

// Set an exclusive timeout, such that only one timer is running at any given
// time
function setExclusiveTimeout(timeId, fn, timeout)
{
    if (timeId > 0) 
        clearTimeout(timeId);
    timeId = 0;
    timeId = setTimeout(fn, timeout);
    timeoutId = timeId;
}

function doNews() {
    addNews();
}

function nextNews()
{
    if(newsText.length <= 1) return;
    document.getElementById('tickerSource').innerHTML = "";
    addNews();
}

function previousNews()
{
    if(newsText.length <= 1) return;
    document.getElementById('tickerSource').innerHTML = "";
    // HACK ALERT: Add news automatically adds one to the news...
    cnews = (cnews-2)%(newsText.length);
    if (cnews < 0)
        cnews += newsText.length;
    addNews();
}

function addNews() {
    if(ttloop == 0 && cnews == (newsText.length-1)) return;
    cnews = (cnews + 1)%newsText.length;
    // Reset character pointer
    cchar = 0;

    dwAText = newsText[cnews];
    mylink = linkURL[cnews];

    document.getElementById('tickerSource').innerHTML = "";
    setExclusiveTimeout(timeoutId, "addChar()", tspeed);
}

function addChar() {
    timeoutId = 0;
    // If the string is not yet fully typed
    if (cchar < dwAText.length) 
    {
        nmttxt = "<a href=\""+mylink+"\">"; for (var k=0; k<=cchar;k++) nmttxt += dwAText.charAt(k);
        nmttxt += "</a>";
        document.getElementById('tickerSource').innerHTML = nmttxt;
        cchar += 1;
        if (cchar != dwAText.length)  
            document.getElementById('tickerSource').innerHTML += "_";
        setExclusiveTimeout(timeoutId, "addChar()", tspeed);
    } 
    else 
    {  
        // Get another news item
        setExclusiveTimeout(timeoutId, "addNews()", tdelay);
    }
}

window.onload=function(e){addNews();};
