//popupzone
function popupzone(num) {
	var d=document;
	for ( i=1 ; d.getElementById("popupzone_btn_0"+i) ; i++ ) {
		var dimg=d.getElementById("popupzone_img_0"+i),dsub=d.getElementById("popupzone_btn_0"+i);
		if ( i == num ) {
			dsub.src='/images/main/info_'+i+'_on.gif';
			if ( dsub!=null ) dimg.style.left=-73;
		} else {
			dsub.src='/images/main/info_'+i+'.gif';
			if ( dsub!=null ) dimg.style.left=-3000;
		}
	}
}


var overSrc="";
function outImages(obj,ext)
{
 var img = obj.getElementsByTagName("img")[0];
 if(img.src != overSrc)
 {
  img.src = img.src.replace("_on."+ext,"."+ext);
 }
}
function overImages(obj,ext)
{  
 var img = obj.getElementsByTagName("img")[0];
 if(img.src.indexOf("_on") > 0)
 {
  overSrc = img.src;
 }else
 {
  img.src = img.src.replace("."+ext,"_on."+ext);
 }
}

/* toggle */
function showBx(id) {
	var obj = document.getElementById(id);
	if(obj) {
		if(obj.style.display == "none" || obj.style.display == "") obj.style.display = "block";
		else obj.style.display = "none";
	}
}
/* roll over-out image */
function menuOver() {
	if(this.src.substring(this.src.length-9) != "_on.gif")
		this.src = this.src.replace(".gif", "_on.gif");
}
function menuClick() {
	if(this.id.indexOf("menu-image") > -1) {
		var submenu = document.getElementById("menu" + this.id.substring(10));
		var uls = submenu.getElementsByTagName("ul");
		if(uls.length>0){
			if(uls[0].style.display == "none")
				uls[0].style.display = "block";
			else
				uls[0].style.display = "none";
		}
	}
}
function menuOut() {
	this.src = this.src.replace("_on.gif", ".gif");
}

/* Tab over,out */
function initImgEffect(ImgEls,SelImg) {
	
	MenuImg = document.getElementById(ImgEls).getElementsByTagName("img");
	MenuImgLen = MenuImg.length;

	for (i=0; i<MenuImgLen; i++) {
		MenuImg.item(i).onmouseover = menuOver;
		MenuImg.item(i).onmouseout = menuOut;
		if (i == SelImg) {
			MenuImg.item(i).onmouseover();
			MenuImg.item(i).onmouseover = null;
			MenuImg.item(i).onmouseout = null;
		}
	}
}

function selectTab(num,more) {
	var tab = document.getElementById("notice"); if(tab == null) return;
	var uls = tab.getElementsByTagName("ul"); if(uls == null) return;
	
	for(var i = 0 , k  = 0 ; i < uls.length ; i++){
		if(uls[i].id == "list") {
			if(k == num) uls[i].style.display = "block";
			else uls[i].style.display = "none";
			k++;
		}
	}
	
	var m = document.getElementById("notice_more"); if(m == null) return;
	m.href=more;
	MenuImg = document.getElementById("notice_tab").getElementsByTagName("img");
	MenuImgLen = MenuImg.length;
	for (i=0; i<MenuImgLen; i++) {
		MenuImg.item(i).onmouseover = menuOver;
		MenuImg.item(i).onmouseout = menuOut;
		if (i == num) {
			MenuImg.item(i).onmouseover();
			MenuImg.item(i).onmouseover = null;
			MenuImg.item(i).onmouseout = null;
		}
		else {
			MenuImg.item(i).onmouseout();
		}
	}
}

/* leftmenu over,out */
function initSubmenuByMenuId(depth1, depth2, depth3,depth4, menuId) {
	selectDepth1 = "menu" + depth1 + "-" + depth2;
	selectDepth2 = "menu" + depth1 + "-" + depth2 + "-" + depth3;
	selectDepth3 = "menu" + depth1 + "-" + depth2 + "-" + depth3 + "-" + depth4;
	
	nav = document.getElementById(menuId);
	if(!nav) return;
	menuEl = nav.getElementsByTagName("li");	
		
	
	for(i = 0; i < menuEl.length; i++) {
		if (menuEl.item(i).id == selectDepth1 || menuEl.item(i).id == selectDepth2  || menuEl.item(i).id == selectDepth3  ) {
			var im = menuEl.item(i).getElementsByTagName("img");
			if(im && im.length > 0 ) {
				im.item(0).src = im.item(0).src.replace(".gif", "_on.gif");
			}
			else {
				var anchor = menuEl.item(i).getElementsByTagName("a");
				anchor(0).style.fontWeight = "bold";
				anchor(0).style.textDecoration = "underline";
			}
		} else {
			var im = menuEl.item(i).getElementsByTagName("img");
			if( im == null || im.length == 0)  continue;
			im.item(0).onmouseover = menuOver;
			im.item(0).onmouseout = menuOut;
			im.item(0).onfocus = menuOver;
			im.item(0).onblur = menuOut;
			im.item(0).onclick = menuClick;
			if (menuEl.item(i).getElementsByTagName("ul").item(0)) {
				menuEl.item(i).getElementsByTagName("ul").item(0).style.display = "none";
			}
		}
	}	
	menuId = "menu" + depth1;
	initTopmenuByMenuId(depth1,depth2,depth3,depth4,menuId);
}
function initTopMenu(el,depth1) {
	topMenuOut(el.getElementsByTagName("img").item(0));
	if(el.id == "top-menu" + depth1) {
		topMenuOver(el.getElementsByTagName("img").item(0));
	}
}
function topMenuOver(img) {
	img.src = img.src.replace(".gif", "_on.gif");
}
function topMenuOut(img) {
	img.src = img.src.replace("_on.gif", ".gif");
}
function selectTopmenuByMenuId() {
	var depth1 = this.id.substring("top-menu-head".length,this.id.length);
	var menuId = "sub-menu" + depth1;		
	var selectDepth1 = "top-" + depth1 + "-1";
	var topnav = document.getElementById("navi_wrap");
	if(!topnav) return;
	var topEl = topnav.getElementsByTagName("ul");
	for(i = 0 ; i < topEl.length ; i++){
		if(topEl[i].id.substring(0,12) == "top-sub-menu") {
			topEl[i].style.display = "none";
		}
	}
	var topEl2 = topnav.getElementsByTagName("li");
	for(i = 0 , seq = 1; i < topEl2.length ; i++){
		if(topEl2[i].id.substring(0,8) == "top-menu") {
			initTopMenu(topEl2[i],depth1);
		}
		if(topEl2[i].id.substring(0,8) == "position") {
			if(depth1 == seq) topEl2[i].style.display = "block";
			else topEl2[i].style.display = "none";
			seq++;
		}
	}
	
	var nav = document.getElementById("top-" + menuId);
	if(!nav) return;
	nav.style.display = "block";
	menuEl = nav.getElementsByTagName("li");
	for(i = 0; i < menuEl.length; i++) {
		var imgEl = menuEl.item(i).getElementsByTagName("img")
		if(imgEl != null && imgEl.length>0) {
			imgEl.item(0).onmouseover = menuOver;
			imgEl.item(0).onmouseout = menuOut;
			imgEl.item(0).onfocus = menuOver;
			imgEl.item(0).onblur = menuOut;
		}
	}
}
function initTopmenuByMenuId(depth1, depth2, depth3, depth4, menuId) {
	var selectDepth1 = "top-" + depth1 + "-" + depth2;
	var selectDepth2 = "top-" + depth1 + "-" + depth2 + "-" + depth3;
	var selectDepth3 = "top-" + depth1 + "-" + depth2 + "-" + depth3 + "-" + depth4;
	var topnav = document.getElementById("navi_wrap");
	if(!topnav) return;
	var topEl = topnav.getElementsByTagName("ul");	
	for(var i = 0 ; i < topEl.length ; i++){
		if(topEl[i].id.substring(0,12) == "top-sub-menu") {
			topEl[i].style.display = "none";
		}
	}
	var topEl3 = topnav.getElementsByTagName("li");
	for(i = 0 , seq = 1; i < topEl3.length ; i++){
		if(topEl3[i].id.substring(0,8) == "position") {
			if(depth1 == seq) topEl3[i].style.display = "block";
			else topEl3[i].style.display = "none";
			seq++;
		}
	}
	
	var topEl2 = topnav.getElementsByTagName("a");
	for(i = 0 , seq = 0; i < topEl2.length ; i++){
		if(topEl2[i].id.substring(0,13) == "top-menu-head") {
			topEl2[i].onmouseover =  selectTopmenuByMenuId;
			topEl2[i].onfocus = selectTopmenuByMenuId;
			if ( seq+1 == depth1) {
				topEl2[i].onmouseover();
				topEl2[i].onfocus();
			}
			seq++;
		}
	}
	
	var nav = document.getElementById("top-" + menuId);
	if(!nav) return;
	nav.style.display = "block";
	menuEl = nav.getElementsByTagName("li");
	for(i = 0; i < menuEl.length; i++) {
		var menuElItm = menuEl.item(i);
		var imgEl = menuElItm.getElementsByTagName("img");
		if(imgEl == null || imgEl.length == 0) continue;
		var itm = imgEl.item(0);
		if (menuElItm.id == selectDepth1 || menuElItm.id == selectDepth2  || menuElItm.id == selectDepth3  ) {			
			itm.src = itm.src.replace(".gif", "_on.gif");
			itm.onmouseover = null;
			itm.onmouseout = null;
			itm.onfocus = null;
			itm.onblur = null;
		}
		else {
			itm.onmouseover = menuOver;
			itm.onmouseout = menuOut;
			itm.onfocus = menuOver;
			itm.onblur = menuOut;
		}
	}
}

/*  메인 화면 게시판 마우스 이벤트 처리 */
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.onmouseover = tabMenuClick;
		thismenu.onfocus = tabMenuClick;
		
		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onmouseover();
		tabContainer.first.onfocus();
}
function tabMenuClick() {
	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");
			} 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");
		} else {
			this.className += " on";
		}
		this.container.current = this;
	}
	return false;
}

/** 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";
	}, 40)
}

/** text-overflow:ellipsis **/
				window.onload = function() {
			
				if (!document.getBoxObjectFor || !window.openDialog) return;
			
				var sNS = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
				var xml =  document.createElementNS(sNS , 'window');
				var label = document.createElementNS(sNS, 'description');
				label.setAttribute('crop','end');
			
				xml.appendChild(label); 
			
				var fn = function(el) {
			
					var xml2 =  xml.cloneNode(true);
					var dd = document.createElement('div');
					xml2.firstChild.setAttribute('value', el.textContent);
					
					el.innerHTML = '<span class="ellipsis-phantom">' + el.innerHTML + '</span>';
					el.appendChild(xml2);
					
				};
				
				var a = document.getElementsByTagName('*');
				for(var i=0; el = a[i]; i++) {
					if (/(^|\s)ellipsis(\s|$)/.test(el.className))
						fn(el);
				};
			
			};

//IE Flicker Bug (function(){ /*Use Object Detection to detect IE6*/ var m = document.uniqueID /*IE*/ && document.compatMode /*>=IE6*/ && !window.XMLHttpRequest /*<=IE6*/ && document.execCommand ; try{ if(!!m){ m("BackgroundImageCache", false, true) /* = IE6 only */ } }catch(oh){}; })(); //png function setPng24(obj) { obj.width=obj.height=1; obj.className=obj.className.replace(/\bpng24\b/i,''); obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" obj.src=''; return ''; }

function contentPrint() { // 프린트스크립트
	var windowLeft = (screen.width-665)/2;
//	var windowTop = (screen.height-480)/2;
	var windowTop = 20;
	var printURL = "/include/printpage.html";
	 window.open(printURL,"content",'width=665, height=620, menubar=yes, scrollbars=yes,status=no,resizable=yes,top=' + windowTop + ',left=' + windowLeft + '');
}


//바로가기
function goUri(uri,target) { 
	if(uri!="") { window.open(uri,target); }
}
//목록상자바로가기
function goSelect(form,target) {
	var myindex=form.uri.selectedIndex
	myUri = form.uri.options[myindex].value;
	if(myUri!="") window.open(myUri,target);
}
//목록상자바로가기2
function goSelectAction(form,target) {
	var myUri = form.uri.value;
	if(myUri!="") { 
		form.action=myUri;
		form.target=target;
		form.submit();
	}
}


function getvodWMV7(murl,mw,mh) //WMPlayer ver7 이상
{
	(mw)? mw = mw : mw = 280;
	(mh)? mh = mh : mh = 280;
	document.writeln('<object classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=6,4,7,1112"');//IE 전용 ActiveX
	document.writeln(' id="player" width="'+ mw +'" height="'+ mh +'">');//IE : 크기를 %로 하면 마우스 오버해야 보임.
	document.writeln('<param name="url" value="'+ murl +'" /> ');
	document.writeln('<param name="autoStart" value="false" />');
	document.writeln('<param name="uiMode" value="full" />');
	document.writeln('<param name="stretchToFit" value="false" />');
	document.writeln('<param name="fullScreen" value="false" />');
	document.writeln('<!--[if !IE]>-->');//IE 조건주석문 - 없으면 IE6에서 2번 보임.
	document.writeln('<object type="video/x-ms-wmv" data="'+ murl +'" width="'+ mw +'" height="'+ mh +'">');//FF,Op,Sf 사용.. parameter 부분지원
	document.writeln('<param name="controller" value="true" />');
	document.writeln('<param name="autostart" value="false" />'); //Vista FF, Op WMP11 지원
	document.writeln('<div>동영상파일 : <a tabindex="0" href="'+ murl +'">'+ murl +'</a></div>');//대체콘텐츠
	document.writeln('</object>');
	document.writeln('<!--<![endif]-->');
	document.writeln('');//여기에 대체콘텐츠를 두면 안됨
	document.writeln('</object>');
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}


function writeFlash(fPath,w,h) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 		  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + w + '" height="' + h+ '">');
	document.write('<param name="movie" value="' + fPath+ '">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<param name="quality" value="high">');
	document.write('<embed src="' + fPath + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + w + '" height="' + h + '"></embed></object>');
}

function flash(id, width, height){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+width+'" height="'+height+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id=ShockwaveFlash1>'
+'<param name="movie" value="'+id+'">'
+'<param name="quality" value="high">'
+'<param name="wmode" value="transparent">'
+'<embed wmode="transparent" src="'+id+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash"></embed>'
+'</object>');
}


function ShowOpenWin( sName, sUrl, nLeft, nTop, nWidth, nHeight,scroll, nType){
	var CreateWin;
	if( nType == 2 || nType == 3 || nType == 4 || nType == 5 || nType == 6)
	{
		nLeft	= ( window.screen.availWidth - nWidth) / 2;
		nTop	= ( window.screen.availHeight - nHeight) / 2;
		if (nLeft < 0)	nLeft	= 0;
		if (nTop < 0)	nTop	= 0;
	}
	if( nType == 0)
		sFeatures = "left="+ nLeft +", top="+ nTop +", width="+ nWidth +", height="+ nHeight;
	else if( nType ==3)
		sFeatures = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, left="+ nLeft +", top="+ nTop +", width="+ nWidth +", height="+ nHeight;
	else if( nType ==4)
		sFeatures = "fullscreen=no,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes, left="+ nLeft +", top="+ nTop +", width="+ nWidth +", height="+ nHeight;
	else if( nType ==5)
		sFeatures = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes, left="+ nLeft +", top="+ nTop +", width="+ nWidth +", height="+ nHeight;
	else if( nType ==6)
		sFeatures = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, left="+ nLeft +", top="+ nTop +", width="+ nWidth +", height="+ nHeight;
	else if( nType ==7)
		sFeatures = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scroll+",resizable=no, left="+ nLeft +", top="+ nTop +", width="+ nWidth +", height="+ nHeight;
	else
		sFeatures = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, left="+ nLeft +", top="+ nTop +", width="+ nWidth +", height="+ nHeight;


	CreateWin = window.open( sUrl, sName, sFeatures);
}


function onSubmit(id)
{
	var select = document.getElementById(id);
	if(id != null)
	{
		if(select.selectedIndex <= 0)
		{
			alert("항목을 선택하시기 바랍니다.")
			return false;
		}else{
			/*if(select.options[select.selectedIndex].value.indexOf(":/") <0)
                    		{
				alert("알맞은 항목을 선택하시기 바랍니다.")
				return false;
			}*/
		}
	}else
	{
		alert("관련사이트 링크 항목이 없습니다.")
		return false;
	}
	return true;
}
