
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.replace(/&amp;/gi, "&");
}


function tick(checkCoookie) {
    
    if(checkCoookie == false && breaktimeout == true)
        return;
        
    if(aktnindex >= tickerarr.length)
        aktnindex = 0;
        
    var item = tickerarr[aktnindex];
    
    if(checkCoookie == true)
    {
        var c2 = Cookie.read("lastnews");
        
        if(c2 != "")
        {
            for(var i=0;i<tickerarr.length;i++)
                if(tickerarr[i].newsid == c2){
                    item = tickerarr[i]; aktnindex = i;
                }
        }
    }
   
    if(item != null)
    {
        var div = $('newstickertext');
        div.innerHTML = item.text;
        div.href = item.link;
        
//        var c = new Coookie();
//        c.setName("lastnews");
//        c.setValue(item.newsid);
//        c.save();

        Cookie.write("lastnews", item.newsid);
        
        aktnindex++;
        if(btimeout == true)
            window.setTimeout("tick(false);",6000);
    }
}

function tickright()
{
    btimeout = false;
    

    tick(false);
}

function tickleft()
{
    btimeout = false;
    aktnindex-=2;
    if(aktnindex < 0)
        aktnindex = tickerarr.length-1;
        
    
    tick(false);
}
