var Ticker = new Class({
	setOptions: function(options) {
		this.options = Object.extend({
			speed: 3000,
			delay: 0,
			direction: 'vertical',
			onComplete: Class.empty,
			onStart: Class.empty
		}, options || {});
	},
	initialize: function(el,options){
		this.setOptions(options);
		this.el = $(el);
		
//					this.el.setStyle('margin-top', '100px');
		
		this.items = this.el.getElements('li');
		var w = 0;
		var h = 0;
		var count = 0;
		this.items.each(function(li,index) {
			if (count>0) {
				h += li.getSize().y;
				h += 10; // padding
			} else {
				w = li.getSize().x;
			}
			count++;
		});

		this.el.setStyles({
			position: 'absolute',
			left: 0,
			top: 0,
			width: w,
			height: h
		});

		this.fx = new Fx.Tween(this.el, {
			duration: this.options.speed*count, 
			transition: Fx.Transitions.linear,
			delay: this.options.delay,
			onComplete: function() {
				this.el.setStyle('top', 0);
				this.fx.start('top', -h);
			}.bind(this)
		});
	
		this.current = 0;

		h = 0;
		w = 0;
		var count = 0;
		this.items.each(function(li,index) {
			if (count>0) {
				h += li.getSize().y;
				h += 10; // padding
			}
			count++;
		});
		this.el.setStyle('top', 0);
//		this.fx.start('top', -h);
	}
});


/*
var Ticker = new Class({
				
				setOptions: function(options) {
					this.options = Object.extend({
						speed: 30000,
						delay: 5000,
						direction: 'vertical',
						onComplete: Class.empty,
						onStart: Class.empty
					}, options || {});
				},
				
				initialize: function(el,options){
					this.setOptions(options);
					this.el = $(el);
					
//					this.el.setStyle('margin-top', '100px');
					
					this.items = this.el.getElements('li');
					var w = 0;
					var h = 0;
					w = this.el.getSize().x;
					this.items.each(function(li,index) {
						h += li.getSize().y;
					});
					this.el.setStyles({
						position: 'absolute',
						top: 0,
						width: w,
						height: h
					});
					this.fx = new Fx.Tween(this.el, {
						duration: this.options.speed, 
						transition: Fx.Transitions.linear,
						onComplete: function() {
							this.el.setStyle('margin-top', 0);
						}.bind(this)
					});
				
					this.fx.start('left', -w);
					this.current = 0;
				},
				
				hide: function() {
//					this.fxout.start('opacity', 0);
				},
				
				next: function() {
					

					var i = (this.current==0)?this.items.length:this.current;
					this.items[i-1].injectInside(this.el);

					this.current++;
					if (this.current >= this.items.length) this.current = 0;
					var pos = this.items[this.current];
					
					this.el.setStyle('margin-top', pos.offsetTop);
					this.fx.start('margin-top', 0 );
					
					this.hide.bind(this).delay(this.options.delay+this.options.speed);
				}
				
			});
*/
