﻿//GNB
function imgMenuOver(containderID) {
	var objwrap = document.getElementById(containderID);
	var imgMenu = objwrap.getElementsByTagName("IMG");
	for (i=0; i<imgMenu.length; i++) {
		if (imgMenu[i].src.indexOf("_on.gif") != -1 || imgMenu[i].parentNode.tagName !="A") {
			continue;
		}
		imgMenu[i].onmouseover = function() {
			this.src = this.src.replace ("_off.gif","_on.gif");
		}
		imgMenu[i].onmouseout = function() {
			this.src = this.src.replace ("_on.gif","_off.gif");
		}
	}
}
function menuD2block(id) {
	for(num=1; num<=7; num++) document.getElementById('D2MG'+num).style.display='none';
		document.getElementById(id).style.display='block';
}

//GNB
function childMenuOver(containderID) {
	var objwrap = document.getElementById(containderID);
	var imgMenu = objwrap.getElementsByTagName("IMG");
	for (i=0; i<imgMenu.length; i++) {
		if (imgMenu[i].src.indexOf("_on.gif") != -1 || imgMenu[i].parentNode.tagName !="A") {
			continue;
		}
		imgMenu[i].onmouseover = function() {
			this.src = this.src.replace (".gif","_on.gif");
		}
		imgMenu[i].onmouseout = function() {
			this.src = this.src.replace ("_on.gif",".gif");
		}
	}
}

// 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;

		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 = 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(".gif", "_on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

// quick
function initMoving(target, position, topLimit, btmLimit) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = position;
	obj.topLimit = topLimit;
	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;

	if (typeof(window.pageYOffset) == "number") {
		obj.getTop = function() {
			return window.pageYOffset;
		}
	} else if (typeof(document.documentElement.scrollTop) == "number") {
		obj.getTop = function() {
			return document.documentElement.scrollTop;
		}
	} else {
		obj.getTop = function() {
			return 0;
		}
	}

	if (self.innerHeight) {
		obj.getHeight = function() {
			return self.innerHeight;
		}
	} else if(document.documentElement.clientHeight) {
		obj.getHeight = function() {
			return document.documentElement.clientHeight;
		}
	} else {
		obj.getHeight = function() {
			return 500;
		}
	}

	obj.move = setInterval(function() {
		if (obj.initTop > 0) {
			pos = obj.getTop() + obj.initTop;
		} else {
			pos = obj.getTop() + obj.getHeight() + obj.initTop;
			//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		}

		if (pos > obj.bottomLimit)
			pos = obj.bottomLimit;
		if (pos < obj.topLimit)
			pos = obj.topLimit;

		interval = obj.top - pos;
		obj.top = obj.top - interval / 3;
		obj.style.top = obj.top + "px";
	}, 30)
}

// input value
function inputValue(obj,value) {
	var inputEl = document.getElementById(obj);
	inputEl.setAttribute("value",value);
	inputEl.onfocus = function() {
		if(this.getAttribute("value") == value) {
			this.setAttribute("value","");
		} else {
			return false;
		}
	}

	inputEl.onblur = function() {
		if(this.getAttribute("value") == "") {
			this.setAttribute("value",value);
		} else {
			return false;
		}
	}
}
