
//==========================
//BBS ��ȣȮ��; '�� JS
//==========================
	function setIndex(index)
	{
		document.form_password.Memo_Index.value = index;
	}

	// 암호창 열기
	function show_password(mode,bdid,bmid)
	{
		
		document.form_password.proc_mode.value=mode;
		if (typeof(movie_area)!="undefined")
		{
			movie_area.style.display='none';
		}
		if (mode=="MEMO_edit" || mode=="MEMO_delete")	// MEMO
		{

			document.form_password.Memo_bdid.value = bdid;
			document.form_password.Memo_bmid.value = bmid;
		}

		dis_password.style.display='';
		document.form_password.check_pw.value='';
		document.form_password.check_pw.focus();
		

	}



	// 암호창 닫기
	function hidden_password()
	{	

		if (typeof(movie_area)!="undefined")
		{
			movie_area.style.display='';
		}
		document.form_password.proc_mode.value = "";
		document.form_password.Memo_bmid.value = "0";
		document.form_password.Memo_Index.value ="0";
		document.form_password.check_pw.value = "";
		dis_password.style.display='none';
	}


	// 암호 체크
	function check_password()
	{	
		
		var proc_mode = document.form_password.proc_mode.value;
		
		// 덧글 암호 체크
		if (proc_mode=="MEMO_edit" || proc_mode=="MEMO_delete")	// MEMO
		{
			var check_bdid = document.form_password.Memo_bdid.value;
			var check_bmid = document.form_password.Memo_bmid.value;
			var check_pw = document.form_password.check_pw.value;
			if (check_pw!="" && parseInt(check_bdid)>0)
				sendRequest(result_memo,'&proc_mode='+proc_mode+'&bdid='+check_bdid+'&bmid='+check_bmid+'&check_pw='+check_pw,'POST','bbs_memo.jsp',true,true);
		}
	}



	// BBS 암호 체크 결과
	function result_password(obj)
	{	

		var Result_msg = decodeURIComponent(obj.responseText).trim();
		//alert(Result_msg);
		eval("var res = "+Result_msg+";");
		
		if (res.procValue=='NoMatch')
		{
			alert('입력하신 암호는 일치하지 않습니다.');
			document.form_password.check_pw.value = "";
			return;
		}

		var proc_mode = document.form_password.proc_mode.value;
		if (res.procMode=="BBS_edit" || res.procMode=="BBS_delete")	// BBS
		{
			if (parseInt(res.bdid) > 0)
			{
				document.bbs.PASS_KEY.value=res.PASS_KEY;				// ����Ű��
				if (res.procMode=='BBS_delete')	// 
				{
					document.bbs.BBS_Mode.value='list';
				}
				if (res.procMode=='BBS_edit')	//
				{
					document.bbs.BBS_Mode.value='edit';
				}
				document.bbs.submit();
			}
		}
		hidden_password();
	}




//==========================
//BBS
//==========================

	var memo_nodes;

	// 메모내용 추가/수정
	function memo_proc(frm)
	{
		
		if(frm.ssn12.value=="N"){
			alert("주민번호를 확인해주십시오");
			frm.ssn1.focus(); 
			frm.ssn1.value="";
			frm.ssn2.value="";
			return;
		}
		var bdid = frm.frid.value;
		var bmid = frm.bmid.value;
		var bmwriter = frm.bmwriter.value.trim();
		var bmpw = frm.bmpw.value.trim();
		var bmcomment = frm.bmcomment.value.trim();
		var PASS_KEY = frm.PASS_KEY.value;
		
		if (parseInt(bdid)==0)
		{
			alert("등록처리되지 못하였습니다.");
			return;
		} 
		if (bmwriter.length<2 || bmwriter.length>6)
		{
			alert("성함을 1자이상 6자 이내로 등록 해 주시기 바랍니다.");
			frm.bmwriter.focus();
			return;
		}
		if (parseInt(bmid)==0 && (bmpw.length<4 || bmpw.length>12))
		{
			alert("암호를 4자이상 12자 이내로 등록 해 주시기 바랍니다.");
			frm.bmpw.focus();
			return;
		}
		if (bmcomment.length>100)
		{
			alert("내용은 100자이내로 등록 해 주시기 바랍니다.");
			frm.bmcomment.focus();
			return;
		}

		if ((parseInt(bdid)>0 && parseInt(bmid)==0))
		{


			sendRequest(result_memo,'&proc_mode=MEMO_add'+'&bdid='+bdid+'&bmid='+bmid+'&bmwriter='+bmwriter+'&bmpw='+bmpw+'&bmcomment='+bmcomment,'POST','bbs_memo.jsp',true,true);
		

		}
		if ((parseInt(bdid)>0 && parseInt(bmid)>0))
		{

			sendRequest(result_memo,'&proc_mode=MEMO_update'+'&bdid='+bdid+'&bmid='+bmid+'&bmwriter='+bmwriter+'&bmpw='+bmpw+'&bmcomment='+bmcomment+'&PASS_KEY='+PASS_KEY,'POST','bbs_memo.jsp',true,true);
		}

	}



	// 메모내용 처리 결과
	function result_memo(obj)
	{		

		var Result_msg = decodeURIComponent(obj.responseText).trim();
		Result_msg = Result_msg.replace(/\r\n|\n/g,"");
		Result_msg = Result_msg.replace(/\+/g," ");
		eval("var res = "+Result_msg+";");

		if (res.procMode=="Error")			// MEMO ERROR
		{
			alert('입력하신 암호가 게시물의 암호와 일치하지않습니다.');
		}
		if (res.procMode=="InsertOk")		// MEMO INSERT
		{

			if (memo_nodes == null)	memo_nodes = TableMemo.childNodes[0].cloneNode(true);

			TableMemo.insertAdjacentElement('beforeEnd',memo_nodes.cloneNode(true));
			
			var memoSu = TableMemo.childNodes.length;
			
			for (var i=memoSu-1;i>1;i--)
			{
				TableMemo.childNodes[i].childNodes[0].innerHTML=TableMemo.childNodes[i-1].childNodes[0].innerHTML;
				TableMemo.childNodes[i].childNodes[1].innerHTML=TableMemo.childNodes[i-1].childNodes[1].innerHTML;
				TableMemo.childNodes[i].childNodes[2].innerHTML=TableMemo.childNodes[i-1].childNodes[2].innerHTML;
				TableMemo.childNodes[i].childNodes[3].innerHTML=TableMemo.childNodes[i-1].childNodes[3].innerHTML;
			}
			
			TableMemo.childNodes[1].childNodes[0].innerHTML=res.mWriter;
			TableMemo.childNodes[1].childNodes[1].innerHTML=res.mComment;
			TableMemo.childNodes[1].childNodes[2].innerHTML=res.mDate;
			TableMemo.childNodes[1].childNodes[3].innerHTML="<a href=\"javascript:show_password('MEMO_edit','"+res.mBid+"','"+res.mMid+"')\"><img src=\"/images/common/bullet/icon_pen.gif\" alt=\"수정\" /></a> <a href=\"javascript:show_password('MEMO_delete','"+res.mBid+"','"+res.mMid+"')\"><img src=\"/images/common/bullet/icon_x.gif\" alt=\"삭제\" /></a>";
			TableMemo.childNodes[memoSu-1].childNodes[0].style.display='';
			TableMemo.childNodes[memoSu-1].childNodes[1].style.display='';
			TableMemo.childNodes[memoSu-1].childNodes[2].style.display='';
			TableMemo.childNodes[memoSu-1].childNodes[3].style.display='';
			

			// 덧글 등록폼 초기화
			document.memo.bmid.value="0";
			document.memo.bmwriter.value="";
			document.memo.bmpw.value="";
			document.memo.bmcomment.value="";
			document.memo.nodeIndex.value="";
		}

		if (res.procMode=="UpdateOk")		// MEMO INSERT
		{
			var nodeIndex = parseInt(document.memo.nodeIndex.value);
			
			if (nodeIndex>0)
			{
				TableMemo.childNodes[nodeIndex].childNodes[0].innerHTML=res.mWriter;
				TableMemo.childNodes[nodeIndex].childNodes[1].innerHTML=res.mComment;
				TableMemo.childNodes[nodeIndex].childNodes[2].innerHTML=res.mDate;
				TableMemo.childNodes[nodeIndex].childNodes[3].innerHTML="<a href=\"javascript:show_password('MEMO_edit','"+res.mBid+"','"+res.mMid+"')\"><img src=\"/images/common/bullet/icon_pen.gif\" alt=\"수정\" /></a> <a href=\"javascript:show_password('MEMO_delete','"+res.mBid+"','"+res.mMid+"')\"><img src=\"/images/common/bullet/icon_x.gif\" alt=\"삭제\" /></a>";
			}

			// 덧글 등록폼 초기화
			document.memo.bmid.value="0";
			document.memo.bmwriter.value="";
			document.memo.bmpw.value="";
			document.memo.bmcomment.value="";
			document.memo.nodeIndex.value="";	
		}		

		if (res.procMode=="EditReady")		// MEMO EditReady
		{
			
			document.memo.nodeIndex.value	= document.form_password.Memo_Index.value;
			document.memo.bmid.value		= res.Mid;
			document.memo.bmwriter.value	= res.mWriter;
			document.memo.bmpw.value		= "";
			document.memo.bmcomment.value 	= res.mComment;
			document.memo.PASS_KEY.value 	= res.PASS_KEY;
		}

		if (res.procMode=="DeleteOk")		// MEMO DELETE
		{
			var nodeIndex = parseInt(document.form_password.Memo_Index.value);
			if (nodeIndex>0)
			{
				TableMemo.childNodes[nodeIndex].removeNode(true);
				//	document.getElementById('test').deleteRow(now_Memo_Index);
			}
		}

		hidden_password();
	}

