/*
ページのトップへスクロールして移動
(c)Sapphirus.Biz

HREFに「#TOP」（大文字・小文字の区別は無し）があるリンクを
クリックした場合、スクロールしてページの一番上に移動します。
Ex.) <a href="#TOP">PAGE TOP</a>
*/
function setGoTop() {
	var aTagList = document.getElementsByTagName('a');
	for (var i = 0; i < aTagList.length; i++) {
		if (aTagList[i].href.match(/#top/i)) {
			aTagList[i].onclick = goPageTop;
		}
	}
}
var goTopMove = 20; // 加速度（0:停止〜大きいほど遅くなる）
var goTopPosi;
function goPageTop() { // 距離取得と実行
	var yPos = document.body.scrollTop || document.documentElement.scrollTop;
	mObj(yPos);
	return false;
}
function mObj(y, s) { // 上に加速移動
	if (s) goTopMove = s;
	goTopPosi = parseInt(y - y * 2 / goTopMove);
	scrollTo(0, goTopPosi);
	if (goTopPosi > 0) setTimeout('mObj(goTopPosi, goTopMove)', 1);
}
if (window.addEventListener) window.addEventListener('load', setGoTop, false);
if (window.attachEvent) window.attachEvent('onload', setGoTop);



/* ---------- 設定領域 start ---------- */

//滑らかさ（最適範囲2〜10）
//数値が大きいほど滑らかになりますが遅くなります。
smooth = 10;

//速さ（最適範囲70〜10）
//数値が小さい程早くなります。
speed = 10;

/* ---------- 設定領域 end ---------- */


function scrlWin(){if(distYY >= 1 || distYY <= -1){if(distYY > 0){moveYY = Math.ceil(distYY / smooth);}else{moveYY = Math.floor(distYY / smooth);}distYY -= moveYY;window.scrollBy(0, -moveYY);clearTimeout(timerId);timerId = setTimeout("scrlWin()", speed);}}function smScroll(ET){if(document.body.scrollTop){winYY = document.body.scrollTop;}else{winYY = document.documentElement.scrollTop;}if(window.innerHeight){winHH = window.innerHeight;}else if(document.all && document.getElementById && (document.compatMode == 'CSS1Compat')){winHH = document.documentElement.clientHeight;}else{winHH = document.body.clientHeight;}linkVal = "" + ET;linkName = linkVal.split("#");targetEt = document.getElementById(linkName[1]);targetYY = targetEt.offsetTop;distYY = winYY - targetYY;pageHH = document.body.scrollHeight;if(pageHH - targetYY < winHH){difVal = winHH - (pageHH - targetYY) - 15;distYY += difVal;}timerId = setTimeout("scrlWin()", speed);}

