﻿var Ticker = new Class({
	setOptions2: function(options2) {
		this.options2 = Object.extend({
			speed: 1500,
			delay: 5000,
			direction: 'vertical',
			onComplete: Class.empty,
			onStart: Class.empty
		}, options2 || {});
	},
	initialize2: function(el2,options2){
		this.setOptions2(options2);
		this.el2 = $(el2);
		this.items = this.el2.getElements('li');
		var w = 0;
		var h = 0;
		if(this.options2.direction.toLowerCase()=='horizontal') {
			h = this.el2.getSize2().size.y;
				this.items.each(function(li,index) {
				w += li.getSize2().size.x;
			});
	} else {
			w = this.el2.getSize2().size.x;
			this.items.each(function(li,index) {
				h += li.getSize2().size.y;
			});
		}
		this.el2.setStyles2({
			position: 'absolute',
			top: 0,
			left: 0,
			width: w,
				height: h
		});
		this.fx = new Fx.Styles(this.el2,{duration:this.options2.speed,onComplete:function() {
			var i = (this.current2==0)?this.items.length:this.current2;
			this.items[i-1].injectInside(this.el2);
			this.el2.setStyles2({
				left:0,
				top:0
			});
		}.bind2(this)});
		this.current2 = 0;
		this.next2();
		},
	
	pause2: function() {
	    $clear(mytimer2);
	    mytimer2 = null;
	},
	resume2: function() {
	    if (mytimer2 == null) {
	    this.next2();
	    }
	},
	next2: function() {
		this.current2++;
		if (this.current2 >= this.items.length) this.current2 = 0;
		var pos = this.items[this.current2];
		this.fx.start({
			top: -pos.offsetTop,
			left: -pos.offsetLeft
		});
		mytimer2 = this.next2.bind2(this).delay(this.options2.delay+this.options2.speed);
	}
});

var mytimer2 = null;

window.addEvent('domready', function() {
   var hor = new Ticker('TickerVertical', {
      speed : 500, delay : 3000, direction : 'vertical'});
    $('stop_scroll').addEvent('click', function() {
		$('play_scroll_cont').style.display='block';
		$('stop_scroll_cont').style.display='none';
		hor.pause2();
	});
    $('play_scroll').addEvent('click', function() {
		$('stop_scroll_cont').style.display='block';
		$('play_scroll_cont').style.display='none';
		hor.resume2();
	});
});
