﻿function startTicker() {
    theCurrentStory = -1;
    theCurrentLength = 0;
    if (document.getElementById) {
        theAnchorObject = document.getElementById("tickerAnchor");
        runTheTicker();
    }
    else {
        document.write("<style>.ticki{display:none;}.ticko {border:0px; padding:0px;}</style>");
        return true;
    }
}
function runTheTicker() {
    var myTimeout;
    if (theCurrentLength == 0) {
        theCurrentStory++;
        theCurrentStory = theCurrentStory % theItemCount;
        theStorySummary = theSummaries[theCurrentStory].replace(/&quot;/g, '"');
        theTargetLink = theSiteLinks[theCurrentStory];
        theAnchorObject.href = theTargetLink;
        thePrefix = "<span class=\"tickls\">" + theLeadString + "</span>";
    }
    theAnchorObject.innerHTML = thePrefix +
    theStorySummary.substring(0, theCurrentLength) + whatWidget();
    if (theCurrentLength != theStorySummary.length) {
        theCurrentLength++;
        myTimeout = theCharacterTimeout;
    }
    else {
        theCurrentLength = 0;
        myTimeout = theStoryTimeout;
    }
    setTimeout("runTheTicker()", myTimeout);
}

function whatWidget() {
    if (theCurrentLength == theStorySummary.length) {
        return theWidgetNone;
    }

    if ((theCurrentLength % 2) == 1) {
        return theWidgetOne;
    }
    else {
        return theWidgetTwo;
    }
}
var theCharacterTimeout = 50;
var theStoryTimeout = 5000;
var theWidgetOne = "";
var theWidgetTwo = "";
var theWidgetNone = "";
var theLeadString = "";
var theSummaries = new Array();
var theSiteLinks = new Array();
var theItemCount = 5;

function startNews(news1Content, news1Link, news2Content, news2Link, news3Content, news3Link, news4Content, news4Link, news5Content, news5Link, news6Content, news6Link) {
    if (news1Content != "") {
        theSummaries[0] = news1Content;
        theSiteLinks[0] = news1Link;
    }
    if (news2Content != "") {
        theSummaries[1] = news2Content;
        theSiteLinks[1] = news2Link;
    }
    if (news3Content != "") {
        theSummaries[2] = news3Content;
        theSiteLinks[2] = news3Link;
    }
    if (news4Content != "") {
        theSummaries[3] = news4Content;
        theSiteLinks[3] = news4Link;
    }
    if (news5Content != "") {
        theSummaries[4] = news5Content;
        theSiteLinks[4] = news5Link;
    }
    if (news5Content != "") {
        theSummaries[5] = news6Content;
        theSiteLinks[5] = news6Link;
    }
    startTicker();
}
