/**
    * PaperInformation Form Script
    * @author Stone
    * @version 1.00 2009.02.14
    * @encoding UTF-8
*/


//-----------------------------------------------------------------------------
//	논문정보 입력/수정 체크
//-----------------------------------------------------------------------------
function formCheck(form) {
	
	if (form.title.value.trim().length == 0) {
		alert("논문명을 입력하여 주세요.");
		form.title.focus();
		return false;
	}
	
	if(document.getElementById("newUpdateDate")){
		if (!checkDateFormat(form.newUpdateDate.value)) {
			alert("수정일을 0000-00-00 형태로 입력해 주십시오");
			form.newUpdateDate.value = "";
			form.newUpdateDate.focus();
			return false;
		}
	
		if (isOverToday(form.newUpdateDate.value)) {
			alert("현재날짜 이후로는 수정이 불가능합니다.");
			return false;
		}
	}
	

	if (form.name.value.trim().length == 0) {
		alert("저자명을 입력하여 주세요.");
		form.name.focus();
		return false;
	}

	/*
	if (form.bookName.value.trim().length == 0) {
		alert("잡지명을 입력하여 주세요.");
		form.bookName.focus();
		return false;
	}
	 */
	
	if(isEmpty(document.getElementById("bookName"))){
		document.getElementById("bookId").value = "";
		flag = true;
	}
	
	if(document.getElementById("beBookName")){
		if(isEmpty(document.getElementById("bookName"))){
			document.getElementById("bookId").value = "";
			flag = true;
		} else if(document.getElementById("bookName").value != document.getElementById("beBookName").value){
			document.getElementById("bookId").value = "";
			flag = true;
		}
	}
	
	/*oEditors.getById["content"].exec("UPDATE_IR_FIELD", []);
	oEditors.getById["contentPoint"].exec("UPDATE_IR_FIELD", []);	// iframe의 value를 contentPoint로 ..
	if (form.content.value.trim().length == 0) {
		alert("글 내용을 입력하여 주세요.");
		return false;
	}*/
	
	var oEditor = FCKeditorAPI.GetInstance('paperInformation.content');
	var div = document.createElement("DIV");

	div.innerHTML = oEditor.GetXHTML();
	if (isNull(div.innerHTML)) {
		alert("내용을 입력하세요.");
		oEditor.Focus();
		return false;
	}
	
	
	
	return true;
	
}



/**
 * 검색후 상세보기로 가는 함수
 * @param boardId
 * @return
 */
function selectRtpiFunc(boardId) {
	document.searchParamForm.boardId.value = boardId;
	document.searchParamForm.action = "/selectRtpi.chem";
	document.searchParamForm.submit();
}

/**
 * 검색후 수정폼으로 가는 함수
 * @return
 */
function updateRtpiFormFunc() {
	document.searchParamForm.action = "/updateRtpiForm.chem";
	document.searchParamForm.submit();
}

/**
 * 검색후 삭제로 가는 함수
 * @return
 */
function deleteRtpiFunc() {
	if(confirm("삭제하시겠습니까?")) {
		document.searchParamForm.action = "/deleteRtpi.chem";
		document.searchParamForm.submit();
	}
}

/**
 * 검색후 리스트로 가는 함수 
 * @return
 */
function selectCmsmListType25Func() {
	document.searchParamForm.action = "/selectCmsmListType25.chem";
	document.searchParamForm.submit();
}


/**
 * 댓글 삭제 함수
 * @param commentId 
 * @return
 */
function deleteRtpiComment(commentId) {
	if(confirm("삭제하시겠습니까?")) {
		document.deleteRtpiForm.elements["boardComment.commentId"].value = commentId;
		document.deleteRtpiForm.submit();
	}
}