<!--

bbs = function(){

	// 바이트 수 체크
	bbs.prototype.ChkLen = function(fName, StrSize, txtArea){	
		var strlength = 0; // 초기 문자셋
		var chars;
		var Val = fName.value;
		chars = new String(Val);
		var tlength = chars.length;
		for (i=0; i < tlength; i++) {
			ch = chars.charAt(i) ;
			if(escape(ch) =='%0D'){ 

			}else if(escape(ch).length > 4) { 
				strlength += 2;
			}else{
				strlength++;
			}
			txtArea.innerHTML = strlength;

			if(strlength > StrSize){
				message = StrSize+"byte까지 입력이 가능합니다.";
				alert(message);
				chars = chars.substring(0, i);
				fName.value = chars;
				txtArea.innerHTML = StrSize;
				break;
			}
		}		
	}	// end ChkLen function

	// ltrim
	bbs.prototype.ltrim = function ( s ) {
		return s.replace( /^[\ ]+/g , "" );
	}	// end ltrim function
	// rtrim
	bbs.prototype.rtrim = function( s ) {
		return s.replace( /[\s*$ ]+$/g, "" );
	}	// end rtrim function
	// trim
	bbs.prototype.trim = function ( s ) {
		return this.rtrim(this.ltrim(s));
	}	// end trim function


	// 글 등록 체크
	bbs.prototype.checkValue = function(){
		var bbsForm = document.bbsForm;

		// 내용 등록
		bbsForm.content.value = EditBox.document.body.innerHTML;

		// 작성자 체크
		if(this.trim(bbsForm.name.value) == ""){
			alert("\n작성자를 입력하세요. ");
			bbsForm.name.focus();
			return false;
		}


		// 제목 체크
		if(this.trim(bbsForm.subject.value) == ""){
			alert("\n제목을 입력하세요. ");
			bbsForm.subject.focus();
			return false;
		}

		// 내용 체크
		if(this.trim(bbsForm.content.value) == ""){
			alert("\n내용을 입력하세요. ");
			return false;
		}

		// 비밀번호를 입력하세요
		if(this.trim(bbsForm.password.value) == ""){
			alert("\비밀번호를 입력하세요. ");
			bbsForm.password.focus();
			return false;
		}

		document.getElementById('bbsBtnArea').style.display='none';
		document.getElementById('bbsTxtArea').style.display='block';

		return true;
	}	// end checkValue function


	// 댓글 체크
	bbs.prototype.checkComment = function(){
		
		var comForm = document.comForm;

		// 내용 체크
		if(this.trim(comForm.comment.value) == ""){
			alert("\n내용을 입력하세요. ");
			comForm.comment.focus();
			return false;
		}

		return true;
	}	// end checkComment function


	// 댓글 삭제
	bbs.prototype.commentDelete = function(cno){
		
		var comForm = document.comForm;

		var check = confirm("\n\n정말로 삭제하시겠습니까? ");
		if(check == true){
			comForm.Process_Type.value = "Comment_Delete";
			comForm.cno.value = cno;
			comForm.submit();
		}
	}	// end commentDelete function


	// 댓글 수정
	bbs.prototype.commentModify = function(cno, comment_Txt){
		var commentTxt = document.getElementById(comment_Txt).innerHTML;
		var comForm = document.comForm;

		nl_cnt = commentTxt.split("<BR>");
		for(i = 0; i < nl_cnt.length; i++){
			commentTxt = commentTxt.replace("<BR>", "\n");
		}
		
		comForm.comment.value = commentTxt;
		comForm.Process_Type.value = "Comment_Modify";
		comForm.cno.value = cno;
		document.getElementById('commentTxt').innerHTML = "<b>댓글수정</b>";
		document.getElementById('commentBtn').src = document.getElementById('commentBtn').value;
		this.ChkLen(comForm.comment, 250, document.getElementById('txtByte'));
		comForm.comment.focus();

	}	// end commentModify function

}

bbs = new bbs();


//-->
