
	var imageType = [".jpg", ".gif", ".bmp", ".png"];
	
	function jumpPage(currPage) {
		var frm = frmHomePost;
		frm.currPage.value = currPage;
		frm.submit();
	}

	function voteRecommend(bno, postno) {
		jQuery.ajax({
			type:"POST"
			, url:"recommendDo.do"
			, data:"bno="+bno+"&postno="+postno
			, success:function(msg) {
				if( msg == 'true' ) {
					alert("추천을 하였습니다.");
				} else {
					alert("이미 추천을 하였습니다.");
				}
			}
		});
	}

	function votePoint(bno, postno, point) {
		jQuery.ajax({
			type:"POST"
			, url:"recommendDo.do"
			, data:"bno="+bno+"&postno="+postno+"&point"+point
			, success:function(msg) {
				if( msg == 'true' ) {
					alert("추천을 하였습니다.");
				} else {
					alert("이미 추천을 하였습니다.");
				}
			}
		});
	}


	function voteClaim(bno, postno) {
		if( confirm('신고 하시겠습니까?') ) {
			jQuery.ajax({
				type:"POST"
				, url:"voteClaim.do"
				, data:"bno="+bno+"&postno="+postno
				, success:function(msg) {
					alert('신고 접수 되었습니다.');
				}
			});
		}
	}


	function boardPostList(frm) {
		frm.action = "list.do";
		frm.method = "get";
		frm.submit();
	}

	function boardPostSearchList(frm) {
		frm.action = "list.do";
		frm.method = "get";
		frm.submit();
	}

	function boardPostWrite(frm) {
		frm.action = "write.do";
		frm.submit();
	}

	function boardPostUpdate(frm) {
		frm.action = 'update.do';
		frm.method = 'get';
		frm.submit();
	}

	function boardPostUpdateWithPostno(frm, postno) {
		frm.action = 'update.do';
		frm.method = 'get';
		frm.postno.value = postno;
		frm.submit();
	}

	function boardPostDelete(frm) {
		frm.action = 'delete.do';
		frm.method = 'get';
		frm.submit();
	}

	function boardPostDeleteWithPostno(frm, postno) {
		frm.action = 'delete.do';
		frm.method = 'get';
		frm.postno.value = postno;
		frm.submit();
	}

	function boardPostSelectDelete(frm) {
		var flag = false;
		for( i=0; i<frm.elements.length; i++ ) {
			if( frm.elements[i].name == 'postnos' && frm.elements[i].checked ) {
				flag = true;
				break;
			}
		}

		if( !flag ) {
			alert('선택된 게시물이 없습니다.');
			return;
		}
		
		if( confirm('게시믈은 답글이 없는 경우에만 삭제됩니다.\n선택하신 게시물을 삭제 하시겠습니까?') ) {
			frm.action = 'selectDeleteDo.do';
			frm.method = "post";
			frm.submit();
		}
	}

	function boardPostDoDelete(frm) {
		frm.action = 'deleteDo.do';
		frm.mehtod = 'post';
		frm.submit();
	}

	function boardPostReply(frm) {
		frm.action = 'reply.do';
		frm.method = 'get';
		frm.submit();
	}

	function boardPostCommentDo(frm) {
		if( frm.content.value == '' ) {
			alert("내용을 입력 하십시오.");
			return;
		}
		
		if( frm.content.value.length > 500) {
			alert("덧글의 내용이 허용 값을 초과 하였습니다.");
			return;
		}
		frm.action = 'commentDo.do';
		frm.method = 'post';
		frm.submit();
	}

	function boardPostCommentDeleteDo(comtno) {
		if( confirm('삭제 하시겠습니까?') ) {
			var frm = document.frmHomePost;
			frm.comtno.value = comtno;
			frm.action = 'commentDeleteDo.do';
			frm.submit();
		}
	}

	function boardPostMove() {
		alert('준비중...');
	}

	function pasteHTMLSelectedFile() {
		var selectBox = document.getElementById("uploaded_file_list");
		if( selectBox.selectedIndex == -1 ) {
			return;
		}

		var selectedText = selectBox.options[ selectBox.selectedIndex ].text;
		var isImage = false;
		for( i=0; i<imageType.length; i++) {
			if( selectedText.toLowerCase().indexOf( imageType[i] ) > 0 ) {
				isImage = true;
				break;
			}
		}

		var sHtml = "";
		if( isImage ) {
			sHtml = "<img src='../homePost/download.do?postfileno="+ selectBox.value +"' onLoad='imageOnload(this, 680)'>";
		} else {
			sHtml = "<a href='../homePost/download.do?postfileno="+ selectBox.value +"'>"+ selectedText +"</a>";
		}
		oEditors.getById["content"].exec("PASTE_HTML", [sHtml]);
	}

	function deleteSelectedFile() {
		var selectBox = document.getElementById("uploaded_file_list");
		if( selectBox.selectedIndex == -1 ) {
			return;
		}

		var selectBox = document.getElementById("uploaded_file_list");
		jQuery.ajax({
			type:"POST"
			, url:"remove.do"
			, data:"postfileno="+ selectBox.value
		});

		selectBox.remove( selectBox.selectedIndex );
	}


	function previewSelected(selectBox) {
		var idx = selectBox.selectedIndex;
		if( idx == -1 ) return;

		var previewBox = document.getElementById("previewBox");

		var selectedText = selectBox.options[ selectBox.selectedIndex ].text;
		var isImage = false;
		for( i=0; i<imageType.length; i++) {
			if( selectedText.toLowerCase().indexOf( imageType[i] ) > 0 ) {
				isImage = true;
				break;
			}
		}

		var sHtml = "";
		if( isImage ) {
			sHtml = "<img src='../homePost/downloadThumb.do?postfileno="+ selectBox.value +"' width='65' height='60'>";
		} else {
			sHtml = "<img src='../img/common/_binary.png' width='65' height='60'>";
		}
	
		previewBox.innerHTML = sHtml;
	}

	function _onSubmit(elClicked){
		// 에디터의 내용을 에디터 생성시에 사용했던 textarea에 넣어 줍니다.
		oEditors.getById["content"].exec("UPDATE_IR_FIELD", []);

		// 에디터의 내용에 대한 값 검증은 이곳에서 document.getElementById("ir1").value를 이용해서 처리하면 됩니다.

		if( elClicked.form.title.value == '' ) {
			alert('제목을 입력하셔야 합니다.');
			return;
		}

		try{
			for( i=0; i<elClicked.form.uploadfiles.length; i++) {
				elClicked.form.uploadfiles.options[i].selected = true;
			}

			elClicked.form.submit();
		}catch(e){}
	}

	function _onSubmit_no_editor(elClicked){
		for( i=0; i<elClicked.form.uploadfiles.length; i++) {
			elClicked.form.uploadfiles.options[i].selected = true;
		}

		elClicked.form.submit();
	}

	function _onSubmit_simple(elClicked){
		elClicked.form.submit();
	}

	function boardPostReceive(frm) {
		if( frm.opt01.value == '' ) {
				alert('접수 부서를 입력 하십시오.');
				return;
		}

		if( frm.opt02.value == '' ) {
				alert('담당자를 입력 하십시오.');
				return;
		}

		frm.action = "receivePost.do";
		frm.submit();
	}
	
	function resizeImage(target_img) {
	    var newX, newY;
	    var newHeight, newWidth;
	    var newImg;

	    var maxWidth = 650;
	    var maxHeight = 700;

	    newImg = new Image();
	    newImg.src = target_img.src;
	    imgw = newImg.width;
	    imgh = newImg.height;

	/*    if (imgw*1.2 >= imgh) {
		   	return false;
	    }
	*/
	    if (imgw > maxWidth){
			if(imgw > maxWidth)
				newWidth = maxWidth;
			else
				newWidth = imgw;
			newHeight = Math.round((imgh*newWidth)/imgw);
		} else {
			newWidth = imgw;
			newHeight = imgh;
		}
		newX = maxWidth/2 - newWidth/2;
		newY = maxHeight/2 - newHeight/2;
		target_img.onload = null;
		target_img.src = newImg.src;
		target_img.width = newWidth;
		target_img.height = newHeight;
	}

