/* aggregated: 2010-03-10 10:46:55 Version:7 */

window.addEvent('domready',function(){try{if($('newsTicker')){var newsTicker=new Ticker('#newsTicker',{speed:3000,delay:6000,content:'.nt-body .nt-content',controller:'.nt-controller',controllerText:{'started':'Ticker anhalten','stopped':'Ticker starten','paused':'Ticker pausiert'},statusClass:{'started':'nt-statusStarted','stopped':'nt-statusStopped','paused':'nt-statusPaused'},cookie:{'status':'newsTicker-status','currentItem':'newsTicker-currentItem','path':'/'}});}}
catch(tickerError){}});var Ticker=new Class({Implements:Options,options:{speed:1500,delay:5000,direction:'vertical',content:null,controller:null,controllerText:null,statusClass:null,cookie:null,onComplete:Class.empty,onStart:Class.empty},initialize:function(container,options){this.setOptions(options);this.container=$$(container)[0];this.controller=this.container.getElement(this.options.controller);this.content=this.container.getElement(this.options.content);this.items=this.content.getElements('li');this.scrollTimer=null;this.currentItem=0;this.tickerStatus="started";var w=0;var h=0;if(this.options.direction.toLowerCase()=='horizontal'){h=this.content.getSize().y;this.items.each(function(li,index){w+=li.getSize().x;});}else{w=this.content.getSize().x;this.items.each(function(li,index){h+=li.getSize().y;});}
this.content.setStyles({position:'absolute',top:0,left:0,width:w,height:h});var tickerStatusFromCookie=Cookie.read(this.options.cookie['status']);if($defined(tickerStatusFromCookie)&&($type(tickerStatusFromCookie)=="string")){this.tickerStatus=tickerStatusFromCookie;}
var currentItemFromCookie=parseInt(Cookie.read(this.options.cookie['currentItem']));if($defined(currentItemFromCookie)&&($type(currentItemFromCookie)=="number")&&(currentItemFromCookie>=0)){this.currentItem=this.jumpTo(currentItemFromCookie);}
this.content.addEvents({'mouseenter':function(){this.pause();}.bind(this),'mouseleave':function(){this.resume();}.bind(this)});this.controller.addEvent('click',function(event){event.stop();if(this.tickerStatus!='stopped'){this.stop();}else if(this.tickerStatus!='started'){this.start();}}.bind(this));this.fx=new Fx.Morph(this.content,{link:"chain",duration:this.options.speed,transition:Fx.Transitions.Quart.easeInOut,onComplete:function(){var i=(this.currentItem==0)?this.items.length:this.currentItem;this.items[i-1].injectInside(this.content);this.content.setStyles({left:0,top:0});}.bind(this)});if(this.tickerStatus=="started"){this.tickerStatus="initStart";this.start();}else if(this.tickerStatus=="stopped"){this.tickerStatus="initStop";this.stop();}},start:function(){if(this.tickerStatus!="started"){this.tickerStatus="started";this.scrollTimer=this.next.periodical(this.options.delay+this.options.speed,this);this.container.removeClass(this.options.statusClass['stopped']).addClass(this.options.statusClass['started'])
this.controller.set("html",this.options.controllerText['started']);Cookie.write(this.options.cookie['status'],this.tickerStatus,{path:this.options.cookie['path']});}
return this.tickerStatus;},stop:function(){if(this.tickerStatus!="stopped"){this.tickerStatus="stopped";this.scrollTimer=$clear(this.scrollTimer);this.container.removeClass(this.options.statusClass['started']).addClass(this.options.statusClass['stopped'])
this.controller.set("html",this.options.controllerText['stopped']);Cookie.write(this.options.cookie['status'],this.tickerStatus,{path:this.options.cookie['path']});}
return this.tickerStatus;},pause:function(){if(this.tickerStatus!="stopped"){this.tickerStatus="paused";this.scrollTimer=$clear(this.scrollTimer);this.container.removeClass(this.options.statusClass['started']).addClass(this.options.statusClass['paused'])
this.controller.set("html",this.options.controllerText['paused']);}
return this.tickerStatus;},resume:function(){if(this.tickerStatus=="paused"){if(this.scrollTimer==null){this.tickerStatus="started";this.scrollTimer=this.next.periodical(this.options.delay+this.options.speed,this);this.container.removeClass(this.options.statusClass['paused']).addClass(this.options.statusClass['started'])
this.controller.set("html",this.options.controllerText['started']);}}
return this.tickerStatus;},next:function(){if(this.tickerStatus=="started"){this.currentItem++;if(this.currentItem>=this.items.length){this.currentItem=0;}
var currentElement=this.items[this.currentItem];this.fx.start({top:-currentElement.offsetTop,left:-currentElement.offsetLeft});Cookie.write(this.options.cookie['currentItem'],this.currentItem,{path:this.options.cookie['path']});return this.currentItem;}},jumpTo:function(index){for(currentItem=0;currentItem<index;currentItem++){this.items[currentItem].injectInside(this.content);}
return currentItem;}});
