//--------------------------------------------------------/
// 	Æ÷Ä¿½º °ü·Ã
//--------------------------------------------------------/
function bluring(){ 
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG"||event.srcElement.tagName=="INPUT") document.body.focus(); 
} 
//document.onfocusin=bluring; 

//--------------------------------------------------------/
// 	µðÀÚÀÎ °ü·Ã
//--------------------------------------------------------/

function echo_swf(file,w,h,opt){
   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='"+file+"'>");
   document.write("<param name='quality' value='high'>");
   if(opt=="1"){document.write("<param name='wmode' value='transparent'>");}
   document.write("<embed src='"+file+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+w+"' height='"+h+"'></embed>");
   document.write("</object>");
}

function echo_dext(src,w,h){
  document.write("<object id='FileUploadManager' codebase='"+src+"' height='"+h+"' width='"+w+"' classid='CLSID:DF75BAFF-7DD5-4B83-AF5E-692067C90316' viewastext'>");
  document.write("<param name='ButtonVisible' value='TRUE' />");
  document.write("<param name='StatusBarVisible' value='FALSE' />");
  document.write("<param name='VisibleListViewFrame' value='FALSE' />");
  document.write("</object>");
}

function echo_embed(src,w,h,option){
	document.write("<embed autostart='"+option+"' src='"+src+"' width='"+w+"' height='"+h+"'>");
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// image roll
function imageOver(imgEl) {
	imgEl.src = imgEl.src.replace(".gif", "r.gif");
}
function imageOut(imgEl) {
	imgEl.src = imgEl.src.replace("r.gif", ".gif");
}

// ÇÃ·¡½Ã »ðÀÔ
function readFlash(flash_url,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+"'>\
	<param name='movie' value='"+flash_url+"'>\
	<param name='quality' value='high'>\
	<param name='wmode' value='transparent'>\
	<embed src='"+flash_url+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+w+"' height='"+h+"'></embed>\
	</object>");	
}

// µ¿¿µ»ó ¹öÆ° °ü·Ã
function OnPlay()
{
    if (MediaPlayer1.PlayState != 2) 
       {
       MediaPlayer1.Play();
       }
}
function OnStop()
{
       MediaPlayer1.Stop(); 
       MediaPlayer1.CurrentPosition=0;
}
function OnPause()
{
         if (MediaPlayer1.PlayState == 2) 
       {
       MediaPlayer1.Pause(); 
       }
}
//¿À´ÃÀÇµ¶µµ ÅÇ
function newstab(n) {
    for(var i = 1; i < 4; i++) {
        obj = document.getElementById('newstab'+i);
        img = document.getElementById('newstab_button'+i);
        if ( n == i ) {
            obj.style.display = "block";
                        img.height = 23;
            img.src = "../images/tab_todayon"+i+".gif";    
        } else {
            obj.style.display = "none";
                        img.height = 23;
            img.src = "../images/tab_today"+i+".gif";
        }
    }
}
// ¸ÞÀÎ ´º½ºÅÇ
function mainnews(n) {
    for(var i = 1; i < 4; i++) {
        obj = document.getElementById('mainnews'+i);
        img = document.getElementById('mainnews_button'+i);
        if ( n == i ) {
            obj.style.display = "block";
                        img.height = 24;
            img.src = "../images/tab_newson"+i+".gif";    
        } else {
            obj.style.display = "none";
                        img.height = 25;
            img.src = "../images/tab_news"+i+".gif";
        }
    }
}

// ½ºÄð µ¶µµ»ó½Ä
function toggle(index) {
	for(i=1;i<=40;i++) {
		if(index ==i) {
			if(eval("tg"+index+".style.display") == 'none')	{
				eval("tg"+index+".style.display='block'");
			} 
			else
			{
				eval("tg"+index+".style.display='none'");
			}
		}
		else
		{
			eval("tg"+i+".style.display='none'");
		}
	}
}
//ÇÏ´Ü ¹è³Ê½ºÅ©¸³Æ®
function move(direction, kind , speed) {
    if(kind == 1) {
        mq1.start();
    } else {
        mq2.start();
    }
    
    if(direction == 'L' || direction == 'l') {
        mq1.direction = 'left';
        mq1.scrollAmount = speed;
    }
    
    else if(direction == 'R' || direction == 'r') {
        mq1.direction = 'right';
        mq1.scrollAmount = speed;
    }
}
//»çÀÌ¹öÅ½¹æ ÆË¾÷
function newFlashPopup(theURL) { //v2.0
  window.open(theURL,'popup_cyber_cont','width=700,height=590,resizable=no,scrollbars=no,left=0,top=0');
}

// ¸¶¿ì½º ¿À¸¥ÂÊ ¹öÆ° ¾ÈµÊ
		function right_click(){
			if ((event.button==2) || (event.button==2)) {
				return false;
			}
		}
		document.onmousedown=right_click


//--------------------------------------------------------/
// 	 ÄíÅ° °Ë»ö
//--------------------------------------------------------/
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 "";
}

// ÄíÅ°¸¦ ¸¸µì´Ï´Ù. ¾Æ·¡ closeWin() ÇÔ¼ö¿¡¼­ È£ÃâµË´Ï´Ù
function setCookie( name, value, expiredays ) 
{ 
        var todayDate = new Date();
        todayDate.setDate( todayDate.getDate() + expiredays ); 
        document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
}

//--------------------------------------------------------/
// 	 ¹®ÀÚ¿­ °ü·Ã
//--------------------------------------------------------/
function trim(str){
	return str.replace(/(^\s+)|(\s+)$/,"");
}

function Replace(strOriginal, strFind, strChange){
  return strOriginal.split(strFind).join(strChange);
}

function only_number(str){
	for(i=0;i<str.value.length;i++){
		var chr=str.value.substr(i,1);
		if(",".indexOf(str.value.substr(i,1))<0){
			if(chr<'0' || chr>'9'){
				alert("¼ýÀÚ¸¸ µé¾î°¥¼ö ÀÖ½À´Ï´Ù.");
				str.value="";
				str.focus();
				return;
			}
		}
	}
}

function onlyNumeric() //¼ýÀÚ¸¸À» ±âÀÔ¹Þ°Ô ÇÏ´Â ¹æ¹ý2
{
	if((event.keyCode<48)||(event.keyCode>57))
		event.returnValue = false;
}

function isEmail(s){
  return s.search(/^\s*[\w\~\-\.]+\@[\w\~\-]+(\.[\w\~\-]+)+\s*$/g)>=0;
}

//--------------------------------------------------------/
// 	 checkbox °ü·Ã ÇÔ¼ö 
//--------------------------------------------------------/

function TableCheck(type){
	var f = document.form1;
	var i;
	var chk = 0;
	
	for(i = 0; i < f.length; i++) {
		if (f[i].type == 'checkbox')
		{
			if (type == 'check')
			{
				f[i].checked = true;
			}
			if (type == 'cancel')
			{
				f[i].checked = false;
			}
			if (type == 'reverse')
			{
				f[i].checked = !f[i].checked;
			}
			if(f[i].checked == true) {
				chk++;
			}
		}
	}
}

function getbtnque(que,str){
	var f = document.form1;
	var intLoop;
	var intLoop2;
	var chk = 0;
	var m_idx="";
	
	for( intLoop = 0; intLoop < f.length; intLoop++) {
		if (f[intLoop].type == 'checkbox'){
			if(f[intLoop].checked == true) {
				if ( chk == 0 ) {
					m_idx = m_idx+f[intLoop].value;	
				}else{
					m_idx = ","+m_idx+f[intLoop].value;
				}
				chk++;
			}
		}
	}
	
	f.unique_num.value=m_idx;
	if (!chk){
		alert('\n'+str+'ÀÌ ¼±ÅÃµÇÁö ¾Ê¾Ò½À´Ï´Ù.\n');
		return false;
	}

	switch (que){
		case "modify" :
			if (confirm('\nÁ¤¸»·Î ¼±ÅÃµÈ '+str+'ÀÇ µ¥ÀÌÅÍ¸¦ ¼öÁ¤ÇÏ½Ã°Ú½À´Ï±î?             \n')){
				f.target = "action_frame";
				f.submit();
			}
		break;

	
		case "DELETE" :
			if (confirm('\n»èÁ¦µÈ '+str+'µ¥ÀÌÅÍ´Â º¹±¸°¡ ºÒ°¡´ÉÇÕ´Ï´Ù.\n\nÁ¤¸»·Î ¼±ÅÃµÈ '+str+' µ¥ÀÌÅÍ¸¦ »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?               \n')){
				f.submit();
			}else{
				f.m_Job.value="";
				f.unique_num.value="";
			}
		break;

	}
}


//--------------------------------------------------------/
// 	 ¸ÞÀÏº¸³»±â ÇÔ¼ö ( ÀÌ¸ÞÀÏÀ» ±×³É º¸ÀÌ¸é ¾ÈµÇ¼­ º¯È¯ÇÑÈÄ ¸µÅ©°É±â ) 
//--------------------------------------------------------/
function mailto(va){
	temp=va.split("+")
	mail=""
	for(i=0;i<temp.length;i++){
		mail=mail+String.fromCharCode(parseInt(temp[i]))
	}
	location.href="mailto:"+mail
}

//--------------------------------------------------------/
// 	 »õÃ¢ ÇÔ¼ö
//--------------------------------------------------------/

function win_open(nurl,win_name,nleft,ntop,nwidth,nheight,scroll){
	if ( nwidth=='' ) nwidth= 300
	if ( nheight=='' ) nheight= 300
	if ( scroll=='' ) scroll= 'no'
	if ( nleft == '' ) nleft=((screen.availWidth/2)-parseInt(nwidth)/2)
	if ( ntop == '' ) ntop=((screen.availHeight/2)-parseInt(nheight)/2)
	window.open(nurl,win_name,'left='+nleft+',top='+ntop+',width='+nwidth+',height='+nheight+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scroll+',resizable=no');
}

//--------------------------------------------------------/
// 	Cancel,¸®¼Â  ÇÔ¼ö 
//--------------------------------------------------------/
function fnCancel(frm){
	if(confirm("´Ù½ÃÀÛ¼º ÇÏ½Ã°Ú½À´Ï±î?")){
		frm.reset();
	}
}
//--------------------------------------------------------/
// 	img resize ÇÔ¼ö
//--------------------------------------------------------/
function img_resize(str,width){
	if(width=="" || width==0 ) width=500
	if( str.width > width ) {
		var h= ( width / str.width ) * str.height;
		str.height=h;
		str.width=width;
	}
		
}


//--------------------------------------------------------/
// 	CapsLock Ã¼Å© ÇÔ¼ö ( ÂüÁ¶ ³×ÀÌ¹ö )
//--------------------------------------------------------/
function checkCapsLock(str) {
	
	var pwd = str.value.length;
	if (pwd > 0) return;
	var e = event;
	var myKeyCode=0;
	var myShiftKey=false;
	if ( document.all ) {                   // Internet Explorer 4+
		myKeyCode=e.keyCode;
		myShiftKey=e.shiftKey;
	} else if ( document.layers ) {         // Netscape 4
		myKeyCode=e.which;  
		myShiftKey=( myKeyCode == 16 ) ? true : false;
	} else if ( document.getElementById ) { // Netscape 6
		myKeyCode=e.which; 
		myShiftKey=( myKeyCode == 16 ) ? true : false;
	}
	capslockNotice();
	
	if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) {
		setCapslockInfoOn();
	} else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) {
		setCapslockInfoOn();
	}
	
}

function capslockNotice(){
	noticestr = '<img src="http://img.konetic.or.kr/konetic/web/common/capslock_fin.gif">';
	document.all.capslockNotice.innerHTML = noticestr;
}

function setCapslockInfoOn() {
	position();
	document.getElementById('CapslockInfo').style.display  = "inline";
	setTimeout("setCapslockInfoOff()", 4000);
}

function setCapslockInfoOff() {
	document.getElementById('CapslockInfo').style.display  = "none";
}

function position() {
	var o = document.getElementById("CapslockInfo");
	var ref = document.getElementById("userpwd");
	if ( typeof(o)=="object" && typeof(ref)=="object" ) {
		var x = getRealX(ref);
		var y = getRealY(ref);
		o.style.pixelLeft = x-55;
		o.style.pixelTop = y+13;
		o.style.pixelLeft = x - 55 //-6;
		o.style.pixelTop = 450  // 70 ;
	}
}

function getRealX(obj) {
	if ( obj.offsetParent == null ) return 0;
	return obj.offsetLeft + obj.clientLeft + getRealX(obj.offsetParent);
}
function getRealY(obj) {
	if ( obj.offsetParent == null ) return 0;
	return obj.offsetTop + obj.clientTop + getRealY(obj.offsetParent);
}


//--------------------------------------------------------/
//  ÀÌ¹ÌÁö Ã¼Å© ÇÔ¼ö ...
//--------------------------------------------------------/
function getFileExtension(filePath){  // ÆÄÀÏÀÇ È®ÀåÀÚ¸¦ °¡Á®¿Å
    var lastIndex = -1;
    lastIndex  = filePath.lastIndexOf('.');
    var extension = "";
    if(lastIndex != -1){
     	extension = filePath.substring( lastIndex+1, filePath.len );
    }else{
	     extension = "";
   }
   return extension;
}

function fn_ImgCheck(value,maxSize,w,h){
     var src = getFileExtension(value);
     if( src.toLowerCase() != "gif" && src.toLowerCase() != "jpg" && src.toLowerCase() != "jpeg"   ){
         return 1;
     }
	 var imgInfo = new Image();
	 imgInfo.src = value;
	 
	  var imgWidth, imgHeight, imgFileSize;
	  imgWidth   = parseInt(imgInfo.width);
	  imgHeight  = parseInt(imgInfo.height);
	  imgFileSize = Math.round(imgInfo.fileSize/1024);
	
	 if ( imgWidth > w ) {
		//return 2;  // Á¦´ë·Î ¾ÈµÊ 
	 }
	 if ( imgHeight > h ) {
		//return 3; // Á¦´ë·Î ¾ÈµÊ 
	 }
	 
	 if ( imgFileSize > maxSize ) {
		//return 4;  // Á¦´ë·Î ¾ÈµÊ 
	 }
	 
}

function imgError(){
	event.srcElement.src = "http://img.konetic.or.kr/web/konetic/web/common/bg.gif";
}

var all_img=document.all.tags("IMG")
if(all_img.length > 0){
	for(var i=0;i<all_img.length;i++)	{
		all_img[i].onerror=imgError;
	}
}


// **  °Ë»ö ·¹ÀÌ¾î 

function show_loading() {
    var loading_x = document.body.clientWidth/2 + document.body.scrollLeft + 0;
    var loading_y = document.body.clientHeight/2 + document.body.scrollTop - 50;
    progress.style.posLeft = loading_x;
    progress.style.posTop = loading_y;
    progress.style.visibility = 'visible';
	check_attack.check.value=1;
}

function hide_waiting() {
    reg_loading.style.visibility='hidden';
    check_attack.check.value=0;
}

//--------------------------------------------------------/
//  Ã·ºÎÆÄÀÏ ´Ù¿î·Îµå 
//--------------------------------------------------------/
function EUN_download(str1,str2){
	action_frame.location.href="./include/EUN_download.asp?str1="+str1+"&str2="+str2
}

function EUN_downloadEng(str1,str2){
	document.dform.action="/include/EUN_download.asp?str1="+str1+"&str2="+str2;
	document.dform.submit();
//	action_frame.location.href="/include/EUN_download.asp?str1="+str1+"&str2="+str2
//	window.reload();
}
//--------------------------------------------------------/
//  ´Þ·ÂÀü¿ë ½ºÅ©¸³Æ®
//--------------------------------------------------------/
function doBlink() {
	var blink = document.all.tags("BLINK")
		for (var i=0; i < blink.length; i++)
			blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : ""
		}
	function startBlink() {
		if (document.all)
		setInterval("doBlink()",550)
	}
	window.onload = startBlink;
	
//--------------------------------------------------------/
//  µ¶µµ¿ìÇ¥  ½ºÅ©¸³Æ®
//--------------------------------------------------------/	
 
function openPictureWindow_Fever(imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' alt='+alt+'>'); 
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}     	
 function view(x,y,z){
  newin=window.open('',y,z);
  newin.document.write("<html><head><title>:: Image View</title></head><body background='"+x+"' onclick='self.close()' style='cursor:hand'></body></html>");
 }
 
 
 function showimg(p1, p2, p3) {
	var param = "str1="+p1
	          + "&str2="+p2
	          + "&str3="+p3;
	var full_win = window.open("http://www.dokdo.re.kr/include/pop_showimg.asp?"+param, "full_image_win", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,Width=600,Height=500");
	full_win.focus();		
}