﻿/*******************************************************************************

 FILE          : common.js
 DESCRIPTIONS  : 자바스크립트 공통 모듈
 REMARKS       : 공통적으로 쓰이는 자바스크립트 함수
 DATE          : 2004.12.15

 *******************************************************************************/


//=============================================================================
// 함수명: fn_~~
// 설  명: 공통적으로 쓰는 팝업
// 작업일: 
// 작업자: 
//=============================================================================

function fn_SetSelectControlOptionAdd(objControl, saVal, saNM){
	var oOption, nfor, nlen;
	
	nlen	= objControl.options.length;
	for(nfor=nlen ; nfor>0 ; nfor--){
		objControl.options[nfor-1] = null
	}
	
	nlen	= saVal.length;
	for(nfor=0 ; nfor<nlen ; nfor++){
		oOption = document.createElement("OPTION");
		objControl.options.add(oOption);
		oOption.innerText	= saNM[nfor];
		oOption.value		= saVal[nfor];
	}
}

function fn_CM_SelectEBMenuPly(p_SelectedMenuID, p_SelectedPly){
	var fn_Url;
	fn_Url	= "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectEBMenu.aspx?SelectedMenuID="+p_SelectedMenuID;
	fn_Url	+="&SelectedPly="+p_SelectedPly;
	
	PopUp(0, 450, 450, "fn_CM_SelectEBMenuPly", fn_Url);
}

/*
	p_SelectedAppLine	==> 선택된 결재/합의라인
	p_SelectedOper		==> 선택된 시행자
	p_SelectedReceip	==> 선택된 수신참조
*/


function fn_CM_SelectApp(p_SelectedAppLine, p_SelectedOper, p_SelectedReceip, nFormID, nDocID, p_sType){
	var fn_OperCheck="0", fn_ReceipCheck="0";
	
	if ((typeof p_sType)=='undefined')
		p_sType	= 'eacommon'
	if ((typeof nFormID)=='undefined')
		nFormID	= 0
	if ((typeof nDocID)=='undefined')
		nDocID	= 0
		
	if(document.getElementById("txtAddID")!=null){
		fn_OperCheck = 1;/*시행자*/
	}
	
	if(document.getElementById("txtManID")!=null){
		fn_ReceipCheck = 1;/*수신참조*/
	}
	
	fn_CM_SelectApp_Popup(p_SelectedAppLine, fn_OperCheck, fn_ReceipCheck, p_SelectedOper, p_SelectedReceip, nFormID, nDocID, p_sType);
	return false;
}


function fn_CM_SelectApp_Edit(p_SelectedAppLine, p_SelectedOper, p_SelectedReceip, nFormID, nDocID, p_sType, p_LastAppYN){
	var fn_OperCheck="0", fn_ReceipCheck="0";
	
	if ((typeof p_sType)=='undefined')
		p_sType	= 'eacommon'
	if ((typeof nFormID)=='undefined')
		nFormID	= 0
	if ((typeof nDocID)=='undefined')
		nDocID	= 0
		
	if(document.getElementById("txtAddID")!=null){
		fn_OperCheck = 1;/*시행자*/
	}
	
	if(document.getElementById("txtManID")!=null){
		fn_ReceipCheck = 1;/*수신참조*/
	}
	
	fn_CM_SelectApp_EditPopup(p_SelectedAppLine, fn_OperCheck, fn_ReceipCheck, p_SelectedOper, p_SelectedReceip, nFormID, nDocID, p_sType, p_LastAppYN);
	return false;
}

function fn_CM_SelectApp_EditPopup(p_SelectedAppLine, fn_OperCheck, fn_ReceipCheck, p_SelectedOper, p_SelectedReceip
								, nFormID, nDocID, p_sType, p_LastAppYN){
	var fn_Url;

	if ((typeof p_sType)=='undefined')
		p_sType	= 'eacommon'
	if ((typeof nFormID)=='undefined')
		nFormID	= 0
	if ((typeof nDocID)=='undefined')
		nDocID	= 0
	if ((typeof sAppLineUrl)=='undefined')
		sAppLineUrl	= "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectAppLine.aspx";
		
	if(document.getElementById("content_agr")==null) {
		fn_app_kind = 1;/*결재만*/
	}else{
		fn_app_kind = 2;/*결재합의 둘다*/
	}

	fn_Url	= sAppLineUrl;
	fn_Url	+="?app_kind="+fn_app_kind;
	fn_Url	+="&type="+p_sType;	
	fn_Url	+="&Form_ID="+nFormID;
	fn_Url	+="&Doc_ID="+nDocID;
	fn_Url  +="&bLastAppYN=" + p_LastAppYN;
	fn_Url	+="&OperCheck="+escape(fn_OperCheck);
	fn_Url	+="&ReceipCheck="+escape(fn_ReceipCheck);
	fn_Url	+="&SelectedOper="+escape(p_SelectedOper);
	fn_Url	+="&SelectedReceip="+escape(p_SelectedReceip);
	fn_Url	+="&SelectedAppLine="+escape(p_SelectedAppLine);
	
	PopUp(0, 830, 650, "SelectAppLine", fn_Url);
}

function fn_CM_SelectApp_2(p_SelectedAppLine, p_SelectedOper, p_SelectedReceip, nFormID, nDocID, p_sType, sAppLineUrl){
	var fn_OperCheck="0", fn_ReceipCheck="0";
	if ((typeof p_sType)=='undefined')
		p_sType	= 'eacommon'
	if ((typeof nFormID)=='undefined')
		nFormID	= 0
	if ((typeof nDocID)=='undefined')
		nDocID	= 0

	if(document.getElementById("txtAddID")!=null){
		fn_OperCheck = 1;/*시행자*/
	}
	
	if(document.getElementById("txtManID")!=null){
		fn_ReceipCheck = 1;/*수신참조*/
	}
	
	fn_CM_SelectApp_Popup(p_SelectedAppLine, fn_OperCheck, fn_ReceipCheck, p_SelectedOper, p_SelectedReceip, nFormID, nDocID, p_sType, sAppLineUrl);
	return false;
}

function fn_CM_SelectApp_Obj(p_SelectedAppLine, p_objOper, p_objReceip, nFormID, nDocID, p_sType, sAppLineUrl){
	var fn_OperCheck="0", fn_ReceipCheck="0";
	var p_SelectedOper="", p_SelectedReceip="";
	var fn_obj;
	if ((typeof p_sType)=='undefined')
		p_sType	= 'eacommon'
	if ((typeof nFormID)=='undefined')
		nFormID	= 0
	if ((typeof nDocID)=='undefined')
		nDocID	= 0
	if (typeof p_objOper =="string"){
		fn_obj	= document.getElementById(p_objOper);
	}else{
		fn_obj	= p_objOper;
	}
	if(fn_obj!=null){
		fn_OperCheck		= 1;/*시행자*/
		p_SelectedOper		= fn_obj.value;
	}
	
	if (typeof p_objReceip =="string"){
		fn_obj	= document.getElementById(p_objReceip);
	}else{
		fn_obj	= p_objReceip;
	}
	if(fn_obj!=null){
		fn_ReceipCheck		= 1;/*수신참조*/
		p_SelectedReceip	= fn_obj.value;
	}
	
	//근태 신청서의 경우 시행자의 다중 선택을 막기 위해 시행자 파라미터를 0으로 준다
	if(document.getElementById("hidOpervalue")!=null){
	    fn_OperCheck = document.getElementById("hidOpervalue").value;
	}
	
	fn_CM_SelectApp_Popup(p_SelectedAppLine, fn_OperCheck, fn_ReceipCheck, p_SelectedOper, p_SelectedReceip, nFormID, nDocID, p_sType);
	return false;
}

function fn_CM_SelectApp_Popup(p_SelectedAppLine, fn_OperCheck, fn_ReceipCheck, p_SelectedOper, p_SelectedReceip
								, nFormID, nDocID, p_sType
								, sAppLineUrl){
	var fn_Url;
	
	if ((typeof p_sType)=='undefined')
		p_sType	= 'eacommon'
	if ((typeof nFormID)=='undefined')
		nFormID	= 0
	if ((typeof nDocID)=='undefined')
		nDocID	= 0
	if ((typeof sAppLineUrl)=='undefined')
		sAppLineUrl	= "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectAppLine.aspx";
		
	if(document.getElementById("settle_line2")==null){
		fn_app_kind = 1;/*결재만*/
	}else{
		fn_app_kind = 2;/*결재합의 둘다*/
	}

	fn_Url	= sAppLineUrl;
	fn_Url	+="?app_kind="+fn_app_kind;
	fn_Url	+="&type="+p_sType;
	fn_Url	+="&Form_ID="+nFormID;
	fn_Url	+="&Doc_ID="+nDocID;
	fn_Url	+="&OperCheck="+escape(fn_OperCheck);
	fn_Url	+="&ReceipCheck="+escape(fn_ReceipCheck);
	fn_Url	+="&SelectedOper="+escape(p_SelectedOper);
	fn_Url	+="&SelectedReceip="+escape(p_SelectedReceip);
	fn_Url	+="&SelectedAppLine="+escape(p_SelectedAppLine);
	
	PopUp(0, 830, 650, "SelectAppLine", fn_Url);
}

function fn_UserInfo(co_id, dept_id, user_id){

	return false;
}
//거래처 코드 팝업
function fn_CustPopup(sSearchValue){
	PopUp(0, 500, 600, "CustPopup", "/KOR_WEBROOT/SRC/CM/Popup/Cust.aspx?SearchValue="+sSearchValue);
}

//품목 코드 팝업
function fn_ItemPopup(sSearchValue){
	PopUp(0, 600, 600, "ItemPopup", "/KOR_WEBROOT/SRC/PF/COMMON/Item.aspx?SearchValue="+sSearchValue);
}

/*부서 멀티 사람 멀티 팝업*/
function fn_MultiDeptMultiUser_Pop(sVal, iSelectCO){
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 800, 630, "MultiDeptMultiUser_Pop", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectMultiDeptMultiUser_POP.aspx?Selected="+sVal+"&SelectCO="+iSelectCO);
}
function fn_MultiDeptMultiUser_Pop2(sCOID, sVal, iSelectCO){
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 800, 600, "MultiDeptMultiUser_Pop", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectMultiDeptMultiUser_POP.aspx?co_id="+sCOID+"&Selected="+sVal+"&SelectCO="+iSelectCO);
}
function fn_MultiDeptMultiUser_Pop4(sCOID, sVal, iSelectCO, sModule){
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 800, 600, "MultiDeptMultiUser_Pop", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectMultiDeptMultiUser_POP.aspx?co_id="+sCOID+"&Selected="+sVal+"&SelectCO="+iSelectCO+"&module="+sModule);
}
function fn_MultiDeptMultiUser_SelectPop(sVal, iSelectCO){
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 800, 630, "MultiDeptMultiUser_Pop", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectMultiDeptMultiUser_SelectPOP.aspx?Selected="+sVal+"&SelectCO="+iSelectCO);
}
function fn_MultiDeptMultiUser_Final(sCOID, sVal, iSelectCO, sModule, sUrl){
	if(typeof sCOID=='undefined')		sCOID		= "0";
	if(typeof sVal=='undefined')		sVal		= "";
	if(typeof iSelectCO=='undefined')	iSelectCO	= 0;
	if(typeof sModule=='undefined')		sModule		= "";
	if(typeof sUrl=='undefined')		sUrl		= "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectMultiDeptMultiUser_POP.aspx";
	
	sUrl	+= "?co_id="+sCOID+"&Selected="+sVal+"&SelectCO="+iSelectCO+"&module="+sModule;
	PopUp(0, 800, 600, "MultiDeptMultiUser_Pop", sUrl);
}


function fn_UserSingle_Pop(iSelectCO){
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 800, 600, "UserSingle_Pop", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectUserSingle_POP.aspx?SelectCO="+iSelectCO);
}
function fn_UserSingle_Pop_OBJ(nSelectCO, ObjUserID, ObjUserNM){
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 800, 600, "UserSingle_Pop", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectUserSingle_POP.aspx?SelectCO="+nSelectCO+"&Type=obj&ObjUserID="+ObjUserID+"&ObjUserNM="+ObjUserNM);
}

/*양식 멀티 팝업*/
function fn_FormMulti_Pop2(sVal){
	PopUp(0, 400, 570, "UserMulti_POP", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectFormMulti_POP.aspx?Selected="+sVal);
}

/*사람 멀티 팝업*/
function fn_UserMulti_Pop2(sVal,iSelectCO){
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 800, 600, "UserMulti_POP", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectUserMulti_POP.aspx?Selected="+sVal+"&SelectCO="+iSelectCO);
}
function fn_UserMulti_Pop3(sCOID, sVal, iSelectCO){
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 800, 600, "UserMulti_POP", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectUserMulti_POP.aspx?co_id="+sCOID+"&Selected="+sVal+"&SelectCO="+iSelectCO);
}
function fn_UserMulti_Pop4(sCOID, sVal, iSelectCO, sModule){
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 800, 600, "UserMulti_POP", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectUserMulti_POP.aspx?co_id="+sCOID+"&Selected="+sVal+"&SelectCO="+iSelectCO+"&module="+sModule);
}
function fn_UserMulti_Pop5(sVal){
	PopUp(0, 800, 600, "UserMulti_POP", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectUserMulti_POP.aspx?co_id=1&Selected="+sVal+"&SelectCO=1&module=EA");
}

function fn_UserMulti_Final(sCOID, sVal, iSelectCO, sModule, sUrl){
	if(typeof sCOID=='undefined')		sCOID		= "0";
	if(typeof sVal=='undefined')		sVal		= "";
	if(typeof iSelectCO=='undefined')	iSelectCO	= 0;
	if(typeof sModule=='undefined')		sModule		= "";
	if(typeof sUrl=='undefined')		sUrl		= "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectUserMulti_POP.aspx";
	
	sUrl	+= "?co_id="+sCOID+"&Selected="+sVal+"&SelectCO="+iSelectCO+"&module="+sModule;
	
	PopUp(0, 800, 600, "MultiDeptMultiUser_Pop", sUrl);
}

// 팝업 : 부서 멀티선택
function fn_DeptMulti_Pop(sVal,iSelectCO) {
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 760, 600, "UserMulti_POP", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectMultiDept_POP.aspx?Selected="+sVal+"&SelectCO="+iSelectCO);
}

// 팝업: 팀게시판 관련 
function fn_TeamMulti_Pop(sVal,iSelectCO, nTeamPortalID){// 관리자 선택하기
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 800, 600, "TeamMulti_POP", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectMultiTeamMultiAdminUser_POP.aspx?Selected="+sVal+"&SelectCO="+iSelectCO+"&teamportal_id="+nTeamPortalID);
}

function fn_TeamUserMulti_Pop(sVal,iSelectCO, nTeamPortalID){// 조회/등록권한 사용자 선택하기
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 800, 600, "TeamMulti_POP", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectSingleTeamMultiUser_POP.aspx?Selected="+sVal+"&SelectCO="+iSelectCO+"&teamportal_id="+nTeamPortalID);
}

// 팝업 : 부서 단일선택
function fn_Dept_Pop(sVal,iSelectCO) {
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
	PopUp(0, 450, 600, "UserMulti_POP", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectDept_POP.aspx?Selected="+sVal+"&SelectCO="+iSelectCO);
}
function fn_Dept_Pop_Obj(iSelectCO, ObjDeptID, ObjDeptNM) {
	if(typeof iSelectCO=='undefined')
		iSelectCO	= 1;
		
	PopUp(0, 450, 600, "UserMulti_POP", "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectDept_POP.aspx?type=OBJ&SelectCO="+iSelectCO+"&ObjDeptID="+ObjDeptID+"&ObjDeptNM="+ObjDeptNM);
}

// 커스터마이징 : Ubprecision
// 팝업 : 휴일근무신청 결재라인선택
function fn_UB_Pop_AppLine(pIDNM, pDivNM, pStateNM, pID) {
	var sUrl = "/KOR_WEBROOT/CUSTERMIZING/Ubprecision/BS_Ubprecision_Pop_AppLine.aspx?id=" + pID + "&IDNM=" + pIDNM + "&DivNM="+ pDivNM + "&State=" + pStateNM;
	PopUp(0, 800, 600, "Pop_AppLine", sUrl);
			
	return false;
}

// 팝업 : 휴일근무 반려
function fn_UB_Pop_AppReturn(pID, pDiv) {
	var sUrl = "/KOR_WEBROOT/CUSTERMIZING/Ubprecision/BS_Ubprecision_AppReturn.aspx?id="+ pID + "&div=" + pDiv;
	PopUp(0, 400, 310, "Pop_AppLine", sUrl);
			
	return false;
}

// 신규 : id , 0:예정 , 0:의미없음
// 신규 : id , 1:실적 , 1:예정이 있는상태 (예정을 조회한 상태에서 실적을 신규등록한다)
// 신규 : id , 1:실적 , 0:예정이 없는상태
function fn_UB_Pop_App_I(psID, psPlanOrResult, psDiv) {
	var sUrl = "/KOR_WEBROOT/CUSTERMIZING/Ubprecision/BS_Ubprecision_0100200.aspx?&id=" + psID +"&PlanOrResult="+psPlanOrResult+"&InsertOrUpdate=0&ResultDiv="+psDiv + "&SearchOrUpdate=1" ;
	PopUp(0, 800, 500, "Pop_Insert", sUrl);
}

// 수정 : id , 0:예정 , 0:의미없음																	, 1:결재라인 변경 가능(결재를 아무도 하지않은 상태)
// 수정 : id , 1:실적 , 1:예정이 있는상태 (예정 및 실적을 조회한상태에서 예정 및 실적을 수정한다)	, 0:결재라인 변경 불가
// 수정 : id , 1:실적 , 0:예정이 없는상태 (실적을 조회한 상태에서 실적을 수정한다)
function fn_UB_Pop_App_U(psID, psPlanOrResult, psDiv, psSearchOrUpdate) {
	var sUrl = "/KOR_WEBROOT/CUSTERMIZING/Ubprecision/BS_Ubprecision_0100200.aspx?&id=" + psID +"&PlanOrResult="+psPlanOrResult+"&InsertOrUpdate=1&ResultDiv="+psDiv + "&SearchOrUpdate=" + psSearchOrUpdate ;
	PopUp(0, 800, 590, "Pop_Edit", sUrl);
}

// 조회 : id , 0:예정, 0:결재처리 안함
// 조회 : id , 0:예정, 1:결재처리
// 조회 : id , 1:실적, 0:결재처리 안함
// 조회 : id , 1:실적, 1:결채처리
function fn_UB_Pop_App_S(psID, psPlanOrResult, psDiv) {
	var sUrl = "/KOR_WEBROOT/CUSTERMIZING/Ubprecision/BS_Ubprecision_0100300.aspx?id="+psID+"&PlanOrResult="+psPlanOrResult+"&SearchOrApp="+psDiv;
	PopUp(0, 800, 590, "Pop_Search", sUrl);
}

//지출결의용 첨부파일 뷰어
function fn_EX_Aattch_File_View(arg) {
	PopUp(6,600,500,"EX0100110_FILE_VIEW", "/KOR_WEBROOT/SRC/EX2/COMMON/EX0100130_FILE_VIEW.aspx?DIR_NM="+arg);
}

//지출결의용 법인카드사용내역
function Fn_ExViewCard(arg1, arg2) {
    var imode = "v";
    if(typeof(arg2) != "undefined") {
       imode = arg2;
    }
	PopUp(0,400,420,"ExViewCard", "/KOR_WEBROOT/SRC/EX2/COMMON/EX0300210_AQ_DETAIL.aspx?GEORAE_COLL="+escape(arg1)+"&imode="+imode);
}

//차량운행일지조회팝업-지출결의사용
function Fn_ExViewOD(arg1) {
	PopUp(0,700,280,"ExViewOD", "/KOR_WEBROOT/SRC/BS/COMMON/BS0800300_POP.aspx?IF_D_ID="+escape(arg1));
}

function Fn_ExViewCard2(arg1) {
	PopUp(0,400,420,"ExViewCard2", "/KOR_WEBROOT/SRC/EX2/COMMON/EX0300210_AQ_DETAIL.aspx?GEORAE_COLL="+escape(arg1));
}

//자산소모품용 첨부파일뷰어
function fn_PF_Aattch_File_View(MOU, DIR) {
	PopUp(6,600,300,"PF_FILE_VIEW", "/KOR_WEBROOT/SRC/PF/COMMON/PF_FILE_VIEW.aspx?MOU="+MOU+"&DIR_NM="+DIR);
}

//=============================================================================
// 함 수 명: fn_FormchangedEvent : true:값이 바뀌었음, false:안 바뀌었음
// 파라미터: paraFrm==>form테그
//		   : unSelectedControls==>|컨트롤명|컨트롤명|
// 설    명: form개체 안에 바뀐 내용이 있는지 없는지 여부
// 작 업 일: newturns ldy
// 작 업 자: 2007-06-26
//=============================================================================
function fn_FormchangedEvent(paraFrm, unSelectedControls)
{	
	unSelectedControls	= "|"+unSelectedControls+"|";
	try
	{
		var element;
		
		for ( var i=0;i<paraFrm.length;i++)
		{
			element=paraFrm.elements[i];
			//컨트롤을 검색할지 여부
			if (unSelectedControls.indexOf("|"+element.name+"|")<0){
				if (((element.type=='text') ||(element.type=='textarea'))&&(element.value!=element.defaultValue) && (element.type!='select-one') && (element.type!='checkbox'))
				{
					return true;
				}
				else if((element.type=='select-one') && !(element.options[element.selectedIndex].defaultSelected)) 
				{
	/*				alert(element.name);
					alert(element.options[element.selectedIndex].defaultSelected);
					alert(element.options[element.selectedIndex].value);
	*/
					return true;
				}
				else if ((element.type=='checkbox') && (element.checked != element.defaultChecked))
				{
					return true;
				}
			}
		} //end for
	} catch(exception)
	{
			alert('폼객체를 점검중에 에러가 발생하였습니다.');
			return false;
	}
} // end  function

//=============================================================================
// 함수명: MM_preloadImages
// 설  명: Mouse Over에 의한 이미지 전환
// 작업일: 
// 작업자: 
//=============================================================================
function MM_preloadImages() 
{ 
  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];
         }
    }
  }
}


//=============================================================================
// 함수명: MM_swapImgRestore
// 설  명: Mouse Over에 의한 이미지 전환
// 작업일: 
// 작업자: 
//=============================================================================
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;
}


//=============================================================================
// 함수명: MM_findObj
// 설  명: Mouse Over에 의한 이미지 전환
// 작업일: 
// 작업자: 
//=============================================================================
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;
}


//=============================================================================
// 함수명: MM_swapImage
// 설  명: Mouse Over에 의한 이미지 전환
// 작업일: 
// 작업자: 
//=============================================================================
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];}
}

//=============================================================================
// 함수명: MM_showHideLayers
// 설  명: Mouse Over에 의한 Layer 전환
// 작업일: 
// 작업자: 
//=============================================================================
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


//=============================================================================
// 함수명: ValidateData                                                        
// 설  명: validateForm에 의해 사용된다
// 작업일:                                                                     
// 작업자:                                                                     
//=============================================================================
function validateData(objValue, strValidateStr, strError) 
{
    var epos = strValidateStr.search("="); 
    var command  = ""; 
    var cmdvalue = ""; 
    
    if(epos >= 0) 
    { 
		command  = strValidateStr.substring(0,epos); 
		cmdvalue = strValidateStr.substr(epos+1);
    } 
    else 
    { 
		command = strValidateStr;
    }
    
    switch(command) 
    { 
		case "req": 
        case "required": 
		{
		   var tp = objValue.value.replace(/\s/g,'');
           if(eval(tp.length) == 0) 
           { 
              alert(strError);
              return false; 
           } 
           break;             
        }
        case "maxlen": 
        case "maxlength": 
        { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
				alert(strError);
				return false; 
             }
             break; 
        }
        case "minlen":
        { 
             if(eval(objValue.value.length) <  eval(cmdvalue) && eval(objValue.value.length) != eval(0)) 
             { 
				alert(strError);
				return false;                 
             }
             break; 
        }
        case "minlength": 
        { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
				alert(strError);
				return false;                 
             }
             break; 
        }       
        case "eng":
        case "english": 
        { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
				alert(strError);
				return false; 
              } 
              break; 
        }
        case "engnum": 
        case "engnumeric": 
        { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                return false; 
              }
              break; 
        }
        case "engnumhyphen":
		{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                return false; 
              }
              break;
		} 
        case "num": 
        case "numeric": 
        { 
              var charpos = objValue.value.search("[^0-9\]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
				alert(strError);
				return false; 
              } 
              break;               
        }
        case "float": 
        { 
			if(objValue != undefined)
			{				
              var charpos = objValue.value.search("[^0-9\-.]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
				alert(strError);
				return false; 
              } 
            }  
            break;           
                
        }
        case "numhyphen": 
        { 
              var charpos = objValue.value.search("[^0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
				alert(strError);
				return false; 
              } 
              break;               
        }
        
        case "han" :
		case "hangul":
		{
              var charpos = objValue.value.search("[^가-힣]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                return false; 
              }
              break;
		}
		case "hannum" :
		case "hangulnumeric":
		{
              var charpos = objValue.value.search("[^ㄱ-ㅎ가-힣0-9]");
              alert(charpos);
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                objValue.select();
				objValue.focus();
                return false; 
              } 			
				break;
		}
		case "hanalpha" :
		case "hangulalphabetic":
		{
              var charpos = objValue.value.search("[^ㄱ-ㅎ가-힣A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                return false;
              } 			
				break;
		}
		case "hanengnum" :
		case "hangulenglishnumeric":
		{
              var charpos = objValue.value.search("[^ㄱ-ㅎ가-힣A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                return false; 
              } 			
				break;
		}
        case "email": 
        { 
               if(!CheckEmail(objValue.value)) 
               { 
                 alert(strError);
                 return false; 
               } 
           break; 
        }
        case "phone": 
        { 
               
               if(!CheckPhone(objValue.value)) 
               { 
                 alert(strError);
                 return false; 
               } 
           break; 
        }
        case "bizno": 
        { 
               if(!CheckBizNo(objValue.value)) 
               { 
                 alert(strError);
                 return false; 
               } 
           break; 
        }                 
        case "lt": 
        case "lessthan": 
        { 
            if(isNaN(objValue.value)) 
            { 
              return false; 
            }
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              alert(strError);
              return false;                 
             }             
            break; 
        } 
        case "gt": 
        case "greaterthan": 
        { 
            if(isNaN(objValue.value)) 
            { 
              return false; 
            }
            if(eval(objValue.value) <=  eval(cmdvalue)) 
            { 
               alert(strError); 
               return false;                 
            }             
            break; 
        }        
        case "regexp": 
        { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              alert(strError);
	              return false;                   
	            } 
			}
           break; 
        } 
        case "dontselect": 
        { 
            if(objValue.selectedIndex == null) 
            { 
              return false;
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
              alert(strError);
              return false;                                   
            } 
            break; 
        }
        case "dategreaterthan":
        {
			var startSplit = objValue.value.split("-");
			var endSplit;
			var startDate = new Date(startSplit[0], parseInt(startSplit[1])-1, startSplit[2]);
			var tempDate = new Date();
			var endDate;
			
			if(cmdvalue != "")
			{
				endSplit = document.all[cmdvalue].value.split("-");
				endDate = new Date(endSplit[0], parseInt(endSplit[1])-1, endSplit[2]);
			}
			else
			{
				endDate = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate());
			}
			
			if(startDate <= endDate)
			{
				alert(strError);
				return false;
			}
			break;
        }
    }

    return true; 
}

//=============================================================================
// 함수명: CheckEmail
// 설  명: 이메일 주소 검사

// 작업일: 
// 작업자: 
//=============================================================================
function CheckEmail(strValue) 
{ 
    if(strValue.length <= 0)
	{
	  return true;
	}
    var splitted = strValue.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null)
		return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }
      return true;
    }
	return false;
}

//=============================================================================
// 함수명: CheckPhone
// 설  명: 전화번호 검사

// 작업일: 
// 작업자: 
//============================================================================= 
function CheckPhone(strValue) 
{ 
    if(strValue.length <= 0)
	{
	  return true;
	}

    var splitted = strValue.match("^(.+)-(.+)-(.+)$");
    if(splitted == null) return false;

    if(splitted[1].length > 3) return false;
    
    if(splitted[2].length > 4) return false;

	var phoneEx1 = /^(\d+)(\-{1})(\d+)(\-{1})(\d{4,4})$/; 

	if (strValue.match(phoneEx1) == null) 	
		return false;
	else
		return true;
}
 
//=============================================================================
// 함수명: CheckBizNo
// 설  명: 사업자번호 검사

// 작업일: 
// 작업자: 
//============================================================================= 
function CheckBizNo(strValue) 
{ 
	var bizNoEx1 = /^(\d{3,3})(\-{1})(\d{2,2})(\-{1})(\d{5,5})$/; 

	if (strValue.match(bizNoEx1) == null) 	
		return false;
	else
		return true;
}

//=============================================================================
// 함수명: isDate
// 설  명: 날짜 유효성

// 작업일: 
// 작업자: 
//=============================================================================
function isDate(yyyy,mm,dd)
{
   if (yyyy.length != 4)
      return false;
   else {   
      yyyy=parseInt(yyyy,10);
      mm=parseInt(mm,10);
      dd=parseInt(dd,10);
      d = new Date(yyyy,mm-1,dd);
      if (d=="NaN") return false;
      if (yyyy == d.getFullYear() &&
         mm == d.getMonth()+1 &&
         dd == d.getDate() ) return true;
      return false;
   }   
}


//=============================================================================
// 함수명: isDate_yyyy_m_d
// 설  명: yyyy-mm-dd 형태 유효성

// 작업일: 
// 작업자: 
//=============================================================================
function isDate_yyyy_m_d(s)// yyyy-mm-dd 형태
{
   s = s.replace(/\s/g,""); // 공백제거
   
   if (s.match(/\d+\-\d+\-\d+/g)!=s) 
      return false; // 1111-11-11 포맷이 아님
      
   var d = s.split(/\-/g);
   
   return isDate(d[0],d[1],d[2]);
}

function DateToReturnArray(s)// yyyy-mm-dd 형태
{
   s = s.replace(/\s/g,""); // 공백제거
   
   if (s.match(/\d+\-\d+\-\d+/g)!=s) 
      return false; // 1111-11-11 포맷이 아님
      
   var d = s.split(/\-/g);
   
   return d;
}


//=============================================================================
// 함수명: checkDate
// 설  명: yyyy-mm-dd 형태 날짜 유효성

// 작업일: 
// 작업자: 
//=============================================================================
function checkDate(s)
{
   var isD

   isD=isDate_yyyy_m_d(s);

   if (isD) 
      return true;
   else
      return false;
}


//=============================================================================
// 함수명: correctDate
// 설  명: yyyy-mm-dd 형태 날짜
// 작업일: 
// 작업자: 
//=============================================================================
function correctDate(s)// yyyy-mm-dd 형태
{
   s=s.replace(/\s/g,""); // 공백제거
   var d = s.split(/\-/g);
   if (d[1].length == 1)
      d[1] = "0" + d[1];
   if (d[2].length == 1)
      d[2] = "0" + d[2];  
   return d[0] + "-"  + d[1] + "-" + d[2];
}
 

//=============================================================================
// 함수명: validateForm
// 설  명: 컨트롤의 유효성을 검사 validateData()를 호출하여 검사한다.
// 작업일: 
// 작업자: 
//=============================================================================
function validateForm(arrObjDesc) 
{ 

	for(var i=0; i < arrObjDesc.length; i++) 
	{
		for(var j=0; j < arrObjDesc[i].length ;j++) 
		{
			var objForm = document.all[arrObjDesc[i][j][0]];
			
			if(validateData(objForm, arrObjDesc[i][j][1], arrObjDesc[i][j][2]) == false) 
			{
				try{
					objForm.focus();
				}catch(e){}
				event.returnValue = false;
				return false;				 
			}
		} 
	}
	return true;
}

//=============================================================================
// 함수명: Trim
// 설  명: 넘어온 문자열들중에 포함된 공백을 모두 없앤 문자열을 리턴
// 작업일: 2004-12-16
// 작업자: 이수경

//=============================================================================
function Trim(strings)
{
    var retString = "";
    var c;
    var i;
    for(i=0;i<strings.length;i++) {
        c = strings.charAt(i);
        if(c != ' '){
           retString += c;
        }
    }
    return(retString);
}

//=============================================================================
// 함수명: ReplaceStr
// 설  명: 문자열 치환 Popup
// 작업일: 
// 작업자: 
//=============================================================================

function ReplaceStr(strOriginal, strFind, strChange)
{
  return strOriginal.split(strFind).join(strChange);
}

//=============================================================================
// 함수명: EnterProcOnKeyDown
// 설  명: Enter Key Event를 Tab Key Event로 전환
// 작업일: 
// 작업자: 
//=============================================================================
function EnterProcOnKeyDown() { 
   if (event.keyCode == 13) {
      event.keyCode = 9;
   } 
}


//=============================================================================
// 함수명: ModifyTxt
// 설  명: strVal 값의 empty 여부에 따라 등록 또는 수정 문구 리턴
// 작업일: 2004-12-16
// 작업자: 
//=============================================================================
function ModifyTxt(strVal)
{
	if (strVal == "")
		retString = garrMsg[1002];	
	else
		retString = garrMsg[1012];

    return(retString);
}


//=============================================================================
// 함수명: Popup 
// 설  명: PopUp 창 호출
// 작업일: 
// 작업자: 
//=============================================================================

function PopUp(intStyle, intWidth, intHeight, strWinNm, strUrl) {
   var intLeft = 0, intTop = 0;
   var winstyle;
   var oWin;            

   //중앙정렬 (스크롤바 무, 상태표시줄 무)
   if (intStyle == 0) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      
      oWin	= window.open(strUrl, strWinNm, 'menubar =0,resizable=0,scrollbars=0,status=no,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }    
   //showModelessDialog
   else if (intStyle == 1) {
      winstyle = "dialogWidth=" + intWidth + "px; dialogHeight=" + intHeight + "px; center:yes; status=no; help:no; ";      
      oWin	= window.showModelessDialog(strUrl, window, winstyle); 
   }
   //showModalDialog
   else if (intStyle == 2) {
      winstyle = "dialogWidth=" + intWidth + "px; dialogHeight=" + intHeight + "px; center:yes; status=no; help:no; ";
      oWin	= window.showModalDialog(strUrl, window, winstyle); 
   }
   //excel
   else if (intStyle == 3) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      
      oWin	= window.open(strUrl, strWinNm, 'menubar =0,resizable=1,scrollbars=0,status=no,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }
   //중앙정렬 (스크롤바 유, 상태표시줄 무)
   else if (intStyle == 4) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      
      oWin	= window.open(strUrl, strWinNm, 'menubar =0,resizable=0,scrollbars=1,status=no,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }
   //좌측상단정렬 (스크롤바 무, 상태표시줄 무)
   else if (intStyle == 5) {      
      
      oWin	= window.open(strUrl, strWinNm, 'menubar =0,resizable=0,scrollbars=0,status=no,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }   
   //중앙정렬 (스크롤바 무, 상태표시줄 무)
   else if (intStyle == 6) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;      
      
      oWin	= window.open(strUrl, strWinNm, 'menubar =0,resizable=0,scrollbars=0,status=no,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }      
   //화면중앙정열
   else if (intStyle == 7) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      
      oWin	= window.open(strUrl, strWinNm, 'menubar =0,resizable=0,scrollbars=0,status=no,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',center:yes;');      
   }
   //테스트용 (스크롤바 유, 상태표시줄 유)   
   else if (intStyle == 99) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      
      oWin	= window.open(strUrl, strWinNm, 'menubar =0,resizable=0,scrollbars=1,status=yes,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }
   else if  (intStyle == 888) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      oWin	= window.open(strUrl, strWinNm, 'menubar=1,resizable=1,scrollbars=1,status=yes,titlebar=1,toolbar=no,location=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }
   else if  (intStyle == 999) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      oWin	= window.open(strUrl, strWinNm, 'menubar=1,resizable=1,scrollbars=1,status=yes,titlebar=1,toolbar=yes,location=yes,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }
   
   
    try
    {
	    if(oWin.focus)
		{
			oWin.focus();
		}
	}
	catch(err)	
	{
	
	}

	   
   return oWin;
}

//=============================================================================
// 함수명: 달력 Popup 
// 설  명: 달력 PopUp 창 호출
// 작업일: 
// 작업자: 
//=============================================================================

function PopUpCalendar(intSeq) {

	var strUrl;
	var temp;
	strUrl = "../COMMON/COMMON_CALENDAR_POP2b93.html?P_SEQ=" + intSeq ;								
	temp = PopUp(1, 212, 268,'PopUpCalendar', strUrl);
	temp.focus();			
   
}

//=============================================================================
// 함수명: 우편번호 Popup 
// 설  명: 우편번호 PopUp 창 호출
// 작업일: 
// 작업자: 
//=============================================================================
function PopUpZipCd(txtSearchValue) {
	var strUrl;
	var temp;
	strUrl = "/KOR_WEBROOT/SRC/CM/COMMON/CM_SelectZipAddr.aspx?SearchValue=" + txtSearchValue ;								
	temp = PopUp(0, 500, 420,'PopUpZipCd', strUrl);
	temp.focus();
	
	return false;
}

//=============================================================================
// 함수명: 상품코드검색 Popup 
// 설  명: 상품코드 검색 PopUp 창 호출
// 작업일: 
// 작업자: 
//=============================================================================

function PopUpGoodsCd(intSeq) {

	PopUp(0,707,442,'PopUpGoodsCd', '../COMMON/COMMON_GOODS_CD_POP.aspx?P_SEQ=' + intSeq);
   
}

//=============================================================================
// 함수명: 매입거래선코드검색 Popup 
// 설  명: 매입거래선코드검색 PopUp 창 호출 (intPartnerType - 0:위탁, 1:직매입, 2: 위탁 + 직매입)
// 작업일: 
// 작업자: 
//=============================================================================

function PopUpBuyPartnerCd(intSeq, intPartnerType) {
	
	PopUp(0,707,395,'PopUpBuyPartnerCd', '../COMMON/COMMON_BUY_PARTNER_CD_POP.aspx?P_SEQ=' + intSeq + '&P_PARTNER_TYPE=' + intPartnerType);
   
}

//=============================================================================
// 함수명: 매출거래선코드검색 Popup 
// 설  명: 매출거래선코드검색 PopUp 창 호출
// 작업일: 
// 작업자: 
//=============================================================================

function PopUpSalePartnerCd(intSeq) {
	
	PopUp(0,707,388,'PopUpSalePartnerCd', '../COMMON/COMMON_SALE_PARTNER_CD_POP.aspx?P_SEQ=' + intSeq);
   
}

//=============================================================================
// 함수명: 파일업로드 Popup 
// 설  명: 파일업로드 PopUp 창 호출
// 작업일: 
// 작업자: 
//=============================================================================

function PopUpFileUpload(intSeq) {

//	PopUp(0,709,444,'../COMMON/COMMON_FILE_UPLOAD_POP.aspx?P_SEQ=' + intSeq);
   
}

//=============================================================================
// 함수명: 팝업 창 닫기
// 설  명: 팝업 창 닫기
// 작업일: 
// 작업자: 
//=============================================================================
function WindowClose()
{						
	top.self.close();				
}

//=============================================================================
// 함수명: 저장 되었습니다.등 간단한 메세지를 보여주는 메서드

// 설  명: 메세지 표시
// 작업일: 
// 작업자: 
//=============================================================================
function fn_Message(str){
	alert(str)
}
//=============================================================================
// 함수명: 에러내용을 나타내는 메서드

// 설  명: 메세지 표시
// 작업일: 
// 작업자: 
//=============================================================================
function fn_Alert(str){
	alert(str)
}
function fn_Calendar(sObj){
	alert(sObj);
}

/**************************************************************
 Split: Returns a zero-based, one-dimensional array containing 
        a specified number of substrings

 Parameters:
      Expression = String expression containing substrings and 
                   delimiters. If expression is a zero-length 
                   string(""), Split returns an empty array, 
                   that is, an array with no elements and no 
                   data.
      Delimiter  = String character used to identify substring 
                   limits. If delimiter is a zero-length 
                   string (""), a single-element array 
                   containing the entire expression string 
                   is returned.

 Returns: String
***************************************************************/
function fn_Split(Expression, Delimiter)
{
	var temp = Expression;
	var a, b = 0;
	var array = new Array();

	if (Delimiter.length == 0)
	{
		array[0] = Expression;
		return (array);
	}

	if (Expression.length == '')
	{
		array[0] = Expression;
		return (array);
	}

	Delimiter = Delimiter.charAt(0);

	for (var i = 0; i < Expression.length; i++) 
	{
		a = temp.indexOf(Delimiter);
		if (a == -1)
		{
			array[i] = temp;
			break;
		}
		else
		{
			b = (b + a) + 1;
			var temp2 = temp.substring(0, a);
			array[i] = temp2;
			temp = Expression.substr(b, Expression.length - temp2.length);
		}
	}

	return (array);
}

//=============================================================================
// 함수명: 임시사용 에디터용 새창띄우기 함수
// 설  명: 새창띄우기

// 작업일: 
// 작업자: 
//=============================================================================
function wn_on(a, b, c){
if(c==1){
					window.open(a, b, "left=100, top=100, status=no, scrollbars=yes, status=no, width=50, height=50");
					return b;
}
if(c==2){
					window.open(a, b, "left=100, top=100, resizable=yes, status=yes, scrollbars=no");
					return b;
}
if(c==3){
					window.open(a, b, "left=100, top=100, left=100, resizable=yes, status=yes, scrollbars=no, width=50, height=50");
					return b;
}
					window.open(a, b, "left=100, top=100, scrollbars=no, status=no, width=50, height=50");
					return b;

}







/*  Function Equivalent to java.net.URLEncoder.encode(String, "UTF-8")

    Copyright (C) 2002, Cresc Corp.

    Version: 1.0

*/

function encodeURL(str){

    var s0, i, s, u;

    s0 = "";                // encoded str

    for (i = 0; i < str.length; i++){   // scan the source

        s = str.charAt(i);

        u = str.charCodeAt(i);          // get unicode of the char

        if (s == " "){s0 += "+";}       // SP should be converted to "+"

        else {

            if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){       // check for escape

                s0 = s0 + s;            // don't escape

            }

            else {                  // escape

                if ((u >= 0x0) && (u <= 0x7f)){     // single byte format

                    s = "0"+u.toString(16);

                    s0 += "%"+ s.substr(s.length-2);

                }

                else if (u > 0x1fffff){     // quaternary byte format (extended)

                    s0 += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);

                    s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);

                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);

                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);

                }

                else if (u > 0x7ff){        // triple byte format

                    s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);

                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);

                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);

                }

                else {                      // double byte format

                    s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);

                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);

                }

            }

        }

    }

    return s0;

}

 

/*  Function Equivalent to java.net.URLDecoder.decode(String, "UTF-8")

    Copyright (C) 2002, Cresc Corp.

    Version: 1.0

*/

function decodeURL(str){

    var s0, i, j, s, ss, u, n, f;

    s0 = "";                // decoded str

    for (i = 0; i < str.length; i++){   // scan the source str

        s = str.charAt(i);

        if (s == "+"){s0 += " ";}       // "+" should be changed to SP

        else {

            if (s != "%"){s0 += s;}     // add an unescaped char

            else{               // escape sequence decoding

                u = 0;          // unicode of the character

                f = 1;          // escape flag, zero means end of this sequence

                while (true) {

                    ss = "";        // local str to parse as int

                        for (j = 0; j < 2; j++ ) {  // get two maximum hex characters for parse

                            sss = str.charAt(++i);

                            if (((sss >= "0") && (sss <= "9")) || ((sss >= "a") && (sss <= "f"))  || ((sss >= "A") && (sss <= "F"))) {

                                ss += sss;      // if hex, add the hex character

                            } else {--i; break;}    // not a hex char., exit the loop

                        }

                    n = parseInt(ss, 16);           // parse the hex str as byte

                    if (n <= 0x7f){u = n; f = 1;}   // single byte format

                    if ((n >= 0xc0) && (n <= 0xdf)){u = n & 0x1f; f = 2;}   // double byte format

                    if ((n >= 0xe0) && (n <= 0xef)){u = n & 0x0f; f = 3;}   // triple byte format

                    if ((n >= 0xf0) && (n <= 0xf7)){u = n & 0x07; f = 4;}   // quaternary byte format (extended)

                    if ((n >= 0x80) && (n <= 0xbf)){u = (u << 6) + (n & 0x3f); --f;}         // not a first, shift and add 6 lower bits

                    if (f <= 1){break;}         // end of the utf byte sequence

                    if (str.charAt(i + 1) == "%"){ i++ ;}                   // test for the next shift byte

                    else {break;}                   // abnormal, format error

                }

            s0 += String.fromCharCode(u);           // add the escaped character

            }

        }

    }

    return s0;

}


//--------------------------------------------------------------------------------------//
// Description  : a function for MS IE ActiveX Rollup Patch                             //
// Parameter    : id                                                                    //
// Example  :                                                                           //
// Etc      :                                                                           //
//--------------------------------------------------------------------------------------//
function __WS__(id)
{
 document.write(id.text); id.id="";
}


function fn_cardview(arg)
{
	PopUp(0, 980, 600, "IL_CARDVIEW", "/KOR_WEBROOT/SRC/IL/COMMON/IL_CARD_VIEW.aspx?app_no="+arg);
	
	return false;
}


//--------------------------------------------------------------------------------------//
// Description	: 달력 popup 호출    													//
// Parameter 	: 텍스트박스이름, 위치Top, 위치Left                                		//
// Example		: TextBox1, 500, 200                                                   	//
// Etc			:            													   	    //
//--------------------------------------------------------------------------------------//

function CalendarPopup(pstrType, pintTop, pintLeft)
{
	var strUrl, strWinStyle;
	var strPosition;
	var temp;
	
	strPosition = 'center:yes;';
	pintTop = '';
	pintLeft = ''
	
	var oDateText = document.getElementById(pstrType);

	var curdt = "";
	
	try
	{
		curdt = oDateText.value;
	}
	catch(err)
	{
			
	}

	strUrl = "/KOR_WEBROOT/SRC/CM/COMMON/CM_Select_Calandar.aspx?P_SEQ=" + pstrType+"&dt="+ curdt;
	//strWinStyle = "dialogWidth=211px; dialogHeight=284px;status=no; help:no; " + strPosition;
	strWinStyle = "dialogWidth=230px; dialogHeight=300px;status=no; help:no; " + strPosition;      
	temp = window.showModalDialog(strUrl, window, strWinStyle);
}

// 상신일자 상신자변경 옵션에서 에서 호출되는 날자 팝업 - 따로 뽑아 냄
function CalendarPopup_Edit(pstrType, pintTop, pintLeft)
{
	var strUrl, strWinStyle;
	var strPosition;
	var temp;
	
	strPosition = 'center:yes;';
	pintTop = '';
	pintLeft = ''
	
	var oDateText = document.getElementById(pstrType);

	var curdt = "";
	
	try
	{
		curdt = oDateText.value;
	}
	catch(err)
	{
			
	}

	strUrl = "/KOR_WEBROOT/SRC/CM/COMMON/CM_Select_Calandar.aspx?P_SEQ=" + pstrType+"&dt="+ curdt;
	//strWinStyle = "dialogWidth=211px; dialogHeight=284px;status=no; help:no; " + strPosition;
	strWinStyle = "dialogWidth=230px; dialogHeight=300px;status=no; help:no; " + strPosition;      
	temp = window.showModalDialog(strUrl, window, strWinStyle);
	
	AppDTEdit_CodeBaseChange(); //품의번호를 실시간으로 바꾸면 좋겠지만 현재는 불가능 
}





function CalendarPopupControlBind(seq, pintTop, pintLeft)
{
	var strUrl, strWinStyle;
	var strPosition;
	var temp;
		
	strPosition = 'center:yes;';
	pintTop = '';
	pintLeft = ''
	strUrl = "/KOR_WEBROOT/SRC/CM/COMMON/CM_Select_Calandar.aspx?P_SEQ=" + seq + "&P_RTN_FUNC_GB=PF" ;
	strWinStyle = "dialogWidth=211px; dialogHeight=300px;status=no; help:no; " + strPosition;
	temp = window.showModalDialog(strUrl, window, strWinStyle);
	
}

function CalendarPopupControlBindPTI(objNM, objVal)
{
	var strUrl, strWinStyle;
	var strPosition;
	var temp;
		
	strPosition = 'center:yes;';
	pintTop = '';
	pintLeft = ''
	strUrl = "/KOR_WEBROOT/SRC/CM/COMMON/CM_Select_Calandar.aspx?P_RTN_FUNC_GB=PTI&objNM="+objNM+"&objVal="+objVal;
	strWinStyle = "dialogWidth=211px; dialogHeight=300px;status=no; help:no; " + strPosition;
	temp = window.showModalDialog(strUrl, window, strWinStyle);
}





function SetDateCalandar(gub, wdt) {
    document.all[gub].value = wdt;
} 

function GNT_GetSelectControlId(gn, rowIndex, col, sXHtmlType)
{		
        /*
		var table = document.all[gn];
		var sub = eval(table.skiptop);
		return gn + ':_ctl' + (rowIndex + 1) + ':_ctl' + col;
		*/		
		
		var table = document.all[gn];
		var sub = eval(table.skiptop);
		
		rowIndex = rowIndex + 1;
	
		var srowIndex = rowIndex.toString();
		var scol = col.toString();
	
		var sClientID = "";

		if ((typeof sXHtmlType) == "undefined")
			sXHtmlType = "Legacy";

		if(sXHtmlType == "undefined" || sXHtmlType == "Legacy") {
			//dgList$_ctl2$_ctl0
			sClientID = gn + '$_ctl' + (srowIndex) + '$_ctl' + scol;
		}
		else{
			if(srowIndex.length == 1) srowIndex = "0" + srowIndex;
			if(scol.length == 1) scol = "0" + scol;

			//dgList$ctl04$ctl00
			sClientID = gn + '$ctl' + (srowIndex) + '$ctl' + scol;
		}

		//alert(sClientID);
		
		return sClientID;
}

//-----**************** 이미지 배율별 리사이즈 -----****************//
function ImgResize(objImg,nHeight,nWidth) {
 if(objImg != null) {
  if(objImg.height > nHeight) {
   objImg.height = nHeight;
   }

  if(objImg.width > nWidth) {
   objImg.width = nWidth;
   }
 } 
}




//-------------------- 체크박스 전체 체크/언체크 -------------------//
function fn_AllCheckBoxChecked(obj, objChked){
	if ((typeof objChked)=='undefined')
		return;
		
	if ((typeof objChked.length)=='undefined'){
		objChked.checked	= obj.checked;
		return;	
	}
		
	var nfor, nlen;
	nlen	= objChked.length
	for(nfor=0 ; nfor<nlen ; nfor++){
		objChked[nfor].checked	= obj.checked;
	}
}
		
		
//=============================================================================
// 함수명: fn_StringToNumber                                                        
// 설  명: 문자열을 숫자로 변환하여 리턴
// 작업일: 2006-12-21                                                                    
// 작업자: 김병열                                                                    
//=============================================================================
function fn_StringToNumber(arg)
{
	var nRtn = 0;
	
	if(arg == null || Trim(arg).length == 0){
		nRtn =  0;
	}
	else{
		try
		{
			nRtn = Number(ReplaceStr(Trim(arg), ",", ""));
		}
		catch(err)
		{
			nRtn = 0;
		}
	}
	
	return nRtn
}

function fn_COMWCT_title(obj)
{
	//obj.title	= obj.innerHTML;
	obj.title	= obj.innerText;
}

function ClickChkAll(chkName1, chkName2)
{
	var frm = document.forms[0];
	
	if ( eval('document.forms[0].'+chkName1).checked)
		SelectAll( frm, chkName2, true );
	else
		SelectAll( frm, chkName2, false );
}

function SelectAll( frm, chkName, checked )
{
	for ( var i = 0; i < frm.elements.length; i++ )
	{
		var e = frm.elements[i];
		if ( e.type == "checkbox" &&  e.name.indexOf( chkName ) >= 0) {
		    if(!e.disabled)
		        e.checked = checked;
		}
			
	}
}




function fctRefreshTreeCnt()
    { 
        try 
        { 
            top.frmLeftMenu.frmGetBoxCnt.location.reload(true); 
        }
        catch(e) 
        {
         }
    }
    
//=============================================================================
// 함수명: fn_UrlExceptionKey                                                        
// 설  명: 요청 주소의 특정 쿼스스트링의 키값을 제거하여 리턴
// 작업일: 2008-03-20                                                                    
// 작업자: 김병열                                                                    
//=============================================================================
function fn_UrlExceptionKey(Url, ExceptionKey){
	var arUrl1 = Url.split("?");
	var arUrl2, arUrl3;
	var sReturnUrl = "";
	var nCount = 0;

	if(arUrl1.length > 1){
		sReturnUrl = arUrl1[0] + "?";
		for(var i=1; i < arUrl1.length; i++) {

			arUrl2 = arUrl1[i].split("&");

			for(var x=0; x < arUrl2.length; x++) {

				arUrl3 = arUrl2[x].split("=");

				if(arUrl3.length > 1) {
					if(arUrl3[0] != ExceptionKey) {
						if(nCount == 0) {
							sReturnUrl = sReturnUrl + arUrl2[x];
							nCount++;
						}
						else {
							sReturnUrl = sReturnUrl + "&" +  arUrl2[x];
						}

						
					}
				}
			}
		}
	}
	else {
		sReturnUrl = Url;
	}

	return sReturnUrl;
}

//=============================================================================
// 함수명: fn_UrlKeyValue                                                        
// 설  명: 요청 주소의 특정 쿼스스트링의 키의 값을 리턴
// 작업일: 2008-03-20                                                                    
// 작업자: 김병열                                                                    
//=============================================================================
function fn_UrlKeyValue(Url, GetKey){
	var arUrl1 = Url.split("?");
	var arUrl2, arUrl3;
	var sReturnValue = "";

	if(arUrl1.length > 1){
		for(var i=1; i < arUrl1.length; i++) {

			arUrl2 = arUrl1[i].split("&");

			for(var x=0; x < arUrl2.length; x++) {

				arUrl3 = arUrl2[x].split("=");

				if(arUrl3.length > 1) {
					if(arUrl3[0] == GetKey) {
						sReturnValue = arUrl3[1];
					}
				}
			}
		}
	}

	return sReturnValue;
}

//=============================================================================
// 함수명: addLoadEvent                                                        
// 설  명: onload 여러개 실행
// 작업일: 2008-06-24                                                                    
// 작업자: 권혁만
// 예  제: 
//			addLoadEvent(firstFunction);
//			addLoadEvent(secondFunction);
//=============================================================================
function addLoadEvent(func) {
    var oldonload = window.onload;
        if(typeof window.onload != 'function') {
            window.onload = func;
        } else {
            window.onload = function() {
                oldonload();
                func();
        }
    }
}

function fn_ShowProgress()
{
	//버튼을 클릭했는지 여부를 나타내는 변수로 처리이벤트는 한번만 실행하도록 하기위해서 사용
	var IsClick=false;

	try
	{
		oPopup = window.createPopup();
		var  oPopBody  =  oPopup.document.body;
		oPopBody.style.backgroundColor  =  "white";
		oPopBody.style.border  =  "solid  #dddddd 1px";

		// "처리중입니다"라는 메시지와 로딩이미지가 표시되도록 한다.
		oPopBody.innerHTML  = "<table width='100%' height='100%'><tr><td align='center'><img src='/KOR_WEBROOT/IMAGE/COMMON/progress_bar.gif'></td></tr></table>";

		var leftX = document.body.clientWidth/2 - 150;
		var topY = (document.body.clientHeight/2) - (oPopBody.offsetHeight/2);

		oPopup.show(leftX,  topY,  400,  150,  document.body);

		// createPopup()를 이용해 팝업페이지를 만드는 경우
		// 기본적으로 해당 팝업에서 onblur이벤트가 발생하면 그 팝업페이지는 닫히게 됩니다.
		// 해당 팝업페이지에서 onblur이벤트가 발생할때마다  메소드를 재호출하여
		// 팝업페이지가 항상 표시되게 합니다.
		oPopBody.attachEvent("onblur", ButtonProcessing);
	}
	catch(e) 
	{
	
	}
}

function fctShowLoding()
{
	if (document.all["divLoading"].style.display=="none")
	{
		//이렇게해야 로딩 이미지가 보임
		var sloadingimghtml = "<table width='100%' height='100%' cellpadding='0' cellspacing='0' background='/KOR_WEBROOT/IMAGE/COMMON/Loadingbg.gif'><tr valign=middle align='center'><td width='170' align='center'><img src='/KOR_WEBROOT/IMAGE/COMMON/loading.gif' border='0' align='absmiddle' style='hight:30px;width:30'></td><td align='left'></td></tr></table>";
	
		document.all["divLoading"].innerHTML = sloadingimghtml;
		document.all["divLoading"].style.display = "block";
		document.all["divLoading"].style.top = (document.body.scrollHeight - (document.body.scrollHeight - document.body.scrollTop)) +200 ;
		document.all["divLoading"].style.left = (document.body.scrollWidth/2)-150; 
	}
	else
	{
		document.all["divLoading"].style.display = "none";
	}
}


function fn_PassWordChange(div, type) {
    if(typeof(type) == "undefined")
        type = "notrequired";

    var args = new Array();
    args["type"] = type;
    
    //showModalDialog(URL, dialogArguments, properties) 
    var msgDialog = window.showModalDialog("/KOR_WEBROOT/SRC/MP/COMMON/MP0400100.aspx?pw_div="+div+"&type="+type, args, "dialogWidth=480px; dialogHeight=380px; center:yes; status=no; help:no;");
   
    if(type != "notrequired") {
        if(msgDialog == "close") {
        	if(navigator.appVersion.indexOf("MSIE 7.0")>=0 || navigator.appVersion.indexOf("MSIE 8.0")>=0) {
    			top.window.open('about:blank','_self').close();
            }
            else {
			  self.opener=self;
			  top.self.close();
			}
        }
        else if(msgDialog == false) {
           fn_PassWordChange(div, type); 
        }
        
    }
    return false;
}

function fctWebSSO(arg) {
    PopUp(999, 1024, 768, "SSO", "/KOR_WEBROOT/SRC/CM/COMMON/CM_WEBSSO.aspx?arg="+arg);
}

//로그인패스워드암호화, 클라이언트 IP
function fn_EncPss(pEncUse) {
    var oText = document.getElementById("txtLoginPwd");
    var oEnc = document.getElementById("txtPwEnc");
    var oIP = document.getElementById("txtClientIP");
    var oBS = document.getElementById("txtClientBS");
    
    if ((typeof pEncUse) == 'undefined') {
        pEncUse = "TRUE";
    }
    
    try {
        oIP.value = document.Form1.ERPSSO.GetLocalIP;
        
        if(pEncUse.toUpperCase() == "TRUE") {
            oEnc.value = document.Form1.ERPSSO.Encrypt_S(oText.value);
            oText.value = "";
        }
        
        var swidth = screen.availWidth;
		var sheight = screen.availHeight;
        oBS.value = swidth + "/" + sheight;
        
        return true;
    }
    catch(err) {
        alert("DUZONERPSSO ActiveX를 설치하여 주십시오.");
        return false;
    }
}

function fn_DuzonEBankView(no_tax, no_biz_no) {
    var url = "http://test.bill36524.com/EMailApi_Tax.jsp?";
    url += "NO_TAX=" + no_tax;
    url += "&NO_BIZ_NO=" + no_biz_no;
    window.open(url, "taxwin", "height=700,width=750, menubar=no, location=no, resizeable=no, status=no, scrollbars=no, top=200, left=300");
    return false;
}

//=============================================================================
// 함수명: getCookieValue                                                        
// 설  명: 쿠키값을 리턴
// 작업일: 2009-05-11                                                                    
// 작업자: 김병열
// 예  제: var sLang = getCookieValue("LangKind");
//=============================================================================
function getCookieValue (strName) {
    var strCookieName = strName + "=";
    var objCookie = document.cookie;
    
    if (objCookie.length > 0) {
        var nBegin = objCookie.indexOf(strCookieName);
        
        if (nBegin < 0) {
            return;
        }
 
        nBegin += strCookieName.length;

        var nEnd = objCookie.indexOf(";", nBegin);
	    var nEnd2 = objCookie.indexOf("&", nBegin);
	
	    if(nEnd > nEnd2)
		    nEnd = nEnd2;	
                
        if (nEnd == -1) {
            nEnd = objCookie.length;
        }
    }
            
    return unescape(objCookie.substring(nBegin, nEnd)); 
}

/**
*
*  Javascript cookies
*  http://www.webtoolkit.info/
*
**/
 
function CookieHandler() {
 
	this.setCookie = function (name, value, seconds) {
 
		if (typeof(seconds) != 'undefined') {
			var date = new Date();
			date.setTime(date.getTime() + (seconds*1000));
			var expires = "; expires=" + date.toGMTString();
		}
		else {
			var expires = "";
		}
 
		document.cookie = name+"="+value+expires+"; path=/";
	}
 
	this.getCookie = function (name) {
 
		name = name + "=";
		var carray = document.cookie.split(';');
 
		for(var i=0;i < carray.length;i++) {
			var c = carray[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
		}
 
		return null;
	}
 
	this.deleteCookie = function (name) {
		this.setCookie(name, "", -1);
	}
 
}

//=============================================================================
// 함수명: 스킨적용
// 설  명: 
//=============================================================================
var menuskin = 'blue';
try {
     var _CookieHandler = new CookieHandler();
     _CookieHandler.name = "NBBST";
     menuskin = _CookieHandler.getCookie("NBBST");
 
    if (menuskin == null || (typeof menuskin) == 'undefined')
        menuskin = 'blue';
}
catch(err) {
    menuskin = 'blue';
}

if(menuskin != null && menuskin != "") {
    for(var docindex = 0 ; docindex < document.all.length; docindex++) {   
        if(document.all[docindex].type=="text/css" && document.all[docindex].href=="/KOR_WEBROOT/COMMON/CSS/Common2.css") {
            if(menuskin != 'blue') {
                document.all[docindex].href="/KOR_WEBROOT/COMMON/CSS/Common2_" + menuskin + ".css"
            }
        }
    }
}