// gnbMenu
function initNavigation(seq) {
	nav = document.getElementById("gnbMenu");
	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);
						menuImg.src = menuImg.src.replace("_on.gif", "_off.gif");
						if (nav.current.submenu)
							nav.current.submenu.style.display = "none";
						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("ul").item(0);
		
		navAnchor.onmouseover = navAnchor.onfocus = function () {
			if (nav.current) {
				menuImg = nav.current.childNodes.item(0);
				menuImg.src = menuImg.src.replace("_on.gif", "_off.gif");
				if (nav.current.submenu)
					nav.current.submenu.style.display = "none";
				nav.current = null;
			}
			if (nav.current != this) {
				menuImg = this.childNodes.item(0);
				menuImg.src = menuImg.src.replace("_off.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();
}

/*	±ÛÀÚÈ®´ëÃà¼Ò */	
	var currentFontSize = 1;
	function zoomUtil(state, e){
		var idx;
		var arrFontSize = new Array();
	
		arrFontSize[0] = "65%";
		arrFontSize[1] = "100%";
		arrFontSize[2] = "110%";
		arrFontSize[3] = "120%";
		arrFontSize[4] = "130%";
		arrFontSize[5] = "140%";
		arrFontSize[6] = "150%";
		
		var e = e || window.event;
		if (e) {
			if (state == "plus") {		
				if (currentFontSize < 6 ) {
					idx = currentFontSize + 1;
					currentFontSize = idx;
				}else{
					idx = 6;
					currentFontSize = idx;
					alert("´õÀÌ»ó ´Ã¸± ¼ö ¾ø½À´Ï´Ù.");
				}			
			} else if (state == "default") {
				idx = 1;
				currentFontSize = idx;
			} else if (state == "minus") {			
				if ( currentFontSize >= 1) {
					idx = currentFontSize - 1;
					currentFontSize = idx;
				}else{
					idx = 0;
					currentFontSize = idx;
					alert("´õÀÌ»ó ÁÙÀÏ ¼ö ¾ø½À´Ï´Ù.");
				}
			}		
		}
		document.body.style.fontSize = arrFontSize[idx];
		return false;
	}

/* ÆË¾÷ ¶Ù¿ì±â */
function openWin(url,win,s)
{	
	var win1=null;
	win1 = window.open(url, win ,'resizable=no, toolbar=no, scrollbars='+s+', menubar=no, top=30, left=30').focus();
}

function PopupAutoResize() {
    window.resizeTo(100, 100);
    var thisX = parseInt(document.body.clientWidth);
    var thisY = parseInt(document.body.clientHeight);
    var maxThisX = screen.width - 50;
    var maxThisY = screen.height - 50;
    var marginY = 0;
    //alert(thisX + "===" + thisY);
    //alert("ÀÓ½Ã ºê¶ó¿ìÀú È®ÀÎ : " + navigator.userAgent);
    // ºê¶ó¿ìÀúº° ³ôÀÌ Á¶Àý. 
    if (navigator.userAgent.indexOf("MSIE 6") > 0) marginY = 35;        // IE 6.x
    else if(navigator.userAgent.indexOf("MSIE 7") > 0) marginY = 80;    // IE 7.x
    else if(navigator.userAgent.indexOf("Firefox") > 0) marginY = 83;   // FF
    else if(navigator.userAgent.indexOf("Opera") > 0) marginY = 30;     // Opera
    else if(navigator.userAgent.indexOf("Netscape") > 0) marginY = -2;  // Netscape

    if (thisX > maxThisX) {
        window.document.body.scroll = "yes";
        thisX = maxThisX;
    }
    if (thisY > maxThisY - marginY) {
        window.document.body.scroll = "yes";
        thisX += 19;
        thisY = maxThisY - marginY;
    }
    window.resizeTo(thisX+10, thisY+marginY);
	 // ¼¾ÅÍ Á¤·Ä
    // var windowX = (screen.width - (thisX+10))/2;
    // var windowY = (screen.height - (thisY+marginY))/2 - 20;
    // window.moveTo(windowX,windowY);

}


/* quick menu */
function Floating(FloatingObj,MarginX,MarginY,Percentage,setTime) {
	this.FloatingObj = FloatingObj;
	this.MarginX = (MarginX) ? MarginX : 0;
	this.MarginY = (MarginY) ? MarginY : 0;
	this.Percentage = (Percentage) ? Percentage : 20;
	this.setTime = (setTime) ? setTime : 10;
	this.FloatingObj.style.position = "absolute";
	this.Body = null;
	this.setTimeOut = null;
	this.Run();
}

Floating.prototype.Run = function () {
	if ((document.documentElement.scrollLeft + document.documentElement.scrollTop) > (document.body.scrollLeft + document.body.scrollTop)) {
		this.Body = document.documentElement;
	} else {
		this.Body = document.body;
	}

	var This = this;
	var FloatingObjLeft = (this.FloatingObj.style.left) ? parseInt(this.FloatingObj.style.left,10) : this.FloatingObj.offsetLeft;
	var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
	var DocLeft = this.Body.scrollLeft + this.MarginX;
	var DocTop = this.Body.scrollTop + this.MarginY;

	var MoveX = Math.abs(FloatingObjLeft - DocLeft);
	MoveX = Math.ceil(MoveX / this.Percentage);
	var MoveY = Math.abs(FloatingObjTop - DocTop);
	MoveY = Math.ceil(MoveY / this.Percentage);

	if (FloatingObjLeft < DocLeft) {
		this.FloatingObj.style.left = FloatingObjLeft + MoveX + "px";
	} else {
		this.FloatingObj.style.left = FloatingObjLeft - MoveX + "px";
	}

	if (FloatingObjTop < DocTop) {
		this.FloatingObj.style.top = FloatingObjTop + MoveY + "px";
	} else {
		this.FloatingObj.style.top = FloatingObjTop - MoveY + "px";
	}

	window.clearTimeout(this.setTimeOut);
	this.setTimeOut = window.setTimeout(function () { This.Run(); },this.setTime);
}

/* ¾ÆÀÌÇÁ·¹ÀÓ */
function resizeFrame(frm) {
		frm.style.height = "auto";
		contentHeight = frm.contentWindow.document.documentElement.scrollHeight;
		frm.style.height = contentHeight + 4 + "px";
	}


/* img over */
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("_on.gif") != -1 ) {
			continue;
		}
		imgMenu[i].onmouseover = function() {
			subImage = this.getElementsByTagName("img")[0];
			if (subImage.src.indexOf("_on.gif") != -1) return false;
			subImage.src = subImage.src.replace("_off.gif","_on.gif");
		}
		imgMenu[i].onfocus = function() {
			subImage = this.getElementsByTagName("img")[0];
			if (subImage.src.indexOf("_over.gif") != -1) return false;
			subImage.src = subImage.src.replace("_off.gif","_on.gif");
		}
		imgMenu[i].onmouseout = function() {
			subImage = this.getElementsByTagName("img")[0];
			subImage.src = subImage.src.replace("_on.gif", "_off.gif");
		}
		imgMenu[i].onblur = function() {
			subImage = this.getElementsByTagName("img")[0];
			subImage.src = subImage.src.replace("_on.gif", "_off.gif");
		}
	}
}
