//JDS 07/05/2010 - This file has been altered from the original downloaded plugin
//as the settings are contained within it. Please check changes below before overriding
//with any new version of tickertype

// when the DOM is ready...
$(document).ready(function() {
    // load the ticker
    createTicker();

});

var timeoutID;

function createTicker() {

    if (timeoutID != undefined) {
        //alert('clear' + timeoutID);
        clearTimeout(timeoutID);
    }

    // put all list elements within #ticker-area into array
    var tickerLIs = $("#TickerItems").children();
    tickerItems = new Array();
    tickerLIs.each(function(el) {
        tickerItems.push(jQuery(this).html());
    });
    i = 0
    if (tickerLIs.length > 0)
        rotateTicker();
}

function rotateTicker() {
    if (i == tickerItems.length) {
        i = 0;
    }
    tickerText = tickerItems[i];
    c = 0;
    typetext();
    //JDS 07/05/2010 - Increased timeout delay from 5000 to 8000
    timeoutID = setTimeout("rotateTicker()", 8000);
    i++;
}

var isInTag = false;
function typetext() {
    var thisChar = tickerText.substr(c, 1);
    if (thisChar == '<') { isInTag = true; }
    if (thisChar == '>') { isInTag = false; }
    //JDS 07/05/2010 removed "&nbsp; +" before the tickerText as this makes the text dislocate
    $('#ticker-area').html(tickerText.substr(0, c++));
    if (c < tickerText.length + 1)
        if (isInTag) {
        typetext();
    } else {
        setTimeout("typetext()", 28);
    }
    else {
        c = 1;
        tickerText = "";
    }
}


