

//マウスカーソルが乗ったときの画像。
var onImg = new Array();
onImg[1] = new Image();
onImg[2] = new Image();
onImg[3] = new Image();
onImg[4] = new Image();
onImg[5] = new Image();
onImg[7] = new Image();
onImg[8] = new Image();
onImg[9] = new Image();

onImg[1].src = "./images/menu/top_menu5.gif";
onImg[2].src = "./images/menu/product_menu5.gif";
onImg[3].src = "./images/menu/recruit_menu5.gif";
onImg[4].src = "./images/menu/company_menu5.gif";
onImg[5].src = "./images/menu/privacy_menu5.gif";
onImg[7].src = "./images/menu/access_menu5.gif";
onImg[8].src = "./images/menu/sitemap_menu5.gif";
onImg[9].src = "./images/menu/contact_menu5.gif";

//インデックス番号は置き換えるドキュメント上の画像オブジェクトのインデックス番号と同じにする

//マウスカーソルが外れたときの画像（他画面）
var offImg1 = new Array();
offImg1[1] = new Image();
offImg1[2] = new Image();
offImg1[3] = new Image();
offImg1[4] = new Image();
offImg1[5] = new Image();
offImg1[7] = new Image();
offImg1[8] = new Image();
offImg1[9] = new Image();

offImg1[1].src = "./images/menu/top_menu4.gif";
offImg1[2].src = "./images/menu/product_menu4.gif";
offImg1[3].src = "./images/menu/recruit_menu4.gif";
offImg1[4].src = "./images/menu/company_menu4.gif";
offImg1[5].src = "./images/menu/privacy_menu4.gif";
offImg1[7].src = "./images/menu/access_menu4.gif";
offImg1[8].src = "./images/menu/sitemap_menu4.gif";
offImg1[9].src = "./images/menu/contact_menu4.gif";

//マウスカーソルが外れたときの画像（自画面）
var offImg2 = new Array();
offImg2[1] = new Image();
offImg2[2] = new Image();
offImg2[3] = new Image();
offImg2[4] = new Image();
offImg2[5] = new Image();
offImg2[7] = new Image();
offImg2[8] = new Image();
offImg2[9] = new Image();

offImg2[1].src = "./images/menu/top_menu3.gif";
offImg2[2].src = "./images/menu/product_menu3.gif";
offImg2[3].src = "./images/menu/recruit_menu3.gif";
offImg2[4].src = "./images/menu/company_menu3.gif";
offImg2[5].src = "./images/menu/privacy_menu3.gif";
offImg2[7].src = "./images/menu/access_menu3.gif";
offImg2[8].src = "./images/menu/sitemap_menu3.gif";
offImg2[9].src = "./images/menu/contact_menu3.gif";

function chgImg(iidx1, iidx2, subm, isme) {
	if(isme == 1){
		document.images[iidx1 + iidx2].src = onImg[iidx2].src;
	}
	if(subm == 1){	mopen(iidx2);	}
}

function rstImg(iidx1, iidx2, subm, isme) {
	if(isme == 1){
		document.images[iidx1 + iidx2].src = offImg1[iidx2].src;
	}else{
		document.images[iidx1 + iidx2].src = offImg2[iidx2].src;
	}
	if(subm == 1){	mclosetime();	}
}


//*********************************************************************************************************

var TimeOut         = 300;
var currentLayer    = null;
var currentitem     = null;
var currentLayerNum = 0;
var noClose         = 0;
var closeTimer      = null;

function mopen(n) {
  var l  = document.getElementById("menu"+n);
  var mm = document.getElementById("mmenu"+n);
	
  if(l) {
    mcancelclosetime();
    l.style.visibility='visible';
    if(currentLayer && (currentLayerNum != n))
      currentLayer.style.visibility='hidden';
    currentLayer = l;
    currentitem = mm;
    currentLayerNum = n;			
  } else if(currentLayer) {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentitem = null;
    currentLayer = null;
 	}
}

function mclosetime() {
  closeTimer = window.setTimeout(mclose, TimeOut);
}

function mcancelclosetime() {
  if(closeTimer) {
    window.clearTimeout(closeTimer);
    closeTimer = null;
  }
}

function mclose() {
  if(currentLayer && noClose!=1)   {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentLayer = null;
    currentitem = null;
  } else {
    noClose = 0;
  }
  currentLayer = null;
  currentitem = null;
}

document.onclick = mclose; 

