﻿function newsFeed()
{
    this.href = '';
    this.title = '';
    this.summary = '';
    this.from = '';
}

var feeds = new Array();

var NV, s;
var roll_over = 0;

function buildNewsBlock(p)
{
    var tmp=document.createElement("div");
    tmp.style.height = "60px";
    tmp.style.width = "100%";
    tmp.innerHTML = p;
    return tmp;
}

function startNews()
{
    NV=document.getElementById("newsDiv");
    NV.onmouseover = function() { roll_over = 1; }
    NV.onmouseout = function() { roll_over = 0; }

    var div, i;
    for(i=0; i<feeds.length; i++)
    {
        div = buildNewsBlock(getFeed(feeds[i]));
        NV.appendChild(div);
    }
    s=setTimeout('scroll()', 2500);
}

function getFeed(feed)
{
    return feed.from + '<br /><a class="boldLink" href="' + feed.href + '" target="_blank">' + feed.title + '</a>';
}

function scroll()
{
    clearTimeout(s);
    ObLast=NV.childNodes[NV.childNodes.length-1];
    
    if(NV.scrollTop >= (feeds.length - 2) * 60)
    {
        NV.scrollTop = -60;
        NV.innerHTML = '';
        startNews();
        return;
    }
    
    if(NV.scrollTop < ((feeds.length - 1) * 60))
    {
        if (roll_over == 0)
            NV.scrollTop += 2;
        
        if(NV.scrollTop % 60 == 0)
            s=setTimeout('scroll()', 2500);
        else
            s=setTimeout('scroll()', 60);
    }
}


