﻿/**************************************************
파 일 명     :  /Scripts/ControlUtil.js
최초작성내역 :  인터데브 정재권(2007년 03월 20일) 
작성목적     :  Control에서 사용하는 함수와 관련된 파일
**************************************************/

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  TextBox에 숫자만 입력하는 함수
                     TextBox의 이벤트 핸들러(예:onkeypress)에 연결하여 사용
Parameter :
반환 값   :  
사용예    :  
                       function PageLoad()
                       {
                            document.all.txtInputMoney.onkeypress = CheckNumberTextBox;
                       }
*******************************************************/
function 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)
	{
		OpenErrorMessage(exception.description);
	}
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  TextBox에 소문자를 입력했을 때 대문자로 변환하는 함수
                     TextBox의 이벤트 핸들러(예:onkeypress)에 연결하여 사용
Parameter :
반환 값   :  
사용예    :  
                       function PageLoad()
                       {
                            document.all.txtUpperData.onkeypress =  ConvertToUpperCase;
                       }
*******************************************************/
function ConvertToUpperCase()
{

    try
   { 
        // 소문자이면 대문자로 변경한다. ( 97(122) -> 65(90) )
	    if ( window.event.keyCode >= 97 && window.event.keyCode <= 122 )
		    window.event.keyCode = window.event.keyCode - 32;
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}		
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  TextBox에 대문자를 입력했을 때 소문자로 변환하는 함수
                     TextBox의 이벤트 핸들러(예:onkeypress)에 연결하여 사용
Parameter :
반환 값   :  
사용예    :  
                       function PageLoad()
                       {
                            document.all.txtLowerData.onkeypress =  ConvertToLowerCase;
                       }
*******************************************************/
function ConvertToLowerCase()
{
    try
   { 
        // 소문자이면 대문자로 변경한다. ( 97(122) <- 65(90) )
        if ( window.event.keyCode >= 65 && window.event.keyCode <= 90 )
            window.event.keyCode = window.event.keyCode + 32;
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}        
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  Radio Button에서 체크된 값을 리턴하는 함수
Parameter :
                     radioName (string : Radio Button에서 사용한 name)
반환 값   :  
사용예    :  
                       ** HTML Sample Start**
                            <input id="rdoChoice" name="rdoChoice" type="radio" value="CODE100" />사과
                            <input id="rdoChoice" name="rdoChoice" type="radio" value="CODE200" />배
                            <input id="rdoChoice" name="rdoChoice" type="radio" value="CODE300" />복숭아  
                       ** HTML Sample End**  
                       
                       GetRadioValue('rdoChoice');         
*******************************************************/
function GetRadioValue(radioName)
{
	var iCount;
	var strValue = "";
	
    try
   { 	
	    var oRadioGroup = document.all[radioName];
	    iCount = oRadioGroup.length;
	    for ( var i = 0 ; i < iCount ; i++ )
	    {
		    if ( oRadioGroup[i].checked)
		    {
			    strValue = oRadioGroup[i].value;
			    break;
		    }
	    }
	        return strValue;
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}	
	
    return strValue;	
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  Radio Button 중 입력한 값을 체크하는 함수
Parameter :
                     radioName (string : Radio Button에서 사용한 name)
                     checkedValue (string : Radion Button 중에서 체크할 값) 
반환 값   :  
사용예    :  
                   ** HTML Sample Start**
                        <input id="rdoChoice" name="rdoChoice" type="radio" value="CODE100" />사과
                        <input id="rdoChoice" name="rdoChoice" type="radio" value="CODE200" />배
                        <input id="rdoChoice" name="rdoChoice" type="radio" value="CODE300" />복숭아  
                   ** HTML Sample End**  
                   
                   CheckRadioValue('rdoChoice', 'CODE100');          
*******************************************************/
function CheckRadioValue(radioName, checkedValue)
{
	var iCount;
	
    try
   { 	
	    var oRadioGroup = document.all[radioName];
	    iCount = oRadioGroup.length;
	    for ( var i = 0 ; i < iCount ; i++ )
	    {
		    if ( oRadioGroup[i].value == checkedValue )
		    {
			    oRadioGroup[i].checked = true;
			    break;
		    }
	    }
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}		
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  이미지를 나타나게 하는 함수
Parameter :
                     imageButton (object : 이미지 버튼 Object) 
반환 값   :  
사용예    :  
                     EnableImageButton(document.all.ibtnSend);           
*******************************************************/
function EnableImageButton(imageButton)
{
    try
   { 
	    imageButton.disabled = false;
	    imageButton.style.cursor = "hand";
	    imageButton.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}		
}


/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  이미지를 희미하게 하는 함수
Parameter :
                     imageButton (object : 이미지 버튼 Object) 
반환 값   :  
사용예    :  
                     DisableImageButton(document.all.ibtnCancle);            
*******************************************************/
function DisableImageButton(imageButton)
{
    try
   { 
	    imageButton.disabled = false;
	    imageButton.style.cursor = "default";
	    imageButton.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=30)";
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}		
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  이미지를 희미하게 하고 링크 정보를 삭제하는 함수
Parameter :
                     imageButton (object : 이미지 버튼 Object) 
반환 값   :  
사용예    :  
                     DisableImageButton(document.all.ibtnCancle);                  
*******************************************************/
function DisableImageLinkButton(imageButton)
{
	try
	{
		imageButton.disabled = true;
		imageButton.style.cursor = "default";
		imageButton.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=30)";
		imageButton.onclick = "";
	}
	catch ( exception )
	{
		OpenErrorMessage(exception.description);
	}	
}


/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  같은 CheckBoxGroup안에 있는 모든 CheckBox를 Checked하는 함수 
Parameter :
                     checkGroupName (string : CheckBox에서 사용하는 Group 명) 
반환 값   :  
사용예    :  
                   ** HTML Sample Start**
                    // CheckBox Tag안의 checkGroupName을 반드시 코딩해야 함수 실행
                    <input id="CheckboxCode" type="checkbox" value="Code100" checkGroupName="JNUCodeGroup" />사과
                    <input id="CheckboxCode" type="checkbox" value="Code200" checkGroupName="JNUCodeGroup"/>배
                    <input id="CheckboxCode" type="checkbox" value="Code300" checkGroupName="JNUCodeGroup"/>토마토
                    <input id="CheckboxCode" type="checkbox" value="Code400" checkGroupName="JNUCodeGroup"/>복숭아
                   ** HTML Sample End**
                                               
                    <input id="btnAllCheck" type="button" value="All Check"  
                             onclick="javascript:SetAllCheck('JNUCodeGroup');"/>                        
*******************************************************/
function SetAllCheck(checkGroupName)
{
	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("checkGroupName") != null )
					    if ( oItem.getAttribute("checkGroupName") == checkGroupName )
						    oItem.checked = true;

	    }	
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}		
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  같은 CheckBoxGroup안에 있는 모든 CheckBox를 UnChecked하는 함수 
Parameter :
                     checkGroupName (string : CheckBox에서 사용하는 Group 명)
반환 값   :  
사용예    :  
                   ** HTML Sample Start**
                    // CheckBox Tag안의 checkGroupName을 반드시 코딩해야 함수 실행
                    <input id="CheckboxCode" type="checkbox" value="Code100" checkGroupName="JNUCodeGroup" />사과
                    <input id="CheckboxCode" type="checkbox" value="Code100" checkGroupName="JNUCodeGroup"/>배
                    <input id="CheckboxCode" type="checkbox" value="Code100" checkGroupName="JNUCodeGroup"/>토마토
                    <input id="CheckboxCode" type="checkbox" value="Code100" checkGroupName="JNUCodeGroup"/>감
                   ** HTML Sample End**
                                               
                    <input id="btnAllUnCheck" type="button" value="All Un Check"  
                             onclick="javascript:SetAllUnCheck('JNUCodeGroup');"/>                     
*******************************************************/
function SetAllUnCheck(checkGroupName)
{
	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("checkGroupName") != null )
					    if ( oItem.getAttribute("checkGroupName") == checkGroupName )
						    oItem.checked = false;
        }
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}			
		
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  같은 CheckBoxGroup안에 있는 CheckBox 중 Check된 Control의 값을 가져오는 함수
Parameter :
                     checkGroupName (string : CheckBox에서 사용하는 Group 명)
반환 값   :  
사용예    :  
                   ** HTML Sample Start**
                    // CheckBox Tag안의 checkGroupName을 반드시 코딩해야 함수 실행
                    <input id="CheckboxCode" type="checkbox" value="Code100" checkGroupName="JNUCodeGroup" />사과
                    <input id="CheckboxCode" type="checkbox" value="Code100" checkGroupName="JNUCodeGroup"/>배
                    <input id="CheckboxCode" type="checkbox" value="Code100" checkGroupName="JNUCodeGroup"/>토마토
                    <input id="CheckboxCode" type="checkbox" value="Code100" checkGroupName="JNUCodeGroup"/>감
                   ** HTML Sample End**
                   
                    var arrReturn = new Array();
                    arrReturn = GetCheckedItems('JNUCodeGroup');

                    for (var  i = 0 ;  i < arrReturn.length; i++)
                    {
                        // 처리
                    }                   
*******************************************************/
function GetCheckedItems(checkGroupName)
{
	var oItem;
	var arrReturn = null;
	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("checkGroupName") != null )
					    if ( oItem.getAttribute("checkGroupName") == checkGroupName )
						    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("checkGroupName") != null )
					    if ( oItem.getAttribute("checkGroupName") == checkGroupName )
						    if ( oItem.checked == true )
							    arrReturn[idx++] = oItem;
	    }
	    return arrReturn;
	
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}		
	
	return arrReturn;	
}


/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  Select 컨트롤의 선택한 값을 리턴하는 함수
Parameter :
                     listBox (object : Select  컨트롤 명)
반환 값   :  
사용예    :  
                   ** HTML Sample Start**
                    <select id="hddlCode">
                        <option value="Code100">사과</option>
                        <option value="Code200">배</option>
                        <option value="Code300">토마토</option>
                        <option value="Code400">감</option>                                                
                    </select>
                   ** HTML Sample End**

                    <input id="hbtnSelectCode" type="button" value="Get SelectedValue"  
                             onclick="javascript:alert(GetListBoxValue(document.all.hddlCode));"/>                  
*******************************************************/
function GetListBoxValue(listBox)
{
    try
   { 
        return listBox[listBox.selectedIndex].value;
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}		        
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :   Select 컨트롤에 option을 추가하는 함수
Parameter :
                     listBox (object : Select  컨트롤 명)
                     displayText (string : Option에 출력된 Text)
                     displayValue (string : Option에 출력된 Value)
반환 값   :  
사용예    :  
                   ** HTML Sample Start**
                    <select id="hddlCode">
                        <option value="Code100">사과</option>
                        <option value="Code200">배</option>
                        <option value="Code300">토마토</option>
                        <option value="Code400">감</option>                                                
                    </select>
                   ** HTML Sample End**

                   <input id="hbtnAddSelectCode" type="button" value="Add SelectCode"  
                            onclick="javascript:AddListBoxItem(document.all.hddlCode,'복숭아','Code500');"/>                   
*******************************************************/
function AddListBoxItem(listBox, displayText, displayValue)
{
    try
   { 
	    var oOption = document.createElement("option");
	    oOption.text = displayText;
	    oOption.value = displayValue;
    	
	    listBox.add(oOption);
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}			
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :   Control의 위치를 이동하기 위한 함수
Parameter :
                     controlObject  (object : 이동할 컨트롤 명)
                     top            (int : Control의 위쪽 위치)
                     left           (int : Control의 왼쪽 위치)
반환 값   :  
사용예    :  
                    <input id="btnMoveControl" type="button" value="컨트롤 이동"  
                             onclick="javascript:MoveControl(document.all.hbtnAddSelectCode,200,300);"/>                
*******************************************************/
function MoveControl(control, top, left)
{
    try
   { 
	    control.style.position = "absolute";
	    control.style.top = top;
	    control.style.left = left;
	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}			
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  체크 박스 컨트롤중에서 체크된 아이템의 td 색을 바꾸는 함수
Parameter :
                     controlObject  (object : 이동할 컨트롤 명)
                     top            (int : Control의 위쪽 위치)
                     left           (int : Control의 왼쪽 위치)
반환 값   :  
사용예    :  
                        <input id="btnHlightCheckboxListl" type="button" value="HlightCheckboxList"  
                                 onclick="javascript:HlightCheckboxList();"/>                
*******************************************************/
function 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)
	{
		OpenErrorMessage(exception.description);
	}				
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  Server Control인 CheckBoxList 컨트롤의 아이템 중에서 선택된 값의 Row의 색을 변하게 하는 함수
Parameter :
                      checkBoxList  (object : Server Control의 CheckBoxList 컨트롤 명)
반환 값   :  
사용예    :  
                   ** HTML Sample Start**
                    <asp:CheckBoxList ID="chklCode" runat="server">
                        <asp:ListItem Value="Code100">사과</asp:ListItem>
                        <asp:ListItem Value="Code200">배</asp:ListItem>
                        <asp:ListItem Value="Code300">토마토</asp:ListItem>
                        <asp:ListItem Value="Code400">감</asp:ListItem>
                    </asp:CheckBoxList>
                   ** HTML Sample End**                            
                   
                    <input id="btnCheckBoxLoad" type="button" value="CheckBox List Load" 
                         onclick="javascript:CheckboxListLoad(document.all.chklCode);" />               
*******************************************************/
function CheckboxListLoad(checkBoxList)
{
	var oTable = null;
	var oTr = null;
	var oTd = null;
	var oChk = null;

	try
	{
		oTable = checkBoxList;

		for ( var i = 0 ; i < oTable.rows.length ; i++ )
		{
			oTr = oTable.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)
	{
		OpenErrorMessage(exception.description);
	}
	
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  지정한 Control을 Update 가능한 화면으로 변환하는 함수
Parameter :
                     control  (object : 화면에 나타낼 Control 명)
반환 값   :  
사용예    :  
                        <input id="hbtnUpdateMode" type="button" value="Update Mode" 
                             onclick="javascript:UpdateMode(document.all.btnSave);" />
*******************************************************/
function UpdateMode(control){
    try
   { 
        switch(control.type){
	        case 'text' :
		        control.readOnly=false;
		        control.className = "basic";
		        break;
	        case 'checkbox' :
		        control.style.visibility='visible';
		        break;
	        case 'select-one' :
		        control.disabled=false;
		        break;
	        case 'image' :
		        control.style.visibility='visible';
		        break;
	        default :
		        control.style.visibility='visible';
		        break;
        }
   	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}		 
}

/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  지정한 Control을 Read(Control이 Read Only 상태거나 숨김 상태 유지)만 가능한 화면으로 변환하는 함수
Parameter :
                     control  (object : 화면에 나타낼 Control 명)
반환 값   :  
사용예    :  
                       <input id="hbtnReadMode" type="button" value="Read Mode" 
                            onclick="javascript:UpdateMode(document.all.txtName);" />
*******************************************************/
function ReadMode(control){
    try
   { 
   	    switch(control.type){
		    case 'text' :
			    control.readOnly=true;
			    control.className = "txt_box_full_disabled";
			    break;
		    case 'checkbox' :
			    control.style.visibility='hidden';
			    break;
		    case 'select-one' :
			    control.disabled=true;
			    break;
		    case 'image' :
			    control.style.visibility='hidden';
			    break;
		    default :
			    control.style.visibility='hidden';
			    break;
	    }
   	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}		
}


/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  지정한 Control을 클래스명을 주어 다양한 스타일의 Read(Control이 Read Only 상태거나 숨김 상태 유지)만 가능한 화면으로 변환하는 함수
Parameter :
                     control  (object : 화면에 나타낼 Control 명)
반환 값   :  
사용예    :  
                       <input id="hbtnReadMode" type="button" value="Read Mode" 
                            onclick="javascript:UpdateMode(document.all.txtName, 'tran2');" />
*******************************************************/
function SetReadMode(control, styleClassName){
    try
   { 
   	    switch(control.type){
		    case 'text' :
			    control.readOnly=true;
			    control.className = styleClassName;
			    break;
		    case 'checkbox' :
			    control.style.visibility='hidden';
			    break;
		    case 'select-one' :
			    control.disabled=true;
			    break;
		    case 'image' :
			    control.style.visibility='hidden';
			    break;
		    default :
			    control.style.visibility='hidden';
			    break;
	    }
   	}
	catch(exception)
	{
		OpenErrorMessage(exception.description);
	}		
}
/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  Server Control 중 CheckBoxList의 첫번째 항목으로 포커스 이동
Parameter :
                     control  (string : **Server Control 중CheckBoxList 명)
반환 값   :  
사용예    :  
                   ** HTML Sample Start**
                    <asp:CheckBoxList ID="chklCode" runat="server">
                        <asp:ListItem Value="Code100">사과</asp:ListItem>
                        <asp:ListItem Value="Code200">배</asp:ListItem>
                        <asp:ListItem Value="Code300">토마토</asp:ListItem>
                        <asp:ListItem Value="Code400">감</asp:ListItem>
                    </asp:CheckBoxList>
                   ** HTML Sample End**   
                   
                <input id="hbtnSetFocusCheckBoxList" type="button" value="SetFocusCheckBoxList" 
                            onclick="javascript:SetFocusCheckBoxList('chklCode');" />   
*******************************************************/
function SetFocusCheckBoxList(control)
{
	var oItem;
	var focusItem;
	var iCnt = 0;
	var temp = 0;
	var  strFindControl;
		
		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("id") != null )
					{
						 strFindControl = oItem.getAttribute("id").substr(0, control.length)
						if ( strFindControl == control)
						{
							if (temp == 0 ) focusItem = oItem;				
							temp = temp + 1;								
						}
					}
		}
		
	focusItem.focus();	
}


/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  Server Control 중 RadioButtonList의 첫번째 항목으로 포커스 이동
Parameter :
                     control  (string : Server Control중 RadioButtonList 명)
반환 값   :  
사용예    :  
                   ** HTML Sample Start**
                    <asp:RadioButtonList ID="rdolCode" runat="server">
                        <asp:ListItem Value="CODE100">사과</asp:ListItem>
                        <asp:ListItem Value="CODE200">배</asp:ListItem>
                        <asp:ListItem Value="CODE300">복숭아</asp:ListItem>
                        <asp:ListItem Value="CODE400">감</asp:ListItem>            
                    </asp:RadioButtonList>
                   ** HTML Sample End**   
                   
                <input id="hbtnSetFocusRadionButtonList" type="button" value="SetFocusRadion Button" 
                            onclick="javascript:SetFocusRadionButtonList('rdolCode');" />
*******************************************************/
function SetFocusRadionButtonList(control)
{
	var oItem;
	var focusItem;
	var iCnt = 0;
	var temp = 0;
	var  strFindControl;	
	
		for ( var i = 0 ; i < document.all.length ; i++ )
		{
			oItem = document.all[i];
			if ( oItem.tagName.toUpperCase() == "INPUT")
				if ( oItem.getAttribute("type").toUpperCase() == "RADIO" )
					if (oItem.getAttribute("id") != null )
					{
						strFindControl = oItem.getAttribute("id").substr(0, control.length)
						if ( strFindControl == control)
						{
							if (temp == 0 ) focusItem = oItem;				
							temp = temp + 1;								
						}
					}
		}
		
		focusItem.focus();	
}


/*******************************************************
작 성 자  :  인터데브 정재권(2007년 03월 20일)
작성목적  :  Control의 값을 세자리마다 ,(컴마)를 출력
Parameter : control  (string : 컴마를 찍을 컨트롤명)
사용예    :  
                    <input name="htxtOrderTotal" type="text" id="htxtOrderTotal" class="basic" maxlength="10" 
                    style="text-align: right;padding-right: 3; width: 145px; ime-mode: disabled;" 
                    onkeypress="return uReplaceFormat(this);" 
                    onkeyup="return uReplaceFormat(this);" />
*******************************************************/
function uReplaceFormat(control)
{
	control.value = formatCurrency(control.value);
}

function formatCurrency(num) 
{
	try
	{	
		num = num.toString().replace(/\$|\,/g,'');
		
		if(isNaN(num))
		num = "0";
		
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		
//			cents = num%100;
		num = Math.floor(num/100).toString();
//			if(cents<10)
//			cents = "0" + cents;			

		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
//		    return (((sign)?'':'-') + '$' + num + '.' + cents);			
		return (((sign)?'':'-') + num);
	}
	catch (exception)
	{
		OpenErrorMessage(exception.description);
	}
}
// 정해진 위치로 부터 이미지를 가져 옮니다.
function GetImage(imgID, bizName, methodName, para, colName)
{
    var obj = eval("document.all."+ imgID);
    obj.src = GetJNURootPath() + "/ARSAMWEB/CMM/REF/CMMUsePage/imageLoader.aspx?BIZNAME="+bizName+"&METHOD="+methodName+"&PARAMS="+para+"&COLNAME="+colName;
}


function GetGridObject(gid)
{
    var grid = eval("document.all." + gid);
    grid.getRow = GetRow;
    return grid;
}

function GetRow(index)
{
    var idx = parseInt(index)+1;
    var rows = this.getElementsByTagName("tr");
    var seletedRow = rows(idx);
    seletedRow.getCell = GetCell;
    return seletedRow;
}

function GetCell(index)
{
      var cells  =  this.getElementsByTagName("td");
      var cell = cells(index); 
      cell.getValue = GetValue;
      return cell;
}

function GetValue()
{
    return this.outerText;
}

//WebTextEdit의 값들을 증가 및 감소 합니다.
function WebTextEdit_Spin(oEdit, delta, oEvent)
{
    var txt = oEdit.getText();
    if(delta > 0)
        txt = parseInt(txt) + 1;
    else if(txt.length > 0)
        txt = parseInt(txt) - 1; 
    oEdit.setText(txt);
    oEvent.needPostBack = true;

}

