/***
*
*  NewsTicker:  
*  
***/
var NewsTicker = new Class({
        //
		//  initialize
		//
		Implements: [Options],
        options: {
			 smoothing:1,
			 duration:500,
             wait:6000,
			 autoStart:true
        },
        initialize: function(lines,options){
                this.setOptions(options)
                this.lines = $$(lines)
				this.setLines()
				this.index = 0
				if (this.options.autoStart) this.start()
		},
		setLines: function(){
				var hide = false
				this.lines.each(function(line){
						line.set("tween",{duration:this.options.duration})
						line.setStyle('position','absolute')
						if (!hide) hide = true
						else {
								line.setStyles({
										opacity:0,
										display:"inline"
								})
						}
				}.bind(this))
		},
		start: function(){
				this.current = this.lines[this.index]
				this.timer = this.next.periodical(this.options.wait,this)
        },
		stop: function(){
				clearInterval[this.timer]
				this.timer = null
        },
		next: function(){
				if (this.current) this.current.fade('out')
				this.index = this.index + 1 < this.lines.length ? this.index + 1 : 0
				this.current = this.lines[this.index]
				var fadein = function(){
						this.current.fade('in')
				}.bind(this)
				fadein.delay(this.options.smoothing * this.options.duration,this)
		}
});
