// JavaScript Document

var chaMax = 20;
var chaShowing = 0;
var chaPoint = 0;
var chaMovAnimTimerID = 0;

function checkValues(form)
{
	return ( form.q.value=='http://' || form.q.value=='' ) ? false:true;
}

function chaSelectRanking(url)
{
	var chaAddressBar = document.getElementById("chaAddressBar");
	chaAddressBar.value = url;
	var inputSupport = document.getElementById("inputSupport");
	inputSupport.style.visibility="hidden";
}

function chaOnFocus()
{
	var chaAddressBar = document.getElementById("chaAddressBar");
	var inputSupport = document.getElementById("inputSupport");
	inputSupport.style.top = chaAddressBar.offsetTop + chaAddressBar.offsetHeight + 2;
	inputSupport.style.left= chaAddressBar.offsetLeft;
	inputSupport.style.width= chaAddressBar.offsetWidth;
	inputSupport.style.visibility = "visible";
}

function chaOnBlur()
{
	var inputSupport = document.getElementById("inputSupport");
	//chaRanking.style.visibility="hidden";
}

window.onload = function ()
{	
	var chaStage = document.getElementById("chaStage");
	chaStage.innerHTML = '<a style="word-wrap: break-word; text-decoration: none; color: red;" href="viewer?q='+chaURL[0]+'">'+chaComment[0]+'</a>';
	
	chaStage.style.fontSize = "13px";
	chaStage.style.fontWeight = "normal";
	chaPoint = 0;
		
	// アニメーションスレッド開始
	chaShowing=0;
	if( chaMovAnimTimerID != 0 ) clearInterval(chaMovAnimTimerID);
	chaMovAnimTimerID = setInterval(chaAnimation,4500);
}

function chaAnimation()
{
	var chaStage = document.getElementById("chaStage");

	chaShowing++;
	if( chaShowing >= chaMax ) chaShowing = 0;
		
	chaStage.innerHTML = '<a style="word-wrap: break-word; word-break: break-all; text-decoration: none; color: red;" href="viewer?q='+chaURL[chaShowing]+'">'+chaComment[chaShowing]+'</a>';

}