// JavaScript Document


var menu1=new Array();
var menu2=new Array();
var menu3=new Array();
var menu4=new Array();
var menu5=new Array();
var menu6=new Array();

var li1=new Array();
var li2=new Array();
var li3=new Array();
var li4=new Array();
var li5=new Array();
var li6=new Array();

//----
menu1[0]="集合住宅";li1[0]="life-housing.html";
menu1[1]="宅地造成";li1[1]="life-curtilage.html";
menu1[2]="官公庁施設";li1[2]="life-government.html";
menu1[3]="処理場/リサイクル施設";li1[3]="life-recycle.html";
menu1[4]="雨水・上下水道施設";li1[4]="life-water.html";
menu1[5]="雨水貯留施設/放水路";li1[5]="life-floodway.html";
menu1[6]="ダム";li1[6]="life-dam.html";

//----
menu2[0]="オフィス";li2[0]="business-office.html";
menu2[1]="商業施設";li2[1]="business-commerce.html";
menu2[2]="宿泊施設";li2[2]="business-hotel.html";
menu2[3]="生産・研究施設";li2[3]="business-product.html";
menu2[4]="物流施設";li2[4]="business-logistics.html";

//----
menu3[0]="学校・教育施設";li3[0]="edu-medi-school.html";
menu3[1]="医療・福祉施設";li3[1]="edu-medi-medical.html";

//----
menu4[0]="文化・スポーツ施設";li4[0]="culture-sports.html";
menu4[1]="伝統建築/歴史的建造物";li4[1]="culture-traditional.html";

//----
menu5[0]="鉄道";li5[0]="traffic-railway.html";
menu5[1]="道路";li5[1]="traffic-road.html";
menu5[2]="空港施設";li5[2]="traffic-airport.html";
menu5[3]="港湾/海洋施設";li5[3]="traffic-port.html";

//----
menu6[0]="火力発電所/LNGタンク";li6[0]="energy-fire.html";
menu6[1]="水力発電施設";li6[1]="energy-water.html";
menu6[2]="原子力発電所";li6[2]="energy-nuclear.html";
menu6[3]="石油タンク/備蓄基地";li6[3]="energy-oil.html";
menu6[4]="新エネルギー";li6[4]="energy-new.html";
menu6[5]="エネルギー施設";li6[5]="energy-energy.html";
menu6[6]="ガス導管/共同溝";li6[6]="energy-gas.html";


var ctg_length = 6;


function init() {

	for (i=0; i<ctg_length; i++) {
	
		var btn_num = i+1;
		mlen=eval("menu"+btn_num+".length"); 
		
		var menu_ctg = document.createElement("ul");
		menu_ctg.setAttribute("id","child_menu"+btn_num);
		menu_ctg.setAttribute("class","child");
		menu_ctg.setAttribute("className","child");

		for (n=0; n<mlen; n++) {
			var menu_txt = eval("menu"+btn_num+"[n]");
			var menu_link = eval("li"+btn_num+"[n]");
			
			var menu_list = document.createElement("li");
			var menu_list_link = document.createElement("a");
			menu_list_link.setAttribute("href",menu_link);
			var menu_list_span = document.createElement("span");
			var link_txt = document.createTextNode(menu_txt);
			
			menu_list_span.appendChild(link_txt);
			menu_list_link.appendChild(menu_list_span);
			menu_list.appendChild(menu_list_link);
			menu_ctg.appendChild(menu_list);
		}
		
		var menu_area = document.getElementById("menu"+btn_num);
		menu_area.appendChild(menu_ctg);
	}
}


function menu(host_object_id, visible_object_id, visible_flag){
	if(document.getElementById){
		var visible_object = document.getElementById(visible_object_id);
		var host_object = document.getElementById(host_object_id);
		var a_tag = host_object.getElementsByTagName("a");
	}

	if(visible_flag=='show'){
		if(document.getElementById){
			visible_object.style.visibility="visible";
			a_tag[0].setAttribute("class","on_mouse");
			a_tag[0].setAttribute("className","on_mouse");
		}
	}
	else if(visible_flag=='hide'){
		if(document.getElementById){
			visible_object.style.visibility="hidden";
			a_tag[0].setAttribute("class","");
			a_tag[0].setAttribute("className","");
		}
	}
}


//
function setEvents() {
	for(i=1;i<ctg_length+1;i++){
	Set_PopUpMenu(i);
	}
}

//ポップアップメニューのイベントをセットする関数
function Set_PopUpMenu(i){
	var menuHost = "menu"+i;
	var ch_menuHost = "child_"+menuHost;
	var menu_target = document.getElementById(menuHost);	
	menu_target.onmouseover = function(){menu(menuHost, ch_menuHost,'show');}
	menu_target.onmouseout = function(){menu(menuHost, ch_menuHost,'hide');}	
}



//ロードイベントを順番に実行する関数
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
		}
	else {
		window.onload = function() {
		oldonload();
		func(); 
		}
	}
}


//ロードイベント発生
addLoadEvent(init);
addLoadEvent(setEvents); 

