function bluring(){  
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="img") document.body.focus(); 
} 
document.onfocusin=bluring;

function ShowFlash(url, width, height){
        document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '" height="' + height + '" VIEWASTEXT>');
        document.write('<param name="movie" value="' + url + '">');
        document.write('<param name="quality" value="high">');
        document.write('<param name="wmode" value="transparent">');
        document.write('<param name="menu" value="false">');
        document.write('<embed src="' + url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
        document.write('</object>');
}


function june_menu(name,after)
{ 
eval(name+'.filters.blendTrans.stop();'); 
eval(name+'.filters.blendTrans.Apply();'); 
eval(name+'.src="'+after+'";'); 
eval(name+'.filters.blendTrans.Play();'); 
}

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_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_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_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 goto_byselect(sel, targetstr)
{
  var index = sel.selectedIndex;
  if (sel.options[index].value != '') {
     if (targetstr == 'blank') {
       window.open(sel.options[index].value, 'win1');
     } else {
       var frameobj;
       if (targetstr == '') targetstr = 'self';
       if ((frameobj = eval(targetstr)) != null)
         frameobj.location = sel.options[index].value;
     }
  }
}


function fn_alert(obj,mess) {
   if(mess) {
      alert(mess);
      obj.focus();
      obj.select();
   }
   return ;
}


function fn_type_id(obj,mess,nMin,nMax) {
   var nLen;
   if(nMin == "") nMin = 4;
   if(nMax == "") nMax = 10;
   if(fn_typeFormat(obj.value,'','AN') == false) {
      alert(mess+' ¿µ¹®ÀÚ¿Í ¼ýÀÚ·Î¸¸ ±¸¼ºÇÏ¼Å¾ß ÇÕ´Ï´Ù. ');
      obj.focus();
      obj.select();
      return false;
   }
   
   nLen = fn_strLength(obj);

   if(nLen < nMin || nLen > nMax) {
      alert(mess+' '+nMin+' ÀÚ ÀÌ»ó '+nMax+'ÀÚ ÀÌÇÏ·Î ±¸¼ºÇÏ¼Å¾ß ÇÕ´Ï´Ù. ');
      obj.focus();
      obj.select();
      return false;
   }

   return true;
}


function fn_type_pwd(obj,mess,nMin,nMax) {
   var nLen;
   if(nMin == "") nMin = 4;
   if(nMax == "") nMax = 10;
   if(fn_typeFormat(obj.value,'','AN') == false) {
      alert(mess+' ¿µ¹®ÀÚ¿Í ¼ýÀÚ·Î¸¸ ±¸¼ºÇÏ¼Å¾ß ÇÕ´Ï´Ù. ');
      obj.focus();
      obj.select();
      return false;
   }
   
   nLen = fn_strLength(obj);

   if(nLen < nMin || nLen > nMax) {
      alert(mess+' '+nMin+' ÀÚ ÀÌ»ó '+nMax+'ÀÚ ÀÌÇÏ·Î ±¸¼ºÇÏ¼Å¾ß ÇÕ´Ï´Ù. ');
      obj.focus();
      obj.select();
      return false;
   }

   return true;

}

function fn_type_name(obj,mess,nMin,nMax) {
   var nLen;
   if(nMin == "") nMin = 2;
   if(nMax == "") nMax = 8;

   nLen = fn_strLength(obj);

   if(nLen < (nMin*2) || nLen > (nMax*2)) {
      alert(mess+' '+nMin+' ÀÚ ÀÌ»ó '+nMax+'ÀÚ ÀÌÇÏ·Î ±¸¼ºÇÏ¼Å¾ß ÇÕ´Ï´Ù. ');
      obj.focus();
      obj.select();
      return false;
   }

   return true;

}

function fn_type_email(obj,mess) {
   if(obj.value != "") {
      if(fn_typeFormat(obj.value,'@.','AN') == false) {
         alert(mess+' Æ¯¼ö¹®ÀÚ´Â µé¾î°¥ ¼ö ¾ø½À´Ï´Ù. ');
         obj.focus();
         obj.select();
         return false;
      }
   
      if(obj.value.indexOf(".") < 0 || obj.value.indexOf("@") < 0 ) {
         alert (mess+' Çü½ÄÀÌ ¹Ù¸£Áö ¾Ê½À´Ï´Ù.\n ´Ù½Ã È®ÀÎÇÏ¿© ÁÖ½Ê½Ã¿ä. ')
         obj.focus();
         obj.select();
         return false;
      }
   }
}

function fn_type_ssno(obj1,obj2) {
   var nSum = 0;
   var nDiv = 0;
   var nComp;
   var nVal;
   var nYear;
   var inx1 = "234567";
   var inx2 = "892345";

   if(obj1.value.length != 6) {
      alert(' À¯È¿ÇÏÁö ¾ÊÀº ÁÖ¹Îµî·Ï¹øÈ£ÀÔ´Ï´Ù. \n ´Ù½Ã ÇÑ¹ø È®ÀÎÇØÁÖ¼¼¿ä. ');
      obj1.focus();
      obj1.select();
      return false;
   }

   if(obj2.value.length != 7) {
      alert(' À¯È¿ÇÏÁö ¾ÊÀº ÁÖ¹Îµî·Ï¹øÈ£ÀÔ´Ï´Ù. \n ´Ù½Ã ÇÑ¹ø È®ÀÎÇØÁÖ¼¼¿ä. ');
      obj1.focus();
      obj1.select();
      return false;
   }

   for(var i=0; i<6; i++) {   nSum += parseInt(obj1.value.charAt(i)) * parseInt(inx1.charAt(i));   }
   for(i=0; i<6; i++) {   nSum += parseInt(obj2.value.charAt(i)) * parseInt(inx2.charAt(i));   }

   nComp = parseInt(obj2.value.charAt(6));

   nDiv = (11-(nSum % 11)) % 10;

   if(nDiv == nComp) {

      nVal = parseInt(obj2.value.charAt(0));
      nYear = parseInt(obj1.value.substring(0,2));

      if((nVal != 1) && (nVal != 2) && (nVal != 3) && (nVal != 4)) {
         alert(' À¯È¿ÇÏÁö ¾ÊÀº ÁÖ¹Îµî·Ï¹øÈ£ÀÔ´Ï´Ù. \n ´Ù½Ã ÇÑ¹ø È®ÀÎÇØÁÖ¼¼¿ä. ');
         obj1.focus();
         obj1.select();
         return false;

      } else  return true;


   } else {
      alert(' À¯È¿ÇÏÁö ¾ÊÀº ÁÖ¹Îµî·Ï¹øÈ£ÀÔ´Ï´Ù. \n ´Ù½Ã ÇÑ¹ø È®ÀÎÇØÁÖ¼¼¿ä. ');
      obj1.focus();
      obj1.select();
      return false;

   }
   return true;
}

function fn_type_cono(obj) {
   var  i, nSum, nNum , ret;
   var  inx = "13713713";
   nSum = 0;
   if(obj.value.length != 10) {
      alert(" »ç¾÷ÀÚ¹øÈ£ 10ÀÚ¸®¸¦ ÀÔ·ÂÇÏ¼¼¿ä. ");
      obj1.focus();
      obj1.select();
      return false;
   }
   
   for(i=0; i<8; i++) {   nSum += parseInt(obj.value.charAt(i)) * parseInt(inx.charAt(i));   }
   nNum = parseInt(obj.value.charAt(8)) * 5;
   nSum += parseInt((nNum/10)) + (nNum%10);
   nSum = 10 - (nSum % 10);

   if( parseInt(obj.value.charAt(9)) != nSum ) {
      alert(" »ç¾÷ÀÚµî·Ï¹øÈ£¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. \n ´Ù½Ã È®ÀÎÇÏ½Ê½Ã¿À. ");
      obj.focus();
      obj.select();
      return false;
   }
}

function fn_type_year(obj,mess) {
   if((obj.value.length != 2) && (obj.value.length != 4)) {
      alert(mess+" ³â(Ò´) Ç¥±â¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. \n ´Ù½Ã È®ÀÎÇÏ½Ê½Ã¿À. ");
      obj.focus();
      obj.select();
      return false;
   }
}

function fn_type_month(obj,mess) {
   if((parseInt(obj.value) <= 0) || (parseInt(obj.value) > 12)) {
      alert(mess+" ¿ù(êÅ) Ç¥±â¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. \n ´Ù½Ã È®ÀÎÇÏ½Ê½Ã¿À. ");
      obj.focus();
      obj.select();
      return false;
   }
}

function fn_type_day(obj,nYear,nMonth,mess) {
   var dt_Month = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
   var nMonth;
   var nDay;
   
   if((parseInt(obj.value) <= 0) || (parseInt(obj.value) > 31)) {
      alert(mess+" ÀÏ(ìí) Ç¥±â¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. \n ´Ù½Ã È®ÀÎÇÏ½Ê½Ã¿À. ");
      obj.focus();
      obj.select();
      return false;
   }

   if(nYear && nMonth) {
      nMonth = parseInt(nMonth)-1;
      nDay = dt_Month[nMonth];
	  if(nMonth == 1) {
         if((nYear % 400 == 0) || ((nYear % 4 == 0) && (nYear % 100 != 0))) {
            nDay = 29; 
         } else  {
            nDay = 28;    
         } 
      }

      if(parseInt(obj.value) > nDay) {   
         alert(mess+" ÀÏ(ìí) Ç¥±â¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù. \n ÀÌ´ÞÀÇ ¸¶Áö¸· ÀÏ¼ö´Â "+nDay+" ÀÔ´Ï´Ù. \n ´Ù½Ã È®ÀÎÇÏ½Ê½Ã¿À. ");
         obj.focus();
         obj.select();
         return false;
      }
   }
}

function fn_type_img(obj) {

   sExt = fn_getExt(obj);
   if(sExt != "") {
      if((sExt != "gif") && (sExt != "jpg") && (sExt != "jpeg")) {
         alert(' ÀÌ¹ÌÁö ÆÄÀÏ¸¸ µî·Ï °¡´ÉÇÕ´Ï´Ù. \n gif, jpg, jpeg ¸¸ °¡´ÉÇÕ´Ï´Ù. ');
		 obj.focus();
		 obj.select();
         return false;
      }
   }
   return ;
}

function fn_type_imgs(obj) {

   sExt = fn_getExt(obj);
   if(sExt != "") {
      if((sExt != "gif") && (sExt != "jpg") && (sExt != "jpeg") && (sExt != "swf")) {
         alert(' ÀÌ¹ÌÁö ÆÄÀÏ¸¸ µî·Ï °¡´ÉÇÕ´Ï´Ù. \n gif, jpg, jpeg, swf ¸¸ °¡´ÉÇÕ´Ï´Ù. ');
		 obj.focus();
		 obj.select();
         return false;
      }
   }
   return ;

}

function fn_type_noupload(obj) {
   var sNoExt = ";html;htm;php;php3;phtml;inc;pl;cgi;exe;txt;asp;class;jsp;java;";
   sExt = fn_getExt(obj);
   if(sNoExt.indexOf(";"+sExt+";") != "-1") {
      alert(" ÇØ´ç ÆÄÀÏÀº Ã·ºÎ°¡ ±ÝÁöµÇ¾î ÀÖ½À´Ï´Ù.\n ¾ÐÃàÀ» ÇØ¼­ ¿Ã·ÁÁÖ¼¼¿ä.");
	  return false;
   }
   return;
}

function fn_strLength(obj) {
   var nSum = 0;
   var nLen = obj.value.length;
   var k;

   for(var i=0; i < nLen; i++) {
      k = obj.value.charCodeAt(i) ; 
      if(k >= 0 && k <= 255) nSum += 1;
      else nSum += 2;
   }
   return nSum;
}


function fn_mustNumber(obj,mess,mess2,opt,nMinLen,nMaxLen) {
   if(nMinLen == "") nMinLen = 0;
   if(nMaxLen == "") nMaxLen = 0;
   if(opt == "Y") {
      if(fn_mustText(obj,mess,nMinLen,nMaxLen) == false) return false;
   } 

   obj.value = fn_trim(obj.value);
   if(fn_typeFormat(obj.value,"","N") == false) {
      alert(mess2);
      obj.focus();
      obj.select();
      return false;
   }
}

function fn_mustText(obj,mess,nMinLen,nMaxLen) {
   obj.value = fn_trim(obj.value);
   if(nMinLen == "") nMinLen = 0;
   if(nMaxLen == "") nMaxLen = 0;
   if(obj.value == "") {
      alert(mess);
      obj.focus();
      return false;
   } else {
      if(nMinLen > 0) {
         if(obj.value.length < nMinLen) {
            alert(' ±ÛÀÚ¼ö°¡ '+nMinLen+' ÀÚ ÀÌ»óÀÌ¿©¾ß ÇÕ´Ï´Ù. ');
			obj.focus();
			return false;
         }
      }
	  if(nMaxLen > 0) {
         if(obj.value.length > nMaxLen) {
            alert(' ±ÛÀÚ¼ö°¡ '+nMaxLen+' ÀÚ ÀÌÇÏÀÌ¿©¾ß ÇÕ´Ï´Ù. ');
			obj.focus();
			return false;
         }
      }
   } 

}


function fn_trim(sVal) {
   var firstPos = 0;
   var lastPos = 0;
   var x;
   var y;
   if(sVal.charAt(0) == " ") {
      for(x=0;x<sVal.length-1;x++) {
         if((sVal.charAt(x) == " ") && (sVal.charAt(x+1) != " ")) {
            firstPos=x+1;
            break;
         }
      }
   }

   if(sVal.charAt(sVal.length-1) == " ") {
      for(y=sVal.length-1;y>=0;y--) {
         if((sVal.charAt(y-1) != " ") && (sVal.charAt(y) == " ")) {
            lastPos=y;
            break;
         }
      }
   } else  lastPos=sVal.length;
   
   if((firstPos == lastPos) && sVal.substring(0,1) != " ") { lastPos=sVal.length; }
   sVal = sVal.substr(firstPos,lastPos-firstPos)
   
   return sVal;

}


function fn_EventNum() {
  if(( event.keyCode < 48 ) || ( event.keyCode > 57 )) {
	event.returnValue = false;
  }
}



function fn_typeFormat(sVal,fVal,Opt) {
	//A: ¾ËÆÄ,N:¼ýÀÚ
   
   if(Opt.indexOf("A") != "-1") {
      fVal += "abcdefghijklmnopqrstuvwxyz";
   }
   
   if(Opt.indexOf("N") != "-1") {
      fVal += "0123456789";
   }

   for(var i=0; i<sVal.length;i++) {
      ch=fVal.indexOf(sVal.charAt(i));
      if(ch == '-1') {
         return false;
      }
   }
   return true;
}




function fn_isAbled(obj,isUsed,strColor) {
   if(isUsed == "N") {
      if(strColor) obj.style.background = strColor;
      else obj.style.background = "silver";
      obj.disabled = true;
   } else {
      if(strColor) obj.style.background = strColor;
      else obj.style.background = "white";
      obj.disabled = false;
   }
   return;
}
