//詳細ページ補助スクリプト sub.js
// 中村 2010/02/18




//フォーム読み込み完了後に関数を実行
addLoadEvent(menuSetup);


//初期設定
function menuSetup(){
	
	//カレント属性のメニュー以外を閉じる	
	
	
	var aObj= document.getElementsByTagName("div");

/* IE6で非動作のため破棄
	for (var i=0;i < aObj.length; i++){
		var objDiv = aObj[i];
		var strClass =	(objDiv.getAttribute("class") || objDiv.getAttribute("className"));
	
		//クラス名がlevel2のとき
		if (strClass === "level2"){
			objDiv.setAttribute("onmouseup" , "menuup(this);" );
			objDiv.setAttribute("onmouseover" ,"menuover(this);" );
			objDiv.setAttribute("onmouseout" ,"menuout(this);" );
		}
		
	}
*/
	

}


//メニューマウスオーバー時の処理
//obj:対象オブジェクト(div)
function menuover(obj){
	var strClass =	(obj.getAttribute("class") || obj.getAttribute("className"));

	if ( strClass === "current" || strClass === "current2"	) {
		//current,current2クラスの場合は何もしない
	
	} else {
	
	
		if ( strClass === "level2" ) {
			obj.style.background='url(img/level2_o.gif)';
		
		} else {

			//obj.style.background='#AA0000';
			obj.style.background='url(img/leftmenu_o.gif)';
		
			obj.style.cursor='pointer';
		}
	}
}

//メニューマウス外れ時の処理
//obj:対象オブジェクト(div)
function menuout(obj){

	var strClass =	(obj.getAttribute("class") || obj.getAttribute("className"));

	if ( strClass === "current" || strClass === "current2"	) {
		//current,current2クラスの場合は何もしない
	
	} else {



		//状態を復元
		if ( strClass === "level2" ) {
			obj.style.background='url(img/leftmenu_d.gif)';
		
		} else {
		//	obj.style.background='#00BB00';	
			obj.style.background='url(img/leftmenu.gif)';
		}
	}
}



//メニューマウスクリック時の処理
function menuup(obj) {
	var strClass =	(obj.getAttribute("class") || obj.getAttribute("className"));

	if ( strClass === "current" || strClass === "current2"	) {
		//current,current2クラスの場合は何もしない
	
	} else {



//	alert(obj.firstChild.href);

	//hrefへページ移動
	document.location = obj.firstChild.href;
	}

}


function addLoadEvent(func) {
 if(typeof window.addEventListener == 'function'){ // addEventListenerが使えるなら
  window.addEventListener('load', func, false);
  return true;
 } else if(typeof window.attachEvent == 'object'){ // attachEventが使えるなら(IE用)
  window.attachEvent('onload', func);
  return true;
 }

 var oldonload = window.onload; // どちらも使えないなら
 if (typeof window.onload != 'function') {
  window.onload = func;
 } else {
  window.onload = function() {
   oldonload();
   func();
  }
 }
}
