/* 탑 메뉴
---------------------------------------------------------*/
function initNavigation(seq, menuid) {

	if(!menuid)
		var nav = document.getElementById("gnbmenu");
	else
		var nav = document.getElementById(menuid);

	nav.menu = new Array();
	nav.current = null;
	nav.menuseq = 0;
	navLen = nav.childNodes.length;

	allA = nav.getElementsByTagName("a")
	for(k = 0; k < allA.length; k++) {
		allA.item(k).onmouseover = allA.item(k).onfocus = function () {
			nav.isOver = true;
		}
		allA.item(k).onmouseout = allA.item(k).onblur = function () {
			nav.isOver = false;
			setTimeout(function () {
				if (nav.isOver == false) {
					if(nav.menu[seq]) {
						nav.menu[seq].onmouseover();
					}
					else {

						if (nav.current) {
							menuImg = nav.current.childNodes.item(0);
							if(menuImg.tagName == "IMG") {
								menuImg.src = menuImg.src.replace("_on.gif", ".gif");
							}
							if (nav.current.submenu) {
								nav.current.submenu.style.display = "none";
							}
							nav.current = null;
						}

					}
				}
			}, 1000);
		}
	}

	for (i = 0; i < navLen; i++) {
		navItem = nav.childNodes.item(i);
		if (navItem.tagName != "LI")
			continue;

		navAnchor = navItem.getElementsByTagName("a").item(0);
		navAnchor.submenu = navItem.getElementsByTagName("ul").item(0);

		if (navAnchor.submenu) {
			navAnchor.submenu.style.display = "none";
		}

		navAnchor.onmouseover = navAnchor.onfocus = function () {
			if (nav.current) {
				menuImg = nav.current.childNodes.item(0);

				if(menuImg.tagName == "IMG") {
					menuImg.src = menuImg.src.replace("_on.gif", ".gif");
				}
					if (nav.current.submenu) {
						nav.current.submenu.style.display = "none";
				}
				nav.current = null;
			}
			if (nav.current != this) {
				menuImg = this.childNodes.item(0);
				if(menuImg.tagName == "IMG") {
					menuImg.src = menuImg.src.replace("_on.gif", ".gif");
					menuImg.src = menuImg.src.replace(".gif", "_on.gif");
				}
					if (this.submenu)
						this.submenu.style.display = "block";
				nav.current = this;
			}
			nav.isOver = true;
		}

		nav.menuseq++;
		nav.menu[nav.menuseq] = navAnchor;
	}

	if (nav.menu[seq])
		nav.menu[seq].onmouseover();

	/* submenu img rollover */
	var subnavLen = nav.getElementsByTagName("ul").length;
	for(i=0; i < subnavLen; i++) {

		var subnav =  nav.getElementsByTagName("ul").item(i).childNodes;
		for(s = 0; s < subnav.length; s++) {

			var subnavItem = subnav.item(s);
			if (subnavItem.tagName != "LI")
				continue;

			subnavAnchor = subnavItem.getElementsByTagName("img").item(0);

			if(subnav.item(s).getElementsByTagName("a").item(0)) {
				subnav.item(s).getElementsByTagName("a").item(0).onmouseover = subnav.item(s).getElementsByTagName("a").item(0).onfocus = function () {

					menuImg = this.childNodes.item(0);

					if(menuImg.tagName == "IMG") {
						menuImg.src = menuImg.src.replace("_on.gif", ".gif");
						menuImg.src = menuImg.src.replace(".gif", "_on.gif");
					}
					else {
						this.className += " on";
					}
					nav.isOver = true;
				}

				subnav.item(s).getElementsByTagName("a").item(0).onmouseout = subnav.item(s).getElementsByTagName("a").item(0).onblur = function () {
					menuImg = this.childNodes.item(0);

					if(menuImg.tagName == "IMG") {
						menuImg.src = menuImg.src.replace("_on.gif", ".gif");
					}
					else {
						if(this.className) {
							this.className = this.className.replace(" on", "");
						}
					}

					nav.isOver = false;
					setTimeout(function () {
						if (nav.isOver == false) {
							if(nav.menu[seq]) {
								nav.menu[seq].onmouseover();
							}
							else {

								if (nav.current) {
									menuImg = nav.current.childNodes.item(0);
									if(menuImg.tagName == "IMG") {
										menuImg.src = menuImg.src.replace("_on.gif", ".gif");
									}
									else {
										if(this.className) {
											this.className = this.className.replace(" on", "");
										}
									}

									if (nav.current.submenu) {
										nav.current.submenu.style.display = "none";
									}
									nav.current = null;
								}

							}
						}
					}, 1000);
				}

			}
		}
	}
	
	/* end submenu img rollover */
}


/* left menu
---------------------------------------------------------*/
var old='';

function LeftMenu(name){
	submenu=eval("Leftmenu_"+name+".style");
		if(old!=submenu)
		{
			if(old!='')
			{
			old.display='none';
			}
				submenu.display='block';
				old=submenu;
        }
        else
        {
			submenu.display='none';
			old='';
		}
}


/* 탭 메뉴
---------------------------------------------------------*/
function initTabMenu(tabContainerID,useImgRoll,useOnMouse) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;
	var imgRoll = 0;
	var onMouse = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);

		/* tab menu event */
		onMouse = useOnMouse;
		if(onMouse) {
			thismenu.onmouseover = thismenu.onfocus = function tabMenuClick() {
				currentmenu = this.container.current;
				if (currentmenu == this)
					return false;

				if (currentmenu) {
					currentmenu.targetEl.style.display = "none";
					if (currentmenu.imgEl) {
						currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
					} else {
						currentmenu.className = currentmenu.className.replace(" on", "");
					}
				}
				this.targetEl.style.display = "";
				if (this.imgEl) {
					this.imgEl.src = this.imgEl.src.replace("_on.gif", ".gif");
					this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
				} else {
					this.className += " on";
				}
				this.container.current = this;

				return false;
			}
		}
		else {
			thismenu.onclick = function tabMenuClick() {
				currentmenu = this.container.current;
				if (currentmenu == this)
					return false;

				if (currentmenu) {
					currentmenu.targetEl.style.display = "none";
					if (currentmenu.imgEl) {
						currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
					} else {
						currentmenu.className = currentmenu.className.replace(" on", "");
					}
				}
				this.targetEl.style.display = "";
				if (this.imgEl) {
					this.imgEl.src = this.imgEl.src.replace("_on.gif", ".gif");
					this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
				} else {
					this.className += " on";
				}
				this.container.current = this;

				return false;
			}

			/* tab img rollover */
			imgRoll = useImgRoll;
			if(imgRoll) {
				thismenu.onmouseover = thismenu.onfocus = function() {
					tabImg = this.getElementsByTagName("img").item(0);
					tabImg.src = tabImg.src.replace("_on.gif", ".gif");
					tabImg.src = tabImg.src.replace(".gif", "_on.gif");
				}
				thismenu.onmouseout = thismenu.onblur = function() {
					currentmenu = this.container.current;
					if (currentmenu == this)
						return false;

					tabImg = this.getElementsByTagName("img").item(0);
					tabImg.src = tabImg.src.replace("_on.gif", ".gif");
				}
			}
			/* end tab img rollover */
		}
		/* end tab menu event */

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first) {
		if(onMouse)
			tabContainer.first.onmouseover();
		else
			tabContainer.first.onclick();
	}
}


/* Footer FamilySite
---------------------------------------------------------*/
function famlistAction1() {	
	var target = document.getElementById('familyList1');
	target.style.display = (target.style.display=='block' ? 'none':'block');
}
function famlistAction2() {	
	var target = document.getElementById('familyList2');
	target.style.display = (target.style.display=='block' ? 'none':'block');
}
