/************************************************************************************************************************************** 
 * 전역변수 선언
 * 페이지에서 필요한 화면에 대한 전역변수를 선언한다.
 *************************************************************************************************************************************/
BUTTON_AUTH_MODE = "1";			// 버튼 권한 제어 모드[ 1(enable/disable) | 2(visible/hidden) ]
DATADIC_URL = "";//getBaseURL();

//전역변수
var SEP1 = "";  //keyvalue를 구분하는 구분자 --> 혹시 ""처럼 보여도 1byte 문자가 있는 것임
var SEP2 = ""; //keyvaluekeyvalue 를 구분하는 구분자
var SEP3 = ""; //keyvaluekeyvaluekeyvaluekeyvalue 를 구분하는 구분자(Row를 구분하는 구분자)

/************************************************************************************************************************************** 
 * 화면 처리를 위한 함수 선언
 * 1) setButtonAuth : 프로그램 권한을 가지고 버튼 세팅
 * 2) setButtonAccesbility : 실제 버튼의 SET 실행
 * 3) setButtonImgStatus : 버튼의 이미지를 처리
 * 4) getParams : 화면의 Form에 있는 파라미터를 세팅하여 반환								2005-04-01
 * 5) setParams : request에서 받은 param 변수를 looping을 돌면서 화면의 해당 필드에 SET		2005-04-01
 * 6) OpenDataViewer
 * 7) OpenCalendar
 * 8) SetDateField : 
 * 9) OpenWindow : window.open을 구현한 Wrapping Method
 *************************************************************************************************************************************/

/* SCRIPT 메소드 주석
 * 메소드명		: setButtonAuth
 * 설명			: 프로그램 권한을 가지고 버튼을 세팅한다.
 * 메소드인수1	: auth(8자리 디지트 CRUDXXXX)
 * 메소드리턴값	: N/A
 */
 function setButtonAuth( auth ) {
	if ( auth.length < 8 ) {
		for (var i=auth.length; i<8; i++) {
			auth = auth + "N";
		}
	}
	var buttonType = "CRUDPEOT";   //C : create,	R : read,	U : update,	D : delete,	P : print,	E : excel,	O : open,	T : total
	var imgList = document.getElementsByTagName("img");
	
	for (var i=0; i<auth.length ; i++)
	{
		var btnStat 
		if ( auth.charAt(i) == "1" ) btnStat = true;
		if ( auth.charAt(i) == "0" ) btnStat = false;

		if ( auth.charAt(i) != 'N' ) {
			for (var j=0; j<imgList.length; j++) {
				if ( imgList[j].getAttribute("authGrp") == buttonType.charAt(i) ) {
					setButtonAccesbility(imgList[j], btnStat);
				}
			}
		}
	}
}


/* SCRIPT 메소드 주석
 * 메소드명		: setButtonAccesbility
 * 설명			: 실제 버튼권한을 SET한다.
 * 메소드인수1	: btnId
 * 메소드인수2	: stat(boolean)
 * 메소드리턴값	: N/A
 */
function setButtonAccesbility( obj, stat, mode)
{
	if ( mode == null || mode == '' ) mode = BUTTON_AUTH_MODE;
	if ( mode == '2') {
		if (stat) {
			obj.style.display = "block";
			obj.style.visibility = "visible";
			
			//basic.css에 있는 .button class의 내용을 적용한다 : padding-bottom:2;vertical-align: bottom;text-align:right;
			obj.style.paddingBottom ="2";
			obj.style.verticalAlign ="bottom";
			obj.style.textAlign ="right";
		} else {
			obj.style.display = "none";
			obj.style.visibility = "hidden";
		}
	} else {
		try {
			if ( !stat ) {
				setButtonImgStatus( obj, stat );
			}
		} catch ( e ) {
			//alert("ID가 '"+ btnId + "'는 존재하지 않습니다");
		}
	}
}


/* SCRIPT 메소드 주석
 * 메소드명		: setButtonImgStatus
 * 설명			: 버튼을 change 한다.
 * 메소드인수1	: obj
 * 메소드인수2	: stat(boolean)
 * 메소드리턴값	: N/A
 */
function setButtonImgStatus( obj, stat )
{	
	try
	{
		var orgnImgSrc = obj.src;
		var imgMode = ( stat ) ? "off.": "dis.";
		var disMode = ( stat ) ? false: true;
		var imgExt = "gif";
		var chgImgSrc = orgnImgSrc.substring(0, orgnImgSrc.length-7) + imgMode + imgExt;

		//alert("chgImgSrc = " + chgImgSrc);
		obj.src = chgImgSrc;
		obj.disabled = disMode;
	}
	catch ( e )
	{
	}
}

/* SCRIPT 메소드 주석
 * 메소드명      : getParams
 * 설명			: 조건을 담고 다니는 파라미터의 세팅해서 얻기
 * 메소드리턴값	: params
 */
function getParams( )
{
	if ( arguments.length > 1 ) {
		alert("하나 이상의 폼 이름이 입력되었습니다.\n확인해 주십시오");
		return false;
	}
	
	var frmName = ( arguments.length == 1) ? arguments[0] : "master";
	//alert( frmName );
	var frm = document.forms(frmName);

	var cols = frm.elements;
	var params ="";
	var split = "^";

	for( var i=0; i<cols.length; i++) {
		if ( cols[i].getAttribute("name") != "params" && cols[i] != undefined && cols[i].getAttribute("name") != "listParams") {
			params += cols[i].getAttribute("name") + "=" + cols[i].value;
			if ( i < cols.length-1 ) params += split;
		}
	}
	//alert(params);
	return params;
}



/* 메소드명		: setParams
 * 설명			: params을 풀어서 세팅
 * 메소드인수1	:
 * 메소드인수2	:
 * 메소드리턴값	:
 * 예외처리1     :
 * 예외처리2     :
 */
function setParams( )
{
	if ( arguments.length > 1 ) {
		alert("하나 이상의 폼 이름이 입력되었습니다.\n확인해 주십시오");
		return false;
	}
	var frmName = ( arguments.length == 1) ? arguments[0] : "master";
	var frm = document.forms(frmName);

	var params = getParamList();
	var param1 = "";
	var param2 = "";
	var split = "^";
	
	if ( params != "")
	{
		param1 = params.split(split);
		for ( var i=0; i<param1.length; i++)
		{
 			param2 = param1[i].split("=");
			//alert("param2[0] = " + param2[0] + ", param2[1] = " + param2[1]);
			try {
				frm.elements.namedItem(param2[0]).value = param2[1];	
			} catch ( e ) {
			}
		}
	}
}


/* SCRIPT 메소드 주석
 * 메소드명		: OpenDataViewer
 * 설명			: 자료사전창을 오픈한다.
 * 메소드인수1	: ownerName
 * 메소드인수2	: dataDicId
 * 메소드인수3	:
 * 메소드리턴값	:
 * 예외처리1		:
 * 예외처리2		:
 */
function OpenDataViewer( ddId, ownerName, initValue, optionCond )
{

	//var DATADIC_URL = getBaseURL() + 'rcodebook?action=CBDVIEWER&event=initialize&dataNum=';
	ddHht = 650;
	ddWdt = 600;
	
	ddLft = (screen.width-ddWdt)/2;
	ddTop  = (screen.height-ddHht)/2;

	//var cond = " AND PRJT_CD='<%=prjtCd%>'";
	var url="";
	
	//추가 조건이 없는 경우는 initCondition 지정한다.
	url = DATADIC_URL+ddId + "&objID="+ownerName + "&initCondition=" + initValue + "&initCond=" + ownerName+'&optionCond='+optionCond;
	window.open( url, "DataViewer", "left=" + ddLft + ",top=" + ddTop + ",height=" + ddHht + 
					",width=" + ddWdt + ",status=yes,toolbar=no,menubar=no,location=no, resizable=yes");
}

/* SCRIPT 메소드 주석
 * 메소드명		: OpenCalendar
 * 설명			: 달력창을 오픈한다.
 * 메소드인수1	: objId
 * 메소드인수2	: dateFormat
 * 메소드인수3	:
 * 메소드리턴값	:
 * 예외처리1		:
 * 예외처리2		:
 */
function OpenCalendar( )
{
	if ( arguments.length != 1 && arguments.length !=2 ) {
		alert("OpenCalendar 호출 에러 : 입력 변수를 확인해 주세요");
		return false;
	}

	var ddWdt = 204;
	var ddHht = 199;
	var ddLft = (screen.width-ddWdt)/2;
	var ddTop  = (screen.height-ddHht)/2;

	var objId = arguments[0];
	var openType = "1";
	var dateFormat = ( arguments.length == 2 ) ? arguments[1] : "";

	var calendar_url = CALD_URL + "?objId=" + objId + "&openType=" + openType + "&dateFormat=" + dateFormat;
	window.open( calendar_url, "CbplmCalendar", "left=" + ddLft + ",top=" + ddTop + ",height=" + ddHht + 
					",width=" + ddWdt + ",status=no,toolbar=no,menubar=no,location=no, resizable=yes");
}

/* SCRIPT 메소드 주석
 * 메소드명		: SetDateField
 * 설명			: 선택한 날짜를 DateFormat에 맞게 세팅한다.
 * 메소드인수1	: objId
 * 메소드인수2	: dataDicId
 * 메소드인수3	:
 * 메소드리턴값	:
 * 예외처리1		:
 * 예외처리2		:
 */
function SetDateField( objId, dateFormat, dateValue ) {
	var obj = document.getElementById(objId);
	if ( dateFormat == '') {
		obj.value = MakeDateFormat(dateValue, "YYYY-MM-DD");
	} else {
		obj.value = MakeDateFormat(dateValue, dateFormat);
	}
}

/* SCRIPT 메소드 주석
 * 메소드명		: OpenWindow
 * 설명			: window.open을 Wrapping한 메소드
 * 메소드인수1	: url 필요한 파라미터를 ? 뒤에 붙여서 넘겨준다.
 * 메소드인수2	: windowname
 * 메소드인수3	: width
 * 메소드인수4	: height
 * 메소드인수5	: 추가인자~
 * 메소드리턴값	:
 * 예외처리1	:
 * 예외처리2	:
 */
function OpenWindow( )
{
	var url		= (arguments.length>0) ? arguments[0] : "";
	var winNm	= (arguments.length>1) ? arguments[1] : "";
	var winWidth	= (arguments.length>2) ? arguments[2] : 300;
	var winHeight	= (arguments.length>3) ? arguments[3] : 200;
	var addArg  = (arguments.length>4) ? "," + arguments[4] : "";

	var winLeft = (screen.width-winWidth)/2;
	var winTop  = (screen.height-winHeight)/2;

	window.open( url, winNm, "left=" + winLeft + ",top=" + winTop + ",height=" + winHeight + 
					",width=" + winWidth + addArg + ",status=yes,toolbar=no,menubar=no,location=no, resizable=yes");
}

/* SCRIPT 메소드 주석
 * 메소드명		: OpenWindow2
 * 설명			: window.open을 Wrapping한 메소드
 * 메소드인수1	: url 필요한 파라미터를 ? 뒤에 붙여서 넘겨준다.
 * 메소드인수2	: windowname
 * 메소드인수3	: width
 * 메소드인수4	: height
 * 메소드인수5	: 추가인자~
 * 메소드리턴값	:
 * 예외처리1	:
 * 예외처리2	:
 */
function OpenWindow2( )
{
	var url		= (arguments.length>0) ? arguments[0] : "";
	var winNm	= (arguments.length>1) ? arguments[1] : "";
	var winWidth	= (arguments.length>2) ? arguments[2] : 300;
	var winHeight	= (arguments.length>3) ? arguments[3] : 200;
	var addArg  = (arguments.length>4) ? "," + arguments[4] : "";

	var winLeft = (screen.width-winWidth)/2;
	var winTop  = (screen.height-winHeight)/2;

	window.open( url, winNm, "left=" + winLeft + ",top=" + winTop + ",height=" + winHeight + 
					",width=" + winWidth + addArg + ",status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,resizable=yes");
}

/************************************************************************************************************************************** 
 * 문자열 처리 관련 함수 선언
 * 문자열의 처리를 위한 함수를 선언한다.
 * 1) ToUpperCase : 받은 영문글자열을 대문자로 바꾸기
 * 2) CharNotAllowed
 * 3) NumAndPointAllowed
 * 4) IsNumber
 * 5) CheckEmail
 * 6) CheckMaxLength : 최대길이 체크(onblur)
 * 7) getByteLength : 넘어온 문자열의 byte를 계산한다.
 *************************************************************************************************************************************/

/* 메소드명		: ToUpperCase
 * 설명			: 받은 영문글자열을 대문자로 바꾸기
 * 메소드인수1	: obj : Upper Case를 하길 원하는 속성객체
 * 메소드인수2	:
 * 메소드리턴값	:
 * 예외처리1		:
 * 예외처리2		:
 */
function ToUpperCase(obj)
{
	var Uname = obj.value;
	if (Uname == "" || Uname == 0)
	{
		return;
	}
	else 
	{	
		Uname = Uname.toUpperCase();
		obj.value = Uname;
	}
}

/* 메소드명		: CharNotAllowed
 * 설명			: 
 * 메소드인수1	: obj : Upper Case를 하길 원하는 속성객체
 * 메소드인수2	:
 * 메소드리턴값	:
 * 예외처리1		:
 * 예외처리2		:
 */
 function CharNotAllowed() {
	
	var input_key = event.keyCode;
	
	if (!(IsNumber( input_key )))
	{	
		event.keyCode = '0';
			return false;
	}
}

/* 메소드명		: NumAndPointAllowed
 * 설명			: 문자열을 입력하지 못하게 하는 함수(onkeypress에 fire)
 * 메소드인수1	: N/A
 * 메소드인수2	:
 * 메소드리턴값	:
 * 예외처리1		:
 * 예외처리2		:
 */
function NumAndPointAllowed() {
	
	var input_key = event.keyCode;
	
	if (!(IsNumber( input_key )))
	{	
		if (input_key != 46) // '.' 인경우
		{
    		event.keyCode = '0';
    			return false;
		}
	}
}


/* 메소드명		: IsNumber
 * 설명			: 입력 값이 숫자인지 체크하는 함수
 * 메소드인수1	: inputValue : 값
 * 메소드인수2	:
 * 메소드리턴값	: boolean
 * 예외처리1		:
 * 예외처리2		:
 */
function IsNumber( inputValue ) {
		if (inputValue >= '48' && inputValue <= '57') return true;
		else 	return false;
}



/* SCRIPT 메소드 주석
 * <!--
 * 메소드명      : CheckEmail
 * 설명			    : 전자 메일 체크-최상위 도메인체크 , 한글사용못하게등이 추가 된것
 * 메소드인수1  : checkField - 전자 메일을 체크할 필드의 ID
 * 메소드인수2  :
 * 메소드리턴값 :
 * 예외처리1      :
 * 예외처리2      :
 * //-->
 */

function CheckEmail(mailObj) 
{
		
	var txt = mailObj.value;

	if(txt.length == 0)
	{
		return false;
	}


	for (i=0; i<txt.length; i++) 
	{   
		if (txt.charCodeAt(i)>127) 
		{  
			alert("한글을 사용할수 없습니다.") ;
			email.focus(); // 포커스 지정
			return false; 
		} 
	} 


	if (txt.indexOf("@")<3)
	{  
		alert("이메일 형식이 잘못 되었거나 @가 빠졌습니다.");
		return false;
	}


	// 최상위 도메인 추가시 &&(txt.indexOf("최상위도메인")<5) 하면 됨
	// 최상위 도메인즉 kr/com/net/org 등이 아닐결우 에러 출력 부분
	if ( (txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5)
	&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".net")<5)
	&&(txt.indexOf(".mil")<5)&&(txt.indexOf(".edu")<5)
	&&(txt.indexOf(".kr")<4)&&(txt.indexOf(".st")<4)
	&&(txt.indexOf(".tv")<4)&&(txt.indexOf(".ro")<4)
	&&(txt.indexOf(".arpa")<6)&&(txt.indexOf(".biz")<5)
	&&(txt.indexOf(".aero")<6)&&(txt.indexOf(".name")<6)
	&&(txt.indexOf(".coop")<6)&&(txt.indexOf(".info")<6)
	&&(txt.indexOf(".pro")<5)&&(txt.indexOf(".museum")<7)
	)
	{ 
		// 참고로 alert 이벤트에서 멘트가 길어질경우 아래에 입력할경우 +"멘트" 이렇게 하면 됩니다. 
		alert("이메일 형식의 최상위 도메인형식이 잘못되었습니다.\n\n"
					+" .kr .com .org .gov .net .mil .edu .arpa .biz\n\n"
					+".aero .name .coop .info .pro .museum .st .tv .ro"
				);
		return false;
   }

	return false;
}


/* SCRIPT 메소드 주석
 * <!--
 * 메소드명     : checkMaxLength             
 * 설명         : 최대길이를 체크한다
 *                onblur()시 발생한다
 * 메소드인수1  :
 * 메소드인수2  :
 * 메소드인수3 :
 * 메소드리턴값 :
 * 예외처리1    :                      
 * 예외처리2    :
 * //-->
 */
function CheckMaxLength()
{
	var obj = event.srcElement;
	var len = getByteLength(obj.value);
	var maxLen = obj.maxLength;
	var name = obj.name;
	
	if (maxLen < len)
	{
		alert("입력된 글자가 최대 길이보다 큽니다");
		return false;
	}
}



/* SCRIPT 메소드 주석
 * <!--
 * 메소드명     : getByteLength             
 * 설명         : Byte를 계산한다
 * 메소드인수1  : s 문자열
 * 메소드인수2  :
 * 메소드인수3 :
 * 메소드리턴값 : 문자열의 Byte수 (한글은 2Byte로 계산)
 * 예외처리1    :                      
 * 예외처리2    :
 * //-->
 */
function getByteLength(s)
{
   var len = 0;
   if ( s == null ) return 0;
   for(var i=0;i<s.length;i++)
	 {
      var c = escape(s.charAt(i) );
      if ( c.length == 1 ) len ++;
      else if ( c.indexOf("%u") != -1 ) len += 2;
      else if ( c.indexOf("%") != -1 ) len += c.length/3;
   }

   return len;
}



/* SCRIPT 메소드 주석
 * <!--
 * 메소드명     : setElement
 * 설명         : form의 text, select, checkbox, radio, textarea와 div, span 등의 name을 가지는 속성의 문자열을 받아서 set하는 함수
 * 메소드인수1  : key SEP1 value SEP2 key SEP1 value SEP2 ... 으로 합쳐진 문자열
 * 메소드인수2  : 해당열이 디테일일 경우의 인덱스
 * 메소드리턴값 : 문자열의 Byte수 (한글은 2Byte로 계산)
 * 예외처리1    :                      
 * 예외처리2    :
 * //-->
 */
function setElement() {
	var elList = arguments[0];
	var idx = (arguments.length > 1) ? ( (parseInt(arguments[1]) < 0 ) ? 0 : arguments[1] ) : 0;
	
	var elArry = elList.split(SEP2);
	var keyValue;
	for(var i=0; i<elArry.length; i++) {
		
		keyValue = elArry[i].split(SEP1);
		setValue(keyValue[0], keyValue[1], idx);
	}
}
function getElByTagName(key) {
	var el = document.getElementsByTagName("span");
	for(var i=0; i<el.length; i++) {
		if( el[i].name == key ) {
			return el[i];
			break;
		}
	}
	return null;
}


function setValue(key, value, idx) {
	var el = null;
	//alert(key + " = " + document.getElementsByName(key)[idx])
	if( document.getElementsByName(key)[idx] != null || document.getElementsByName(key)[idx] != undefined ) {
		el = document.getElementsByName(key)[idx];
	} else {

		el = getElByTagName(key);


	}

	if( el != null ) {
		var elType = getType(el);
		if( elType == "select" || elType=="text" || elType=="hidden") {
			if(el.getAttribute("dateFormat") != null ) {
				value = MakeDateFormat(value, el.getAttribute("dateFormat"));
			}
			if(el.getAttribute("timeFormat") != null ) {
				value = MakeTimeFormat(value, el.getAttribute("timeFormat"));
			}
			if(el.getAttribute("numberFormat") != null ) {
				value = value.number_format();
				if(!value) value = '0';
			}
			el.value = value;
		} else if( elType == "check" || elType=="radio") {
			if( el.value == value ) {
				el.checked = true;
			} else {
				el.checked = false;
			}
		} else if( elType == "span" || elType == "div" || elType == "td" ) {

			el.innerHTML = toCodeJsHtml2(value);
		} else if( elType == "img" ) {

			el.src = value;
		}		
		setUserDefineValue(key, value, idx);
	} else {
		//alert(key + "에 해당하는 element가 없습니다.");
		return;
	}
}

//div나 span의 값을 set하면서 사용자 정의 값을 set하는 경우 main화면에서 불러서 사용함
function setUserDefineValue() {
}


function getType(el) {
    switch (el.tagName.toLowerCase()) {
    case "select"	: return "select";
    case "textarea"	: return "text";
	case "div"		: return "div";
	case "td"		: return "td";
	case "span"		: return "span";
	case "img"		: return "img";
    case "input":
        switch (el.type.toLowerCase()) {
        case "radio": return "radio";
        case "checkbox": return "check";
        case "file": return "file";
        case "text": case "password": return "text";
        case "hidden": return "hidden";
        }
        break;
    }
}

function setDetailLine(dId, linePerPage) {
	var detail = document.getElementById(dId);
	var line = linePerPage;//(linePerPage == 0 ) ? detail.getAttribute("line") : linePerPage ;
	for(var i=1; i<parseInt(line); i++) {
		addRow(dId);
	}
}


function addRow( tbl, cloneIdx ) {
	if( arguments.length != 1 ) {
		//alert("파라미터가 잘못되었습니다");
	}
	var srcTbl = document.getElementById(tbl);
	var trLength = (cloneIdx == null ) ? srcTbl.rows.length : cloneIdx;
	if( trLength > 0 ) {
		var srcTr = srcTbl.rows(trLength-1);
		var newTr = srcTr.cloneNode(true);
		//srcTbl.insertAdjacentElement("AfterEnd", newTr);
		srcTr.insertAdjacentElement("AfterEnd", newTr);
	} else {
		alert("현재 행이 하나도 없어서 행추가를 할수 없습니다.");
		return;
	}
}


//
function getValue(obj, str) {
	//alert("str = " + str);
	var idx = getIdx(obj);
	var strVal = document.getElementsByName(str)[idx].value;
	return strVal;
}

//해당 속성에 대한 값을 가져오는 것
function getIdx(obj) {
	var objs = document.getElementsByName(obj.name);
	var idx = 0;
	for(var i=0; i<objs.length; i++) {
		if(objs[i] == obj ) {
			idx = i;
			break;
		}
	}
	return idx;
}

//attach event
function attachEvent(key, value, idx, evntNm, funcNm) {
	document.getElementsByName(key)[idx].attachEvent(evntNm,goDetail);
}


//javascript에서 사용하는 문자열 변경
function toCodeJsStr(str) {
	// 파일 내용의의 \r 을 Replace 하기 위한 정규식 패턴 설정
	
	var strVal;
	var strVal1;
	var strVal2;
	var reR = /\\r/g;
	var reN = /\\n/g;
	var reT = /\\t/g;
	strVal = str.replace(reR,"");
	strVal1 = strVal.replace(reN,"\n");
	strVal2 = strVal1.replace(reT,"\t");
	//alert("strVal1 = " + strVal1);
	return strVal2;
}

//javascript에서 사용하는 문자열 변경
function toCodeJsHtml(str) {
	// 파일 내용의의 \r 을 Replace 하기 위한 정규식 패턴 설정

	var strVal;
	var strVal1;
	var strVal2;
	var reR = /\\r/g;
	var reN = /\\n/g;
	var reT = /\\t/g;
	strVal = str.replace(reR,"");
	strVal1 = strVal.replace(reN,"<br>");
	strVal2 = strVal1.replace(reT,"&nbsp;&nbsp;&nbsp;&nbsp;");
	//alert("strVal1 = " + strVal1);
	return strVal2;
}

//javascript에서 사용하는 문자열 변경
function toCodeJsHtml2(str) {
	// 파일 내용의의 \r 을 Replace 하기 위한 정규식 패턴 설정
	
	var strVal;
	var strVal1;
	var strVal2;
	var reR = /\r/g;
	var reN = /\n/g;
	var reT = /\t/g;
	strVal = str.replace(reR,"");
	strVal1 = strVal.replace(reN,"<br>");
	strVal2 = strVal1.replace(reT,"&nbsp;&nbsp;&nbsp;&nbsp;");
	//alert("strVal1 = " + strVal1);
	return strVal1;
}


//전체 체크 여부
function allCheck() {
	var obj = event.srcElement;
	var chkYn = false;
	var chkEl = document.getElementsByName("delChk");
	
	if( obj.checked == true ) {
		chkYn = true;
	} else {
		chkYn = false;
	}

	for(var i=0; i<chkEl.length; i++) {
		//alert(chkYn);
		chkEl[i].checked = chkYn;
	}
}

//전체 체크 여부
function delCheck() {
	var obj = event.srcElement;
	var chkEl = document.getElementsByName("delChk");
	if( obj.checked == false) {
		document.getElementsByName("allChk")[0].checked = false;
		for(var i=0; i<chkEl.length; i++) {
			//alert(chkYn);
			chkEl[i].checked = false;
		}
	}
}


//체크된 체크박스 개수 파악
function getChkCnt(name) {
	var chkEl = document.getElementsByName(name);
	var chkCnt = 0;
	for(var i=0; i<chkEl.length; i++) {
		if(chkEl[i].checked) {
			chkCnt++;
		}
	}
	return chkCnt;
}

//화면에 출력
function documentWrite(val) {
	document.write(val);
}