// board.js
//한글과 영문혼합문자열의 byte 수 구하기
function cal_byte(aquery) {

	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;

	tmpStr = new String(aquery);
	temp = tmpStr.length;

	for (k=0;k<temp;k++) {
		onechar = tmpStr.charAt(k);
		if (escape(onechar) =='%0D') { } else if (escape(onechar).length > 4) { tcount += 2; } else { tcount++; }
	}
	
	return tcount;

}

//게시판, 공지사항, 자료실 내용등록 오류체크
function content_check() {
	
	if ( document.forms[0].subject.value.length == 0) {
		alert( getMsg("NOT_TITLE") );
		document.forms[0].subject.focus();
		return false;
	} else if ( cal_byte(document.forms[0].subject.value) > 199 ) {
		alert(getMsg("CONTENT_BIG_SIZE"));
		document.forms[0].subject.focus();
		return false;
	} else if ( document.forms[0].content.value.length == 0 ) {
		alert(getMsg("NOT_CONTENT"));
		document.forms[0].content.focus();
		return false;
	} else if ( cal_byte(document.forms[0].content.value) > 3999 ) {
		alert(getMsg("CONTENT_BIG_SIZE"));
		document.forms[0].content.focus();
		return false;
	} 	
	return true;

}


//나우리 문예제 작품등록시 입력값 체크
function content_check1() {
	
	if ( document.forms[0].app_gubun1.value.length ==0 ) {
		alert(getMsg("SEL_GUBUN_1"));
		document.forms[0].app_gubun1.focus();
		return false;
	} else if ( document.forms[0].app_gubun2.value.length ==0 ) {
		alert(getMsg("SEL_GUBUN_2"));
		document.forms[0].app_gubun2.focus();
		return false;
	} else if ( document.forms[0].subject.value.length == 0) {
		alert( getMsg("NOT_TITLE") );
		document.forms[0].subject.focus();
		return false;
	} else if ( cal_byte(document.forms[0].subject.value) > 199 ) {
		alert(getMsg("CONTENT_BIG_SIZE"));
		document.forms[0].subject.focus();
		return false;
	} else if ( document.forms[0].content.value.length == 0 ) {
		alert(getMsg("NOT_CONTENT"));
		document.forms[0].content.focus();
		return false;
	} else if ( cal_byte(document.forms[0].content.value) > 3999 ) {
		alert(getMsg("CONTENT_BIG_SIZE"));
		document.forms[0].content.focus();
		return false;
	} 	
	
	return true;

}


//메모등록 오류 체크
function memo_check() {

	 if ( document.forms[0].memo.value.length == 0 ) {
		alert(getMsg("NOT_CONTENT"));
		document.forms[0].memo.focus();
		return false;
	} else if ( cal_byte(document.forms[0].memo.value) > 255 ) {
		alert(getMsg("CONTENT_BIG_SIZE"));
		document.forms[0].memo.focus();
		return false;
	}
	
	return true;

}
	
//게시판등록 오류체크
function board_check() {

	if ( document.forms[0].boardcode.value.length == 0  ) {
		alert(getMsg("CONTENT_BIG_SIZE"));
		document.forms[0].boardcode.focus();
		return false;
	} else if ( cal_byte(document.forms[0].boardcode.value.length) > 20  ) {
		alert(getMsg("NOT_BD_CODE"));
		document.forms[0].boardcode.focus();
		return false;
	} else if ( document.forms[0].boardname.value.length == 0  ) {
		alert(getMsg("NOT_BD_NAME"));
		document.forms[0].boardname.focus();
		return false;
	} else if ( cal_byte(document.forms[0].boardname.value) > 29  ) {
		alert(getMsg("CONTENT_BIG_SIZE"));	
		document.forms[0].boardname.focus();
		return false;
	}
	
	return true;
}

//사진게시판 메모등록 오류 체크
function photo_memo_check(frm) {

	 if (frm.memo.value.length == 0 ) {
		alert(getMsg("NOT_CONTENT"));
		frm.memo.focus();
		return false;
	} else if ( cal_byte(frm.memo.value) > 255 ) {
		alert(getMsg("CONTENT_BIG_SIZE"));
		frm.memo.focus();
		return false;
	}
	
	return true;

}

//사진게시판 입력 오류체크
function photo_insert_check() {
	
	if ( document.forms[0].subject.value.length == 0) {
		alert( getMsg("NOT_TITLE") );
		document.forms[0].subject.focus();
		return false;
	} else if ( cal_byte(document.forms[0].subject.value) > 199 ) {
		alert(getMsg("CONTENT_BIG_SIZE"));
		document.forms[0].subject.focus();
		return false;
	} else if ( document.forms[0].content.value.length == 0 ) {
		alert(getMsg("NOT_CONTENT"));
		document.forms[0].content.focus();
		return false;
	} else if ( cal_byte(document.forms[0].content.value) > 3999 ) {
		alert(getMsg("CONTENT_BIG_SIZE"));
		document.forms[0].content.focus();
		return false;
	} else if ( document.forms[0].filename.value.length == 0 ) {
		alert(getMsg("NOT_SELECTED_FILE"));
		document.forms[0].filename.focus();
		return false;
	} 	
	return true;

}

//사진게시판 입력 오류체크
function photo_update_check() {
	
	if ( document.forms[0].subject.value.length == 0) {
		alert( getMsg("NOT_TITLE") );
		document.forms[0].subject.focus();
		return false;
	} else if ( cal_byte(document.forms[0].subject.value) > 199 ) {
		alert(getMsg("CONTENT_BIG_SIZE"));
		document.forms[0].subject.focus();
		return false;
	} else if ( document.forms[0].content.value.length == 0 ) {
		alert(getMsg("NOT_CONTENT"));
		document.forms[0].content.focus();
		return false;
	} else if ( cal_byte(document.forms[0].content.value) > 3999 ) {
		alert(getMsg("CONTENT_BIG_SIZE"));
		document.forms[0].content.focus();
		return false;
	}
	
	return true;

}
