/************************************************************************************
 js_AllClear(mForm) : 화면 초기화

 사용예              : js_allClear(document.search01)
*************************************************************************************/

function js_AllClear(mForm){
	var iElements = mForm.elements.length;
	for(i=0; i<iElements; i++){
		if (mForm.elements[i].name != "PublicSearch") {
			if(mForm.elements[i].type == "checkbox" || mForm.elements[i].type == "radio"){
				mForm.elements[i].checked = false;
			} else if (mForm.elements[i].type == "text" || mForm.elements[i].type == "textarea"){ //input type이 text인 경우만 clear
				mForm.elements[i].value="";
			} 
		}
	}
}

/************************************************************************************
 js_FrmSubmit(mForm, view, no, mode) : view, no, mode값을 세팅후에 submit

 사용예              : js_FrmSubmit(document.frm, '<%=view%>', '<%=no%>', 'search')
*************************************************************************************/

function js_FrmSubmit(mForm, view, no, mode) {
	mForm.View.value = view;
	mForm.No.value = no;
	mForm.Mode.value = mode;
	mForm.submit();
}

/************************************************************************************
 js_FrmEnterSubmit(mForm, mode) : mode값을 세팅후에 submit

 사용예              : onkeydown="js_FrmEnterSubmit(document.frm, 'search')"
*************************************************************************************/
function js_FrmEnterSubmit(mForm) {
    if (event.keyCode == 13) {
		mForm.submit();
	}
}

/************************************************************************************
 js_printPage(view, no, w) :  각 서브화면의 프린트 버튼클릭시 새창으로 프린트화면호출

 사용예              : js_printPage('<%=view%>','<%=no%>')
*************************************************************************************/
function js_PrintPage(view, no, num, w){
	window.open("./printpage.jsp?View="+ view +"&No="+ no + "&Num=" + num + "&Mode=print","","width=" + w +", height=650, resizable=no, scrollbars=yes");
}


/************************************************************************************
 js_KSMPrintPage(view, no, baseYear, baseMonth, baseDay, w) :  각 서브화면의 프린트 버튼클릭시 새창으로 프린트화면호출

 사용예              : js_printPage('<%=view%>','<%=no%>')
*************************************************************************************/
function js_KSMPrintPage(page, view, no, baseYear, baseMonth, baseDay, mode, w){
	window.open("./"+ page +"?View="+ view +"&No="+ no + "&BaseYear="+ baseYear + "&BaseMonth=" + baseMonth +  "&BaseDay=" + baseDay + "&Mode="+mode+"","","width=" + w +", height=650, resizable=no, scrollbars=yes");
}

/************************************************************************************
 js_SetFontSize : 글자확대 축소 (단, id는 Content1, Content2, Content3...순차적으로)

 사용예          : id="Content1" 
*************************************************************************************/
var CurrentFontSize = 10
var CurrentLineHeight = 16
//글자크기 조정
function js_SetFontSize(SizeFlag) {
	if (SizeFlag == 'B') {
		CurrentFontSize = CurrentFontSize + 1
		CurrentLineHeight = parseInt(CurrentFontSize*1.6)
	} else {
		if (CurrentFontSize>0) {
			CurrentFontSize = CurrentFontSize - 1
			CurrentLineHeight = parseInt(CurrentFontSize*1.6)
		}
	}
	for ( i=1; i<=100; i++ ){
		var obj = eval("document.getElementById(\"Content"+ i +"\")");
		if (obj){
			obj.style.fontSize = CurrentFontSize + "pt"
			obj.style.lineHeight = CurrentLineHeight + "pt"
		} else {
			break;
		}		
	} //for
}


/************************************************************************************
 js_OnlyNumber() : 숫자만 입력 (Ctrl+C, Ctrl+V 가능)

 사용예			 : onKeyPress="js_OnlyNumber()"
*************************************************************************************/
function js_OnlyNumber() {
	//alert("1-" + event.keyCode);
	if( !(event.keyCode >47 && event.keyCode < 60)) {
		event.returnValue = false;
    }
}

/************************************************************************************
 js_WinClose() : 팝업창 close

 사용예			  : 
*************************************************************************************/
function js_WinClose(){
	window.close();
}

/************************************************************************************
 js_WinOpen() : 팝업창 open

 사용예			  :
*************************************************************************************/
function js_WinOpen(url){
	window.open(url);
}

/************************************************************************************
 js_AttachWinOpen() : 첨부파일 팝업창 open

 사용예			  :
*************************************************************************************/
/*
function js_AttachWinOpen(view, no, num, type, fileType){

	var actionPage = "../ksmadmin/common/fileupload.jsp?" 
					+ "View="+ view 
					+ "&No="+ no 
					+ "&Num="+ num 
					+ "&Type="+ type 
					+ "&FileType="+ fileType;


	window.open(actionPage,"","width=415, height=230, resizable=no, scrollbars=no");
}
*/


/************************************************************************************
 js_AttachWinOpen() : 첨부파일 팝업창 open

 사용예			  :
*************************************************************************************/
function js_AttachWinOpen(param){
	var actionPage = "../ksmadmin/board/KAD_fileupload.jsp?";
	actionPage = actionPage + param;
	window.open(actionPage,"AttachWin","width=415, height=230, resizable=no, scrollbars=no");
}


/************************************************************************************
 js_WindowClose() : 플래쉬 팝업창 open

 사용예			  :
*************************************************************************************/
function js_WinOpenFile(url){
	window.open(url, "", "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1");
}

/************************************************************************************
 js_SetFocus(obj)   : enter를 입력하는경우 obj로 포커스이동

 사용예              : onkeydown="js_EnterSetFocus(document.frm.Password)"
*************************************************************************************/
function js_EnterSetFocus(obj) {
    if (event.keyCode == 13) {
		obj.focus();
	}
}

/************************************************************************************
 js_LoadSetFocus(obj) : 로드시 포커스를 이동

 사용예              : onload="js_LoadSetFocus(document.frm.ID)"
*************************************************************************************/
function js_LoadSetFocus(obj) {
	obj.focus();
}

/************************************************************************************
  js_AutoSelect(a,b) : 페이지이동시 Select박스의 선택값 유지

 사용예              : js_AutoSelect(f.ksmlistsort, "<%= ksmlistsort %>");
*************************************************************************************/
function js_AutoSelect(a,b)
{
	var i;
        if(b == "") return;
	for ( i=0; i < a.length ; i++) {
		if (a.options[i].value == b) {
			a.selectedIndex = i;
			break;
		}
	}
}
/************************************************************************************
  js_FileType(s) : 확장자명추출

 사용예              : js_FileType("광개토.hwp");
*************************************************************************************/
function js_FileType(s) {
	var type = "";
	var len = 0;
	var index = 0;
	if(s == null)
		return "";
	if("null" == (s))
		return "";
	if("" == (s))
		return "";
	else {
		len = s.length;
		index = s.lastIndexOf(".") + 1;
		type = s.substr(index,len);
		return type;
	}
}

/************************************************************************************
  js_SetAreaSearch(mfrm, code, area, addr) : 지역별검색 key값 set

 사용예              :js_SetAreaSearch(
*************************************************************************************/
function js_SetAreaSearch(mfrm, code, area, addr) {
	mfrm.Code.value = code;
	mfrm.Area.value = area;
	mfrm.Addr.value = addr;
	mfrm.submit();
}

/************************************************************************************
  js_CheckCalFromTo(date1, date2) : date2가 date1보다 작다면 false

 사용예              :
*************************************************************************************/
function js_CheckCalFromTo(date1, date2) {
	if (date1 == false || date2 == false) {
		return false;
	}
	var gap = eval(date2) - eval(date1); // 받아온 날짜값을 숫자로 바꾼후 계산한다
	// 종료일자에서 시작일자를 뺀값이 0보다 적다면(시작일자가 크다면)
	if(gap < 0) { 
		return false;
	}
	return true;
}

/************************************************************************************
  js_CheckCalTodayTo(date2) : date2가 오늘날짜보다 작다면 false

 사용예              :
*************************************************************************************/
function js_CheckCalTodayTo(date2) {
	var today = new Date(); // 오늘
	var year = today.getYear();
	var month = today.getMonth() + 1;
	var day	= today.getDate();
	if (month < 10){
		month = "0" + month;
	}
	if (day < 10) {
		day = "0" + day;
	}
	var date1 = year + "" + month + "" + day;
	return js_CheckCalFromTo(date1, date2);
}

/************************************************************************************
  js_GoodDate(date) : date가 유효한날짜가 아니라면 false

 사용예              :
*************************************************************************************/
function js_GoodDate(date) {
	if(date == '') {
		return true;
	} else {
		date=date.replace(".","").replace(".","").replace("-","").replace("-","");
		for(i=0;i<date.length;i++) {
			ck=date.charAt(i);
			if (!(ck>="0" && ck<="9")) {
				return false;
				break;
			}
		}
		if(date.length!=8) {
			return false;
		} else {
			year = date.substring(0, 4);
			month = date.substring(4, 6);
			day = date.substring(6, 8);
			if(month < 1 || month > 12)
				return false;
			if(day < 1 || day > 31)
				return false;
			if(year < 0 || year > 9999)
				return false;
			if(month == 4 || month == 6 || month == 9 || month == 11) {
				if (day == 31)
				return false;
			}
			if(month == 2) {
				if (isNaN(parseInt(year/4)))
					return false;
				if (day > 29)
					return false;
				if (day == 29 && ((year/4) != parseInt(year/4)))
					return false;
			}
		}
		return true;
	}
}








/////////////////////////////////////////////임시/////////////////////////////////////////////////

/************************************************************************************
 js_OpenPage(view, no, subNo) :  각 서브화면의 프린트 버튼클릭시 새창으로 프린트화면호출

 사용예              : js_openPage('<%=view%>','<%=no%>','<%=subNo%>')
*************************************************************************************/
function js_WriteMail(view, no, num){
	window.open("./mail/KBI001.jsp?View="+ view +"&No="+ no + "&Num=" + num,"","width=625, height=635, resizable=no, scrollbars=no");
}


/////////////////////////////////////////////임시/////////////////////////////////////////////////
