//背景スクロール・メニュー反転
function calcParallax(tileheight, speedratio, scrollposition) {
  //    by Brett Taylor http://inner.geek.nz/
  //    originally published at http://inner.geek.nz/javascript/parallax/
  //    usable under terms of CC-BY 3.0 licence
  //    http://creativecommons.org/licenses/by/3.0/
  return ((tileheight) - (Math.floor(scrollposition / speedratio) % (tileheight+1)));
}

//メニューリスト
menuList = new Array("gMenu00","gMenu01","gMenu02","gMenu03","gMenu04","gMenu05","gMenu06","gMenu07");
//コンテンツリスト
cntList = new Array("Top","Service","Works","ItemMap01","Company","Recruit","Access","Contact","Last");
//アクティブ背景色
colorList = new Array("#000","#c00","#f60","#fc0","#060","#03c","#60c","#909");

function menuActive() {
	var posX = document.documentElement.scrollLeft || document.body.scrollLeft;
	var posY = document.documentElement.scrollTop || document.body.scrollTop;
	for (i=0; i<=7; i++) {
		var menu = document.getElementById(menuList[i]);
		var cnt = document.getElementById(cntList[i]);
		var cnt2 = document.getElementById(cntList[i+1]);
		var w = 1000;
		menu.style.background = "none";
		menu.style.color = colorList[i];
		if (posX >= cnt.offsetLeft-w && posX < cnt2.offsetLeft-w) {
			menu.style.backgroundColor = colorList[i];
			menu.style.color = "#FFFFFF";
		}
	}
	// メニュー位置固定表示
	//var globalmenu = document.getElementById('floatMenu');
	//globalmenu.style.top = posY + "px";
	//globalmenu.style.left = posX + "px";
}

window.onload = function() {
	window.onscroll = function() {
		var posX = document.documentElement.scrollLeft || document.body.scrollLeft;
	
		// 図面スクロール
		var ground = document.getElementById('Contents');
		var groundparallax = calcParallax(3500, 12, posX);
		ground.style.backgroundPosition = groundparallax + "px 0";
		
		// 空スクロール
		var ground2 = document.getElementById('body_bg');
		var groundparallax2 = calcParallax(3940, 4, posX);
		ground2.style.backgroundPosition = groundparallax2 + "px bottom";
			
		menuActive();
	}
	menuActive();
}


