//<![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 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;
	}
}


// 탭 메뉴
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") {
			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("_o.gif", ".gif");
			}
		}

		this.targetEl.style.display = "block";
		if (this.imgEl) {
			this.imgEl.src = this.imgEl.src.replace(".gif", "_o.gif");
		}
		this.container.current = this;
	}
	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 (gs_mainDirtory + "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;
}

//]]>
