var newsText = new Array();
    newsText[0] = "The winner of the codequest online phase is Mr. Mohan Krishna";
  
    newsText[1] = "Click here to veiw the bus schedule.";
    newsText[2] = "Elan - e - Jung<br/>The biggest rock band competition...!!!";
    newsText[3] = "Mall Mazaa problem statement is up!";
    newsText[4] = "Elan Green Circuit Challenge (EGCC) problem statement is up!";
    newsText[5] = "The winner of the codequest online phase is Mr. Mohan Krishna";
    newsText[6] = "Registrations for Elan Green Circuit Challenge (EGCC) are still open.";
    newsText[7] = "Registrations for Contraptions are still open."; 
    newsText[8] = "Event Criteria for the Codequest has been modified.";
    newsText[9] = "Robotics problem statement has been updated!";
      

var linkURL = new Array();
    linkURL[0]="codequest3.html"; 

    linkURL[1]="busschedule.html";
    linkURL[2]="elanejung.html";
    linkURL[3]="mallmazaa2.html";
    linkURL[4]="EGCC2.html";
    linkURL[5]="codequest3.html";
    linkURL[6]="EGCC.html"; 
    linkURL[7]="contraptions.html";
    linkURL[8]="codequest2.html";
    linkURL[9]="robotics2.html";
    

var ttloop = 1;    // 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=0, 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()
{
    document.getElementById('tickerSource').innerHTML = "";
    addNews();
}

function previousNews()
{
    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() {
    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();};

