
	function trim( str )
	{
		var s = new String( str );
		if ( s.substr( s.length - 1, 1 ) == " " )
			return trim( s.substring( 0, s.length-1 ) )
		else
			return s;
	}

	function Clear( Ctrl )
	{
		document.all[Ctrl].value = "";
	}

  function MaxLimitStop( Ctrl, SpanCtrl, intMax )
  {
    if ( document.all[Ctrl].value.length > intMax )
    {
      alert( "ÃÖ´ë " + intMax + "ÀÚ ±îÁö ÀÔ·ÂÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù." );
      document.all[Ctrl].value = document.all[Ctrl].value.substring( 0, intMax );
      CountChr( Ctrl, SpanCtrl )
      return;
    }
  }  

	function CountChr( txtName, ShowSpanCtrl )
	{
		var Count = document.all[txtName].value.length;
		document.all[ShowSpanCtrl].innerHTML = "<b>" +Count +"</b>";
	}

	//----------------------------------------------------------------------
	
	//-- Ã¢ Áß¾Ó ¶ç¿ì±â, Focus()
	function PopCenterOpen( Url, WindowWidthSize, WindowHeightSize )
	{
		var LeftPosition = (screen.width) ? (screen.width - WindowWidthSize) / 2 : 100;
		var TopPosition = (screen.height) ? (screen.height - WindowHeightSize) / 2 : 100;
		var wintype = "scrollbars=no,width="+ WindowWidthSize +", height="+ WindowHeightSize +", top=" + TopPosition + ", left=" + LeftPosition;
		var f = window.open( Url, "PopCenter", wintype );
		f.focus();
	}

	function PopCenterOpenWname( Url, WindowWidthSize, WindowHeightSize, wName )
	{
		var LeftPosition = (screen.width) ? (screen.width - WindowWidthSize) / 2 : 100;
		var TopPosition = (screen.height) ? (screen.height - WindowHeightSize) / 2 : 100;
		var wintype = "scrollbars=no,width="+ WindowWidthSize +", height="+ WindowHeightSize +", top=" + TopPosition + ", left=" + LeftPosition;
		var f = window.open( Url, wName, wintype );
		f.focus();
	}

	//-- Ã¢ Áß¾Ó ¶ç¿ì±â, Focus(), Scroll
	function PopCenterScrollOpen( Url, WindowWidthSize, WindowHeightSize )
	{
		var LeftPosition = (screen.width) ? (screen.width - WindowWidthSize) / 2 : 100;
		var TopPosition = (screen.height) ? (screen.height - WindowHeightSize) / 2 : 100;
		var wintype = "scrollbars=yes,width="+ WindowWidthSize +", height="+ WindowHeightSize +", top=" + TopPosition + ", left=" + LeftPosition;
		var f = window.open( Url, "PopCenter", wintype );
		f.focus();
	}

	//-- Ã¢ Áß¾Ó ¶ç¿ì±â, Focus(), Scroll
	function PopCenterScrollOpenWname( Url, WindowWidthSize, WindowHeightSize, wName )
	{
		var LeftPosition = (screen.width) ? (screen.width - WindowWidthSize) / 2 : 100;
		var TopPosition = (screen.height) ? (screen.height - WindowHeightSize) / 2 : 100;
		var wintype = "scrollbars=yes,width="+ WindowWidthSize +", height="+ WindowHeightSize +", top=" + TopPosition + ", left=" + LeftPosition;
		var f = window.open( Url, wName, wintype );
		f.focus();
	}

	//-- ¸ð´ÞÃ¢ Áß¾Ó ¶ç¿ì±â, Focus()
	function ModalCenterOpen( Url, WindowWidthSize, WindowHeightSize )
	{
		var LeftPosition = (screen.width) ? (screen.width - WindowWidthSize) / 2 : 100;
		var TopPosition = (screen.height) ? (screen.height - WindowHeightSize) / 2 : 100;
		var wintype = "scrollbars=no,width="+ WindowWidthSize +", height="+ WindowHeightSize +", top=" + TopPosition + ", left=" + LeftPosition;
		
		showModalDialog( Url, "PopCenter", wintype );
	}

  //---------------------------------------------------
 
	function Number2( Str )
	{
		var tmp = Str.toString();

		if ( tmp.length == 1 )
			return "0" + tmp;
		return Str;
	}
 
	function CheckImgFile( FileName )
	{
		var go = 0;
		var Reg1 = /\.gif/gi;
		var Reg2 = /\.jpg/gi;
		
		if ( Reg1.test( FileName ) == true )
			go++;
		else if ( Reg2.test( FileName ) == true )
			go++;

		if ( go == 0 )
		{
			alert( 'ÀÌ¹ÌÁö È­ÀÏ(jpg, gif)À» ¿Ã·ÁÁÖ¼¼¿ä.' );
			return false;
		}
		else
			return true;
	}

	function CheckSwfFile( FileName )
	{
		var go = 0;
		var Reg1 = /\.swf/gi;
		
		if ( Reg1.test( FileName ) == true )
			go++;

		if ( go == 0 )
		{
			alert( 'ÇÃ·¡½¬ È­ÀÏ(swf)À» ¿Ã·ÁÁÖ¼¼¿ä.' );
			return false;
		}
		else
			return true;
	}
	
	//-- RadioButton ------------- 
	function SetValueListRadio( hdCtrlId, Value )
	{
		document.all[hdCtrlId].value = Value;
	}
	
	//-- CheckBox -----------------
	function ChkSetValue( ChkId, HiddenId )
	{
		var Chk = eval( "document.all." + ChkId );
		if ( Chk == null )
			return false;

		var SetValue = "";

		if ( typeof( Chk.length ) == "undefined" )
		{
			if ( Chk.checked == true )
				SetValue = Chk.value;
		}
		else
		{
			for ( var i = 0; i < Chk.length; i++ )
				if ( Chk[i].checked == true )
					SetValue += Chk[i].value + ",";

			SetValue = SetValue.substring( 0, SetValue.length - 1 );
		}		
		
		document.all[HiddenId].value = SetValue;
	}
	
	function IsCheck( ChkId )
	{
		var Chk = eval( "document.all." + ChkId );
		if ( Chk == null )
			return false;

		var bolIsOk = false;

		if ( typeof( Chk.length ) == "undefined" )
		{
			if ( Chk.checked == true )
				bolIsOk = true;
		}
		else
		{
			for ( var i = 0; i < Chk.length; i++ )
			{
				if ( Chk[i].checked == true )
				{
					bolIsOk = true;
					break;
				}
			}
		}

		return bolIsOk;
	}
	
	function AllCheckToggle( ChkId )
	{
		var Chk = eval( "document.all." + ChkId );
		if ( Chk == null )
			return false;

		if ( typeof( Chk.length ) == "undefined" )
		{
			if ( Chk.checked == true )
				Chk.checked = false;
			else
				Chk.checked = true;				
		}
		else
		{
			for ( var i = 0; i < Chk.length; i++ )
				if ( Chk[i].checked == true )
					Chk[i].checked = false;
				else
					Chk[i].checked = true;
		}
	}
	
	//-- Select
	function SelOnChange( SelCtrlId, HdCtrlId )
	{
		document.all[HdCtrlId].value = document.all[SelCtrlId].value;
	}
	
	function CalWin( CtrlId )
	{
		PopCenterOpen( "Common/PopCalendar.aspx?ctrl=" + CtrlId, 200, 200 );
	}

	//-- PopZipCode
	function PopZipCode( CtrlPostCode, CtrlAddress, CtrlAddress1 )
	{
		PopCenterOpen( "Common/PopZipCode.aspx?ctcd=" + CtrlPostCode + "&ctad=" + CtrlAddress + "&ctad1=" + CtrlAddress1, 410, 500 );
	}
	
	function ZipCodeSearch()
	{
		var CtrlPostCode = document.all.hdCtrlPostCode.value;
		var CtrlAddress = document.all.hdCtrlAddress.value;
		var CtrlAddress1 = document.all.hdCtrlAddress1.value;
		var Dong = trim( document.all.txtDong.value );
		var Url = "PopZipCodeIFMList.aspx?ctcd={0}&ctad={1}&ctad1={2}&dg={3}";

		if ( Dong.length == 0 )
		{
			alert( "À¾/¸é/µ¿À» ÀÔ·ÂÇØÁÖ¼¼¿ä." );
			document.all.txtDong.focus();
			return;
		}
		
		if ( Dong.length == 1 )
		{
			alert( "2 ±ÛÀÚ ÀÌ»ó ÀÔ·ÂÇØ ÁÖ¼¼¿ä." );
			document.all.txtDong.focus();
			return;
		}
		
		Url = Url.replace( /\{0\}/, CtrlPostCode );
		Url = Url.replace( /\{1\}/, CtrlAddress );
		Url = Url.replace( /\{2\}/, CtrlAddress1 );
		Url = Url.replace( /\{3\}/, escape( Dong ) );

		ifrList.location.href = Url;
	}

	function ZipCodeSet( ZipCode, Address, Address1 )
	{
		var CtrlPostCode = document.all.hdCtrlPostCode.value;
		var CtrlAddress = document.all.hdCtrlAddress.value;
		var CtrlAddress1 = document.all.hdCtrlAddress1.value;
		
		parent.opener.document.all[CtrlPostCode].value = ZipCode;
		parent.opener.document.all[CtrlAddress].value = Address;
		parent.opener.document.all[CtrlAddress1].value = Address1;
		
		parent.opener.focus();
		parent.self.close();
	}

	//-- Æ¯¼ö¹®ÀÚ È®ÀÎ
	function SpecialWordValidate( Ctrl ) 
	{
		var CtrlValue = Ctrl.value;
		var FilteredValues = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890";     
		// Æ¯¼ö±âÈ£

		for ( var i = 0; i < CtrlValue.length; i++ )
		{
			var c = CtrlValue.charAt(i);
			if ( FilteredValues.indexOf(c) == -1 ) 
			{
				alert( "À¯È¿ÇÑ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.\n\n´Ù½Ã ÀÔ·ÂÇØÁÖ¼¼¿ä." );
				Ctrl.value = "";
				return false;
			}
		}
		return true;
	}
	
	//-- ºñ¹Ð¹øÈ£ È®ÀÎ
	function PassWordValidate( Ctrl ) 
	{
		var CtrlValue = Ctrl.value;
		TelFilteredValues = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890-!@$%^*()_+|-=";     
		// ¾ËÆÄºª, Æ¯¼ö±âÈ£, ¼ýÀÚ

		for ( var i = 0; i < CtrlValue.length; i++ )
		{
			var c = CtrlValue.charAt(i);
			if ( TelFilteredValues.indexOf(c) == -1 ) 
			{
				alert( "À¯È¿ÇÑ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.\n\n´Ù½Ã ÀÔ·ÂÇØÁÖ¼¼¿ä." );
				Ctrl.value = "";				
				return false;
			}
		}
		return true;
	}

	//-- ¼ýÀÚ È®ÀÎ
	function NumberValidate( Ctrl ) 
	{
		var CtrlValue = Ctrl.value;
		TelFilteredValues = "1234567890";

		for ( var i = 0; i < CtrlValue.length; i++ )
		{
			var c = CtrlValue.charAt(i);
			if ( TelFilteredValues.indexOf(c) == -1 ) 
			{
				alert( "¼ýÀÚ¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä." );
				Ctrl.value = "";
				break;
			}
		}
	}
	

	function Comma3( CtrlId )
	{
		if ( document.all[CtrlId].value.length == 0 )
		{
			document.all[CtrlId].value = "";
			return;
		}
	
		var Str = document.all[CtrlId].value;
		var Length = Str.length;
		var Times = Math.floor( ( Length - 1 ) / 3 );
		var startIndex = Length - ( Times ) * 3;
		var Result = Str.substring( 0, startIndex );

		for ( i = 0; i < Times; i++ )
		{
			Result = Result + "," + Str.substring( startIndex, startIndex + 3 );
			startIndex = startIndex + 3;
		}

		document.all[CtrlId].value = Result;
	}
	
	function CtrlValueCopyClipBoard( CtrlID )
	{
		var CopyCtrl = document.all[CtrlID];	
		var CopyValue = CopyCtrl.createTextRange();	
		CopyValue.execCommand( "Copy" );
		CopyCtrl.select();
	}
	
	//--- ToolTip
	
function ShowTip( current, e, Msg )
{
	if ( document.layers ) // Netscape 4.0+
	{
		theString = "<DIV CLASS='ttip'>"+ Msg +"</DIV>";
		document.tooltip.document.write( theString );
		document.tooltip.document.close();
		document.tooltip.left = e.pageX + 14;
		document.tooltip.top = e.pageY + 2;
		document.tooltip.visibility = "show";
	}
	else
	{
		if ( document.getElementById ) // Netscape 6.0+ , Internet Explorer 5.0+
		{
			objDiv =document.createElement( "div" );
			objDiv.style.left = 0;
			objDiv.style.top = 0;						
			objDiv.style.position = "absolute";
			objDiv.style.border = "1px solid black";
			objDiv.style.backgroundColor = "lightyellow";
			objDiv.style.fontFamily = "tahoma";
			objDiv.style.fontSize = "11";
			objDiv.style.width = "105";
			objDiv.style.padding = "2";
			
			current.appendChild( objDiv );
			
			elm = objDiv;
			elml = current;	
			elm.innerHTML = Msg;
			elm.style.height = elml.style.height;
			elm.style.top = parseInt( elml.offsetTop + elml.offsetHeight + 130 );
			elm.style.left = parseInt( elml.offsetLeft + elml.offsetWidth );
			elm.style.visibility = "visible";
		}
	}
}

function HideTip()
{
	if ( document.layers ) // Netscape 4.0+
	{
		document.tooltip.visibility = "hidden";
	}
	else
	{
		if ( document.getElementById ) // Netscape 6.0+ , Internet Explorer 5.0+
		{
			elm.style.visibility = "hidden";			
		}
	}
}
