//<![CDATA[

// 새창
function openWindow(theURL,theName,theTop,theLeft,theWidth,theHeight,theScroll) { 
	window.open(theURL, theName,'top='+theTop+',left='+theLeft+',width='+theWidth+',height='+theHeight+',marginwidth=0,marginheight=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+theScroll+',resizable=no');
}

// 메일 선택
function mailChange(obj, value) {
	document.getElementById(obj).value = value;
}

// 우편번호 찾기	
function findZip(as_form, as_formZip1, as_formZip2, as_formAddr1, as_zip1, as_zip2, as_addr1) {
	eval('var openerform = window.opener.document.'+as_form);
	eval('var openerformZip1 = openerform.'+as_formZip1);
	eval('var openerformZip2 = openerform.'+as_formZip2);
	eval('var openerformAddr1 = openerform.'+as_formAddr1);
			
	openerformZip1.value  = as_zip1;
	openerformZip2.value  = as_zip2;
	openerformAddr1.value = as_addr1;	
	self.close();
}

// 메뉴 네비게이션
function initNavigation(seq) {		
	var nav = document.getElementById("topmenu");
	nav.menu = new Array();
	nav.current = null;
	nav.menuseq = 0;
	var navLen = nav.childNodes.length;
	var menuImg;
	
	var allA = nav.getElementsByTagName("a");
	for(var 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("_o.gif", ".gif");
						if (nav.current.submenu) {
							nav.current.submenu.style.display = "none";
						}
						nav.current = null;
					}
				}
			}, 900000);
		}
	}

	for (var i = 0; i < navLen; i++) {
		var navItem = nav.childNodes.item(i);
		if (navItem.tagName != "LI") {
			continue;
		}
		var 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("_o.gif", ".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(".gif", "_o.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();
	}
}

// 탭 메뉴
function initTabMenu(tabContainerID) {
	document.getElementById("news").className = "divLatest";
	document.getElementById("newsMore").className = "moreLatest";
	document.getElementById("gonggo").className = "divLatest";
	document.getElementById("gonggoMore").className = "moreLatest";
	document.getElementById("ipchal").className = "divLatest";
	document.getElementById("ipchalMore").className = "moreLatest";
	document.getElementById("gyeyak").className = "divLatest";
	document.getElementById("gyeyakMore").className = "moreLatest";
	document.getElementById("bodo").className = "divLatest";
	document.getElementById("bodoMore").className = "moreLatest";
																					
	document.getElementById("boardLatest").style.height = "140px";					
	document.getElementById("article-tab").style.height = "23px";			
	
	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") {
			var 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);
		if (thismenu.imgEl) {
			thismenu.onfocus = function () {
				this.onclick();
			}
		}
		thismenu.onclick = tabMenuClick;

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

function tabMenuClick() {
	var 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.gif", ".gif");
			}
		}

		this.targetEl.style.display = "block";
		if (this.imgEl) {
			this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
		}
		this.container.current = this;
	}
	return false;
}

// 자주찾는
function navZoneMove(navID, moveDirection) {
	var obj = document.getElementById(navID);
	for (var i=0; i<obj.childNodes.length; i++) {
		if (obj.childNodes[i].nodeType == 1) {
			var objChild = obj.childNodes.item(i);
			var objHeight = objChild.clientHeight;
			if ((parseInt(objChild.style.top) + "") == "NaN") {
				objChild.style.top = 0;
			}
			if (moveDirection == "next") {
				objChild.style.top = parseInt(objChild.style.top) - 75 + "px";
				if (("-" +  objHeight) >= parseInt(objChild.style.top)) {
					objChild.style.top = parseInt(objChild.style.top) + 75 + "px";
					alert("더 이상 이동할 수 없습니다.");
				}
			} else {
				objChild.style.top = parseInt(objChild.style.top) + 75 + "px";
				if (0 < parseInt(objChild.style.top)) {
					objChild.style.top = parseInt(objChild.style.top) - 75 + "px";
					alert("더 이상 이동할 수 없습니다.");
				}
			}
		}
	}
}

function isAccess(e) {
	var keynum;
	var ismouseClick = 1;
	
	if (window.event) {		//IE & Safari
		keynum = e.keyCode;		
		//Safari의 경우 마우스클릭은 keynum 0 이 넘어옴
		if (event.button == 0 || keynum == 0) {
			ismouseClick = 0;
		}				
	} else if ( e.which ) {		// Netscape/Firefox/Opera
		keynum = e.which;		
		if (keynum == 1) {
			ismouseClick = 0;
		}				
	}	
	//마우스 클릭이거나 엔터키를 누른경우 true값 반환
	if ( ismouseClick == 0 || keynum == 13 ) {
		return true;
	} else {
		return false;
	}
}

// 글자 확대 축소
var currentFontSize = 2;
function zoomInOut(state, e) {
	var idx;
	var arrFontSize = new Array();	
		arrFontSize[0] = "0.65em";
		arrFontSize[1] = "0.7em";
		arrFontSize[2] = "0.75em";
		arrFontSize[3] = "0.85em";
		arrFontSize[4] = "0.95em";
		arrFontSize[5] = "1em";
		arrFontSize[6] = "1.1em";
		arrFontSize[7] = "1.2em";
		arrFontSize[8] = "1.3em";
		arrFontSize[9] = "1.4em";						
	
	if (isAccess(e)) {
		if (state == "plus") {								
			if (currentFontSize < 9 ) {
				idx = currentFontSize + 1;
				currentFontSize = idx;
			}					
		} else if (state == "default") {
			idx = 2;
			currentFontSize = idx;		
		} else if (state == "minus") {						
			if ( currentFontSize >= 1) {
				idx = currentFontSize - 1;
				currentFontSize = idx;
			}	
		}		
		if ((idx >= 1) || (idx < 9)) {
			document.body.style.fontSize = arrFontSize[idx];		
		}
	}		

	return false;
}

// 컨텐츠 프린터
function jsPrintContent(e) {	
	if (isAccess(e)) {	
		var width = 700;
		var height = 600;
		var x, y;
		var screen_width = screen.width;
		var screen_height = screen.height;
		x = (screen_width  / 2) - (width  / 2);
		y = (screen_height / 2) - (height / 2);
		var pop = window.open ("/include/printView.php","print","width=" + width + ", height=" + height + ", left=" + x + ", top=" + y + ", toolbar=no, status=no, menubar=no, scrollbars=yes, resizable=yes");
		pop.focus();
	}
	return false;
}

//행정조직 및 업무 부분처리
function initOrgMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName('a');

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className.split(" ")[0] == 'tab') {
			var thismenu = tabAnchor.item(i);
		} else {
			continue;
		}

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).className.split(" ")[1]);
		thismenu.targetEl.style.display = 'none';
		if (thismenu.imgEl) {
			thismenu.onfocus = function () {
				this.onmouseover();
			}
		}
		thismenu.onmouseover = tabMenuClick1;

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

function tabMenuClick1() {
	var currentmenu = this.container.current;
	if (currentmenu != this) {
		if (currentmenu) {
			currentmenu.targetEl.style.display = 'none';
		}

		this.targetEl.style.display = 'block';
		this.container.current = this;
	}
	return false;
}

function initOrgMenu1(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName('area');
	var i = 0;
	for(i=0; i<tabAnchor.length; i++) {
		var thismenu = tabAnchor.item(i);

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).className);
		thismenu.targetEl.style.display = 'none';
		if (thismenu.imgEl) {
			thismenu.onfocus = function () {
				this.onmouseover();
			}
		}
		thismenu.onmouseover = tabMenuClick1;	
		thismenu.onfocus = tabMenuClick1;

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


/*********************************************************************
*	쿠키관련 
*********************************************************************/
// SETCOOKIE
function setCookie(name,value,expiredays) {
	var todayDate = new Date();
	todayDate.setDate(todayDate.getDate() + expiredays);
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

// GETCOOKIE
function getCookie(name) {
	var nameOfCookie = name + "=";
	var x = 0;
	while (x <= document.cookie.length) {
		var y = (x+nameOfCookie.length);
		if (document.cookie.substring( x, y ) == nameOfCookie) {
			if ((endOfCookie=document.cookie.indexOf(";",y)) == -1) {
				endOfCookie = document.cookie.length;
			}
			return unescape(document.cookie.substring(y,endOfCookie));
		}

		x = document.cookie.indexOf(" ",x) + 1;
		if (x == 0) {
			break;
		}
	}
	return "";
}
//회원가입
function hiddenTypeName(type){

	if(type=="1"){ 
		type1.style.display="block";
		type2.style.display="none";
		type1img.setAttribute("src", "/upload/images/common/tap1_on.gif")
		type2img.setAttribute("src", "/upload/images/common/tap2_off.gif")
	}else {
		type2.style.display="block";
		type1.style.display="none";
		type1img.setAttribute("src", "/upload/images/common/tap1_off.gif")
		type2img.setAttribute("src", "/upload/images/common/tap2_on.gif")
	}
	return false;
}

//]]>

