var firstmn=0;
function top2menuView(a){ //2차메뉴보기
	if(this.id){
		eidStr = this.id;
		eidNum=eidStr.substring(eidStr.lastIndexOf("m",eidStr.length)+1,eidStr.length);
		a = parseInt(eidNum);
	}
	top2menuHideAll();
	top1Menu = document.getElementById("top1m"+a);
	top2Menu = document.getElementById("top2m"+a);
	ann=a;
	if (a=0) { //메인은2차메뉴활성화안함
	} else {
		if (top1Menu) {
			var top1Menu_img = top1Menu.getElementsByTagName("img");
			imgOver(top1Menu_img[0]);
			if (top2Menu) { top2Menu.style.display = 'inline'; }
		}
	}
}

function top2menuHide(a){ //2차메뉴감추기
	if(firstmn == 0)
		firstmn = a;

	if(this.id){
		eidStr = this.id;
		eidNum=eidStr.substring(eidStr.lastIndexOf("m",eidStr.length)+1,eidStr.length);
		a = parseInt(eidNum);
	}
	top2menuHideAll();
	top1Menu = document.getElementById("top1m"+a);
	top2Menu = document.getElementById("top2m"+a);
	if(firstmn){
		top1MenuCurr = document.getElementById("top1m"+firstmn);
		top2MenuCurr = document.getElementById("top2m"+firstmn);
	}
	ann=a;
	if (top1Menu) {
		if (top2Menu) {
			top2Menu.style.display = 'none';
		}
		if(firstmn){
			if (top2MenuCurr) {
				var top1Menu_img = top1MenuCurr.getElementsByTagName("img");
				imgOver(top1Menu_img[0]);
				top2MenuCurr.style.display = 'inline';
			}else{
				var top1Menu_img = top1MenuCurr.getElementsByTagName("img");
				imgOut(top1Menu_img[0]);
			}
		}
	}
}

function top2menuHideAll(){ //2차메뉴모두감추기
	top1menuEl = document.getElementById("top1menu").getElementsByTagName("ul");
	for (i=1;i<=top1menuEl.length;i++){
		top1Menu = document.getElementById("top1m"+i);
		top2Menu = document.getElementById("top2m"+i);
		inn=i;
		if (top1Menu){
			if (top2Menu) { top2Menu.style.display = 'none'; }
			var top1Menu_img = top1Menu.getElementsByTagName("img");
			imgOut(top1Menu_img[0]);
		}
	}
}

function initTopMenu() {
	top1menuEl = document.getElementById("top1menu").getElementsByTagName("ul");
	for (i=1;i<=top1menuEl.length;i++){
		top1Menu = document.getElementById("top1m"+i);
		top2Menu = document.getElementById("top2m"+i);
		if (top1Menu) {
			top1Menu.onmouseover = top1Menu.onfocus = top2menuView;
			top1Menu.onmouseout = top2menuHide;
			if (top2Menu) {
				top2Menu.onmouseover = top2Menu.onfocus = top2menuView;
				top2Menu.onmouseout = top2menuHide;
			}
		}
	}
}