﻿//*******************************************************************************//
//**************************** HTML OBJECT **************************************//
//*******************************************************************************//
// div Object 생성
document.title = "퓨리나사료-고객과 함께 성장하는 사업의 동반자";
function USR_getDivObj(name, isChecked) {
	var oDiv = document.createElement("div");
	oCheck.id = name;
	return oCheck;
}
// Check Box Object 생성
function USR_getChkBoxObj(name, isChecked) {
	var oCheck = document.createElement("input");
	oCheck.type = "checkbox";
	oCheck.name = name;
	oCheck.id = name;
	oCheck.defaultChecked = isChecked==null?false:(isChecked=='1'?true:false);
//	oCheck.onclick	= new Function("onChange();");
//	oCheck.onfocus	= new Function("this.blur()");
	return oCheck;
}
// radio button Object 생성
function USR_getChkRadioObj(name, isChecked) {
	var oCheck = document.createElement("input");
	oCheck.type = "radio";
	oCheck.name = name;
	oCheck.id = name;
	oCheck.defaultChecked = isChecked==null?false:(isChecked=='1'?true:false);
//	oCheck.onclick	= new Function("onChange();");
//	oCheck.onfocus	= new Function("this.blur()");
	return oCheck;
}
// HiddenText Object 생성
function USR_getHdnObj(hName, hValue) {
	var oHidden = document.createElement("input");
	oHidden.type = "hidden";
	oHidden.name = hName;
	oHidden.id = hName;
	oHidden.value = hValue;
	return oHidden;
}
// TextArea Object 생성
function USR_getTextAreaObj(hName, hValue) {
	var oHidden = document.createElement("textarea");
	oHidden.name = hName;
	oHidden.id = hName;
	oHidden.value = hValue;
	return oHidden;
}
// Text Object 생성
function USR_getTextBox(tName, tValue, tSize, tMaxLength) {
	var oText = document.createElement("input");
	oText.type = "text";
	oText.name = tName;
	oText.id = tName;
	oText.value = tValue;

	if( tSize != "" )
		oText.size = tSize;

	if( tMaxLength != "" )
		oText.maxLength = tMaxLength;
	return oText;
}
// Image Object 생성
function USR_getImageObj( src ) {
	var oImg = document.createElement('img');
	oImg.src = src;
	oImg.style.verticalAlign = "middle";
//	oImg.style.cursor = "hand";
//	oImg.onclick = new Function("MAIN('');");
//	oImg.hspace = "2";
	oImg.border = "0";
	return oImg;
}
/**
 * 관계 콤보박스 Object 생성
 * data형태 : 
 * occDt = new Array()
 * occDt[0] = ["-1","전체"];
 * occDt[1] = ["01","하나"];
 */
function USR_getCreateComboObj(occDt, hName, item) {

	var oSel = document.createElement('select'); 

	oSel.name		= hName;
	oSel.id			= hName;
//	oSel.onchange	= new Function("onChange();");

	for( var i=0; i<occDt.length; i++ ){
		oSel.options[i] = new Option(occDt[i][1], occDt[i][0]);
	}

	//set selected
	oSel.value = item;
//	oSel.style.width = '80px';

	return oSel;
}
/**
 * 관계 콤보박스 Object 생성
 * data형태 : 
 * occDt = XML Array Data
 */
function USR_getComboObj(obj, occDt, args, item) { 

	if( args[0] == null || args[0] == "" || args[1] == null || args[1] == "" ){
		args[0] = "code";
		args[1] = "name";
	}

	var cnt = 0;
	for(var i=0;i<occDt.length;i++)
	{	
		obj.options[cnt++] = new Option(occDt[i][ args[1] ], occDt[i][ args[0] ]);
	}

	//set selected
	obj.value = item; 

	return obj;
}
// 객체가 포함된 FORM 또는 BODY를 리턴
function getForm(obj) {

	if (obj == null)	return null;

	while (obj.tagName != null && obj.tagName != "FORM" && obj.tagName != "BODY"){
		obj = obj.parentNode;
	}
	return obj;
}

// 객체가 포함된 TR을 리턴
function getTr(obj) {

	if (obj == null)	return null;

	while (obj.tagName != "TR" && obj.tagName != "TABLE" && obj.tagName != "FORM" && obj.tagName != "BODY"){
		obj = obj.parentNode;
	}

	if (obj.tagName == "TR")	return obj;
	else						return null;
}

// 개체에서 id에 해당하는 TD를 리턴한다.
function getTdByTr(oTr, str) {

	if (oTr == null)	return null;
	if (oTr.tagName != "TR")	oTr = getTr(oTr);

	var item = null
	var td = null;
	for (var i=0; i<oTr.children.length; i++){
		item = oTr.children.item(i);
		if (item.id == str) {
			td = item;
			break;
		}
	}
	return td;
}
// item에서 속성(str)을 찾아서 값을 리턴 한다.
function getObjByName(item, str, gubun) {
	if (item == null) return null;
	if (gubun == null) gubun = "dhtml";

	var td = null;
	var el = null;

	while (item.tagName != "TR" && item.tagName != "TH" && item.tagName != "TD") {
		if ( item.children.length != 0)		item = item.children.item(0);
		else		break;
	}

	if (item.children.length != 0) {
		for (var i=0; i<item.children.length; i++){
			//if (i == 25) {
			//	el = null;
			//	break;
			//}

			td = item.children.item(i);

			if(true){
				if(gubun=="htmlTag"){
					try {
						while (td.tagName != "SELECT" && td.tagName != "INPUT") {
							if (td.children.length != 0){
								//td = td.children.item(0);
								td = getObjTD(td, str);
							}else{
								break;
							}
						}
						el = td;
					} catch (e) {
						el = null;
					}
				}
				if(gubun=="dhtml"){
					try {
						while (td.tagName != "SELECT" && td.tagName != "INPUT") {
							if (td.children.length != 0)		td = td.children.item(0);
							else		break;
						}
						if (td.getAttribute("NAME") != null && str.toUpperCase() == td.getAttribute("NAME").toUpperCase()) {
							el = td;
							break;
						}
					} catch (e) {
						el = null;
					}
				}
			}
		}
	}
	return el;
}
function getObjTD(td, str){
	var el = null;
	for(var i=0; i<td.children.length; i++){
		var _tmp = td.children.item(i);
		if (_tmp.getAttribute("NAME") != null && str.toUpperCase() == _tmp.getAttribute("NAME").toUpperCase()) {
			el = _tmp;
			break;
		}
	}
	return el;
}
// 테이블 값을 초기화 합니다.
function clearTableInit( objName ) {

	// 동적으로 tr과 td를 생성할 테이블을 지정한다
	var oTable = document.getElementById(objName);
	// table의 두번째 차일드 즉 tbody를 지정한다.
	var oTbody = oTable.childNodes[1];
	// 테이블 초기화
	if(true) {
		while (oTbody != null && oTbody.rows != null && oTbody.rows.length > 0) {
			oTbody.deleteRow(0);
		}
	}
}
///HTML OBJECT_END
//*******************************************************************************//
//**************************** HTML OBJECT **************************************//
//*******************************************************************************//


//*******************************************************************************//
//**************************** UTIL 함수   **************************************//
//*******************************************************************************//
// -------------------------------------------------
// @ 문자를 대체한다.
// @ 사용법 : str-원문자열, baseStr-바꿀문자, repStr-대체할문자
// ---------------------------------------------------
function replaceAll(str, baseStr, repStr) {
    var index;
    while (str.search(baseStr) != -1) {
      str = str.replace(baseStr, repStr);
    }
    return str;
}
// -----------------------------------------------------
// @ 문자열을 구분자로 나눈다.
// @ 사용법 : originString- 원 문자열, delimeter - 구분자
// ----------------------------------------------------
function stringTokenizer(originString, delimeter)
{
	var result = new Array();
	var i = 0;
	while(true)
	{
		if(originString.indexOf(delimeter) < 0)
		{
			result[i] = trim(originString);
			break;
		}
		else
		{
			result[i] = originString.substring(0,originString.indexOf(delimeter));
			originString = originString.substring(originString.indexOf(delimeter) + delimeter.length);
		}

		i++;
	}

	return result;
}
//----------------------------------------------------------------------------------
// @ 모달 다이얼로그 박스를 연다.
// @ 추가설명 : showModalDialog로 여는 창은 액션을 줄수 없다, 단지 view기능만을 수행한다.
//                     그래서, 응용함수 openDialogBox() 를 만들어 그 문제점을 보완한다.
//-----------------------------------------------------------------------------------
function openDialogBox(openUrl,opt)
{
	if(opt == '')
	{
		var modalWidth = 584;
		var modalHeight = 600;
		var xPos = window.screenX/2 - modalWidth/2;
		var yPos = window.screenY/2 - modalHeight/2;
		
		opt = "dialogwidth:"+modalWidth+"px;dialogheight:"+modalHeight+"px;";
		opt += "dialogleft:"+xPos+"px;dialogtop:"+yPos+"px;center:yes;";
		opt += "help:no;scroll:no;resizable:no;status:no;titlebar:no;";
	}

	var result = showModalDialog("/scms/html/dialog.html",openUrl,opt);

	return result;
}
//----------------------------------------------------------------------------------
// @ 모달 메시지 박스를 연다.
// @ 추가설명 : openModelessDialogBox 여는 창은 액션을 줄수 없다, 단지 view기능만을 수행한다.
//                     그래서, 응용함수 openDialogBox() 를 만들어 그 문제점을 보완한다.
//-----------------------------------------------------------------------------------
function openModelessDialogBox(openUrl,opt)
{
	if(opt == '')
	{
		var modalWidth = 584;
		var modalHeight = 600;
		var xPos = window.screenX/2 - modalWidth/2;
		var yPos = window.screenY/2 - modalHeight/2;
		
		opt = "dialogwidth:"+modalWidth+"px;dialogheight:"+modalHeight+"px;";
		opt += "dialogleft:"+xPos+"px;dialogtop:"+yPos+"px;center:yes;";
		opt += "help:no;scroll:no;resizable:1;status:no;titlebar:no;";
	}

	var result = showModelessDialog("/scms/html/dialog.html",openUrl,opt);

	return result;
}
//----------------------------------------------------------------------------------
// @ 쿠키를 세팅하는 함수입니다.
// @ 추가설명 : setCookie( 쿠키명, 값, 설정일 )
//-----------------------------------------------------------------------------------
function setCookie( name, value, expires )
{
	document.cookie = name + "=" + escape (value) + "; path=/; expires=" + expires.toGMTString();
}
//----------------------------------------------------------------------------------
// @ 쿠키에 설정된 값을 가져오는 함수입니다.
// @ 추가설명 : getCookie( 쿠키명 )
//-----------------------------------------------------------------------------------=
function getCookie( Name ){
    var search = Name + "="
	if (document.cookie.length > 0) { // DmE00! <3A$5G>n @V4Y8i
		offset = document.cookie.indexOf(search)
		if (offset != -1) { // DmE00! A8@gGO8i
		offset += search.length
		// set index of beginning of value
		end = document.cookie.indexOf(";", offset)
		// DmE0 0*@G 86Av87 @'D! @N5&=: 9xH# <3A$
		if (end == -1)
			end = document.cookie.length
		return unescape(document.cookie.substring(offset, end))
		}
	}
	return "";
} 
// ----------------------------------------
// @ 모든 폼의 모든 엘리멘트를 초기화 한다.(clear 시킴)
function allFormElementsClear(docs)
{
	var len=docs.forms.length;
	for(var i=0;i<len;i++)
	{
		formElementsCleared(docs.forms[i])
	}
}
// ----------------------------------------
// @ 특정 폼의 모든 엘리멘트를 초기화 한다.
// ----------------------------------------
function formElementsCleared(frm)
{
	var len=frm.elements.length;
	var type;
	for(var i=0;i<len;i++)
	{
		type = frm.elements[i].type.toLowerCase();
		if(type=='text' || type=='hidden' || type=='textarea' || type=='password')
		{
			frm.elements[i].value = "";
		}
		else if(type=='radio')
		{
			frm.elements[0].checked = true;
		}
		else if(type=='checkbox')
		{
			frm.elements[0].checked = true;
		}
		else if(type.substring(0,7) == 'select-')
		{
			frm.elements[i].options[0].selected = true;
		}
	}
}

// ----------------------------------------
// @ 모든 폼의 엘리먼트를 못 쓰게 한다.(disable 시킴)
// ----------------------------------------
function allFormElementsDisabled(docs)
{
	var len=docs.forms.length;
	for(var i=0;i<len;i++)
	{
		formElementsDisabled(docs.forms[i])
	}
}
// ----------------------------------------
// @ 특정 폼의 모든 엘리멘트를 못 쓰게 한다.
// ----------------------------------------
function formElementsDisabled(frm)
{
	var len=frm.elements.length;
	var type;
	for(var i=0;i<len;i++)
	{
		type = frm.elements[i].type.toLowerCase();
		if(type=='text' || type=='hidden' || type=='textarea' || type=='password')
		{
			frm.elements[i].style.border="0";
			frm.elements[i].style.background="#EFEFEF";
			frm.elements[i].style.color="#000000";
		}

		frm.elements[i].disabled = true;
	}
}

// ----------------------------------------
// @ 셀렉트 옵션 초기화
// ----------------------------------------
function setSelectInit(obj) {
	if (obj != null && obj.options != null && obj.options.length != null) {
		for( var kk = obj.options.length-1; kk>=0; kk--) {
			obj.options[kk] = null;
		}
	}
	return null;
}

// ----------------------------------------
// @ 체크된 라디오 버튼의 값을 가져온다.
// ----------------------------------------
function getRadioButtonValue( obj ){
	
	var _ret = "";

	if( obj.length == null || obj.length == "undifined" ){
		_ret = obj.value;
	}else{

		for(var i=0; i<obj.length; i++){
			if( obj[i].checked ){
				_ret = obj[i].value;
				break;
			}
		}
	}

	return _ret;
}

// ----------------------------------------
// @ 라이오 버튼에 해당 값으로 체크한다.
// ----------------------------------------
function setRadioButtonValue( obj, arg1 ){
    
	if( obj.length == null || obj.length == "undifined" ){
		if( obj.value == arg1 ) obj.checked = true;
	}else{
		for(var i=0; i<obj.length; i++){
			if( obj[i].value == arg1 ) obj[i].checked = true;
		}
	}
}



// ----------------------------------------
// @ 셀렉트박스에 해당 값으로 체크한다.
// ----------------------------------------
function setSelectBoxValue( obj, arg1 ){
	if(arg1 == null || arg1 == "") arg1 = "";

	for(var i=0; i<obj.length; i++){
		if(obj.options[i].value == arg1 ){
			obj.options[i].selected = true;
			break;
		}
	}
}

// ----------------------------------------
// @ 셀렉트박스 전체선택 
// ----------------------------------------
function setSelectBoxCheckAll(obj){
	if (obj!=null){
		if (obj.value==null){
	    	bCheck = !obj[0].checked;
	      	
	      	for (i=0; i<obj.length; i++) {
	        	obj[i].checked=bCheck;
	      	}
	    }else{
	      obj.checked = !obj.checked;
	    }
	}
} 

// ----------------------------------------
// @ 상태바 설정
// ----------------------------------------
function setProgress(obj,mode) {
	var obj = document.getElementById(obj);	

	obj.style.display = (mode==true?"inline":"none");
}

// ----------------------------------------
// @ 브라우져의 속성을 가져온다.
// ----------------------------------------
function isXP(){
	var _ret = false;
	
	if( navigator['appMinorVersion'].slice(1,4) == "SP2" ) _ret = true;
	
	return _ret;
}

// -----------------------------
// @ 바이트계산한 값을 가져온다.
// -----------------------------
function getMsgByte( msg )
{
	var nbytes = 0;

	for (var z=0; z<msg.length; z++) {
		var ch = msg.charAt(z);

		if(escape(ch).length > 4) {
			nbytes += 2;
		} else if (ch == '\n') {
			if (msg.charAt(z-1) != '\r') {
				nbytes += 1;
			}else{
				nbytes += 1;
			}
		} else if (ch == '<' || ch == '>') {
			nbytes += 4;
		} else {
			nbytes += 1;
		}
	}

	return nbytes;
}

// ----------------------------------------
// @ 바이트계산한 값을 가져온다.
// ----------------------------------------
function isAvailableBytes( msg , nbytes )
{
	return (getMsgByte(msg) > nbytes) ? false : true;
} 

// ----------------------------------------
// @ str의 좌측에 특정한 문자로 채우는 함수
// ----------------------------------------
function padLeft( src, ch, length )
{
	var i = src.legnth;
	if(i <= length){
		return src;
	}
	for(i ; src.length < length ; i += ch.length ){
		src = ch + src;
	}
	return src;
}

// ----------------------------------------
// @ 해당창의 위치와 크기가 다를 경우 수정하는 함수
// ----------------------------------------
function resetWindow(obj, width, height, left, top){
	if(obj == null){
		return;
	}

	//값이 윈도우에 따라 달라져 무조건 실행
	window.moveTo(left,top);
	window.resizeTo(width+10,height+49);
}

// ----------------------------------------------------
// @ 체크된 라디오 버튼의 인덱스를 가져온다.
// ----------------------------------------------------
function getRadioButtonIndex( obj ){
	
	var _ret = "";

	if( obj.length == null || obj.length == "undifined" ){
		_ret = obj.value;
	}else{

		for(var i=0; i<obj.length; i++){
			if( obj[i].checked ){
				_ret = i;
				break;
			}
		}
	}
	return _ret;
}

/*===============================
  주민번호에 '-' 추가 시킨다
  @param JuminNo
  @return '-' 추가된 주민번호
===============================*/
function setJuminNo(JuminNo){
	
	if( JuminNo.length <= 0 || ( JuminNo.length != 13 && JuminNo.length != 14 ) )
		return JuminNo;

	var strRet = "";
	if( JuminNo.length == 13 ){
		strRet = JuminNo.substring(0, 6) + "-" + JuminNo.substring(6);
	}else if( (JuminNo.length == 14) ){
		strRet = JuminNo;
	}
	return strRet;
}




//--------------------
// 내용입력시 바이트 수 표시하기
//--------------------
function viewByte( obj, objMsg, size ){ 

	var _byteCnt = getMsgByte( obj.value );

	objMsg.innerText = "("+ _byteCnt + "byte)";

	if( _byteCnt > size ){
		objMsg.style.color = "#FF0000";
	}else{
		objMsg.style.color = "#000000"; 
	}
}

// ----------------------------------------
// @ 시작날과 끝날의 차이가 N월이내인지 확인한다.
// @ ex) arg1 : 90 --> 3개월
// ----------------------------------------
function isDateInterval(startDt, endDt, arg1){

	if(!this.isValidDate(startDt)){
		alert("날짜포맷에 맞지 않습니다.");
		return false;
	}
	if(!this.isValidDate(endDt)){
		alert("날짜포맷에 맞지 않습니다.");
		return false;
	}

	var sDate = new Date(startDt.value.split('-')[0], startDt.value.split('-')[1]-1,  startDt.value.split('-')[2]);
	var eDate = new Date(endDt.value.split('-')[0], endDt.value.split('-')[1]-1,  endDt.value.split('-')[2]);

	var newdate = (eDate-sDate)/(24*60*60*1000);
	if(newdate > arg1 || newdate < 0){
		return false;
	}else{
		return true;
	}
}

// ----------------------------------------
// @ 윈도우 창을 screen 중간에 띄웁니다.
// @ ex) 
// ----------------------------------------
function openDocManage(ref,ref1,w,h)
{
	var window_left = (screen.width)/2;
	var window_top  = (screen.height-40)/2;
	if (isUndefined(w) || w == 0) {
		w =screen.width - 10;
		window_left = 0;
	} else
		window_left = window_left - w / 2;
		
	if (isUndefined(h) || h == 0) {
		h =screen.height - 25 - 30;	// status bar + workspace bar
		window_top = 0;
	} else
		window_top = window_top - h / 2;

	signWindow = window.open(ref,ref1, "width=" + w +",height=" + h + ",status=no,scrollbars=no,resizable=no,top=" + window_top + ",left=" + window_left);
	signWindow.focus();
}

// ----------------------------------------
// @ 해당 오브젝트에 undefined 여부를 판단합니다.
// @ ex) 
// ----------------------------------------
function isUndefined(a) {
    return typeof a == 'undefined';
} 



//*******************************************************************************//
//**************************** DOC문서보안관련 함수   **************************************//
//*******************************************************************************//

// ----------------------------------------
// @ 문서의 보안키 설정입니다.
// ----------------------------------------
function Doc_prohibit(){
	
	var isProhibit = true; // 보안 설정 여부
	
	if( isProhibit ){
		try{
			//document.body.oncontextmenu = prohibitContextMenu; // 마우스 오른쪽 버튼 제한
			//document.body.ondragstart = prohibitContextDrag; // 마우스 드레그 제한
			//document.body.onselectstart = prohibitContextDrag; // 마우스 드레그 제한
			document.onkeydown = prohibitKey; // KeyBoard Key 제한함수 호출
		 
			// 윈도우 종료시 처리
			//window.attachEvent("onbeforeunload", chkWinClose);
			//window.onbeforeunload = chkWinClose; 
		}catch(e){}
	}
} 
// ----------------------------------------
// @ 문서의 마우스 오른쪽 버튼 제한
// ----------------------------------------
function prohibitContextMenu(){
	return false;
}
// ----------------------------------------
// @ 문서의 마우스 드레그 제한
// ----------------------------------------
function prohibitContextDrag(){
	return false;
}
// ----------------------------------------
// @ 키보드 키값 제한 및 보안설정
// ----------------------------------------
function prohibitKey() 
{   
	var mode = false;  

	// key 값 제어 
	switch( event.keyCode ){
		case 8 : // ←(백스페이스) 
			var el = event.srcElement.type;
			if( el == "text" || el == "hidden" || el == "textarea" || el == "password" || 
				el == "radio" || el == "checkbox" || el == "select-" ){
		    }else{
		    	mode = true;
		    }
			break;
		case 9 : break; // TAB
		case 13 : break; // ENTER 
		case 16 : break; // SHIFT 
		case 17 : break; // CTRL
		case 18 : break; // ALT 
		case 19 : break; // PAUSEBREAK 
		case 20 : break; // CAPSLOOK 
		case 21 : break; // 한/영 
		case 25 : break; // 한자 
		case 27 : break; // ESC 
		case 32 : break; // 스페이스 
		case 112 : break; // F1 
		case 113 : break; // F2 
		case 114 : break; // F3 
		case 115 : break; // F4 
		case 116 : // F5
			mode = true;
			break;
		case 117 : break; // F6 
		case 118 : break; // F7 
		case 119 : break; // F8 
		case 120 : break; // F9 
		case 121 : break; // F10
		case 122 : break; // F11 
		case 123 : break; // F12  
		
		default : break;
	}
	
	if( mode ){
		event.keyCode = 0; 
		event.cancelBubble = true; 
		event.returnValue = false; 

		this.ErrMsgOptin("ErrMsg","금지된 Key 호출.");
	}
}

// ----------------------------------------
// @ 헤더부분의 스크롤 제어함수
// ----------------------------------------
function SetScroll(tagDIV, idName)
{
	var positionTop = 0;
	if (tagDIV != null)
	{
		positionTop = parseInt(tagDIV.scrollTop, 10);
		document.getElementById(idName).style.top = positionTop;
	}
}

// ----------------------------------------
// @ 해당 Row의 색상을 바꾼다.
// ----------------------------------------
var g_oRow = null; // 하이라이트된 행을 계속 기억하고 있을 녀석입니다. 객체를 할당합니다. 시작은 nulL입니다.
function list(oRow) // 객체를 바로 받습니다.
{
	if (g_oRow != null) // 하이라이트된 객체가 있는지 보고, 있다면 원상태로 복구합니다.
	  g_oRow.style.backgroundColor = "";

	// 클릭한 행을 바꿉니다.
	oRow.style.backgroundColor = "#fff4f2";
	g_oRow = oRow; // 클릭한 행을 전역변수로 바꿉니다. 간단하죠.
} 

var g_oRow2 = null; // 하이라이트된 행을 계속 기억하고 있을 녀석입니다. 객체를 할당합니다. 시작은 nulL입니다.
function list2(oRow) // 객체를 바로 받습니다.
{
	if (g_oRow2 != null) // 하이라이트된 객체가 있는지 보고, 있다면 원상태로 복구합니다.
	  g_oRow2.style.backgroundColor = "";

	// 클릭한 행을 바꿉니다.
	oRow.style.backgroundColor = "#fff4f2";
	g_oRow2 = oRow; // 클릭한 행을 전역변수로 바꿉니다. 간단하죠.
} 

var g_oRow3 = null; // 하이라이트된 행을 계속 기억하고 있을 녀석입니다. 객체를 할당합니다. 시작은 nulL입니다.
function list3(oRow) // 객체를 바로 받습니다.
{
	if (g_oRow3 != null) // 하이라이트된 객체가 있는지 보고, 있다면 원상태로 복구합니다.
	  g_oRow3.style.backgroundColor = "";

	// 클릭한 행을 바꿉니다.
	oRow.style.backgroundColor = "#fff4f2";
	g_oRow3 = oRow; // 클릭한 행을 전역변수로 바꿉니다. 간단하죠.
} 

/*----------------------------------------------------------------------------------------------------
 *----------------------------------------------------------------------------------------------------
 *----------------------------------------------------------------------------------------------------
 * 추가로 함수를 생성시 아래에 기입해 주세요~~
 *----------------------------------------------------------------------------------------------------
 *----------------------------------------------------------------------------------------------------
 *----------------------------------------------------------------------------------------------------*/

// ----------------------------------------
// @ 화면의 첨부파일을 제어하기 위한 함수입니다.
// @ 다음은 사용예제입니다.
//   <input type="button" value="+" onClick="var objFileMgr = new USR_FILE_MGR();
//											objFileMgr.addFile();">
//   <table id="fileList"></col><tbody></tbody></table>
// ----------------------------------------
function USR_FILE_MGR() {}
//@@.초기 등록할수 있는 첨부파일 리스트를 설정합니다.
USR_FILE_MGR.prototype.init = function ( rowNum ) {
	if( rowNum == null ) rowNum = 3;

	var objFileMgr = new USR_FILE_MGR();
	for(var i=0; i<rowNum; i++){
		objFileMgr.addFile();
	}
}
//@@.첨부파일관련 추가등록 함수
USR_FILE_MGR.prototype.addFile = function () {
	// 동적으로 tr과 td를 생성할 테이블을 지정한다
	var oTable = document.getElementById("fileList"); 
	// table의 두번째 차일드 즉 tbody를 지정한다.
	var oTbody = oTable.childNodes[1];

	var rowNum = oTbody.rows.length;

	var oRow = null;
	var oCol = null;
	var oObj = null;
	var oTag = null;

	if(true){
		oRow = oTable.insertRow(rowNum);

		var fileIndex = rowNum * 2; 

		oCol = new Array();	
		oCol[0] = oRow.insertCell(0);
		oCol[0].className = "file_search01";
		oTag  = '';
		oTag += ' <input type="file" name="fileList['+ fileIndex +']" style="width:310px" class="file_search01"> ';
		oCol[0].innerHTML = oTag;
		
		oCol[1] = oRow.insertCell(1);
		oCol[1].width = "13";

		oCol[2] = oRow.insertCell(2);
		oCol[2].className = "file_search01";
		oTag  = '';
		oTag += ' <input type="file" name="fileList['+ (fileIndex+1) +']" style="width:310px" class="file_search01"> ';
		oTag += ' <img src="/scms/images/button/btn_minus.gif" align="absmiddle" onClick="var objFileMgr = new USR_FILE_MGR(); objFileMgr.delFile();" style="cursor:hand;">';
		oCol[2].innerHTML = oTag;
	}
};
//@@.해당 파일객체를 삭제시 호출함수
USR_FILE_MGR.prototype.delFile = function () {
	var oTr = getTr(event.srcElement);

	var oTable = document.getElementById("fileList");
	oTable.deleteRow( oTr.rowIndex );

	var objFileMgr = new USR_FILE_MGR();
	objFileMgr.resetFileName();
};
//@@.파일명을 재정리하기 위한 함수
USR_FILE_MGR.prototype.resetFileName = function () {
	// 동적으로 tr과 td를 생성할 테이블을 지정한다
	var oTable = document.getElementById("fileList"); 
	// table의 두번째 차일드 즉 tbody를 지정한다.
	var oTbody = oTable.childNodes[1];

	var oRow = null;

	if( oTbody.rows.length > 0 ){
		for(var i=0;i<oTbody.rows.length;i++)
		{
			var oRow = oTbody.rows[i];
			var oTd = oRow.children.item(0);

			var objFile = oTd.children.item(0);
			objFile.name = "fileList["+i+"]";
		}
	} 
};

/*=======================================================================
Function명 :fun_Search()
내용 : 검색
작  성  자  : 이성근
최초작성일  : 2009년 04월 20일
최종수정일  : 2009년 04월 20일
========================================================================*/			
function fun_Search(bName, bMenu)
{
    try
    {
        var theForm = document.forms[0];
	    var nSelectedID = theForm.hddlSearch.selectedIndex
	    theForm.hhdSearchColumn.value = theForm.hddlSearch.options[nSelectedID].value ;
	    
	    if(!theForm.hhdSearchWord.value)
	    {
	        alert("검색어를 입력하시기 바랍니다.");
	        theForm.hhdSearchWord.focus();
	        return false;
	    }
	    else
	    {
	        
	        theForm.hhdSearchColumn.value = theForm.hddlSearch.selectedIndex;
	        theForm.hhdCurPage.value="1";
	        
	        if( (bName && bMenu) )
	            theForm.action="./board_list.aspx?BoardName="+eval("document.all."+bName+".value")+"&BoardMenu="+eval("document.all."+bMenu+".value");
	        document.forms[0].submit();
	    }
    } catch(E) {
        alert(E.description);
    }
}


/*=======================================================================
Function명 :fun_MemberSearch()
내용 : 고객지원 회원관리 검색에서 사용
작  성  자  : 이성근
최초작성일  : 2009년 04월 20일
최종수정일  : 2009년 04월 20일
========================================================================*/			
function fun_MemberSearch(Name, bMenu)
{
    try
    {
      var theForm = document.forms[0];
	    var nSelectedID = theForm.hddlSearch.selectedIndex
	    theForm.hhdSearchColumn.value = theForm.hddlSearch.options[nSelectedID].value ;
	    
	    if(!theForm.hhdSearchWord.value)
	    {
	        alert("검색어를 입력하시기 바랍니다.");
	        theForm.hhdSearchWord.focus();
	        return false;
	    }
	    else
	    {	        
	        theForm.hhdSearchColumn.value = theForm.hddlSearch.selectedIndex;
	        theForm.hhdCurPage.value="1";
	        
	        if( (bName && bMenu) )
	            theForm.action="./member_list.aspx?BoardName="+eval("document.all."+bName+".value")+"&BoardMenu="+eval("document.all."+bMenu+".value");
	        document.forms[0].submit();
	    }
    } catch(E) {
        alert(E.description);
    }
}


/*=======================================================================
Function명 :fun_TechSearch()
내용 : 고객의소리 기술정보 검색에서 사용
작  성  자  : 이성근
최초작성일  : 2009년 04월 20일
최종수정일  : 2009년 04월 20일
========================================================================*/			
function fun_TechSearch(bName, bMenu)
{
    try
    {
        var theForm = document.forms[0];
	    var nSelectedID = theForm.hddlSearch.selectedIndex
	    theForm.hhdSearchColumn.value = theForm.hddlSearch.options[nSelectedID].value ;
	    
	    if(!theForm.hhdSearchWord.value)
	    {
	        alert("검색어를 입력하시기 바랍니다.");
	        theForm.hhdSearchWord.focus();
	        return false;
	    }
	    else
	    {
	        
	        theForm.hhdSearchColumn.value = theForm.hddlSearch.selectedIndex;
	        theForm.hhdCurPage.value="1";
	        
	        if( (bName && bMenu) )
	            theForm.action="./tech_infoList.aspx?BoardName="+eval("document.all."+bName+".value")+"&BoardMenu="+eval("document.all."+bMenu+".value");
	        document.forms[0].submit();
	    }
    } catch(E) {
        alert(E.description);
    }
}

/*=======================================================================
Function명 :fun_CaseSearch()
내용 : 실증자료 검색에서 사용
작  성  자  : 이성근
최초작성일  : 2009년 04월 20일
최종수정일  : 2009년 04월 20일
========================================================================*/			
function fun_CaseSearch(bName, bMenu)
{
    try
    {
        var theForm = document.forms[0];
	    var nSelectedID = theForm.hddlSearch.selectedIndex
	    theForm.hhdSearchColumn.value = theForm.hddlSearch.options[nSelectedID].value ;
	    
	    if(nSelectedID==0)
	    {
	        alert("구분 검색자를 선택해 주시기 바랍니다.");
	        theForm.hddlSearch.focus();
	        return false;
	    }
	    else if(!theForm.hhdSearchWord.value)
	    {
	        alert("검색어를 입력하시기 바랍니다.");
	        theForm.hhdSearchWord.focus();
	        return false;
	    }
	    else
	    {
	        
	        theForm.hhdSearchColumn.value = theForm.hddlSearch.selectedIndex;
	        theForm.hhdCurPage.value="1";
	        
	        if( (bName && bMenu) )
	            theForm.action="./product_case.aspx?BoardName="+eval("document.all."+bName+".value")+"&BoardMenu="+eval("document.all."+bMenu+".value");
	        document.forms[0].submit();
	    }
    } catch(E) {
        alert(E.description);
    }
}

/*=======================================================================
Function명 :fun_FarmSearch()
내용 : 팜뉴스에서 사용
작  성  자  : 이성근
최초작성일  : 2009년 04월 20일
최종수정일  : 2009년 04월 20일
========================================================================*/			
function fun_FarmSearch(bName, bMenu)
{
    try
    {
        var theForm = document.forms[0];
	    var nSelectedID = theForm.hddlSearch.selectedIndex
	    theForm.hhdSearchColumn.value = theForm.hddlSearch.options[nSelectedID].value ;
	    
	    if(!theForm.hhdSearchWord.value)
	    {
	        alert("검색어를 입력하시기 바랍니다.");
	        theForm.hhdSearchWord.focus();
	        return false;
	    }
	    else
	    {
	        
	        theForm.hhdSearchColumn.value = theForm.hddlSearch.selectedIndex;
	        theForm.hhdCurPage.value="1";
	        
	        if( (bName && bMenu) )
	            theForm.action="./farm_list.aspx?BoardName="+eval("document.all."+bName+".value")+"&BoardMenu="+eval("document.all."+bMenu+".value");
	        document.forms[0].submit();
	    }
    } catch(E) {
        alert(E.description);
    }
}



// 데이터 입력 시  데이터의 최대 길이를 체크한다.
function checkInputMaxLength(obj,title,maxLength)
{
    if (CheckByte(obj.value) > maxLength)
	{
		
		//alert(title + " 한글 " + Math.floor(maxLength/2) + "자  영문,숫자 "+ maxLength +"자 이내로 작성하십시오.");
		alert("입력가능한 최대글자수를 초과하였습니다.");
		obj.value=obj.value.substring(0,countMaxLength(obj.value,maxLength));		
		return false;
	}
	else{
		return true;
	}
}
// 데이터 submit 시 데이터의 최대 길이를 체크한다.
function checkSubmitMaxLength(str,title,maxLength)
{
    if (CheckByte(str) > maxLength)
	{		
		//alert(title + " 한글 " + Math.floor(maxLength/2) + "자  영문,숫자 "+ maxLength +"자 이내로 작성하십시오.");
		alert("입력가능한 최대글자수를 초과하였습니다.");
		return false;
	}
	else{
		return true;
	}
}

function CheckByte(str)
{

    var IEYES = 0;
    var menufacture = navigator.appName;
    var version = navigator.appVersion;
    var brow = navigator.appName;
    
    if((0 < brow.indexOf('Explorer'))
      && (version.indexOf('4') >= 0 || version.indexOf('5') > 0
      || veirsioni.indexOf('6') > 0 || veirsioni.indexOf('7') > 0
      || veirsioni.indexOf('8') > 0 || veirsioni.indexOf('9') > 0))
    {
         IEYES = 1;
    }

    var i;
    var strLen;
    var strByte;
    strLen = str.length;

    if(IEYES == 1)
    {
        for(i=0, strByte=0;i<strLen;i++)
        {
            if(str.charAt(i) >= ' ' && str.charAt(i) <= '~' )
                strByte++;
            else
                strByte += 2;
        }
        return strByte;
    }
    else
    {
        return strLen;
    }
}


function countMaxLength(str,maxlength)
{
   
    var IEYES = 0;
    var menufacture = navigator.appName;
    var version = navigator.appVersion;
    var brow = navigator.appName;
    
    if((0 < brow.indexOf('Explorer'))
      && (version.indexOf('4') >= 0 || version.indexOf('5') > 0
      || veirsioni.indexOf('6') > 0 || veirsioni.indexOf('7') > 0
      || veirsioni.indexOf('8') > 0 || veirsioni.indexOf('9') > 0))
    {
         IEYES = 1;
    }

    var i;
    var strLen;
    var strLength=0;;
    
    strLen = str.length;

    if(IEYES == 1)
    {
        for(i=0;i<maxlength;i++)
        {
            (str.charAt(i) >= ' ' && str.charAt(i) <= '~' ? strLength++:strLength += 2);
            if(strLength == maxlength) 
               	return i+1;
            if(strLength > maxlength)
                return i;                                    
        }
        
        return maxlength;
    }
    else
    {
        return maxlength;
    }
}

function escapeDm(s)
{
    
	if (s.length > 0) {
	   
	    s  =   s.replace(/</g,'&lt');
	    s  =   s.replace(/>/g,'&gt');
	    s  =   s.replace(/\\/g,'\\\\');
	    s  =   s.replace(/'/g,'\'');
	    s  =   s.replace(/"/g,'&quot');
	   
	    //s  =   s.replace(/&/g,'&amp');
   		     
		return s;
	} else {
		return "";
	}
}

/*=======================================================================
Function명 :fn_totalSearch()
내용 : 전체 검색에서 사용
작  성  자  : 이성근
최초작성일  : 2009년 06월 06일
최종수정일  : 2009년 06월 06일
========================================================================*/	
function fn_totalSearch()
{
    try {
        d = document.forms[0];
        
        if(typeof(d.searchKey1)!="undefined") {
        	if(!d.searchKey1.value) {
	            alert("검색어를 기입하신후 조회하시기 바랍니다.");
	            d.searchKey1.focus();
	            return false;
	        }
        }
        else if(!d.searchKey.value) {
            alert("검색어를 기입하신후 조회하시기 바랍니다.");
            d.searchKey.focus();
            return false;
        }
        
        d.action="../search/result.aspx";
        d.submit();
    }catch(E){}
}

/*=======================================================================
Function명 :fun_downLoad()
내용 : 게시판 자료에서 파일다운로드시 사용
작  성  자  : 이성근
최초작성일  : 2009년 06월 06일
최종수정일  : 2009년 06월 06일
========================================================================*/			
function fun_downLoad(sitepath)
{
    try
    {
        var theForm = document.forms[0];
        theForm.action=sitepath+"/cyberpr/FileDownLoad.aspx";
	    theForm.target = "_if_save";
	    theForm.submit();
	    
    } catch(E) {
        
    }
}

/*=======================================================================
Function명 :fun_applyProgram()
내용 : 각종 컴퓨터프로그램 신청
작  성  자  : 이성근
최초작성일  : 2009년 06월 06일
최종수정일  : 2009년 06월 06일
========================================================================*/			
function fun_applyProgram()
{
    try
    {
        var theForm = document.forms[0];
        theForm.action="./apply_program.aspx";
        theForm.target = "_if_save";
	    theForm.submit();
	    
    } catch(E) {
        
    }
}
