var Post = {
	newpost:function(boardType){
		var title=$("input[name=title]").val();
		var board_content=$("textarea[name=text_body]").val();
		if( title == ""  ) {
			alert('please check your title');
			return false;
		}
		if(board_content == "" ) {
			alert('please check content');
			return false;
		}
		var options_check = { 
			type: "POST",
		    url:  '/forum/forum/forum_new_post_update_proc', 
		    data:  'board_type='+boardType+'&board_title='+title+'&board_content='+board_content, 
		    success: function(e) { 
				e=$.trim(e);
				if(e=="msg_success") {
					alert("Success");
					window.location="/forum/board?type="+boardType;
				}
		    } 
		};
		$.ajax(options_check); 
	},
	modify:function(){
		//$('#modify').slideToggle("slow");
		$('.mbutton').toggle();
		$('.content').toggle();
	},
	cancel:function(){
		//$('#modify').slideToggle("slow");
		$('.mbutton').toggle();
		$('.content').toggle();
	},
	saveModify:function(){
		var board_content=$("textarea[name=content]").val();
		var board_id=$("input[name=board_id]").val();
		var board_title=$(".post_title h2").html();
		var options_check = { 
			type: "POST",
		    url:  '/forum/forum/forum_post_update_proc', 
		    data:  'board_id='+board_id+'&board_title='+board_title+'&board_content='+board_content, 
		    success: function(e) { 
				e=$.trim(e);
				if(e=="msg_success") {
					alert("Success");
            		$('#post_body_content').load('/forum/elements/post_body_content?id='+board_id);
				}
		    } 
		};
		$.ajax(options_check); 
	},
	deletePost:function(boardType){
		if(!confirm("Are you sure to delete this post?")){
			return false;
		}
		var board_id=$("input[name=board_id]").val();
		var options_check = { 
			type: "POST",
		    url:  '/forum/forum/forum_post_delete_proc', 
		    data:  'board_id='+board_id,
		    success: function(e) { 
				e=$.trim(e);
				if(e=="msg_success") {
					alert("Success");
					window.location="/forum/board?type="+boardType;
				}
		    } 
		};
		$.ajax(options_check); 
	},
	showComment:function(){
		$("#add_comment").toggle();
		return false;
	},
	addComment:function(){
		var comment_content=$("textarea[name=new_comment_content]").val();
		var board_id=$("input[name=board_id]").val();
		var options_check = { 
			type: "POST",
		    url:  '/forum/forum/forum_comment_add_proc', 
		    data:  'board_id='+board_id+'&comment_content='+comment_content, 
		    success: function(e) { 
				e=$.trim(e);
				if(e=="msg_success") {
					alert("Success");
            		$('#comment_list').load('/forum/elements/post_comment_body?id='+board_id);
				}
		    } 
		};
		$.ajax(options_check); 
	},
	editComment:function(obj){
		
		$(obj).parents("div").children('.comment_button').toggle();
		$(obj).parents("div.views").children('.views_body').toggle();
	},
	modifyComment:function(obj,comment_id){
		var board_id=$("input[name=board_id]").val();
		
		var comment_content=$(obj).parents("div.views").find(".textcomment").val()
		var options_check = { 
			type: "POST",
		    url:  '/forum/forum/forum_comment_update_proc', 
		    data:  'comment_id='+comment_id+'&comment_content='+comment_content, 
		    success: function(e) { 
				e=$.trim(e);
				if(e=="msg_success") {
					alert("Success");
					//Post.cancelComment();
            		$('#comment_list').load('/forum/elements/post_comment_body?id='+board_id);
				}
		    } 
		};
		$.ajax(options_check); 
	},
	deleteComment:function(comment_id){
		if(!confirm("Are you sure to delete this comment?")){
			return false;
		}
		var board_id=$("input[name=board_id]").val();
		var options_check = { 
			type: "POST",
		    url:  '/forum/forum/forum_comment_del_proc', 
		    data:  'comment_id='+comment_id,
		    success: function(e) { 
				e=$.trim(e);
				if(e=="msg_success") {
					alert("Success");
            		$('#comment_list').load('/forum/elements/post_comment_body?id='+board_id);
				}
		    } 
		};
		$.ajax(options_check); 
	},
	cancelComment:function(obj){
		$(obj).parents("div").children('.comment_button').toggle();
		$(obj).parents("div.views").children('.views_body').toggle();

		return false; 
	},
	cancelNewComment:function(){
		$("#add_comment").toggle();
		return false; 
	}		
}