var fehler = true;
var news = new Array();

var ticker = null;
//var ts = speed * 7;
var ts = 10;
var textcontent = '';


//ticker = new Ticker('ticker', 'inner', 1, ts);
function Ticker(name, id, shiftBy, interval){

    this.name = name;
    this.id = id;
    this.shiftBy = shiftBy ? shiftBy : 1;
    this.interval = interval ? interval : 100;
    this.runId = null;
    this.div = document.getElementById(id);
    var node = this.div.firstChild;
    var next;

    while(node){
        next = node.nextSibling;
      
        if(node.nodeType == 3) {

            this.div.removeChild(node);
        }
        node = next;
    }

    this.left = 0;
    this.shiftLeftAt = this.div.firstChild.offsetWidth;
    this.div.style.height = this.div.firstChild.offsetHeight;
    this.div.style.width = 2 * screen.availWidth;
    this.div.style.visibility = 'visible';
}

function startTicker(){
   
    this.stop();
    this.left -= this.shiftBy;
    if(this.left <= -this.shiftLeftAt){
        this.left = 0;
        this.div.appendChild (this.div.firstChild);
        this.shiftLeftAt = this.div.firstChild.offsetWidth;
    }
    this.div.style.left = this.left+'px';
    this.runId = setTimeout(this.name+'.start()', this.interval);
}
function stopTicker(){
    
    if(this.runId) {
        clearTimeout(this.runId);
        this.runId = null;
    }
}
function changeTickerInterval(newinterval){
    if(typeof(newinterval) == 'string') {
        
        newinterval = parseInt('0' + newinterval, 10);   
    }

    if(typeof(newinterval) == 'number' && newinterval > 0) {
        
        this.interval = newinterval;
        this.stop();
        this.start()

    }

}

Ticker.prototype.start = startTicker;
Ticker.prototype.stop = stopTicker;
Ticker.prototype.changeInterval = changeTickerInterval;


function SNTICKER_initTickerText(){
    if(fehler === true){
        news.length = 0;
        news[0] = "<span style=\"color:Yellow\">DESIGN" + "&nbsp;" + "AROUND"+ "&nbsp;" + "THE" + "&nbsp;" + "BRAND</span>";
        news[1] = "Brand Strategy";
        news[2] = "Corporate Design";
        news[3] = "Corporate Identity";
        news[4] = "Packaging Design";
        news[5] = "Product Design";
        news[6] = "3D-Structural Design";
        news[7] = "Shop Design";
        news[8] = "<span style=\"color:Yellow\">DESIGN" + "&nbsp;" + "AROUND"+ "&nbsp;" + "THE" + "&nbsp;" + "BRAND</span>";
        news[9] = "Brand Strategy";
        news[10] = "Corporate Design";
        news[11] = "Corporate Identity";
        news[12] = "Packaging Design";
        news[13] = "Product Design";
        news[14] = "3D-Structural Design";
        news[15] = "Shop Design";
    }
    for(var i = 0; i <= news.length; i++){
        if(news[i] == null){
            break
        }
        textcontent += "<li>" + news[i] + "</li>";

        //alert(textcontent);
       
    }
}

function SNTICKER_initSSNTicker(){
    SNTICKER_initTickerText();
    document.getElementById('inner').innerHTML = '' + textcontent + '';
    ticker = new Ticker('ticker', 'inner', 1, ts);
    ticker.start();
}
if(window.addEventListener){
    window.addEventListener('load', SNTICKER_initSSNTicker, false);
}
else if(window.attachEvent){
    var r = window.attachEvent("onload", SNTICKER_initSSNTicker);
} else {
    window.onload = SNTICKER_initSSNTicker
}
