/**
 * °ø¿ë ½ºÅ©¸³Æ®
 * @auth ¸íÁö¿¬
 */



/**
 * °ø¹éÁ¦°Å
 */
 String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$/g, "");
 }
 

/**
 * ÇÁ¸°Æ®
 *
 * @param {String} elementId ¿¤¸®¸ÕÆ® ½Äº°ÀÚ
 * @param {Number} width Ã¢³ÐÀÌ
 * @param {Number} height Ã¢³ôÀÌ
 */
function jsPrint(elementId, width, height){
	var tmpWindow = window.open('', 'tmpWindow', 'width='+(width||800)+', height='+(height||640)+', scrollbars=yes, toolbars=no, status=no, resizable=no');
	tmpWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
	tmpWindow.document.write('<html xmlns="http://www.w3.org/1999/xhtml" lang="ko">');
	tmpWindow.document.write('<head>');
	tmpWindow.document.write('<title>::ÇÁ¸°Æ®::</title>');
	tmpWindow.document.write('<meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />');
	tmpWindow.document.write('<link href="/css/ktr.css" rel="stylesheet" type="text/css">');
	tmpWindow.document.write('</head>');
	tmpWindow.document.write('<body>');
	tmpWindow.document.write(document.getElementById(elementId).innerHTML);
	tmpWindow.document.write('</body>');
	tmpWindow.document.write('</html>');
	tmpWindow.document.close();
	tmpWindow.print();
	tmpWindow.close();
}


/**
 * ÆË¾÷Ã¢ ¼¾ÅÍ ¿­±â 
 *
 * @param {String} action	ÆË¾÷ url
 * @param {String} popname	ÆË¾÷Ã¢ ÀÌ¸§
 * @param {String} w		ÆÎ¾÷Ã¢ ³ÐÀÌ
 * @param {String} h		ÆË¾÷Ã¢ ³ôÀÌ
 * @param {String} scroll	½ºÅ©·Ñ¿©ºÎ (yes, no)
 */
function popupOpen(action,popname,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; 
	TopPosition	= (screen.height) ? (screen.height-h)/2 : 0; 
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
	window.open(action,popname,settings) ;
}


/**
 * À©µµ¿ì ´Ý±â
 *
 */
function closeWin() {
	window.close();
}

function replaceAll(strTemp, strValue1, strValue2){
     while(1){
         if( strTemp.indexOf(strValue1) != -1 )
         strTemp = strTemp.replace(strValue1, strValue2);
         else
         break;
     }
     return strTemp;
 }



/**
 * IFRAME ³ôÀÌ ¸®»çÀÌÂ¡
 *
 * @param {IFrame} iframe IFrame °´Ã¼
 */
function resizeIFrame(iframe){
	iframe.height = iframe.contentWindow.document.body.offsetHeight;
}

//-----------------------------------------------------------------------------
function f_len_chk(obj, lbl, num)
{
	if( obj.value.length < num)
	{
		alert(lbl + ' '  + num + '¹®ÀÚ ÀÌ»ó ÀÔ·ÂÇÏ½Ê½Ã¿À.');
		obj.focus(); 
		return true;   
	}
	return false; 
}
// ¼ýÀÚ ¿©ºÎ Ã¼Å©
function f_is_int(obj,lbl)
{
		var nLen = obj.value.length; 
		for( i = 0 ; i < nLen ; i++)
		{
			temp = obj.value.substring(i,i+1);
			if( temp < '0' || temp > '9' )
			{
				
				alert( lbl + ' ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù.' );
				obj.focus();
				return true;
				
			}     
		}
		return false;
}
/**
 * null Ã¼Å©
 * @param {obj °´Ã¼}
 * @param {lbl °´Ã¼¸í}
 */
function f_nul_chk(obj,lbl)
{
	if( obj.value.replace(/^\s+|\s+$/g,"").trim() == '' )
	{
		alert(lbl + ' ÀÔ·Â ÇÏ½Ê½Ã¿À.');
		obj.focus(); 
		return true;   
	}
	return false; 
}


/**
 * null Ã¼Å©
 * @param {obj °´Ã¼}
 * @param {lbl °´Ã¼¸í}
 */
function f_nul_sel_chk(obj,lbl)
{
	if( obj.value.replace(/^\s+|\s+$/g,"").trim() == '' )
	{
		alert(lbl + ' ¼±ÅÃ ÇÏ½Ê½Ã¿À.');
		obj.focus(); 
		return true;   
	}
	return false; 
}

/**
 * ÇÑ±Û,¿µ¹® Á¦ÇÑ¼ö Ã¼Å©
 * @param {obj °´Ã¼}
 * @param {nByte Á¦ÇÑ ¹ÙÀÌÆ®}
 * @param {lbl °´Ã¼¸í}
 */
function con_byte_chk(obj, nByte, lbl)
{
	with(Math) {

	   var nLength = obj.value.length;
	   var nCnt = 0;
	   var nHan, nTemp;
	
	// ÇÑ±Û ¹®ÀÚ¼ö °è»ê(¹ö¸²)
	   nHan  = nByte / 2;
	   nTemp = round(nHan);
	
	   if   (nHan != nTemp)
	        nHan = nTemp - 1;
	
	   for (i = 0; i < nLength; i++)
		{
	      sTemp = escape(obj.value.substring(i, i+1));
		   if(sTemp.substring(1,2) == "u" )
		      nCnt += 2;
		   else
		      nCnt += 1;
	   }
	   if  (nCnt > nByte) {
			alert(lbl + ' ÇÑ±Û ' + nHan + ' ÀÚ, ¿µ¹® ' + nByte + ' ÀÚ ÀÌ³»·Î ÀÔ·ÂÇÏ½Ê½Ã¿À. ');
			//obj.focus(); 
			return true;   
	   }    
	   return false;
 	}
}   



/**
* ÀÌ¹ÌÁö ½º¿Ò¿ë ½ºÅ©¸³Æ®
*/


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_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_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 jsSearch(formObj){
	formObj.submit();
}

