var popup_waitingtime=5000;		// 멈추는 시간
var popup_num = 1;				// 초기 팝업
var popup_length = 0;			// 팝업 갯수 초기화

// 스크롤 시작
function startPopup()
{ 
	setInterval("popup_num_img();", popup_waitingtime);
}

function popup_num_img(){
	popup_length = document.getElementsByName("popup_num").length; //팝업 갯수 가져옴
	
	if(popup_num == popup_length) popup_num = 1;
	else popup_num++;
	
	for(var i=1 ; i <= popup_length ; i++){
		if(i == popup_num){
			var popup_src = document.getElementById('popup_num'+(i)).src;
			if(popup_src.indexOf("_on")<0){
				document.getElementById('popup_num'+(i)).src = document.getElementById('popup_num'+(i)).src.replace('.gif','_on.gif');
				document.getElementById('popup_layer'+(i)).style.display = "block";
			}
			
		}else{	
			document.getElementById('popup_num'+(i)).src = document.getElementById('popup_num'+(i)).src.replace('_on.gif','.gif');
			document.getElementById('popup_layer'+(i)).style.display = "none"; 
		}
	} 
}
 
function popup(num){
	popup_num = num-1;   
	popup_num_img();
}

var initBody 
function beforePrint() 
{ 
 initBody = document.body.innerHTML; 
 document.body.innerHTML = subContent.innerHTML; 
} 

function afterPrint() 
{ 
 document.body.innerHTML = initBody; 
} 

function printArea() 
{ 
 window.print(); 
} 

window.onbeforeprint = beforePrint; 
window.onafterprint = afterPrint; 


// Top Menu
function initNavigation(seq) {
	var nav = document.getElementById("topmenu");
	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( seq != 0)
						this.current.parentNode.className = this.current.parentNode.className.replace(" over","");						
						if (nav.current.submenu){						
							nav.current.submenu.style.display = "none";
						}
						nav.current = null;					
					}
				}
			}, 1000);
		}
	}

	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(seq !=0)
				nav.current.parentNode.className = nav.current.parentNode.className.replace(" over","");
				if (nav.current.submenu){
					nav.current.submenu.style.display = "none";
				}
				nav.current = null;
			}
			
			if (nav.current != this) {
				if( seq != 0)
				this.submenu.parentNode.className +=" over";
				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] != ""){
		nav.menu[seq].onmouseover();
	}
}

// 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")
			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.onfocus();
			}
		}
		thismenu.onclick = tabMenuOver;
		
		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	tabContainer.first.onclick();
}
function tabMenuOver() {
	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");
				currentmenu.className = currentmenu.className.replace(" on", "");
			} else {
				currentmenu.className = currentmenu.className.replace(" on", "");
			}
		}

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

// Tab Content02
function initTabMenu02(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.onfocus();
			}
		}
		thismenu.onmouseover = thismenu.onfocus = tabMenuOver;
		
		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	tabContainer.first.onmouseover();
}

//목록상자바로가기
function goSelect(form,target) {
	var myindex=form.selectedIndex
	myUri = form.options[myindex].value;
	if(myUri!="") { window.open(myUri,target); }
}
