// 현재 url에 따라서 활성화 시킬 메뉴를 결정하는 값들
var menuLinkMatches = {
	// GAMES
	"/game/metin2.htm" : "mn2",
	"/game/metin1.htm" : "mn2",

	// COMPANY
	"/company/overview.htm" : "mn1",
	"/company/vision.htm" : "mn1",
	"/company/news.htm" : "mn1",
	"/company/history.htm" : "mn1",
	"/company/ci.htm" : "mn1",
	"/company/ci_2.htm" : "mn1",

	// CONTACT
	"/contact/contact.htm" : "mn4"
};


var menuLinkIndex = null;
var menuLinkName = null;

for (var i in menuLinkMatches)
{
	var pos = location.href.search(i);
	if (0 <= pos)
		menuLinkName = menuLinkMatches[i];	
}

//	alert(menuLinkMatches[i]);

// Tab Content
function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		var menuName = tabAnchor.item(i).href.split("#")[1];

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);

		if (thismenu.targetEl && thismenu.targetEl.style)
			thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		if (thismenu.imgEl) {
			thismenu.onmouseover = function () {
				//this.onmouseover();
			}
		}
		thismenu.onmouseover = tabMenuClick;
		
		// 현재 페이지에 맞는 메뉴를 초기에 펼침
		if (menuLinkName && menuName == menuLinkName)
			thismenu.onmouseover();

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
//	tabContainer.first.onmouseover();
}
function tabMenuClick() {
	currentmenu = this.container.current;
	if (currentmenu != this) {
		if (currentmenu) {
			currentmenu.targetEl.style.display = "none";
			if (currentmenu.imgEl) {
				currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.png", ".png");
			} else {
				currentmenu.className = currentmenu.className.replace("on", "");
			}
		}

		this.targetEl.style.display = "block";
		if (this.imgEl) {
			this.imgEl.src = this.imgEl.src.replace(".png", "_on.png");
		} else {
			this.className += " on";
		}
		this.container.current = this;
	}
	return false;
}



