
var tickerarr = new Array();
var aktnindex = 0;
var btimeout = true;
var breaktimeout = false;

function TickerItem(id, text, link)
{
    this.newsid = id;
    this.text = text;
    this.link = link;
}


function tick(checkCookie)
{
    if(checkCookie == false && breaktimeout == true)
        return;
        
    if(aktnindex >= tickerarr.length)
        aktnindex = 0;
        
    var item = tickerarr[aktnindex];
    
    if(checkCookie == true)
    {
        var c2 = Cookie.get("lastnews");
        if(c2.getValue() != "")
        {
            for(var i=0;i<tickerarr.length;i++)
                if(tickerarr[i].newsid == c2.getValue()){
                    item = tickerarr[i]; aktnindex = i;
                }
        }
    }
   
    if(item != null)
    {
        var div = $('newstickertext');
        div.innerHTML = "<a href=\"" + item.link + "\">" + item.text + "</a>"; 
        
        var c = new Cookie();
        c.setName("lastnews");
        c.setValue(item.newsid);
        c.save();
        
        aktnindex++;
        if(btimeout == true)
            window.setTimeout("tick(false);",4000);
    }
}

function tickright()
{
    btimeout = false;
    

    tick(false);
}

function tickleft()
{
    btimeout = false;
    aktnindex-=2;
    if(aktnindex < 0)
        aktnindex = tickerarr.length-1;
        
    
    tick(false);
}