	// 코멘트추가
	 function addComment(tf) {

		if (tf.name && tf.name.tagName == "INPUT" && (!tf.name.done || !tf.name.value)) {
			alert("이름을 입력해 주세요");
			tf.name.focus();
			return false;
		}
		if (tf.passwd && !tf.passwd.value) {
			alert("패스워드를 입력해 주세요");
			tf.passwd.focus();
			return false;
		}
		if (tf.comment && (tf.comment.done != true || !tf.comment.value)) {
			alert("내용을 입력해 주세요");
			tf.comment.focus();
			return false;
		}
		tf.command.value = "add_comment";
		return true;

	}
	
	//코멘트삭제
	function  deleteComment(tf, commentID) {
		return true;
	}	

// 텍스트 박스 포커스시
	function focusInput(sObj) {
		try {
			if(!sObj.done) sObj.value = "";
			sObj.done = true;
		} catch (e) {
			alert(e);
		}	
	}
	
// 파일, 링크추가	
	var addHTML = new Array();
	function addFormEL(formEleID, trID) {
		
		var elForm =document.all(formEleID);
		var elTr = document.all(trID);
		
		var objTbody, objRow, objCell;
		
		if (addHTML[formEleID] == null) {
		 	if (elForm.length > 0) {
		 		addHTML[formEleID] = elForm[0].outerHTML;
		 	} else {
		 		addHTML[formEleID] = elForm.outerHTML;
		 	}	
		}
		
	    	objTbody = elTr;
	    	objRow = objTbody.insertRow();
	    	objCell = objRow.insertCell();
	  //  	objCell.className = "table_03";
	    	objCell.insertAdjacentHTML("AfterBegin", addHTML[formEleID]);
	}
	
// 파일, 링크 삭제
	function removeFormEL(trID) {
		var elTrLen = trID.rows.length;
		if (elTrLen > 1) {
			trID.deleteRow(elTrLen - 1);	
		}		
	}
		
	
// 글쓰기 

	function writeArticle(tf, essFile) {
		
		//miniwini.visualEditor 사용의 경우 글수정시 파일첨부의 경우 finalizeVisualEditor함수가 호출되지 않는 버그
		try {
			g_bVisualEditor==true
			finalizeVisualEditor();
		} catch (e) {}	
		
		if (typeof  tf.article_type == "object" && !tf.article_type.value) {
			alert("글의 분류를 선택해 주세요");
			tf.article_type.focus();
			return false;	
		}	
		if (typeof  tf.name == "object" && !tf.name.value) {
			alert("이름을 입력해 주세요");
			tf.name.focus();
			return false;	
		}	
		if (typeof  tf.title == "object" && !tf.title.value) {
			alert("제목을 입력해 주세요");
			tf.title.focus();
			return false;	
		}	
		if (typeof  tf.content == "object" && !tf.content.value) {
			alert("내용을 입력해 주세요");
			try {
				tf.content.focus();
			} catch (e){}	
			return false;	
		}	
		if (typeof  tf.passwd == "object" && !tf.passwd.value) {
			alert("패스워드를 입력해 주세요");
			tf.passwd.focus();
			return false;	
		}	
		if (typeof  tf.auth_code == "object" && !tf.auth_code.value) {
			alert("광고글방지 글을 입력해 주세요");
			tf.auth_code.focus();
			return false;	
		}
		if (typeof tf.reply_email_yn == "object" && tf.reply_email_yn.checked) {
			if (typeof  tf.email == "object" && !tf.email.value) {
				alert("전자우편 주소를 입력해야 답변메일을 받을 수 있습니다.");
				tf.email.focus();
				return false;	
			}
		}
		

		if (essFile == "Y") {	
			if (typeof document.all["id_userfile"] == "object") {
				var ufile = document.all["id_userfile"];
				if (ufile.length > 1) {
					if (!ufile[0].value) {
						alert("파일을 첨부해 주세요");
						ufile[0].focus();
						return false;	
					}
				} else {
					if (!ufile.value) {
						alert("파일을 첨부해 주세요");
						ufile.focus();
						return false;	
					}
				}
			}		
		}	
	
		return true;
		
	}	
	
	// 답글 달기
	function replyArticle(tf) {
		
		//miniwini.visualEditor 사용의 경우 글수정시 파일첨부의 경우 finalizeVisualEditor함수가 호출되지 않는 버그
		try {
			g_bVisualEditor==true
			finalizeVisualEditor();
		} catch (e) {}	
			
		if (typeof  tf.article_type == "object" && !tf.article_type.value) {
			alert("글의 분류를 선택해 주세요");
			tf.article_type.focus();
			return false;	
		}	
		if (typeof  tf.name == "object" && !tf.name.value) {
			alert("이름을 입력해 주세요");
			tf.name.focus();
			return false;	
		}	
		if (typeof  tf.title == "object" && !tf.title.value) {
			alert("제목을 입력해 주세요");
			tf.title.focus();
			return false;	
		}	
		if (typeof  tf.content == "object" && !tf.content.value) {
			alert("내용을 입력해 주세요");
			try {
				tf.content.focus();
			} catch (e){}	
			return false;	
		}	
		if (typeof  tf.passwd == "object" && !tf.passwd.value) {
			alert("패스워드를 입력해 주세요");
			tf.passwd.focus();
			return false;	
		}	
		if (typeof  tf.auth_code == "object" && !tf.auth_code.value) {
			alert("광고글방지 글을 입력해 주세요");
			tf.auth_code.focus();
			return false;	
		}
		
		if (typeof tf.reply_email_yn == "object" && tf.reply_email_yn.checked) {
			if (typeof  tf.email == "object" && !tf.email.value) {
				alert("전자우편 주소를 입력해야 답변메일을 받을 수 있습니다.");
				tf.email.focus();
				return false;	
			}
		}
		
		return true;
	}
	
	function editArticle(tf) {
		
		//miniwini.visualEditor 사용의 경우 글수정시 파일첨부의 경우 finalizeVisualEditor함수가 호출되지 않는 버그
		try {
			g_bVisualEditor==true
			finalizeVisualEditor();
		} catch (e) {}	
			
		if (typeof  tf.article_type == "object" && !tf.article_type.value) {
			alert("글의 분류를 선택해 주세요");
			tf.article_type.focus();
			return false;	
		}	
		if (typeof  tf.name == "object" && !tf.name.value) {
			alert("이름을 입력해 주세요");
			tf.name.focus();
			return false;	
		}	
		if (typeof  tf.title == "object" && !tf.title.value) {
			alert("제목을 입력해 주세요");
			tf.title.focus();
			return false;	
		}	
		if (typeof  tf.content == "object" && !tf.content.value) {
			alert("내용을 입력해 주세요");
			try {
				tf.content.focus();
			} catch (e){}	
			return false;	
		}	
		if (typeof  tf.passwd == "object" && !tf.passwd.value) {
			alert("패스워드를 입력해 주세요");
			tf.passwd.focus();
			return false;	
		}	
		if (typeof  tf.auth_code == "object" && !tf.auth_code.value) {
			alert("광고글방지 글을 입력해 주세요");
			tf.auth_code.focus();
			return false;	
		}
		if (typeof tf.reply_email_yn == "object" && tf.reply_email_yn.checked) {
			if (typeof  tf.email == "object" && !tf.email.value) {
				alert("전자우편 주소를 입력해야 답변메일을 받을 수 있습니다.");
				tf.email.focus();
				return false;	
			}
		}
		
		return true;
	}
	
	// 패스워드 폼체크
	function sendPassword(tf) {
		if (typeof tf.passwd == "object" && !tf.passwd.value) {
			alert("패스워드를 입력해주세요");
			tf.passwd.focus();
			return false;
		}
		return true;
	}
	
	//검색
	function search(tf) {
		if (typeof tf.key == "object" && !tf.key.value) {
			alert("검색영역을 선택해 주세요.");
			tf.key.focus();
			return false;	
		}
		if (typeof tf.value == "object" && !tf.value.value) {
			alert("검색어을 선택해 주세요.");
			tf.value.focus();
			return false;	
		}
		tf.mode.value = "search";
		return true;
		
	}
	
	// html 체크
	function checkHTML(checkBox) {
		if (typeof checkBox == "object" && checkBox.checked) {
			if (confirm("자동 줄바꿈을 하시겠습니까?\n\n자동 줄바꿈은 게시물 내용중 줄바뀐 곳을<br>태그로 변환하는 기능입니다.")) {
				checkBox.value = "P";	
			} else {
				checkBox.value = "Y";	
			}
		}	
	}
	
	// 메세지 출력(퍼미션관련)
	
	function alertMsg(msg, rtBool) {
		if (!rtBool) rtBool = false;
		alert(msg);
		return rtBool;
	}


// 바로재생
	function playMultimediaFile(sUri,obj)
	{
	  var nPlayState = obj.getAttribute("isPlaying");
	  if (nPlayState==0)
	  {
	   el = obj.previousSibling;
	   while (el.tagName!="A")
	   el = el.previousSibling;
	   var oMedia = document.createElement("EMBED");
	   oMedia.style.display = "block";
	   oMedia.src = sUri;
	   oMedia.id = "mw_autoplayer";
	   oMedia.autostart = true;
	   obj.parentNode.appendChild(oMedia);
	   obj.setAttribute("isPlaying",1);
	  }
	  else
	  {
	   //alert("이미 재생중입니다");
	   var el = document.getElementById('mw_autoplayer');
	   el.stop();
	   el.style.display = "none";
	   obj.parentNode.removeChild(el);
	   obj.setAttribute("isPlaying",0);
	   //return;
	  }
	}
	
	// 임시저장 
	function tmpSaveArticle(typeDesc, titleID, contentID) {
	//	alert(document.getElementById(g_sVisualEditor).innerHTML);
		
		var titleHTML = $F(titleID);
		// ie 의 경우 에디터
		var contentHTML = typeof g_sVisualEditor != "undefined" && $(g_sVisualEditor) ? $(g_sVisualEditor).innerHTML :  $F(contentID);
		
		try {
			finalizeVisualEditor();
		} catch (e) {};
			
		if (	!titleHTML.strip() && !contentHTML.strip()) {
			return;	
		}
		
		var msgID = "div_tmp_save_msg";
		
		var hPost = $H({
			type_desc : typeDesc,
			title : titleHTML,
			content : contentHTML
		});
		
		if (!$(msgID)) {
			var msgDiv = new Element("div", {
					id : msgID, 
					style : 'position:absolute; top:131; right:3px; background-color:#00a0dc; width:200px; color:#ffffff; font-size:11px; padding:5px 10px;'
			});
			$$("body")[0].insert({bottom: msgDiv});
		}

		
	
		var url = "_aj_tmp_article_save.php";		
		var postBody = hPost.toQueryString();
	
		new Ajax.Request(url, {
			method: 'post', 
			evalJSON : true,
			postBody : postBody,
	//		asynchronous : async,  
			onSuccess: function(transport) {
				var jsRT = transport.responseJSON;
			
				if (jsRT.canUseTF) {
					$(msgID).show();
					$(msgID).update("작성하신 글을 임시 저장하였습니다.");
					setTimeout("$('" + msgID + "').hide()", 1000 * 5);
				} else {
					$(msgID).show();
					$(msgID).update(jsRT.msg);
					setTimeout("$('" + msgID + "').hide()", 1000 * 5);
				}	
			
			},
			onFailure: function(transport) {
				$(msgID).show();
				$(msgID).update("임시저장 실패");
				setTimeout("$('" + msgID + "').hide()", 1000 * 5);
			}
			
		});	
	}
	
	// 임시저장 가져오기
	function getTmpSaveArticle(typeDesc, titleID, contentID) {
		var url = "_aj_tmp_article_get.php?";		
		var hPost = $H({
			type_desc : typeDesc
		});
		var postBody = hPost.toQueryString();
	
		new Ajax.Request(url, {
			method: 'post', 
			evalJSON : true,
			postBody : postBody,
	//		asynchronous : async,  
			onSuccess: function(transport) {
				var jsRT = transport.responseJSON;
				var repInfo = jsRT.repInfo;
				
				if (jsRT.canUseTF) {
					if (confirm("임시 저장글이 있습니다. 불러오기하시겠습니까?\r\n취소할 경우 임시저장글은 삭제됩니다.")) {
						$(titleID).value = repInfo.TITLE;
						if (typeof g_sVisualEditor != "undefined" && $(g_sVisualEditor)) {
							$(g_sVisualEditor).innerHTML = repInfo.CONTENT;
						} else {
							$(contentID).value = repInfo.CONTENT;
						}	
					} 
				} 
			
			},
			onFailure: function(transport) {
		
			}
			
		});	
	}

	

	//갤러리 기능.
	function big_img(img)
	{        
	    a_win = window.open("view_img.php?img=" + img,"popwin", "width=520 ,height=400,resizable=yes,scrollbars=no");
	    a_win.focus();
	}
	
	function ShowImg(file_name)
	{
	        var file_name;
	        img_layer.filters.blendTrans.apply();
	        img_layer.style.visibility = "visible";
	        img_layer.filters.blendTrans.play();
	
	        img_layer.innerHTML="<table border=0 cellpadding=0 cellspacing=0 width=100% bgcolor=black><tr><td align=center><img src=" + file_name + " border=0 alt=\"원래크기로 보기- 클릭!\" onclick=big_img(this.src)></td></tr></table>";
	}
	
	function moveBoardArticle(tf) {
		
		if (!tf.target_db.value) {
			alert("이동할 게시판을 선택해 주세요");	
			return;
		}
		if (!tf.db.value) {
			alert("원글 게시판을 찾을수 없습니다");	
			return;
		}
		if (!tf.id.value) {
			alert("게시물 번호를 찾을수 없습니다");	
			return;
		}
		
		if (!confirm("선택한 게시판으로 글을 이동하시겠습니까?")) {
			return;	
		}
		
		tf.command.value = "move_article";
		tf.submit();
		
	}
