// JavaScript Document

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function GlobalNaviInit(){
	MM_preloadImages('/images/navi_company_over.jpg',
					 '/images/navi_commodity_over.jpg',
					 '/images/navi_movie_over.jpg',
					 '/images/navi_event_over.jpg',
					 '/images/navi_employ_over.jpg',
					 '/images/navi_ichiba_over.jpg',
					 '/images/navi_inq_over.jpg',
					 '/images/navi_link_over.jpg',
					 '/images/navi_inq_over.jpg');
}
function CompanyNaviInit(){
	MM_preloadImages('/images/localnavi_greeting_over.gif',
					 '/images/localnavi_info_over.gif',
					 '/images/localnavi_history_over.gif',
					 '/images/localnavi_office_over.gif',
					 '/images/localnavi_group_over.gif',
					 '/images/localnavi_map_over.gif',
					 '/images/localnavi_environment_over.gif');
}
function ComodityNaviInit(){
	MM_preloadImages('/images/localnavi_shovel_over.gif',
					 '/images/localnavi_attachment_over.gif',
					 '/images/localnavi_compressor_over.gif',
					 '/images/localnavi_catalog_over.gif');
}
function EventNaviInit(){
	MM_preloadImages('/images/localnavi_event2007_over.gif',
					 '/images/localnavi_event2009_over.gif',
					 '../images/localnavi_event2008_over.gif',
					 '../images/localnavi_event2009_over.gif',
					 '../images/localnavi_event2010_over.gif');
}

function init_company(){
	GlobalNaviInit();
	CompanyNaviInit();
	displayset();
}
function init_commodity(){
	GlobalNaviInit();
	ComodityNaviInit();
	displayset();
}
function init_event(){
	GlobalNaviInit();
	EventNaviInit();
	displayset();
}


//サイドメニューがスクロールにあわせてついてくる

var scrolly=new Number();
var menuY = new String();
var y_array = new Array();

function displayset(){
	setInterval(moveMenu, 40);
}
function moveMenu() {
	//IEとFirefoxの指定は別。pageYOffsetがIEでは利かない、scrollTopがIE以外では利かない。
	if (window.ActiveXObject) {
		scrolly = document.documentElement.scrollTop;
	} else if (window.XMLHttpRequest) {
		scrolly = window.pageYOffset;
	}
	//メニューをスムーズに移動させるために
	//今のメニューの位置を取得、計算が必要なので数値に変換。
	//menuY=document.getElementById("side").style.top;
	//y_array=menuY.split("px");
	//y_num=Number(y_array[0]);
	//alert(menuY+"メニュー位置　"+scrolly);
	//※90…移動するメニューのTopからの位置（初期位置）。
	if(scrolly<90){
		//y = (90-y_num)/4+y_num;
		y = 90;
	}else{
		//moveNum = (scrolly-y_num)/4+y_num;
		//y = moveNum + 2;
		y = scrolly;
	}
	//if(y>=1){
		document.getElementById("side").style.top = y + "px";
	//}
}

