// Copyright (c) 2009, Fast Lane Institute for Knowledge Transfer

var FL_NewsTicker=Class.create();FL_NewsTicker.prototype={initialize:function(config)
{this.config=config;if(!this.config.tickerspeed)
{this.config.tickerspeed=0.02;}
this.tickernode=$(config.nodename);this.tickertext='';Event.observe(window,'load',this.initTicker.bind(this));},stopScrolling:function()
{if(this.pe)
{this.pe.stop();}},continueScrolling:function()
{this.pe=new PeriodicalExecuter(this.newsScroller.bind(this),this.config.tickerspeed);},initTicker:function()
{if(!this.tickernode)
{CMS.raiseError(2500,'newsticker '+this.config.nodename+' not found');return;}
this.clipregion=new Element('span');this.clipregion.addClassName('clipregion');this.textnode=new Element('span');this.textnode.addClassName('tickertext');this.textnode.setAttribute('id',this.config.nodename+'_content');this.textnode.innerHTML=this.tickertext;this.clipregion.appendChild(this.textnode);this.tickernode.appendChild(this.clipregion);this.startpos=this.textnode.offsetLeft;this.textnode.style.left=this.startpos+"px";this.boxwidth=this.textnode.offsetWidth;Event.observe(this.textnode,'mouseover',this.stopScrolling.bind(this));Event.observe(this.textnode,'mouseout',this.continueScrolling.bind(this));this.continueScrolling();},newsScroller:function(pe)
{xpos=parseInt(this.textnode.style.left);if(isNaN(xpos))
{return;}
if(this.boxwidth>0&&this.boxwidth*-1==xpos)
{xpos=this.startpos;}
this.textnode.style.left=(xpos-1)+'px';},addTickerText:function(text)
{if(!this.tickertext)
{this.tickertext=' &nbsp; +++ &nbsp; ';}
this.tickertext+=text+' &nbsp; +++ &nbsp; ';}};