// JavaScript Document

var stopScroll = 0
var x
var allow

function init () {

	/*隠れている領域(repeatHeight)のサイズを取得*/
	repeatHeight = $('news_area').scrollHeight
	
	Event.observe($('scrolldown'), 'mouseover', scrollUp, false);/*←scrolldown(downボタン)をマウスオーバーすると関数scrollUpを実行*/
	Event.observe($('scrolldown'), 'mouseout', scrollStop, false);
	Event.observe($('scrollup'), 'mouseover', scrollDown, false);
	Event.observe($('scrollup'), 'mouseout', scrollStop, false);
}

function scrollUp() {
	stopScroll=0;/*変数stopScrollに0を代入*/
	allow=1;/*変数allowに1を代入*/
	scrollMe()/*関数scrollMe()を実行*/
}

function scrollDown() {
	stopScroll=0;
	allow=0;
	scrollMe()
}

function scrollStop() {
	stopScroll=1
}

function scrollMe() {
	clearTimeout(x)

	if(stopScroll==1) {
		return
	}

	if(allow == 1){
		$('news_area').scrollTop = $('news_area').scrollTop + 5
	}

else if(allow == 0){
		$('news_area').scrollTop = $('news_area').scrollTop - 5
	}

	/*setTimeoutでスクロールの速さを設定*/
	if($('news_area').scrollTop<=repeatHeight) {
		x = setTimeout("scrollMe()",60)
	}
	//we have hit the wrap point
	else { 
		$('news_area').scrollTop=0
		x = setTimeout("scrollMe()",60)
	}
}

//-------------ページロード時に実行-----------

Event.observe(window, 'load', init, false);

//--------------------------------------------
