﻿//다중 레이어 변환
function layerChange(show,hide){
	for(var i in show) document.getElementById(show[i]).style.display='block';
	for(var i in hide) document.getElementById(hide[i]).style.display='none';
}

//ie 이미지 레이블
function label(inputid){
	var input=document.getElementById(inputid);
	if(input){if(input.tagName.toLowerCase()=='input' || input.tagName.toLowerCase()=='textarea' || input.tagName.toLowerCase()=='select') input.focus();}
}

//이미지 변환
function imgchange(imgobj){
	if(imgobj.src.indexOf('on.gif')==-1){
		imgobj.src=imgobj.src.replace('.gif','on.gif');
		imgobj.onmouseout=function(){if(this.src.indexOf('on.gif')!=-1) this.src=this.src.replace('on.gif','.gif');}
	}
}

//이미지 변환 
function imgchange2(imgid){
	var imgobj=document.getElementById(imgid);	
	if(imgobj.src.indexOf('on.gif')==-1){
		imgobj.src=imgobj.src.replace('.gif','on.gif');
		imgobj.onmouseout=function(){if(this.src.indexOf('on.gif')!=-1) this.src=this.src.replace('on.gif','.gif');}
	}
}

//이미지 변환 
function imgchangeout(imgid){
	var imgobj=document.getElementById(imgid);	
	if(imgobj.src.indexOf('on.gif')!=-1){
		imgobj.src=imgobj.src.replace('on.gif','.gif');
	}
}

//팝업
function popup(url,w,h,scroll,resize){
	var scroll=(!scroll)? 'no' : 'yes';
	var resize=(!resize)? 'no' : 'yes';
	var winl=(screen.width-w)/2;
	var wint=((screen.height-h)/2)-30;
	var winnameset=url.split('/');
	var winname=winnameset[winnameset.length-1].split('.')[0];
	window.open(url,winname,'width='+w+',height='+h+',top='+wint+',left='+winl+',resizable='+resize+',scrollbars='+scroll+',toolbars=no,status=yes,menu=no');
}

//스크롤메뉴
function scrollMenu(objid,starttop,bottommargin){
	var obj=document.getElementById(objid);	
	var ntop,maxtop,speed=10;
	var move=function(){
		ntop=starttop+document.body.scrollTop;
		maxtop=document.body.scrollHeight-(bottommargin+obj.offsetHeight);
		if(maxtop<ntop) ntop=maxtop;
		ntop=(quickallowedtomove) ? ntop : starttop;
		movevalue=Math.floor((ntop-obj.offsetTop)/speed);
		obj.style.top=(obj.offsetTop+movevalue)+'px';
		setTimeout(move,10);
	}
	move();
}

//클래스 변경
function overclass(obj,offclass){
	obj.className='over';
	obj.onmouseout=function(){
		if(!offclass){
			this.className='';
		}else{
			this.className=offclass;
		}
	}
}

//레이어 숨김
function hide(objid){
	document.getElementById(objid).style.display='none';
}

//레이어 온오프
function showorhide(objid){
	var obj=document.getElementById(objid);
	obj.style.display=(obj.style.display=='none')? 'block' : 'none';
}

//faq 만들기
function makefaqstyle(objid){
	var childs=document.getElementById(objid).childNodes;
	var titleobj,findclose,childnum=1;
	for(var i=0,childslen=childs.length; i<childslen; i++){
		if(childs[i].nodeType==1){
			if((childnum%2)==0){
				titleobj.innerHTML='<a href="#" onclick="showorhide(\''+childs[i].id+'\');return false;" title="내용열기" style="cursor:pointer;">'+titleobj.innerHTML+'</a>';
				findclose=childs[i].getElementsByTagName('div');
				for(var j=0,fclen=findclose.length; j<fclen; j++){
					if(findclose[j].className=='close'){
						findclose[j].style.display='block';
						findclose[j].innerHTML='<a href="#" onclick="showorhide(\''+childs[i].id+'\');return false;">'+findclose[j].innerHTML+'</a>';
					}
				}
			}else{
				titleobj=childs[i];
			}
			childnum++;
		}
	}
}

/* 탭 만들기 */
function maketab(objid, nIndex){
	var obj=document.getElementById(objid);
	var tabs=obj.childNodes[0].childNodes;
	var tabschild,temp,ntabshtml='';

	if(nIndex == null) {
		nIndex = 0;
	}

	for(var i = 0, x = 0; i < tabs.length; i++){
		if(tabs[i].nodeType==1) {
			tabschild=tabs[i].childNodes;

			for(var j = 0; j < tabschild.length; j++){
				if(tabschild[j].nodeType==1){
					if(tabschild[j].className=='tab'){
						tabschild[j].getElementsByTagName('img')[0].onmouseover=function(){tabchange(this,objid)};
						tabschild[j].getElementsByTagName('img')[0].onfocus=function(){tabchange(this,objid)};

						if(x == nIndex){
							ntabshtml+=tabschild[j].innerHTML.replace('&nbsp;','');
						}else{
							temp=tabschild[j].innerHTML.replace('&nbsp;','');
							ntabshtml+=temp.replace('on.gif','.gif');
						}

						tabs[i].removeChild(tabschild[j]);
					}
				}
			}

			x++;
		}
	}

	if(navigator.userAgent.toLowerCase().indexOf('msie')!=-1) ntab=document.createElement('<div class="tab">');
	else{
		ntab=document.createElement('div');
		ntab.setAttribute('class','tab');
	}
	ntab.innerHTML=ntabshtml;

	obj.insertBefore(ntab,obj.childNodes[0]);
	var imgs=ntab.getElementsByTagName('img');
	for(var i=0; i<imgs.length; i++){
		imgs[i].onmouseover=function(){tabchange(this,objid)}
	}
}

function maketab1(objid, nIndex){
	var obj=document.getElementById(objid);
	var tabs=obj.childNodes[0].childNodes;
	var tabschild,temp,ntabshtml='';

	for(var i = 0, x = 0; i < tabs.length; i++){
		if(tabs[i].nodeType==1) {
			tabschild=tabs[i].childNodes;

			for(var j = 0; j < tabschild.length; j++){
				if(tabschild[j].nodeType==1){
					if(tabschild[j].className=='tab'){
						tabschild[j].getElementsByTagName('img')[0].onfocus=function(){tabchange(this,objid)};

						if(x == nIndex){
							ntabshtml+=tabschild[j].innerHTML.replace('&nbsp;','');
						}else{
							temp=tabschild[j].innerHTML.replace('&nbsp;','');
							ntabshtml+=temp.replace('on.gif','.gif');
						}

						tabs[i].removeChild(tabschild[j]);
					}
				}
			}

			x++;
		}
	}
	
	if(navigator.userAgent.toLowerCase().indexOf('msie')!=-1) ntab=document.createElement('<div class="tab">');
	else{
		ntab=document.createElement('div');
		ntab.setAttribute('class','tab');
	}
	ntab.innerHTML=ntabshtml;

	obj.insertBefore(ntab,obj.childNodes[0]);
	var imgs=ntab.getElementsByTagName('img');

	for(var i=0; i<imgs.length; i++){
		imgs[i].onfocus=function(){tabchange(this,objid)};
		imgs[i].onmouseover=function(){tabchange(this,objid)};
	}
}

/* 탭 변환 */
function tabchange(img,divid){
	var tabarea=img.parentNode.parentNode;
	var imgs=tabarea.getElementsByTagName('img');
	var obj;

	for(var i=0; i<imgs.length; i++){
		obj=eval(document.getElementById(divid+(i+1)));

		if(imgs[i].src.indexOf('on.gif')!=-1) imgs[i].src=imgs[i].src.replace('on.gif','.gif');
		if(obj) obj.style.display='none';
	}

	for(var i=0; i<imgs.length; i++){
		obj=eval(document.getElementById(divid+(i+1)));
		if(img==imgs[i]){
			if(img.src.indexOf('on.gif')==-1) img.src=img.src.replace('.gif','on.gif');
			if(obj) obj.style.display='';

		}
	}
}

var oldObj = "";
var oldImgObj = "";
function newsntvTabChange(name, objid){
	var obj = document.getElementById(name);
	var imgObj = document.getElementById(objid);
	if(oldObj == ""){
		oldObj = document.getElementById('newsntv1');
		oldImgObj = document.getElementById('m_tab01_01');
	}
	if(obj != oldObj){
		oldImgObj.src = oldImgObj.src.replace('on.gif', '.gif');
		imgObj.src = imgObj.src.replace('.gif', 'on.gif');
		oldObj.style.display = "none";
		obj.style.display = "block";
		oldObj = obj;
		oldImgObj = imgObj;
	}
}

var oldObj2 = "";
var oldImgObj2 = "";
function noticeTabChange(name, objid){
	var obj = document.getElementById(name);
	var imgObj = document.getElementById(objid);
	
	if(oldObj2 == ""){
		oldObj2 = document.getElementById('noticendata1');
		oldImgObj2 = document.getElementById('tab02_01');
	}
	if(obj != oldObj2){
		oldImgObj2.src = oldImgObj2.src.replace('on.gif', '.gif');
		imgObj.src = imgObj.src.replace('.gif', 'on.gif');
		oldObj2.style.display = "none";
		obj.style.display = "block";
		oldObj2 = obj;
		oldImgObj2 = imgObj;
	}
}

//rewritehtml for flash movie
function rewriteflash(obj,url,w,h,t,bg,usedefaultimg,usebase){
	if(navigator.userAgent.toLowerCase().indexOf('msie')==-1){
		obj.innerHTML=obj.innerHTML;
	}else{
		if(!t) var t='transparent'; if(!bg) var bg='none';
		var innerhtml='<object type="application/x-shockwave-flash" width='+w+' height='+h+'>';
		innerhtml+='<param name="movie" value='+url+' /><param name="wmode" value='+t+' /><param name="bgcolor" value='+bg+' />';
		innerhtml+='<param name="allowScriptAccess" value="sameDomain" /><param name="quality" value="high" /><param name="menu" value="false" />';
		if(usebase) innerhtml+='<param name="base" value=".">';
		if(usedefaultimg) innerhtml+='<p><img src="'+url.replace('.swf','.gif')+'" alt="" /></p>';
		innerhtml+='</object>';
		obj.innerHTML=innerhtml;
	}
}

//플래시출력
function getFlash(id,url,w,h,t,bg){
	if(!t) var t='transparent'; if(!bg) var bg='none';
	var flashOut='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width='+w+' height='+h+' id='+id+'>';
	flashOut+='<param name="movie" value='+url+' /><param name="wmode" value='+t+' /><param name="bgcolor" value='+bg+' />';
	flashOut+='<param name="allowScriptAccess" value="sameDomain" /><param name="quality" value="high" /><param name="menu" value="false" />';
	flashOut+='<embed src='+url+' width='+w+' height='+h+' name='+id+' wmode='+t+' bgcolor='+bg+' swLiveConnect="true" allowScriptAccess="sameDomain" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flashOut+='</object>';
	document.write(flashOut);
}

//플래시출력(base url)
function getFlashWithBase(id,url,w,h,t,bg){
	if(!t) var t='transparent'; if(!bg) var bg='none';
	var flashOut='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width='+w+' height='+h+' id='+id+'>';
	flashOut+='<param name="movie" value='+url+' /><param name="wmode" value='+t+' /><param name="bgcolor" value='+bg+' /><param name="base" value=".">';
	flashOut+='<param name="allowScriptAccess" value="sameDomain" /><param name="quality" value="high" /><param name="menu" value="false" />';
	flashOut+='<embed src='+url+' base="." width='+w+' height='+h+' name='+id+' wmode='+t+' bgcolor='+bg+' swLiveConnect="true" allowScriptAccess="sameDomain" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flashOut+='</object>';
	document.write(flashOut);
}

function sellang(hide){
	var obj=document.getElementById('sellanglayer');
	var clickobj=document.getElementById('sellangbtn');
	if(!hide){
		obj.style.top='17px';
		clickobj.onclick=function(){sellang(true);return false};
	}else{
		obj.style.top='-50px';
		clickobj.onclick=function(){sellang();return false};
	}
}

var Notice_timer;
var intervaltime = 3000;
nekr_now_pop = 0;

function showPopup() {
	var notice_width = 170;
	var notice_height = 189;

	var notice_contents = "<iframe width='" + notice_width + "' height='" + notice_height + "' frameborder='0' scrolling='no' src='/usr/popup1.html' id='nekr_pop_content0' class='popup_contents'></iframe>";
	notice_contents += "<iframe width='" + notice_width + "' height='" + notice_height + "' frameborder='0' scrolling='no' src='/usr/popup2.html' id='nekr_pop_content1' style='display:none' class='popup_contents'></iframe>";
	notice_contents += "<iframe width='" + notice_width + "' height='" + notice_height + "' frameborder='0' scrolling='no' src='/usr/popup3.html' id='nekr_pop_content2' style='display:none' class='popup_contents'></iframe>";
	notice_contents += "<iframe width='" + notice_width + "' height='" + notice_height + "' frameborder='0' scrolling='no' src='/usr/popup4.html' id='nekr_pop_content3' style='display:none' class='popup_contents'></iframe>";
	notice_contents += "<iframe width='" + notice_width + "' height='" + notice_height + "' frameborder='0' scrolling='no' src='/usr/popup5.html' id='nekr_pop_content4' style='display:none' class='popup_contents'></iframe>";
	notice_contents += "<iframe width='" + notice_width + "' height='" + notice_height + "' frameborder='0' scrolling='no' src='/usr/popup6.html' id='nekr_pop_content5' style='display:none' class='popup_contents'></iframe>";

	var notice_title = "<a href=\"javascript:nekr_popup_click('0')\" hideFocus><img src='/html/images/main/1_off.gif' border=0 align=absmiddle id='nekr_popimg0' border=0 hspace=1></a>";
	notice_title += "<a href=\"javascript:nekr_popup_click('1')\" hideFocus><img src='/html/images/main/2_on.gif' border=0 align=absmiddle id='nekr_popimg1' border=0 hspace=1></a>";
	notice_title += "<a href=\"javascript:nekr_popup_click('2')\" hideFocus><img src='/html/images/main/3_on.gif' border=0 align=absmiddle id='nekr_popimg2' border=0 hspace=1></a>";
	notice_title += "<a href=\"javascript:nekr_popup_click('3')\" hideFocus><img src='/html/images/main/4_on.gif' border=0 align=absmiddle id='nekr_popimg3' border=0 hspace=1></a>";
	notice_title += "<a href=\"javascript:nekr_popup_click('4')\" hideFocus><img src='/html/images/main/5_on.gif' border=0 align=absmiddle id='nekr_popimg4' border=0 hspace=1></a>";
	notice_title += "<a href=\"javascript:nekr_popup_click('5')\" hideFocus><img src='/html/images/main/6_on.gif' border=0 align=absmiddle id='nekr_popimg5' border=0 hspace=1></a>";

	var oNumber = document.getElementById("main_popup_no");
	oNumber.innerHTML = notice_title;

	var oConts = document.getElementById("main_popup_conts");
	oConts.innerHTML = notice_contents;
	
	Notice_timer = window.setInterval("nekr_popup_rotate()",intervaltime);
	nekr_max_pop = 6;
	nekr_rotate_stop();
}

function nekr_popup_rotate() {
	if ( nekr_now_pop < nekr_max_pop ) {
		document.getElementById("nekr_popimg"+nekr_now_pop).src='/html/images/main/' + (nekr_now_pop + 1)+'_off.gif';
		document.getElementById("nekr_pop_content"+nekr_now_pop).style.display = 'block';

		for ( i = 0 ; i < nekr_max_pop; i++ ) {
			if ( i != nekr_now_pop ) {
				document.getElementById("nekr_popimg" + i).src='/html/images/main/' + (i + 1) + '_on.gif';
				document.getElementById("nekr_pop_content"+i).style.display = 'none';
			}
		}

		nekr_now_pop++;		
	} else {
		nekr_now_pop = 0;
		nekr_popup_rotate();
	}
}

function nekr_rotate_stop() {
	if ( Notice_timer ) window.clearInterval(Notice_timer);
}

function nekr_rotate_start() {
	Notice_timer = window.setInterval("nekr_popup_rotate()",intervaltime);
}

function nekr_popup_click( va ) {
	nekr_now_pop = parseInt(va,10);
	if ( Notice_timer ) {
		nekr_rotate_stop();
		nekr_popup_rotate();
		//nekr_rotate_start();
	}
}
