function news (ident, array) {
    
    this.ident = ident;
    this.newsArray = array;
    
    this.timer;
    
    this.target = document.getElementById(this.ident + "content");
    
    this.position = 0;
    
    this.maxChar = 105;
    
    this.init = function (){
        
        document.getElementById("nav").style.height = "24px";
        this.display(0);
        //this.startTimer();
        
    }
    
    this.next = function() {
        
        if (this.position == this.newsArray.length - 1) return 0;
        else return this.position+1;
        
    }
    
    this.display = function(id) {
        
        this.clearElement(this.ident + "content");
        
        var title = this.newsArray[id]['title'];
        titleLength = this.newsArray[id]['title'].length;
        
        var minus;
        
        if (this.newsArray[id]['info'].charAt(this.maxChar-titleLength) == "\\") minus = (this.maxChar-titleLength) + 1;
        else minus = (this.maxChar - titleLength);
        
        var string = this.newsArray[id]['info'].substr(0, minus) + "...";
        
        this.typeWords(title, string, 0);
        //this.target.innerHTML = "<b>" + title + ": </b>" + string;
       
        
    }
    
    this.typeWords = function (title, string, pos) {
        
        titleLength = title.length;
        
        if (pos < titleLength) {
            output = "<b>" + title.substr(0, pos) + "</b>";
        }
        else if (pos >= titleLength && pos <= string.length + titleLength)
        {
            output = "<b>" + title + "</b>: " + string.substr(0, pos-titleLength);
        }
        else
        {
            
            setTimeout(this.ident + ".chooseNext()", 5000);
            return;
        }
        
        
 
        this.clearElement(this.ident + "content");
        this.target.innerHTML = output;
        pos++;
        
        var funk = this.ident + ".typeWords(\"" + title + "\", \"" + string + "\", " + pos + ");";
        setTimeout(funk, 100);
        
       
    }
    
    this.chooseNext = function() {
        
        newpos = this.next();
        
        this.display(newpos);
        this.position = newpos;
    }
    
    this.clearElement = function (element) {
	content = document.getElementById(element);

        if ( content.hasChildNodes() )
        {
  	    while ( content.childNodes.length >= 1 )
            {
    			content.removeChild( content.firstChild );       
    	    } 
		}
	
        
    }
    
    this.startTimer = function () {
        
        this.timer = window.setInterval (this.ident + '.chooseNext();', 2000);
    }
    
    this.stopTimer = function () {
        
        clearInterval(this.timer);
    }
}