var TICKER_WIDTH = 950;
var TICKER_LOOP_TIME = 70;
var TICKER_SPEED = 3;

// ティッカー本体
var Ticker = Class.create();
Ticker.prototype = {
initialize: function() {
	this.scrollType = 'normal';
	this.timerID = null;
	this.x = TICKER_WIDTH;
	this.width = 500 * 15;

	this.tickertext = $('voutscLR');
	this.tickertext.style.left = this.x + 'px';
	Event.observe(this.tickertext, 'mouseover', this.slow.bindAsEventListener(this),    false);
	Event.observe(this.tickertext, 'mouseout',  this.forward.bindAsEventListener(this), false);
	this.play();
},

// 表示テキストのスクロール
scroll: function(event) {
	switch(this.scrollType) {
		case 'slow' :
			if (this.x + this.width < 0) {
				this.x = TICKER_WIDTH;
			}
			this.x -= 1;
			break;
		case 'normal' :
		default:
			if (this.x + this.width < 0) {
				this.x = TICKER_WIDTH;
			}
			this.x -= TICKER_SPEED;
			break;
	}

	this.tickertext.style.left = this.x + 'px';
	this.tickertext.style.top = '0px';
	this.timerID = setTimeout(this.scroll.bindAsEventListener(this), TICKER_LOOP_TIME);
	return false;
},

playstop: function(event) {
	if (this.timerID) {
		this.stop();
	} else {
		this.play();
	}
},

// 通常のスクロール
forward: function(event) {
	this.scrollType = 'normal';
	return false;
},

// マウスオーバーでゆっくりのスクロール
slow: function(event) {
	this.scrollType = 'slow';
	return false;
},

play: function() {
	if (this.timerID) return;
	this.timerID = setTimeout(this.scroll.bindAsEventListener(this), TICKER_LOOP_TIME);
},

stop: function() {
	if (this.timerID == null) return;
	clearTimeout(this.timerID);
	this.timerID = null;
}
}
function initTicker(){
	Ticker  = new Ticker();
}

