// JavaScript Document


window.onload = steup;
var time;
//time = setTimeout(closed,100);
var display01;
var display02;
var subMenu;
var subArray;

function steup(){
	//alert('show');
	//clearTimeout(time);
	
	display01 = document.getElementById("sub_0");
	display02 = document.getElementById("sub_3");
	subMenu = document.getElementById("totalSub");
	//alert(subMenu.childNodes[0].childNodes.length);
	
	subArray=new Array();
	
	for(k=0; k<subMenu.childNodes.length; k++){
		if (subMenu.childNodes[k].tagName == "UL"){
			//alert(subMenu.childNodes[k].childNodes[0].tagName);
			if(subMenu.childNodes[k].childNodes[k].tagName == "LI"){
				//alert(subMenu.childNodes[k].childNodes.length);
				for(x=0; x<subMenu.childNodes[k].childNodes.length; x++){
					if(subMenu.childNodes[k].childNodes[x].tagName == "LI"){
						subArray.push(subMenu.childNodes[k].childNodes[x]);
					}
				}
			}
		}
	}
	//alert("subArray"+subArray.length);
	
	//次選監聽
	for (z=0; z<subArray.length; z++) {
		if(subArray[z].addEventListener){
	       subArray[z].addEventListener("mouseover",killCount,false);
		   subArray[z].addEventListener("mouseout",startCount,false);
		}else if(subArray[z].attachEvent){
	       subArray[z].attachEvent("onmouseover",killCount);
		   subArray[z].attachEvent("onmouseout",startCount);
		}else if(menuArray[0].onclick){
	       subArray[z].onmouseover=killCount;
		   subArray[z].onmouseout=startCount;
		}
	}
	
	objMenu = document.getElementById("menuAll");
	//alert(objMenu.childNodes[0].tagName);
	
	//實體..............
	menuArray = new Array();
	
	for (i=0; i<objMenu.childNodes.length; i++){
		//alert(objMenu.childNodes[i].tagName);
		if (objMenu.childNodes[i].tagName=="LI"){
			menuArray.push(objMenu.childNodes[i]);
			//alert("try");
		}
	}
	
	//alert(menuArray.length);
	
	//About KODA選項監聽
	if(menuArray[0].addEventListener){
	       menuArray[0].addEventListener("mouseover",show01,false);
		   menuArray[0].addEventListener("mouseout",startCount,false);
		}else if(menuArray[0].attachEvent){
	       menuArray[0].attachEvent("onmouseover",show01);
		   menuArray[0].attachEvent("onmouseout",startCount);
		}else if(menuArray[0].onclick){
	       menuArray[0].onmouseover=show01;
		   menuArray[0].onmouseout=startCount;
		}
		
	//Products選項監聽	
	if(menuArray[3].addEventListener){
	       menuArray[3].addEventListener("mouseover",show02,false);
		   menuArray[3].addEventListener("mouseout",startCount,false);
		}else if(menuArray[3].attachEvent){
	       menuArray[3].attachEvent("onmouseover",show02);
		   menuArray[3].attachEvent("onmouseout",startCount);
		}else if(menuArray[3].onclick){
	       menuArray[3].onmouseover=show02;
		   menuArray[3].onmouseout=startCount;
		}
		
}

function show01(){
	clearTimeout(time);
	display01.style.display = "block";
	//info.innerHTML="kill";
	//alert("show01");
}

function show02(){
	clearTimeout(time);
	display02.style.display = "block";
	//info.innerHTML="kill";
}

function startCount(){
	time = setTimeout(closed,100);
	//info.innerHTML="time";
}

function killCount(){
	clearTimeout(time);
	//alert("sdfgsdfg");
	//info.innerHTML="kill";
}

function closed(){
	//alert("hjkhjkhj");
	//clearTimeout(time);
	display01.style.display ="none";
	display02.style.display ="none";
	//alert(display01.style.display);
}





