var tmrID;
var offsetY = 50;
var beforeY = 50;


// 移動開始処理
function setMenu(){
	clearInterval(tmrID);
	tmrID=setTimeout("mvMenu()",1)
}

// 移動距離計算処理
function mvMenu(){
	var scrollY;	// スクロールされた高さ
	var moveToY;	// 移動先のＹ座標
	var moveByY;	// 今回移動する値（相対値）
	var speed;		// レイヤー移動速度

	if(navigator.userAgent.indexOf("Safari") > 0){
		scrollY = document.body.scrollTop;
		speed   = 50;
	}else{
		scrollY = document.documentElement.scrollTop;
		speed   = 10;
	}
	moveToY = scrollY+offsetY;
	moveByY = Math.floor((moveToY - beforeY) / speed);
	beforeY = beforeY+moveByY;

	moveByLayer("lyrMenu",moveByY);

	if(Math.abs((moveToY-beforeY)) > 1){
		tmrID=setTimeout("mvMenu()",1)
	}

}


// レイヤーを移動する
function moveByLayer(idName,y){
	if(document.getElementById){
		var oj = document.getElementById(idName).style;
		oj.top  = (parseInt(oj.top)  + y ) + 'px';
	}else if(document.all){
		document.all(idName).style.pixelTop  += y;
	}else if(document.layers){
		document.layers[idName].moveBy(y);
	}

}

window.onscroll=setMenu;
