// GNB
function Navigation(seq, navID) {
	nav = document.getElementById(navID);
	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) {
						
						if (nav.current.submenu)
							nav.current.submenu.style.visibility = "hidden";
						nav.current = null;
					}
				}
			}, 500);
		}
	}

	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("div").item(0);

		navAnchor.onmouseover = navAnchor.onfocus = function () {
			if (nav.current) {
				
				if (nav.current.submenu)
					nav.current.submenu.style.visibility = "hidden";
				nav.current = null;
			}
			if (nav.current != this) {

				if (this.submenu)
					this.submenu.style.visibility = "visible";
				nav.current = this;
			}
			nav.isOver = true;
		}
		nav.menuseq++;
		nav.menu[nav.menuseq] = navAnchor;
	}
	if (nav.menu[seq])
		nav.menu[seq].onmouseover();
}

// LNB
function imgMenuOver(containderID) {
	var objwrap = document.getElementById(containderID);
	var imgMenu = objwrap.getElementsByTagName("a");

	for (i=0; i<imgMenu.length; i++) {
		if(imgMenu[i].getElementsByTagName("img").length == 0) continue;

		if (imgMenu[i].getElementsByTagName("img")[0].src.indexOf("_o.gif") != -1 ) {
			continue;
		}
		imgMenu[i].onmouseover = function() {
			subImage = this.getElementsByTagName("img")[0];
			if (subImage.src.indexOf("_o.gif") != -1) return false;
			subImage.src = subImage.src.replace(".gif","_o.gif");
		}
		imgMenu[i].onfocus = function() {
			subImage = this.getElementsByTagName("img")[0];
			if (subImage.src.indexOf("_o.gif") != -1) return false;
			subImage.src = subImage.src.replace(".gif","_o.gif");
		}
		imgMenu[i].onmouseout = function() {
			subImage = this.getElementsByTagName("img")[0];
			subImage.src = subImage.src.replace("_o.gif", ".gif");
		}
		imgMenu[i].onblur = function() {
			subImage = this.getElementsByTagName("img")[0];
			subImage.src = subImage.src.replace("_o.gif", ".gif");
		}
	}
}

// layer open,close

function layerOpen(layerID){
	var layer = document.getElementById(layerID);	
		if(layer.style.display == 'block')
			layer.style.display = 'none';
		else 
			layer.style.display = 'block';
}

// graph 

function graphOpen(Layer) {
	document.getElementById(Layer).style.display = "block";
}
function graphClose(Layer) {
	document.getElementById(Layer).style.display = "none";
}

// Tab Content
function initTabMenu(tabContainerID, tabClassName, tabNum, tabBtnFormat) {
		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 == tabClassName)
				thismenu = tabAnchor.item(i);
			else
				continue;

			if (thismenu.href.split("#")[1] == "prev" || thismenu.href.split("#")[1] == "next") {

				thismenu.onclick = function btnNextClick() {

					currentmenu = tabContainer.current;

					var _prefix = "photo", _btnNum = 3;

					if (tabBtnFormat != null && tabBtnFormat != "") {
						_prefix = tabBtnFormat.split("^")[0];
						_btnNum = parseInt(tabBtnFormat.split("^")[1], 10);
					}
					_targetElId = parseInt(currentmenu.targetEl.id.replace(_prefix, ""), 10);
					if (this.href.split("#")[1] == "prev")
						_targetElId = (_targetElId - 1 == 0 ? _btnNum : (_targetElId - 1));
					else
						_targetElId = (_targetElId + 1 == (_btnNum + 1) ? 1 : (_targetElId + 1));
					_targetElId = _prefix + (_targetElId < 10 ? '0' + _targetElId : _targetElId);

					_tabAnchor = document.getElementById(tabContainerID).getElementsByTagName("a");
					for (i = 0; i < _tabAnchor.length; i++) {
						if (tabAnchor.item(i).className == tabClassName && tabAnchor.item(i).href.split("#")[1] == _targetElId) {
							tabAnchor.item(i).onclick();
							break;
						}
					}

					return false;
				};
				
				continue;
			}
		
			thismenu.container = tabContainer;
			thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
			thismenu.targetEl.style.display = "none";
			
			thismenu.onclick = thismenu.onmouseover = thismenu.onfocus = function tabMenuClick() {
				currentmenu = this.container.current;
				if (currentmenu == this)
					return false;

				if (currentmenu) {
					currentmenu.targetEl.style.display = "none";
					currentmenu.className = currentmenu.className.replace("_over", "");				
				}
				this.targetEl.style.display = "";
				this.className += "_over";
				
				this.container.current = this;

				return false;
			};

			 if (tabNum != null && tabNum != "" && tabNum == parseInt(tabAnchor.item(i).href.split("#")[1].substr(tabAnchor.item(i).href.split("#")[1].length - 2, 2), 10))
				thismenu.container.first = thismenu;
			else if (!thismenu.container.first)
	   thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

function initTabMenuOver(tabContainerID, tabClassName, tabNum, tabBtnFormat) {
		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 == tabClassName)
				thismenu = tabAnchor.item(i);
			else
				continue;

			if (thismenu.href.split("#")[1] == "prev" || thismenu.href.split("#")[1] == "next") {

				thismenu.onclick = function btnNextClick() {

					currentmenu = tabContainer.current;

					var _prefix = "photo", _btnNum = 3;

					if (tabBtnFormat != null && tabBtnFormat != "") {
						_prefix = tabBtnFormat.split("^")[0];
						_btnNum = parseInt(tabBtnFormat.split("^")[1], 10);
					}
					_targetElId = parseInt(currentmenu.targetEl.id.replace(_prefix, ""), 10);
					if (this.href.split("#")[1] == "prev")
						_targetElId = (_targetElId - 1 == 0 ? _btnNum : (_targetElId - 1));
					else
						_targetElId = (_targetElId + 1 == (_btnNum + 1) ? 1 : (_targetElId + 1));
					_targetElId = _prefix + (_targetElId < 10 ? '0' + _targetElId : _targetElId);

					_tabAnchor = document.getElementById(tabContainerID).getElementsByTagName("a");
					for (i = 0; i < _tabAnchor.length; i++) {
						if (tabAnchor.item(i).className == tabClassName && tabAnchor.item(i).href.split("#")[1] == _targetElId) {
							tabAnchor.item(i).onclick();
							break;
						}
					}

					return false;
				};
				
				continue;
			}
		
			thismenu.container = tabContainer;
			thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
			thismenu.targetEl.style.display = "none";
			
			thismenu.onmouseover = thismenu.onfocus = function tabMenuClick() {
				currentmenu = this.container.current;
				if (currentmenu == this)
					return false;

				if (currentmenu) {
					currentmenu.targetEl.style.display = "none";
					currentmenu.className = currentmenu.className.replace("_over", "");				
				}
				this.targetEl.style.display = "";
				this.className += "_over";
				
				this.container.current = this;

				return false;
			};

			 if (tabNum != null && tabNum != "" && tabNum == parseInt(tabAnchor.item(i).href.split("#")[1].substr(tabAnchor.item(i).href.split("#")[1].length - 2, 2), 10))
				thismenu.container.first = thismenu;
			else if (!thismenu.container.first)
	   thismenu.container.first = thismenu;
	}

}

function initTabMenuClick(tabContainerID, tabClassName, tabNum, tabBtnFormat) {
		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 == tabClassName)
				thismenu = tabAnchor.item(i);
			else
				continue;

			if (thismenu.href.split("#")[1] == "prev" || thismenu.href.split("#")[1] == "next") {

				thismenu.onclick = function btnNextClick() {

					currentmenu = tabContainer.current;

					var _prefix = "photo", _btnNum = 3;

					if (tabBtnFormat != null && tabBtnFormat != "") {
						_prefix = tabBtnFormat.split("^")[0];
						_btnNum = parseInt(tabBtnFormat.split("^")[1], 10);
					}
					_targetElId = parseInt(currentmenu.targetEl.id.replace(_prefix, ""), 10);
					if (this.href.split("#")[1] == "prev")
						_targetElId = (_targetElId - 1 == 0 ? _btnNum : (_targetElId - 1));
					else
						_targetElId = (_targetElId + 1 == (_btnNum + 1) ? 1 : (_targetElId + 1));
					_targetElId = _prefix + (_targetElId < 10 ? '0' + _targetElId : _targetElId);

					_tabAnchor = document.getElementById(tabContainerID).getElementsByTagName("a");
					for (i = 0; i < _tabAnchor.length; i++) {
						if (tabAnchor.item(i).className == tabClassName && tabAnchor.item(i).href.split("#")[1] == _targetElId) {
							tabAnchor.item(i).onclick();
							break;
						}
					}

					return false;
				};
				
				continue;
			}
		
			thismenu.container = tabContainer;
			thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
			thismenu.targetEl.style.display = "none";
			
			thismenu.onclick = function tabMenuClick() {
				currentmenu = this.container.current;
				if (currentmenu == this)
					return false;

				if (currentmenu) {
					currentmenu.targetEl.style.display = "none";
					currentmenu.className = currentmenu.className.replace("_over", "");				
				}
				this.targetEl.style.display = "";
				this.className += "_over";
				
				this.container.current = this;

				return false;
			};

			 if (tabNum != null && tabNum != "" && tabNum == parseInt(tabAnchor.item(i).href.split("#")[1].substr(tabAnchor.item(i).href.split("#")[1].length - 2, 2), 10))
				thismenu.container.first = thismenu;
			else if (!thismenu.container.first)
	   thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

function initTabMenu2(tabContainerID, tabClassName, tabNum, tabBtnFormat) {
		var tabContainer = document.getElementById(tabContainerID);
		var tabAnchor = tabContainer.getElementsByTagName("a");
		var i = 0;

		var tabBtnAnchor = document.getElementsByTagName("a");
		for (i = 0; i < tabBtnAnchor.length; i++) {
	   
			if (tabBtnAnchor.item(i).href.split("#")[1] == "prev" || tabBtnAnchor.item(i).href.split("#")[1] == "next")
				thisTabBtn = tabBtnAnchor.item(i);
			else
				continue;
 
			thisTabBtn.onclick = function tabButtonClick() {
 
				currentmenu = tabContainer.current;
 
				var _prefix, _btnNum = 0, _btnMaxNum = 5;
				_prefix = currentmenu.href.split("#")[1].substr(0, currentmenu.href.split("#")[1].length - 2);
 
				var _tabAnchor = document.getElementById(tabContainerID).getElementsByTagName("a");
				for (i = 0; i < _tabAnchor.length; i++) {
					if (_tabAnchor.item(i).className.replace("_over", "") == tabClassName)
						_btnNum += 1;
				}
				if (_btnNum <= _btnMaxNum) return false;
 
				var _objH4 = document.getElementById(tabContainerID).getElementsByTagName("H4");
				var _tabAnchorParent;
				for (i = 0; i < _objH4.length; i++) {
					if (_objH4.item(i).getElementsByTagName("a").item(0).href.split("#")[1] == _prefix + "01") {
						_tabAnchorParent = _objH4.item(i);
						break;
					}
				}
 
				var _marginTop = 0;
				if (_tabAnchorParent.style.marginTop == null || _tabAnchorParent.style.marginTop == "")
					_marginTop = 0;
				else
					_marginTop = parseInt(_tabAnchorParent.style.marginTop.replace("px", ""), 10);
 
				if (this.href.split("#")[1] == "prev") {
					_tabAnchorParent.style.marginTop = (_marginTop < 0 ? _marginTop + 20 : 0) + "px";
				}
				else {
					_tabAnchorParent.style.marginTop = (_marginTop > (_btnNum - _btnMaxNum) * -20 ? _marginTop - 20 : (_btnNum - _btnMaxNum) * -20) + "px";
				}
				return false;
			};
 
		}
 
		for (i = 0; i < tabAnchor.length; i++) {
			if (tabAnchor.item(i).className == tabClassName || tabAnchor.item(i).href.split("#")[1] == "prev" || tabAnchor.item(i).href.split("#")[1] == "#prev")
				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.onclick = thismenu.onmouseover = thismenu.onfocus = function tabMenuClick() {
				currentmenu = this.container.current;
				if (currentmenu == this)
					return false;
 
				if (currentmenu) {
					currentmenu.targetEl.style.display = "none";
					currentmenu.className = currentmenu.className.replace("_over", "");				
				}
				this.targetEl.style.display = "";
				this.className += "_over";
				
				this.container.current = this;
 
				return false;
			};
 
			 if (tabNum != null && tabNum == parseInt(tabAnchor.item(i).href.split("#")[1].substr(tabAnchor.item(i).href.split("#")[1].length - 2, 2), 10))
				thismenu.container.first = thismenu;
			else if (!thismenu.container.first)
				thismenu.container.first = thismenu;
 
		}
	
		if (tabContainer.first)
			tabContainer.first.onclick();
	}
	
function moveLi(tabContainerID, tabClassName, tabNum, maxNum) {
		
		var tabContainer = document.getElementById(tabContainerID);
		var tabAnchor = tabContainer.getElementsByTagName("a");
		var oLi = tabContainer.getElementsByTagName("li");
		var i = 0, anchorIdx = 0, liStartIdx = 0;
 
		// li style(display:none or display:block) init
		for (i = 0; i < oLi.length; i++) {
			oLi.item(i).style.display = (i > maxNum - 1 ? "none" : "block");
		}
		
		for (i = 0; i < tabAnchor.length; i++) {
			if (tabAnchor.item(i).className == tabClassName || tabAnchor.item(i).href.split("#")[1] == "prev" || tabAnchor.item(i).href.split("#")[1] == "next")
				thismenu = tabAnchor.item(i);
			else
				continue;
 
			// prev,next button eventhandler setting
			if (thismenu.href.split("#")[1] == "prev" || thismenu.href.split("#")[1] == "next") {
 
 
 
				thismenu.onclick = function() {
					for (i = 0; i < oLi.length; i++) {
						if (oLi.item(i).style.display == "block") {
							liStartIdx = i;
							break;
						}
					}
 
					if (this.href.split("#")[1] == "prev" && liStartIdx > 0) {
						oLi.item(liStartIdx - 1).style.display = "block";
						oLi.item(liStartIdx + maxNum - 1).style.display = "none";
					}
					else if (this.href.split("#")[1] == "next" && liStartIdx < oLi.length - maxNum) {
						oLi.item(liStartIdx).style.display = "none";
						oLi.item(liStartIdx + maxNum).style.display = "block";
					}
				}
				
				continue;
			}
 
			// img  onmouseover eventhandler setting
			anchorIdx++;
			thismenu.container = tabContainer;
 
			thismenu.onclick = thismenu.onmouseover = thismenu.onfocus = function(){
				currentmenu = this.container.current;
				if (currentmenu == this)
					return false;
 
				if (currentmenu) {
					currentmenu.className = currentmenu.className.replace("_over", "");
				}
				this.className += "_over";
				this.container.current = this;
				return false;
			};
 
			if (tabNum != null && tabNum == anchorIdx)
				thismenu.container.first = thismenu;
			else if (!thismenu.container.first)
				thismenu.container.first = thismenu;
				
		}
 
		if (tabContainer.first)
			tabContainer.first.onclick();
		
	}
	
function moveSlide(tabContainerID, tabClassName, tabNum, maxNum) {

		var tabContainer = document.getElementById(tabContainerID);
		var tabAnchor = tabContainer.getElementsByTagName("a");
		var oLi = tabContainer.getElementsByTagName("li");
		var i = 0, anchorIdx = -1, liStartIdx = -1, curIdx = -1;

		// li style(display:none or display:block) init
		for (i = 0; i < oLi.length; i++) {
			oLi.item(i).style.display = (i > maxNum - 1 ? "none" : "block");
			oLi.item(i).value = i + 1;

		}





		for (i = 0; i < tabAnchor.length; i++) {


			if (tabAnchor.item(i).className == tabClassName ||
				tabAnchor.item(i).href.split("#")[1] == "prev" ||
				tabAnchor.item(i).href.split("#")[1] == "prev_main" ||
				tabAnchor.item(i).href.split("#")[1] == "next" ||
				tabAnchor.item(i).href.split("#")[1] == "next_main")
				thismenu = tabAnchor.item(i);

			else
				continue;

			// prev button eventhandler setting
			if (thismenu.href.split("#")[1] == "prev" || thismenu.href.split("#")[1] == "prev_main") {


				thismenu.onclick = function() {
					liStartIdx = -1; curIdx = -1;
					for (i = 0; i < oLi.length; i++) {
						if (oLi.item(i).style.display != "block") continue;

						if (liStartIdx == -1) liStartIdx = i;

						if(oLi.item(i).getElementsByTagName("a").item(0).className.indexOf("_over") >= 0) curIdx = i;

						if(liStartIdx > -1 && curIdx > -1) break;
					}

					if (liStartIdx > 0) {
						oLi.item(liStartIdx - 1).style.display = "block";
						oLi.item(liStartIdx + maxNum - 1).style.display = "none";
					}

					if((this.href.split("#")[1] == "prev_main" && curIdx > 0) ||
					   //(this.href.split("#")[1] == "prev" && liStartIdx > 0))
						(this.href.split("#")[1] == "prev" && curIdx > 0))
					{
						oLi.item(curIdx - 1).getElementsByTagName("a").item(0).onclick();
					}
					else if(curIdx == 0 || liStartIdx == 0)
					{
						PrevTest();
					}
				}

				continue;
			}
			// next button eventhandler setting
			if (thismenu.href.split("#")[1] == "next" || thismenu.href.split("#")[1] == "next_main") {
				thismenu.onclick = function() {
					liStartIdx = -1; curIdx = -1;
					for (i = 0; i < oLi.length; i++) {

						if (oLi.item(i).style.display != "block") continue;

						if (liStartIdx == -1) liStartIdx = i;

						if(oLi.item(i).getElementsByTagName("a").item(0).className.indexOf("_over") >= 0) curIdx = i;

						if(liStartIdx > -1 && curIdx > -1) break;
					}

					if (liStartIdx < oLi.length - maxNum) {
						oLi.item(liStartIdx).style.display = "none";
						oLi.item(liStartIdx + maxNum).style.display = "block";
					}
					if((this.href.split("#")[1] == "next_main" && curIdx < oLi.length - 1) ||
					   //(this.href.split("#")[1] == "next" && liStartIdx < oLi.length - maxNum))
						(this.href.split("#")[1] == "next" && curIdx < oLi.length - 1))
					{
						oLi.item(curIdx + 1).getElementsByTagName("a").item(0).onclick();
					}
					else if(curIdx == oLi.length - 1 || liStartIdx == oLi.length - maxNum)
					{
						NextTest();
					}
				}
				continue;
			}



			// img  onmouseover eventhandler setting
			anchorIdx++;
			thismenu.container = tabContainer;


			thismenu.onclick =  function(){
			 currentmenu = this.container.current;

			 if (currentmenu == this)
				 return false;

			 if (currentmenu) {
				 currentmenu.className = currentmenu.className.replace("_over", "");

				 if (currentmenu.getElementsByTagName("p").length > 0)
					 currentmenu.getElementsByTagName("p").item(0).className = currentmenu.getElementsByTagName("p").item(0).className.replace("_over", "");
				 if (currentmenu.getElementsByTagName("span").length > 0)
					 currentmenu.getElementsByTagName("span").item(0).className = currentmenu.getElementsByTagName("span").item(0).className.replace("_over", "");
			 }
			 oImg = this.getElementsByTagName("img").item(0);

			if (document.getElementById("mainimg"))
			{
				document.getElementById("mainimg").src =  oImg.src.substring(0, oImg.src.lastIndexOf("/") + 1) + oImg.src.substring(oImg.src.lastIndexOf("/") +1 , oImg.src.length-6 )+"_p.jpg" ;

			}

			 this.className += "_over";
			 if (this.getElementsByTagName("p").length > 0)
				 this.getElementsByTagName("p").item(0).className += "_over";
			 if (this.getElementsByTagName("span").length > 0)
				 this.getElementsByTagName("span").item(0).className += "_over";
			 this.container.current = this;
			 return false;
		 };

			if (tabNum != null && tabNum == anchorIdx + 1)
				thismenu.container.first = thismenu;
			else if (!thismenu.container.first)
				thismenu.container.first = thismenu;

		}

		if (tabContainer.first)
			tabContainer.first.onclick();
	}

function initPopMenu(tabContainerID, tabClassName, tabNum){
	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 == tabClassName)
			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);

		thismenu.onclick = 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("_o.gif", ".gif");
					currentmenu.className = currentmenu.className.replace( "_over", "");
				} else {
					currentmenu.className = currentmenu.className.replace("_over", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_o.gif");
				this.className += "_over";
			} else {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_o.gif");
				this.className += "_over";
			}
			this.container.current = this;

			return false;
		};	
			if (tabNum != null && i + 1 == tabNum)
				thismenu.container.first = thismenu;
			else if (!thismenu.container.first)
				thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

function initImgMenu(imgContainerID, imgClassName){
	var imgContainer = document.getElementById(imgContainerID);
	var imgAnchor = imgContainer.getElementsByTagName("a");

	for(i=0; i<imgAnchor.length; i++) {
		if (imgAnchor.item(i).className == imgClassName)
			thismenu = imgAnchor.item(i);
		else 
			continue;

		thismenu.container = imgContainer;
		thismenu.targetEl = document.getElementById("mainimg");
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);

		thismenu.onclick = thismenu.onmouseover = thismenu.onfocus = function imgMenuClick() {

			if (imgContainer.current != this) {
				imgContainer.current.className = imgContainer.current.className.replace("_over", "");
			}				

			imgContainer.current = this;
			currentmenu = this.imgEl;


			this.className += (this.className.toString().indexOf("_over") > 0 ? "" : "_over");
			if (currentmenu) {
				var imgSrc = currentmenu.src.split("/");
				this.targetEl.getElementsByTagName("img").item(0).src = currentmenu.src.replace(imgSrc[imgSrc.length - 1], imgSrc[imgSrc.length - 1].replace("_p", "_t","_preview"));

			}
			return true;

		};
		
		
		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}

	if (imgContainer.first) {
		imgContainer.current = imgContainer.first;
		imgContainer.current.onclick();
	}
}

function initImgMenu3(imgContainerID, imgClassName){
	var imgContainer = document.getElementById(imgContainerID);
	var imgAnchor = imgContainer.getElementsByTagName("a");
	for(i=0; i<imgAnchor.length; i++) {
		if (imgAnchor.item(i).className == imgClassName)
			thismenu = imgAnchor.item(i);
		else 
			continue;
		thismenu.container = imgContainer;
		thismenu.targetEl = document.getElementById("mainimg");
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = thismenu.onmouseover = thismenu.onfocus = function imgMenuClick() {
			if (imgContainer.current != this) {
				imgContainer.current.className = imgContainer.current.className.replace("_over", "");
			}				
			imgContainer.current = this;
			currentmenu = this.imgEl;

			this.className += (this.className.toString().indexOf("_over") > 0 ? "" : "_over");
			if (currentmenu) {
				var imgSrc = currentmenu.src.split("/");
				this.targetEl.getElementsByTagName("img").item(0).src = currentmenu.src.replace(imgSrc[imgSrc.length - 1], imgSrc[imgSrc.length - 1].replace("_t", "_p","_preview"));
			}
			return true;
		};
		
		
		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (imgContainer.first) {
		imgContainer.current = imgContainer.first;
		imgContainer.current.onclick();
	}
}


function initImgMenu2(imgContainerID, imgClassName){
	var imgContainer = document.getElementById(imgContainerID);
	var imgAnchor = imgContainer.getElementsByTagName("a");

	for(i=0; i<imgAnchor.length; i++) {
		if (imgAnchor.item(i).className == imgClassName)
			thismenu = imgAnchor.item(i);
		else 
			continue;

		thismenu.container = imgContainer;
		thismenu.targetEl = document.getElementById("mainimg");
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);

		thismenu.onclick = thismenu.onmouseover = thismenu.onfocus = function imgMenuClick() {

			if (imgContainer.current != this) {
				imgContainer.current.className = imgContainer.current.className.replace("_over", "");
			}				

			imgContainer.current = this;
			currentmenu = this.imgEl;


			this.className += (this.className.toString().indexOf("_over") > 0 ? "" : "_over");
			if (currentmenu) {
				var imgSrc = currentmenu.src.split("/");
				this.targetEl.getElementsByTagName("img").item(0).src = currentmenu.src.replace(imgSrc[imgSrc], imgSrc[imgSrc]);

			}
			return true;

		};
		
		
		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}

	if (imgContainer.first) {
		imgContainer.current = imgContainer.first;
		imgContainer.current.onclick();
	}
}

function initImgMenu_pre(imgContainerID, imgClassName){
	var imgContainer = document.getElementById(imgContainerID);
	var imgAnchor = imgContainer.getElementsByTagName("a");

	for(i=0; i<imgAnchor.length; i++) {
		if (imgAnchor.item(i).className == imgClassName)
			thismenu = imgAnchor.item(i);
		else 
			continue;

		thismenu.container = imgContainer;
		thismenu.targetEl = document.getElementById("mainimg");
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);

		thismenu.onclick = thismenu.onmouseover = thismenu.onfocus = function imgMenuClick() {

			if (imgContainer.current != this) {
				imgContainer.current.className = imgContainer.current.className.replace("_over", "");
			}				

			imgContainer.current = this;
			currentmenu = this.imgEl;


			this.className += (this.className.toString().indexOf("_over") > 0 ? "" : "_over");
			if (currentmenu) {
				var imgSrc = currentmenu.src.split("/");
				this.targetEl.getElementsByTagName("img").item(0).src = currentmenu.src.replace(imgSrc[imgSrc.length - 1], imgSrc[imgSrc.length - 1].replace("_preview", "_t"));

			}
			return true;

		};
		
		
		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}

	if (imgContainer.first) {
		imgContainer.current = imgContainer.first;
		imgContainer.current.onclick();
	}
}


function initBtnMenu(tabContainerID, tabClassName, tabNum){
	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 == tabClassName)
			thismenu = tabAnchor.item(i);
		else
			continue;

		if(thismenu.href.split("#")[1] == "prev")
		{
			thismenu.onclick = function btnPrevClick() {
				currentmenu = tabContainer.current;
				
				_targetElId = parseInt(currentmenu.targetEl.id.replace("photo", ""), 10);
				_targetElId = (_targetElId - 1 == 0 ? 3 : (_targetElId - 1));
				_targetElId = "photo" + (_targetElId < 10 ? '0' + _targetElId : _targetElId);

				_tabAnchor = document.getElementById(tabContainerID).getElementsByTagName("a");
				for(i=0; i<_tabAnchor.length; i++) {
					
					if(tabAnchor.item(i).className == tabClassName && tabAnchor.item(i).href.indexOf(_targetElId) > 0)
					{
						tabAnchor.item(i).onclick();
					}
				}

				return false;
			};
			continue;
		}
		
		if(thismenu.href.split("#")[1] == "next")
		{
			thismenu.onclick = function btnNextClick() {
				currentmenu = tabContainer.current;
				
				_targetElId = parseInt(currentmenu.targetEl.id.replace("photo", ""), 10);
				_targetElId = (_targetElId + 1 == 4 ? 1 : (_targetElId + 1));
				_targetElId = "photo" + (_targetElId < 10 ? '0' + _targetElId : _targetElId);

				_tabAnchor = document.getElementById(tabContainerID).getElementsByTagName("a");
				for(i=0; i<_tabAnchor.length; i++) {
					
					if(tabAnchor.item(i).className == tabClassName && tabAnchor.item(i).href.indexOf(_targetElId) > 0)
					{
						tabAnchor.item(i).onclick();
					}
				}

				return false;
			};
			continue;
		}


		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		
		thismenu.onclick = thismenu.onmouseover = thismenu.onfocus = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				currentmenu.className = currentmenu.className.replace("_over", "");				
			}
			this.targetEl.style.display = "";
			this.className += "_over";
			
			this.container.current = this;

			return false;
		};	

		if (tabNum != null && i + 1 == tabNum)
			thismenu.container.first = thismenu;
		else if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

//min-height
function min_height(obj,h){
	if(obj.readyState != "complete") return "auto";
	if(obj.offsetHeight<h){
		obj.style.height="0";
		obj.style.height=h+"px";
	}
}

function display_change(tn,n,t) {
	for (i=1; i<=t; i++) {
		if (i==n) document.getElementById(tn+i).style.display='block';
		else document.getElementById(tn+i).style.display='none';
	}
}


function LayerOpens(layerID,n){
	var Layer = document.getElementById(layerID);
	var Layer2 = document.getElementById("u"+layerID);

		if(Layer.style.display == 'block') {
			Layer.style.display = 'none';
			Layer2.className="plus";
		}
		else {
			Layer.style.display = 'block';
			Layer2.className="minus";
		}
}


//------------------han ----------------------------------------------------------------------
/* onload function */
function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

// tab 3
function tabChangeFunc(t,showElement,hideElement){
	var gParent = t.parentNode;
	var gGrand = gParent.parentNode;
	var gGrandLI = gGrand.getElementsByTagName("li");
	
	var showElement = document.getElementById(showElement);
	for(var i=0; i<gGrandLI.length; i++){
		gGrandLI[i].className = "tabOff";
		gGrandLI[i].style.marginLeft = "-1px";
	}

	var str = hideElement.split(",");
	for(var i=0; i<str.length; i++){
		document.getElementById(str[i]).style.display = "none";
	}

	gParent.className = "tabOn";
	gGrandLI[0].style.marginLeft = "0";
	showElement.style.display = "block";
}


function srhResultExtendFunc(flag){
	if(!document.getElementById("srhResultList")) return false;
	var gId = document.getElementById("srhResultList");
	var gIdLi = gId.getElementsByTagName("li")
	var gImgOn = document.getElementById("extendImgOn");
	var gImgOff = document.getElementById("extendImgOff");

	if(flag == "open"){
		for(var i=0; i<gIdLi.length; i++){
			gIdLi[i].style.display = "list-item";
		}
		gImgOn.style.display = "none";
		gImgOff.style.display = "block";
	} else {
		for(var i=0; i<gIdLi.length; i++){
			if(i>7) gIdLi[i].style.display = "none";
		}
		gImgOn.style.display = "block";
		gImgOff.style.display = "none";
	}
}

window.onload = function(){
	srhResultExtendFunc('close');
}


function todayPhotoPageFunc1(flag,v){
	if(!document.getElementById("todayPhotoList")) return false;
	if(!document.getElementById("todayPhotoPageList")) return false;

	var gIdUL = document.getElementById("todayPhotoList");
	var gIdDIV = document.getElementById("todayPhotoPageList");
	var gIdLi  = gIdUL.getElementsByTagName("li");

	for(var i=0; i<gIdLi.length; i++){
		gIdLi[i].style.display = "list-item";
		if(flag == 1){
			if(i>1) gIdLi[i].style.display = "none";
		} else if(flag == 2){
			if(i<2 || i>3) gIdLi[i].style.display = "none";
		} else if(flag == 3){
			if(i<4) gIdLi[i].style.display = "none";
		}
	}

	for(var k=0; k<gIdDIV.getElementsByTagName("a").length; k++){
		gIdDIV.getElementsByTagName("a")[k].className = "";
	}
	v.className = "current";
}


var photoPageNum = 0;
function todayPhotoPageFunc2(flag){
	if(!document.getElementById("todayPhotoList")) return false;
	if(!document.getElementById("todayPhotoPageList")) return false;

	var gIdUL = document.getElementById("todayPhotoList");
	var gIdDIV = document.getElementById("todayPhotoPageList");
	var gIdLi  = gIdUL.getElementsByTagName("li");
	
	if(flag == "next" && photoPageNum<2){
		photoPageNum = photoPageNum + 1;
	} else if(flag == "prev" && photoPageNum>0){
		photoPageNum = photoPageNum - 1;
	}

	for(var i=0; i<gIdLi.length; i++){
		gIdLi[i].style.display = "list-item";
		if(photoPageNum+1 == 1){
			if(i>1) gIdLi[i].style.display = "none";
		} else if(photoPageNum+1 == 2){
			if(i<2 || i>3) gIdLi[i].style.display = "none";
		} else if(photoPageNum+1 == 3){
			if(i<4) gIdLi[i].style.display = "none";
		}
	}

	for(var k=0; k<gIdDIV.getElementsByTagName("a").length; k++){
		gIdDIV.getElementsByTagName("a")[k].className = "";
	}
	gIdDIV.getElementsByTagName("a")[photoPageNum].className = "current";
}


function change(){
	if (document.getElementById("layer01").style.display == 'none')
	{
		document.getElementById("layer01").style.display = 'block';
		document.getElementById("layer02").style.display = 'none';
	}
	else if (document.getElementById("layer01").style.display == 'block')
	{
		document.getElementById("layer02").style.display = 'block';
		document.getElementById("layer01").style.display = 'none';
	}
}


function setPng24(obj) {
	obj.width=obj.height=1;
	 obj.className=obj.className.replace(/\bpng24\b/i,'');
	obj.style.filter =
	 "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
	obj.src='';obj.src='';
	return '';
}


function Over(num) {
var max = 8;
	for(i=1;i<=max;i++){
		document.getElementById("Layer0"+i).style.display = 'none';
		document.getElementById("Btn"+i).src = eval('"/images/DownCenter/btn_install03_0'+i+'.gif"');
	}
	document.getElementById("Layer0"+num).style.display = 'block';
	document.getElementById("Btn"+num).src = eval('"/images/DownCenter/btn_install03_0'+num+'_.gif"');
	
}


function ReplyOpen(layerID,LayerID2,LayerID3){
	var Layer = document.getElementById(layerID);
	var Layer2 = document.getElementById(LayerID2);
	var Layer3 = document.getElementById(LayerID3);

		if(Layer.style.display == 'block') {
			Layer.style.display = 'none';
			Layer2.style.display='block';
			Layer3.style.display='none';
		}
		else {
			Layer.style.display = 'block';
			Layer2.style.display='none';
			Layer3.style.display='block';
		}
}

function ReWriteOpen(layerID,LayerID2){
	var Layer = document.getElementById(layerID);
	var Layer2 = document.getElementById(LayerID2);
	if(Layer.style.display == 'block') {
			Layer.style.display = 'none';
			Layer2.style.display='block';
		}
		else {
			Layer.style.display = 'block';
			Layer2.style.display='none';
		}

}

/*ActiveX 플래쉬*/
// id: flash id
// url: source url
// w: source width
// h: source height
// t: wmode (window/transparent/opaque)
function Flash(id,url,w,h,bg,t){
document.write("\
	<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width="+w+" height="+h+" id="+id+">\
	<param name='movie' value="+url+" />\
	<param name='wmode' value="+t+" />\
	<param name='bgcolor' value="+bg+" />\
	<param name='allowScriptAccess' value='always' />\
	<param name='quality' value='high' />\
	<param name='menu' value='false' />\
	<embed src="+url+" width="+w+" height="+h+" wmode="+t+" name="+id+" bgcolor="+bg+" allowScriptAccess='always' quality='high' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />\
	</object>\
");
}


function fontPlus()
{
	var getSize = $('articleTxt').getStyle('fontSize');
	var endString = '';
	var limit = 0;

	if( getSize.endsWith('pt') )
	{
		endString = 'pt';
		limit = 18.5;
	}
	else if( getSize.endsWith('px') )
	{
		endString = 'px';
		limit = 20;
	}

	var cutSize = eval(getSize.replace(endString,''))+2;

	if( cutSize <= limit )
		$('articleTxt').style.fontSize = cutSize+endString;
}

function fontMinus()
{
	var getSize = $('articleTxt').getStyle('fontSize');
	var endString = '';
	var limit = 0;

	if( getSize.endsWith('pt') )
	{
		endString = 'pt';
		limit = 8.5;
	}
	else if( getSize.endsWith('px') )
	{
		endString = 'px';
		limit = 12;
	}

	var cutSize = eval(getSize.replace(endString,''))-2;

	if( cutSize >= limit )
		$('articleTxt').style.fontSize = cutSize+endString;
}

function mylink(){
	if("none" == document.getElementById("my_link").style.display){
		document.getElementById("my_link").style.display = "";
	} else {
		document.getElementById("my_link").style.display = "none";
	}
}

function pop(url,name,w,h){ window.open(url,name,'width='+w+',height='+h+',scrollbars=no,status=1') } //Popup(scroll no)
function pops(url,name,w,h){ window.open(url,name,'width='+w+',height='+h+',scrollbars=yes') } //Popup(scroll yes)
function newwin(url){ window.open(url,'new','location=1,directories=1,resizable=1,status=1,toolbar=1,menubar=1,scrollbars=1') } //NewPopup(scroll no)

function textScroll(scroll_el_id) {
	this.objElement = document.getElementById(scroll_el_id);
	this.objElement.style.position = 'relative';
	this.objElement.style.overflow = 'hidden';

	this.objLi = this.objElement.getElementsByTagName('li');
	this.height = this.objElement.offsetHeight; 
	this.num = this.objLi.length; 
	this.totalHeight = this.height*this.num; 
	this.scrollspeed = 2;
	this.objTop = new Array(); 
	this.timer = null;
	
	for(var i=0; i<this.num; i++){
		this.objLi[i].style.position = 'absolute';
		this.objTop[i] = this.height*i;
		this.objLi[i].style.top = this.objTop[i]+"px";
	}
}

textScroll.prototype.move = function(){
	for(var i=0; i<this.num; i++) {
		this.objTop[i] = this.objTop[i] - this.scrollspeed;
		this.objLi[i].style.top = this.objTop[i]+"px";
	}
	if(this.objTop[0]%this.height == 0){
		this.jump();
	}else{
		clearTimeout(this.timer);
		this.timer = setTimeout(this.name+".move()",50);
	}
}

textScroll.prototype.jump = function(){
	for(var i=0; i<this.num; i++){
		if(this.objTop[i] == this.height*(-2)){
			this.objTop[i] = this.objTop[i] + this.totalHeight;
			this.objLi[i].style.top = this.objTop[i]+"px";
		}
	}
	clearTimeout(this.timer);
	this.timer = setTimeout(this.name+".move()",3000);
}

textScroll.prototype.start = function() {
	this.timer = setTimeout(this.name+".move()",3000);
}



function display_change2(tn,n,t) {
	for (i=1; i<t; i++) {
		var targetElOffset = "00" + i;
		targetElOffset = targetElOffset.substring(targetElOffset.length, targetElOffset.length-2)
		if (i==n) document.getElementById(tn+targetElOffset).style.display='block';
		else document.getElementById(tn+targetElOffset).style.display='none';
	}
}





function setPng24(obj) {
	obj.width=obj.height=1;
	 obj.className=obj.className.replace(/\bpng24\b/i,'');
	obj.style.filter =
	 "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
	obj.src='';obj.src='';
	return '';
}

function resizeTagCloudDivHeight( value )
{
	document.getElementById( "tagClould" ).style.height = value + "px";
}




/**
* ---------------------------------------------------------------
*	SWF 임베드
* ---------------------------------------------------------------
*
*	param
*		swf: swf 파일의 경로
*		width:	너비 ( px )
*		height: 높이 ( px )
*		bgcolor: 배경색 ( #FFFFFF )
*		id:	object 태그의 id값
*		flashvars:	SWF 파일 내부로 전달할 변수
*		trans:	투명 설정 변수( transparent ).
*		
*/
function insertFlash(swf, width, height, bgcolor, id, flashvars)
{
	insertFlashWithVersion( swf, width, height, bgcolor, id, flashvars, '9,0,124,0' );
}


function insertFlashWithVersion(swf, width, height, bgcolor, id, flashvars, verstr)
{
	var strFlashTag = new String();

	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		strFlashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		strFlashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+verstr+'" ';
		strFlashTag += 'id="' + id + '" width="' + width + '" height="' + height + '">';
		strFlashTag += '<param name="movie" value="' + swf + '"/>';

		if(flashvars != null) {strFlashTag += '<param name="flashvars" value="' + flashvars + '"/>'};
		strFlashTag += '<param name="quality" value="best"/>';
		strFlashTag += '<param name="bgcolor" value="' + bgcolor + '"/>';
		strFlashTag += '<param name="menu" value="false"/>';
		strFlashTag += '<param name="salign" value="LT"/>';
		strFlashTag += '<param name="scale" value="noscale"/>';
		strFlashTag += '<param name="wmode" value="opaque"/>';
		strFlashTag += '<param name="allowScriptAccess" value="always"/>';
		strFlashTag += '</object>';
	}
	else
	{
		strFlashTag += '<embed src="' + swf + '" ';
		strFlashTag += 'quality="best" ';
		strFlashTag += 'bgcolor="' + bgcolor + '" ';
		strFlashTag += 'width="' + width + '" ';
		strFlashTag += 'height="' + height + '" ';
		strFlashTag += 'menu="false" ';
		strFlashTag += 'scale="noscale" ';
		strFlashTag += 'id="' + id + '" ';
		strFlashTag += 'salign="LT" ';
		strFlashTag += 'wmode="opaque" ';
		strFlashTag += 'allowScriptAccess="always" ';
		if(flashvars != null) {strFlashTag += 'flashvars="' + flashvars + '" '};
		strFlashTag += 'type="application/x-shockwave-flash" ';
		strFlashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
		strFlashTag += '</embed>';
	}

	document.write(strFlashTag);
}



function cleanup() 
{
	__flash_unloadHandler = function(){
		externalProbSet = true;
		obj = document.getElementsByTagName('OBJECT');
		for (i=0;i<obj.length;i++){
			var theObj = eval(obj[i]);
			theObj.style.display = "none";

			try{	
				for (var prop in theObj){
					if (typeof(theObj[prop]) == "function"){
						theObj[prop]=null
					}
				}
			}catch( ignored ){
			
			}

		}
	}
	if (window.onunload != __flash_unloadHandler){
		__flash_savedUnloadHandler = window.onunload;
		window.onunload = __flash_unloadHandler;
	}
}
window.onbeforeunload=cleanup;

function nowDate() {
	day = new Array("&#51068;", "&#50900;", "&#54868;", "&#49688;", "&#47785;", "&#44552;", "&#53664;");
	now = new Date;
	
	document.write(now.getFullYear(),". ",now.getMonth()+1,". ",now.getDate(),"  (",day[now.getDay()],") ");
	}
	
/* 시작페이지 설정 */
function startPage(Obj,urlStr){
	if (document.all && window.external){
		Obj.style.behavior='url(#default#homepage)';
		Obj.setHomePage(urlStr);
	} else {
		
	}
}

