function Newsticker(newsAnchorId) {
    //
    // Public members
    //
    
    this.addItem=function(headline, title, className, href) {
        this.items[this.nItems++]=new NewstickerItem(headline, title, className, href);
    };
    
    this.charTimeout=50; // ms between characters
    this.itemTimeout=2000; // ms between items
    
    this.start=function() {
        if (this.nItems>0) {
            this.running=1;
            this.nextChar();
        }
    };
    
    this.stop=function() {
        this.running=0;
    };
    
    //
    // private members
    //
    
    function NewstickerItem(headline, title, className, href) {
        this.headline=headline;
        this.title=title;
        this.className=className;
        this.href=href;
    }
    
    this.nItems=0;
    this.items=new Array();
    this.newsAnchorId=newsAnchorId;
    this.newsAnchorObject=getObjectById(newsAnchorId);
    
    this.currentItem=0;
    this.currentLength=0;
    this.running=0;
    
    if (!document.newstickers) {
        document.newstickers=new Array();
    }
    
    document.newstickers[newsAnchorId]=this;
    
    this.timeoutExpression="document.newstickers[\"" + this.newsAnchorId + "\"].nextChar()";
    
    this.nextChar=function() {
        if (this.running==0) {
            return;
        }
        
        var item=this.items[this.currentItem];
        
        if (this.currentLength==0) {
	    // Start past the last '>' to make sure we don't cut up any markup
            this.currentLength=item.headline.search(/[^>]*$/);
            this.newsAnchorObject.href=item.href;
            this.newsAnchorObject.className=item.className;
            this.newsAnchorObject.title=item.title;
        }
        else {
            ++this.currentLength;
        }
        
        if (this.currentLength>item.headline.length) {
            ++this.currentItem;
            
            if (this.currentItem>=this.nItems) {
                this.currentItem=0;
            }
            
            item=this.items[this.currentItem]
            this.currentLength=0;
            setTimeout(this.timeoutExpression, this.itemTimeout);
        }
        else {
            this.newsAnchorObject.innerHTML=item.headline.substr(0,this.currentLength);
            setTimeout(this.timeoutExpression, this.charTimeout);
        }
    };
}

