﻿/************************************************************************
파 일 명		: /Scripts/ControlUtil.js
작성목적		: Html Element 동작을 제어한다.
					  Radio Group, ListBox, Image Button, TextBox, Control Move


*************************************************************************/

/************************************************************************
함수명			: fn_CheckNumberTextBox()
작성목적		: text box에 입력값이 숫자일 경우에만 입력 받는다.
					  text box의 onkeypress 이벤트 헨들러로 추가한다.
					  ex) document.all.txtPrice.onkeypress = fn_CheckNumberBox
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_CheckNumberTextBox()
{
	try
	{
		// 허용키 : 8, 13, 27, 48 ~ 57
		if ( window.event.keyCode >= 48 && window.event.keyCode <= 57 )
		{
			window.event.returnValue = true;
			return;
		}
		if ( window.event.keyCode == 8 && window.event.keyCode == 13 && window.event.keyCode == 27 )
		{
			window.event.returnValue = true;
			return;
		}
		window.event.returnValue = false;
	}
	catch ( exception )
	{
	}	
}

/************************************************************************
함수명			: fn_ConvertToUpperCase()
작성목적		: text box에 입력값이 소문자이면 대문자로 고친다.
						ex) document.all.txtPrice.onkeypress = fn_CheckNumberBox
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_ConvertToUpperCase()
{
	try
	{
		// 소문자이면 대문자로 변경한다. ( 97(122) -> 65(90) )
		if ( window.event.keyCode >= 97 && window.event.keyCode <= 122 )
			window.event.keyCode = window.event.keyCode - 32;
	}
	catch (exception)
	{
	}	
}

/************************************************************************
함수명			: fn_ConvertToLowerCase()
작성목적		: text box에 입력값이 소문자이면 대문자로 고친다.
					ex) document.all.txtPrice.onkeypress = fn_CheckNumberBox
Parameter		:
Return :
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_ConvertToLowerCase()
{
	try
	{
		// 소문자이면 대문자로 변경한다. ( 97(122) <- 65(90) )
		if ( window.event.keyCode >= 65 && window.event.keyCode <= 90 )
			window.event.keyCode = window.event.keyCode + 32;
	}
	catch (exception)
	{
	}	
}

/************************************************************************
함수명			: fn_GetListBoxValue(oListBox)
작성목적		: ListBox의 선택된 항목 값을 가져온다.
Parameter		:
Return :
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_GetListBoxValue(oListBox)
{
	try
	{
		return oListBox[oListBox.selectedIndex].value;
	}
	catch (exception)
	{
	}	
}

/************************************************************************
함수명			: fn_AddListBoxItem(oListBox, sText, sValue)
작성목적		: ListBox에 삽입한다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_AddListBoxItem(oListBox, sText, sValue)
{
	try
	{
		var oOption = document.createElement("option");
		oOption.text = sText;
		oOption.value = sValue;
		
		oListBox.add(oOption);
	}
	catch (exception)
	{
	}
}

/************************************************************************
함수명			: fn_GetRadioValue(radioName)
작성목적		: Radion 컨트롤의 이름을 문자열로 전달하면 해당 컨트롤 그룹을 검색하여
					  checked = true인 컨트롤의 value를 리턴한다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_GetRadioValue(radioName)
{
	try
	{
		var iCount;
		var strValue;
		
		var oRGroup = document.all[radioName];
		iCount = oRGroup.length;
		for ( var i = 0 ; i < iCount ; i++ )
		{
			if ( oRGroup[i].checked)
			{
				strValue = oRGroup[i].value;
				break;
			}
		}
		return strValue;
			
	}
	catch ( exception )
	{
	
	}	
}

/************************************************************************
함수명			: fn_SetRadioValue(radioName, sValue)
작성목적		: Radion 컨트롤의 이름과 값을 문자열로 전달하면 해당 컨트롤 그룹을 검색하여
					 해당 값을 가진 컨트롤을 체크한다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_SetRadioValue(radioName, sValue)
{
	try
	{
		var iCount;
		var oRGroup = document.all[radioName];
		iCount = oRGroup.length;
		for ( var i = 0 ; i < iCount ; i++ )
		{
			if ( oRGroup[i].value == sValue )
			{
				oRGroup[i].checked = true;
				break;
			}
		}
	}
	catch (exception)
	{
	}
}

/************************************************************************
함수명			: fn_DisableImageButton(imgID)
작성목적		: 해당 이미지 Control을 disable시키고 마우스 모양을 default로 설정한다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_DisableImageButton(oImgBtn)
{

	try
	{
		oImgBtn.disabled = false;
		oImgBtn.style.cursor = "default";
		oImgBtn.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=30)";
	}
	catch ( exception )
	{
	}	
}

/************************************************************************
함수명			: fn_EnableImageButton(imgID)
작성목적		: 해당 이미지 Control을 Enable시키고 마우스 모양을 hand로 설정한다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_EnableImageButton(oImgBtn)
{
	try
	{
		oImgBtn.disabled = false;
		oImgBtn.style.cursor = "hand";
		oImgBtn.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
	}
	catch ( exception )
	{
	}	
}

/************************************************************************
함수명			: fn_SetAllCheck(attrValue)
작성목적		: 해당 Attribute를 갖는 모든 체크박스를 Check한다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_SetAllCheck(attrValue)
{
	var oItem;
	
	try
	{
		for ( var i = 0 ; i < document.all.length ; i++ )
		{
			oItem = document.all[i];
			
			if ( oItem.tagName.toUpperCase() == "INPUT")
				if ( oItem.getAttribute("type").toUpperCase() == "CHECKBOX" )
					if (oItem.getAttribute("chkgrpname") != null )
						if ( oItem.getAttribute("chkgrpname") == attrValue )
							oItem.checked = true;

		}	
	}
	catch (exception)
	{
	}
}

/************************************************************************
함수명			: fn_SetAllUnCheck(attrValue)
작성목적		: 해당 Attribute를 갖는 모든 체크박스를 UnCheck한다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_SetAllUnCheck(attrValue)
{
	var oItem;
	try
	{
		for ( var i = 0 ; i < document.all.length ; i++ )
		{
			oItem = document.all[i];
			
			if ( oItem.tagName.toUpperCase() == "INPUT")
				if ( oItem.getAttribute("type").toUpperCase() == "CHECKBOX" )
					if (oItem.getAttribute("chkgrpname") != null )
						if ( oItem.getAttribute("chkgrpname") == attrValue )
							oItem.checked = false;
		}	
	}
	catch (exception)
	{
	}	
}

/************************************************************************
함수명			: fn_GetCheckedItems(attrValue)
작성목적		: 해당 Attribute를 갖는 모든 체크박스 중 Check된 항의 배열을 가져온다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_GetCheckedItems(attrValue)
{
	var oItem;
	var arrReturn;
	var iCnt = 0;
	var idx = 0;
	try
	{
		for ( var i = 0 ; i < document.all.length ; i++ )
		{
			oItem = document.all[i];
			if ( oItem.tagName.toUpperCase() == "INPUT")
				if ( oItem.getAttribute("type").toUpperCase() == "CHECKBOX" )
					if (oItem.getAttribute("chkgrpname") != null )
						if ( oItem.getAttribute("chkgrpname") == attrValue )
							if ( oItem.checked == true )
								iCnt++;
		}
		arrReturn = new Array(iCnt);
		for ( var i = 0 ; i < document.all.length ; i++ )
		{
			oItem = document.all[i];
			if ( oItem.tagName.toUpperCase() == "INPUT")
				if ( oItem.getAttribute("type").toUpperCase() == "CHECKBOX" )
					if (oItem.getAttribute("chkgrpname") != null )
						if ( oItem.getAttribute("chkgrpname") == attrValue )
							if ( oItem.checked == true )
								arrReturn[idx++] = oItem;
		}
		return arrReturn;
	}
	catch (exception)
	{
	}
	return null;
}

/************************************************************************
함수명			: fn_MoveControl(oCtrl, posTop, posLeft)
작성목적		: 해당 Control을 절대 위치로 옴긴다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_MoveControl(oCtrl, posTop, posLeft)
{
	try
	{
		oCtrl.style.position = "absolute";
		oCtrl.style.top = posTop;
		oCtrl.style.left = posLeft;
	}
	catch (exception)
	{
	}
}

/************************************************************************
함수명			: fn_HlightCheckboxList()
작성목적		: CheckBox List에서 Check될때 Highlight시킨다.
					  Web Control의 Checkbox List Attribute에 onclick 이벤트로 정의한다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_HlightCheckboxList()
{
	var oTd = null;
	try
	{
		oTd = window.event.srcElement.parentNode;
		if ( window.event.srcElement.checked == true )
			oTd.style.backgroundColor = '#ffffcc';
		else
			oTd.style.backgroundColor = '#ffffff';
	}
	catch (exception)
	{
		return false;
	}
	return true;
}

/************************************************************************
함수명			: fn_CheckboxListLoad(checkboxList)
작성목적		: CheckBox List에서 Check될때 Highlight시킨다.
					  Web Control의 Checkbox List Attribute에 onclick 이벤트로 정의한다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_CheckboxListLoad(checkboxList)
{
	var oTb = null;
	var oTr = null;
	var oTd = null;
	var oChk = null;

	try
	{
		
		oTb = checkboxList;

		for ( var i = 0 ; i < oTb.rows.length ; i++ )
		{
			oTr = oTb.rows(i);
			oTd = oTr.cells(0);
			oChk = oTd.childNodes(0);
			
			if ( oChk.checked == true )
				oTd.style.backgroundColor = '#ffffcc';
			else
				oTd.style.backgroundColor = '#ffffff';		
		}
	}
	catch (exception)
	{
		document.all.errorMessage.value = exception.description;
		fn_OpenErrorMessage();
	}
	
}

/************************************************************************
함수명			: fn_DisableImageButton(imgID)
작성목적		: 해당 이미지 Control을 disable시키고 마우스 모양을 default로 설정한다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.10.07
최종작성일	:
수정내역		: anchor 사용시 onclick으로 실행되는 함수 제거
*************************************************************************/
function fn_DisableImageLinkButton(oImgBtn)
{
	try
	{
		oImgBtn.disabled = true;
		oImgBtn.style.cursor = "default";
		oImgBtn.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=30)";
		//oImgBtn.parentElement.onclick = "";
		oImgBtn.onclick = "";
	}
	catch ( exception )
	{
		fn_OpenErrorMessage(exception.description);
	}	
}

/************************************************************************
함수명			: fn_EnableImageButton(imgID)
작성목적		: 해당 이미지 Control을 Enable시키고 마우스 모양을 hand로 설정한다.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_EnableImageButton(oImgBtn)
{
	try
	{
		oImgBtn.disabled = false;
		oImgBtn.style.cursor = "hand";
		oImgBtn.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
	}
	catch ( exception )
	{
		fn_OpenErrorMessage(exception.description);
	}	
}

/************************************************************************
함수명			: fn_UpdateMode(item)
작성목적		: 컨트롤 수정모드
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*************************************************************************/
function fn_UpdateMode(item){
	switch(item.type){
		case 'text' :
			item.readOnly=false;
			item.style.borderTop=' #969a9a 1px solid';
			item.style.borderLeft=' #969a9a 1px solid';
			item.style.borderRight=' #969a9a 1px solid';
			item.style.borderBottom=' #969a9a 1px solid';;
			break;
		case 'checkbox' :
			item.style.visibility='visible';
			break;
		case 'select-one' :
			item.disabled=false;
			break;
		case 'image' :
			item.style.visibility='visible';
			break;
		default :
			item.style.visibility='visible';
			break;
	}
}


/************************************************************************
함수명			: fn_ReadMode(item)
작성목적		: 컨트롤 읽기모드.
Parameter		:
Return			:
작 성 자		: 
최초작성일	: 2004.01.07
최종작성일	:
수정내역		:
*********	***************************************************************/
function fn_ReadMode(item){

	switch(item.type){
		case 'text' :
			item.readOnly=true;
			item.style.border=0;
			break;
		case 'checkbox' :
			item.style.visibility='hidden';
			break;
		case 'select-one' :
			item.disabled=true;
			break;
		case 'image' :
			item.style.visibility='hidden';
			break;
		default :
			item.style.visibility='hidden';
			break;
	}
}



 /**********************************Utility Script Start*************************************/
// Utility 성격의 Script 목록 

/************************************************************************
파 일 명		: /Scripts/ControlUtil.js
작성목적		: Utility Script 
작 성 자		: 
최초작성일	: 2004. 08. 10.
*************************************************************************/

 /************************************************************************
함수명			: fn_MovePage
Parameter 	:
						linkURL : 링크 URL
작성목적		:  현재 페이지에서 URL 이동
작 성 자			: 
최초작성일		: 2005. 05 . 31.
최종작성일		:
수정내역			:
*************************************************************************/
 function fn_MovePage(linkURL)
{
		self.location.href = linkURL;
}
 /************************************************************************
함수명			: fn_MovePageNew
Parameter 	:
						linkURL : 링크 URL
작성목적		:  현재 페이지에서 URL 이동
작 성 자			: 
최초작성일		: 2005. 05 . 31.
최종작성일		:
수정내역			:
*************************************************************************/
 function fn_MovePageNew(linkURL)
{
		//self.location.href = linkURL;
		window.open(linkURL);
}
 /************************************************************************
함수명				: fn_GetNowTime
Parameter 		:
작성목적			:  현재 시간(hh:mm:ss) Return 
작 성 자			: 
최초작성일		: 2005. 08 . 10.
최종작성일		:
수정내역			:
*************************************************************************/
function fn_GetNowTime(flag)
{
		var strHours = "";
		var strMinutes = "";
		var strSeconds = "";
		var strTime = " ";
		
		date = new Date();
		
		strHours = date.getHours();
		if (strHours < 10) 
			strHours = "0" + strHours;		
		
		strMinutes = date.getMinutes();
		if (strMinutes < 10) 
			strMinutes = "0" + strMinutes;
			
		strSeconds = date.getSeconds() 
		if (strSeconds < 10)
			strSeconds = "0" + strSeconds;
			
		if (flag == "F")
		{
			strTime = strTime +  strHours + ":" + strMinutes + ":" + strSeconds;			
		}
		if (flag == "N")
		{
			strTime =  strTime + strHours + ":" + strMinutes
		}
					
		return strTime;	
}

 /************************************************************************
함수명				: fn_GetNowDate
Parameter 		:
작성목적			:  현재 날짜(yyyy-mm-dd) Return 
작 성 자			: 
최초작성일		: 2005. 08 . 09.
최종작성일		:
수정내역			:
*************************************************************************/
function fn_GetNowDate()
{
		var strYear = "";
		var strMonth = "";
		var strDay = "";
		var strDate = "";
		
		date = new Date();
		
		strYear = date.getYear();		
		
		strMonth = date.getMonth() + 1;
		if (strMonth < 10)
			strMonth = "0" + strMonth;
			
		strDay = date.getDate() ;
		if (strDay < 10)
			strDay = "0" + strDay;
			
		strDate =  strYear + "-" + strMonth + "-" + strDay;
					
		return strDate;
}					

 /************************************************************************
함수명			: fn_GetNowDateTime
Parameter 	:
						linkURL : 링크 URL
작성목적			:  현재 날짜(yyyy-mm-dd HH:MM) Return 
작 성 자			: 
최초작성일		: 2005. 08 . 09.
최종작성일		:
수정내역			:
*************************************************************************/
function fn_GetNowDateTime()
{
	return fn_GetNowDate() + fn_GetNowTime("N");
}

 /************************************************************************
함수명			: fn_GetNowFullDateTime
Parameter 	:
						linkURL : 링크 URL
작성목적			:  현재 날짜(yyyy-mm-dd HH:MM:SS) Return 
작 성 자			: 
최초작성일		: 2005. 08 . 09.
최종작성일		:
수정내역			:
*************************************************************************/
function fn_GetNowFullDateTime()
{
	return fn_GetNowDate() + fn_GetNowTime("F");
}


 /************************************************************************
함수명				:CheckByteLength
Parameter 		:
							fo 		:	this 객체
							ctlText :	Control 명
							mx		:	입력 범위
작성목적			:  TextBox의 문자열 체크 함수 
작 성 자			: 
최초작성일		: 2005. 08 . 18.
최종작성일		:
수정내역			:
*************************************************************************/
   function fn_CheckByteLength(fo, ctlText, mx) 
{

		 var len = ctlText.length; 
		 var charCode = 0;
		 var i = 0 ;
		 
		 for (i=0; i<ctlText.length; i++) 
		 { 
		 	charCode = ctlText.substr(i,1).charCodeAt(0); 
		 	if (charCode > 127) 
		 	{ len++; } 
		 }  
 
	  	if (mx < len) 
	  	{ 
	  			alert("입력한 글이 길어서 잘릴 수 있습니다. 다시 입력해 주세요");
		  	 	fo.focus();
		  		fo.select(); 
	  	 }
 
	  	 return len; 
 }  
 
 
 /************************************************************************
함수명				:	fn_GetComma
Parameter 		:
							item 		: ,를 나타낼 Object
작성목적			:  Comma를 자동으로 출력해 주는 함수
작 성 자			: 
최초작성일		: 2005. 08 . 22.
최종작성일		:
수정내역			:
*************************************************************************/ 
function fn_GetComma(itemValue) 
{
//		var itemValue = item.value;
		var result = ""			
		var strDecimalUp = "";
		var strDecimalDown = "";
		
		
		var decimalPosition = 0;
		strInfoMsg = "숫자가 아닙니다.  다시 확인해 주세요";
		
		var strm = itemValue.indexOf("-");
		if(strm == 0)
			itemValue = itemValue.substr(1,itemValue.length);
				
		// 숫자와 소숫점 체크 함수 호출
		if (!isNumberCommaType(itemValue))
		{
			fn_OpenInformation(strInfoMsg);
			return "";
		}			
	
		itemValue = itemValue.replace(/,/g, "")
		itemValue = itemValue.replace(/ /g, "")		
		itemValue = itemValue.toString()
		
		decimalPosition =  itemValue.indexOf(".")
			
	
		if (decimalPosition != -1)
		{
			strDecimalUp = itemValue.substr(0, decimalPosition);				
			strDecimalDown =  itemValue.substring(decimalPosition);		
		}		
		else
		{
			strDecimalUp = itemValue;
		}
		
		for(var i=0; i<strDecimalUp.length; i++) 
		{
			var tmp = strDecimalUp.length-(i+1)
			
			if(i%3==0 && i!=0) result = ',' + result
			
			result = strDecimalUp.charAt(tmp) + result
		}
			result = result + strDecimalDown
		if(strm == 0)
			result = "-" + result;
		return result; 
}


 /************************************************************************
함수명				:	fn_ValidMoneyControl
Parameter 		:
							item 			: ,를 나타낼 Object
							tempItem 	: 사용될 Temp Object
							decimals 		: 소숫점 표시
작성목적			:  Comma를 자동으로 출력해 주는 함수
작 성 자			: 
최초작성일		: 2005. 08 . 22.
최종작성일		:
수정내역			:
*************************************************************************/ 

function fn_ValidMoneyControl1(item, tempItem, decimals)
{
	var itemValue = item.value;
	itemLength = itemValue.length;      
	var checkFlag = true;   

		FirstNum = itemValue.substr(0,1);
		FirstNum2 = itemValue.substr(1,itemLength);
   
		if(FirstNum == "0"){
				alert("숫자는 0 으로 시작할 수 없습니다.");
		
		return FirstNum2;
				itemValue = FirstNum2;
		}

		loop = /^\$|,/g; 
		
		itemValue = itemValue.replace(loop, ""); 
	
		var num = "0123456789-.";
	
					
			for (var intLoop = 0; intLoop < itemValue.length; intLoop++) 
			{
				if (num.indexOf(itemValue.charAt(intLoop)) == -1) {
					checkFlag = false;   
				}
			}
			
			if (!checkFlag)
			{
			alert(" 패턴 숫자만 입력하실 수 있습니다.");        
			item.value == "";
			item.focus();
			return "";
			}

	
		tempItem.value=itemValue;
        
		var fieldnum = '' + itemValue;    

		if (isNaN(fieldnum)) {
			alert("숫자만 입력하실 수 있습니다.");        
			item.value == "";
			item.focus();
			return "";
		}
		else {
		var comma = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
		var data = fieldnum.split('.');
		data[0] += '.';
		do {
			data[0] = data[0].replace(comma, '$1,$2');
			} while (comma.test(data[0]));

		if (data.length > 1) {
		item.value = data.join('');
		}
		else {
		item.value = data[0].split('.')[0];
				}
		}	
}	


	function formatNumber1(s)
	{
	
	if (s.substring(0,1) != "-") {
	s=s.replace(/\D/g,"");
	rl=s.length;
	l=s.length-3;
	while(l > 0) {
	if(s.substring(rl-1,1) == "."){ //마지막에 들어온 문자가 소수점이면 그냥 내보낸다. 
	return s;
	}
	
	else { 
	s=s.substr(0,l)+","+s.substr(l);
	l-=3;
	}
	}
	return s;
	}else {
	if (s.length > 2) {
	f=s.substring(1)
	f=f.replace(/\D/g,""); 
	l=f.length-3;
	while(l > 0) {
	f=f.substr(0,l)+","+f.substr(l);
	l-=3;
	}
	s = "-"+f 
	}
	return s;
	}
	}
	
	var oldv=""
	
	function fn_ValidMoneyControl(tx, decimalPlace)
	{
	if (event.keyCode == 9) return;
	if(oldv==tx.value) return;
	oldv=tx.value;
	tx.value=formatNumber1(oldv);
	}
	

 /************************************************************************
함수명				:	fn_AutoTab()
Parameter 		:
							input 			: Object
							tempItem 	: 사용될 Temp Object
							decimals 		: 소숫점 표시
작성목적			:  입력 상자 자동 이동 함수 
작 성 자			: 
최초작성일		: 2005. 08 . 29.
최종작성일		:
수정내역			:
Sample 			: 
							주민등록번호 	<asp:TextBox id="txtJumin1" runat="server" MaxLength="6" onkeyup="return fn_AutoTab(this, 6, event);" ></asp:TextBox>-<asp:TextBox id="txtJumin2" runat="server" MaxLength="7" onkeyup="return fn_AutoTab(this, 7, event);">
*************************************************************************/ 	

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function fn_AutoTab (input, len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	
	if(input.value.length >= len && !fn_ContainsElement(filter,keyCode)) 
	{
		input.value = input.value.slice(0, len);
		input.form[(fn_GetIndex(input)+1) % input.form.length].focus();
	}

	return true;
}

function fn_ContainsElement(arr, ele) 
{
	var found = false, index = 0;
	
	while(!found && index < arr.length)
		if(arr[index] == ele)
			found = true;
		else
			index++;
			
	return found;
}

function fn_GetIndex(input) {
	var index = -1, i = 0, found = false;
	
	while (i < input.form.length && index == -1)
		if (input.form[i] == input)
			index = i;
		else 
			i++;
			
	return index;
}

/**********************************Utility Script End*************************************/
