var storyTimeout = 5000;
var charTimeout = 100;

var currentStory = 0;
var currentStoryText = '';
var currentChar = 0;
var flash = new Array();
var link = new Array();

function runFlash()
{
    if (!flash[currentStory]) {
        currentStory = 0;
    }
    currentStoryText = flash[currentStory];
    if (currentChar == 0) {
        $('newsFlash').update('&nbsp;');
    }
    if (link[currentStory]) {
        $('newsFlash').update('<a href="'+link[currentStory]+'" target="_blank">' + currentStoryText.substring(0,currentChar) + '</a>');
    } else {
        $('newsFlash').update(currentStoryText.substring(0,currentChar));
    }
    
    currentChar++;
    if (currentChar <= currentStoryText.length) {
        setTimeout("runFlash()", charTimeout);
    } else {
        currentStory++;
        currentChar = 0;
        currentStoryText = flash[currentStory];
        setTimeout("runFlash()", storyTimeout);
    }
}

