/**
 * @brief jf_Board
 * Require : jQuery
 */
var jf_Board = {
	board_url_pattern:/\/board\/([^/?#]*)[/]*([^?#]*)/,

	/*** Attributes ***/
	DI_file : null,
	auth : {},

	passForm_modal : null,
	passForm_after_fn : null,


	/********************************************/
	/*** get URL data ***/
	/********************************************/
	get_base_url : function()
	{
		return location.href.match(/(\/admin|\/pims|)\/board\//)[0];
	},
	get_board : function()
	{
		return location.href.match(/\/board\/([^/#?]*)/)[1];
	},
	get_act : function()
	{
		return location.href.match(/\/board\/[^/]*\/([^/?#]*)/)[1];
	},
	get_document_id : function()
	{
		var tmp	 = location.href.match(/\/board\/[^/]*\/([^/?#]*\/)?([0-9]+)/);
		return (tmp==null)?"":tmp[2];
	},
	get_pims_id : function()
	{
		var tmp = location.href.match(/pims_id=([^&]*)/);
		return (tmp==null)?"":tmp[1];
	},
	is_admin_page : function()
	{
		return (this.get_base_url() == "/admin/board/") ? true : false;
	},



	/********************************************/
	/*** get URL ***/
	/********************************************/
	get_docsFirstList_URL : function()
	{
		if(this.auth.docsList==0)	return '/';

		var url = location.href.replace(/[&?](s_[^=]+|sort|start|page|category)=[^&]*/g, "");	// remove Search information
		return url.replace(jf_Board.board_url_pattern, "/board/$1");
	},
	get_docsList_URL : function()
	{
		if(this.auth.docsList==0)	return '/';

		return location.href.replace(jf_Board.board_url_pattern, "/board/$1");
	},
	get_docView_URL : function(document_id)
	{
		if(this.auth.docView==0)	return this.get_docsFirstList_URL();

		return location.href.replace(jf_Board.board_url_pattern, "/board/$1/"+document_id);
	},
	get_docWrite_URL : function()
	{
		if(this.auth.docWrite==0)	return this.get_docsFirstList_URL();

		return location.href.replace(jf_Board.board_url_pattern, '/board/$1/docWrite');
	},
	get_docUpate_URL : function(document_id)
	{
		if(this.auth.docUpdate==0)	return this.get_docView_URL(document_id);
		if ( document_id!=null )
			return location.href.replace(jf_Board.board_url_pattern, "/board/$1/docUpdate/"+document_id);
		else
			return location.href.replace(jf_Board.board_url_pattern, "/board/$1/docUpdate/$2");
	},
	get_docReply_URL : function(document_id)
	{
		if(this.auth.docReply==0)	return this.get_docView_URL(document_id);

		if ( document_id!=null )
			return location.href.replace(jf_Board.board_url_pattern, "/board/$1/docReply/"+document_id);
		else
			return location.href.replace(jf_Board.board_url_pattern, "/board/$1/docReply/$2");
	},



	/********************************************/
	/*** go_URL ***/
	/********************************************/
	go_docsFirstList : function()
	{
		location.href = this.get_docsFirstList_URL();
	},
	go_docsList : function()
	{
		location.href = this.get_docsList_URL();
	},
	go_docWrite : function()
	{
		// content URL
		/*
		if($("#wrap.content_wrap").size() > 0)
			window.open(this.get_docWrite_URL().replace(eval("/"+jf_api.content_host+"/"), jf_api.host), "_blank");
		else
		/**/
			location.href = this.get_docWrite_URL();
	},
	go_docReply	: function(document_id)
	{
		location.href = this.get_docReply_URL(document_id);
	},
	go_docUpdate : function(document_id)
	{
		location.href = this.get_docUpate_URL(document_id);
	},
	go_docView	: function(document_id)
	{
		location.href = this.get_docView_URL(document_id);
	},


	/********************************************/
	/*** after ***/
	/********************************************/
	afterdocWrite : function(document_id)
	{
		this.go_docsFirstList();
	},
	afterdocReply : function(document_id)
	{
		this.go_docsFirstList();
	},
	afterdocUpdate : function(document_id)
	{
		this.go_docsList();
	},
	afterdocDelete : function(document_id)
	{
		this.go_docsList();
	},

	aftercmtWrite : function(comment_id)
	{
		this.relisting_comments();
	},
	aftercmtReply : function(comment_id)
	{
		this.relisting_comments();
	},
	aftercmtUpdate : function(comment_id)
	{
		this.relisting_comments();
	},
	aftercmtDelete : function(comment_id)
	{
		this.relisting_comments();
	},


	/********************************************/
	/*** procedure ***/
	/********************************************/
	proc_docDelete : function(document_id)
	{
		$.ajaxProcedure(location.href.replace(jf_Board.board_url_pattern, "/board/$1/docDeleteProc/"+(document_id==null?this.get_document_id():document_id)));
	},
	proc_docExpire : function(document_id)
	{
		$.ajaxProcedure(location.href.replace(jf_Board.board_url_pattern, "/board/$1/docExpireProc/"+(document_id==null?this.get_document_id():document_id)));
	},
	proc_cmtDelete : function(comment_id)
	{
		$.ajaxProcedure(location.href.replace(jf_Board.board_url_pattern, "/board/$1/cmtDeleteProc/"+this.get_document_id()+"/"+comment_id));
	},



	/********************************************/
	/*** render ***/
	/********************************************/
	_render_docListPrev : function(base_obj){},
	_render_docListAfter : function(base_obj){},
	render_docsList : function(json)
	{
		this.auth = json.auth;

		var base_obj = $("#docsList");

		this._render_docListPrev(base_obj);

		/*** Rendering ***/
		base_obj
			.attachFormListSort()
			// SearchBox
			.find(".searchBox > form")
				.attachFormListSearch(this.get_docsList_URL())
				.end()

		/*** Buttons ***/
			.find("button,a")
				.filter(".board_btn_go_docsFirstList").click(function(){jf_Board.go_docsFirstList();}).end()
				.filter(".board_btn_docWrite")
					.click(json.takingdocWrite=="Y" ? function(){$.ajaxProcedure('/boardExt/'+jf_Board.get_board()+'/docWrite');} : function(){jf_Board.go_docWrite();})
					.css("display", this.auth.docWrite==0?"none":"")
					.end()
				.filter(".board_btn_go_docsExcelDown")
					.click(function(){
						location.href = location.href.replace(jf_Board.board_url_pattern, "/board/$1/docsExcelDown/$2");
					})
					.end()
				
				.filter(".board_btn_go_docsManage")
					.click(function(){
						$this	= $(this);

						var checked_data		= base_obj.find("input[name='checked_data[]']:checked").serializeArray();
						var target_board_list	= $this.attr("target_board_list");
						var default_action		= $this.attr("default_action");

						if(checked_data.length == 0)
						{
							alert("하나 이상의 게시물을 선택해주세요!");
							return false;
						}

						// data
						var data = {};
						data["checked_data"] = [];
						for(k in checked_data)
							data["checked_data"].push(checked_data[k]["value"]);

						if(target_board_list)
							data.target_board_list = target_board_list;

						var callback = function(is_exists){
							$docsManage	= $("#docsManage");
							$docsManage.dialog({
								modal: true,
								autoOpen : true,
								bgiframe: true,
								closeOnEscape: false,
								resizable: false,
								width: 350,
								height: 200,
								title: "게시물관리",
								buttons: {
										"취소": function(){ $(this).dialog("close").remove(); },
										"확인": function(){ $.ajaxProcedure(jf_Board.get_base_url()+jf_Board.get_board()+"/docsManageProc/", $(this).find("form").serialize()); $(this).remove(); }
									}
							});
							if(is_exists != true)
							{
								$docsManage.find("select[name='action']").change(function(){
									$docsManage = $("#docsManage");
									if($(this).val() == "delete")
										$docsManage.find("div.target_board_code").hide();
									else
										$docsManage.find("div.target_board_code").show();
								});
							}

							// set Default Action
							if(default_action)
								$docsManage.find("select[name='action']").val(default_action).trigger("change");
						};

						$('<div id="docsManage"></div>')
							.appendTo(document.body)
							.load(jf_Board.get_base_url()+jf_Board.get_board()+"/docsManage/", data, callback);

					})
					.css("display", this.is_admin_page()==false?"none":"")
					.end()
				.end()
		;

		/*** List ***/
		if(this.is_admin_page())
		{
			// Check all
			base_obj
				.find("table.list")
					.find(">thead>tr").find(">th:first")
						.before($('<th class="checkbox"></th>').append($('<input type="checkbox" class="check_all" />').click(function(){var target=base_obj.find("input[name='checked_data[]']");if(this.checked)target.attr("checked","checked");else target.removeAttr("checked");})))
						.end().end()
					.find(">tbody>tr").find(">td:first")
						.each(function(){
							var $this = $(this);
							$this.before('<td class="checkbox"><input type="checkbox" name="checked_data[]" value="'+$this.attr("data_id")+'" /></td>');
						})
						.end().end()
					.find(">tfoot>tr").find(">td:first")
						.each(function(){
							$(this).before('<td class="checkbox"></td>');
						})
						.end().end()
					.end()
				;
		}

		this._render_docListAfter(base_obj);
	},
	_render_docViewAfter : function(base_obj){},
	render_docView : function(json)
	{
		this.auth = json.auth;

		var board = this.get_board();
		var document_id = this.get_document_id();

		var base_obj = $("#docView");

		/*** Buttons ***/
		if(this.auth.docUpdate == 0)
		{
			base_obj.find("button.board_btn_docUpdate").css("display", "none").end()
					.find("button.board_btn_docDelete").css("display", "none").end();
		}
		else if(this.auth.docUpdate == 1)
		{
			base_obj.find("button.board_btn_docUpdate").click(function(){jf_Board.on_openPassForm(function(){jf_Board.go_docUpdate();});}).end()
					.find("button.board_btn_docDelete").click(function(){jf_Board.on_openPassForm(function(){jf_Board.on_docDelete();});}).end();
		}
		else
		{
			base_obj.find("button.board_btn_docUpdate").click(function(){jf_Board.go_docUpdate();}).end()
					.find("button.board_btn_docDelete").click(function(){jf_Board.on_docDelete();}).end();
		}

		base_obj.find("button.board_btn_go_docsList").click(function(){jf_Board.go_docsList();}).css("display", this.auth.docsList==0?"none":"").end()
				.find("button.board_btn_docReply").click(function(){jf_Board.go_docReply();}).css("display", this.auth.docReply==0?"none":"").end()
				.find("button.board_btn_docExpire").click(function(){jf_Board.on_docExpire();}).css("display", this.auth.docExpire==0?"none":"").end()
				.find("button.board_btn_docPrint").click(function(){
						var $content = $("#content");
						var $hide_obj = $("#header,#footer,#snb,#aside,#floating,#locationbar,#docsList");
						var tmpcontent_float = $content.css("float");
						$hide_obj.hide();
						$content.css("float", "none");
						window.print();
						$content.css("float", tmpcontent_float);
						$hide_obj.show();
					}).end()
				;

		/*** comment List ***/
		$("#cmtsList").find("input.regdate").attr("readonly", "readonly").end()
					.find(".data[cmtUpdateAuth=0] .del_btn").css("display", "none").end()
					.find(".data[cmtUpdateAuth=1] .del_btn").click(function(){jf_Board.on_openPassForm($(this).parents("[data_id]").attr("data_id"));}).end()
					.find(".data[cmtUpdateAuth=2] .del_btn").click(function(){jf_Board.on_cmtDelete($(this).parents("[data_id]").attr("data_id"));}).end()
					;
		/*** comment Write Form ***/
		var cmtWriteForm_obj = $("#cmtWrite form");
		switch(this.auth.cmtWrite)
		{
			case 0:
				cmtWriteForm_obj.hide();
				break;

			case 1:
				cmtWriteForm_obj.submit(function(){return false;})
								.find("textarea[name='content']").attr("readonly", "readonly");
				break

			case 2:
				cmtWriteForm_obj.attr("name", "jf_cmt_write_form")
								.attachFormAJAX(this.get_base_url()+board+"/cmtWriteProc/"+document_id)
								.find("textarea[name='content']").val("").end();
				break;
		}

		/*** callback docViewAfter ***/
		this._render_docViewAfter(base_obj);


		jQuery(function(){
			if(jf_api.location == "popup") return;

			/*** resize Images ***/
			var output_width	= $(".smartOutput").width();
			var content_width	= $("#content").width();
			var width	= (content_width != null && output_width > content_width) ? content_width : output_width;
			$(".smartOutput img").each(function(){
				var this_obj = $(this);
				var image_width = this_obj.width();
				var image_height = this_obj.height();
				if(image_width>width)
				{
					var new_width	= width;
					var new_height	= Math.floor(width*image_height/image_width);
					this_obj
						.width(new_width).height(new_height)
						.attr("image_width", image_width).attr("image_height", image_height)
						.click(function(){
							jf_api.load.script("/r/js/jquery.imagetool.min.js");

							var this_obj = $(this);
							var popup_width	= Number(this_obj.attr("image_width"));
							var popup_height= Number(this_obj.attr("image_height"));
							var new_win = window.open("/board/"+jf_Board.get_board()+"/imagetool/?src="+encodeURIComponent(this_obj.attr("src")), "_blank", "width="+popup_width+",height="+popup_height+",status=yes,menubar=no,resizable=no,scrollbars=no,location=no");
						})
						;
				}
			});
		});
	},
	_render_docWriteAfter : function(base_obj){},
	_render_docWrite : function(json)
	{
		this.auth = json.auth;

		var board		= this.get_board();
		var act			= this.get_act();
		var document_id	= this.get_document_id();

		var base_obj = $("#docWrite");

		/*** Create Board Write Form ***/
		base_obj.find("form")
			/* set name */
			.attr("name", "jf_doc_write_form")
			/* set content_type */
			.submit(function(){
				if(base_obj.find("textarea[name='content']").css("display") == "none")
					base_obj.find("input[name='content_type']").val("HTML");
			})
			/* FormAJAX */
			.attachFormAJAX(this.get_base_url()+board+"/"+act+"Proc/"+document_id)
			/* Create Hidden */
			.append($('<input type="hidden" name="content_type" />'))
			.append($('<input type="hidden" name="pims_id" value="'+this.get_pims_id()+'" />'))
			/* Reset Button */
			.find("button.reset").click(function(){jf_Board.go_docsList();})
				.end()
			/* sms_auth */
			.find("button.btn_sms_auth_number").click(function(){
				jf_sms_auth.send(this, this.form, "user_mobile[]");
				}).end()
			;

		/*** Buttons ***/
		base_obj.find(".board_btn_docDelete").click(function(){jf_Board.on_docDelete();}).css("display", this.auth.docUpdate==0?"none":"").end()
				.find(".board_btn_go_docsList").click(function(){jf_Board.go_docsList();}).css("display", this.auth.docsList==0?"none":"").end();

		/* FillForm */
		if(act == "docUpdate")
		{
			base_obj.find("form").autoFillForm(json.row);
		}

		/*** dynamic Columns ***/
		base_obj.find("ul.userinfo,ul.function,div.period,ul.extra_vars,div.thumbnail").css("visibility", "hidden");
		jQuery(function(){
			/*** Userinfo, Functions, Extra_vars ***/
			base_obj.find("ul.userinfo,ul.function,ul.extra_vars").find(":input").each(function(){
					$this = $(this);
					if(this.disabled)
						$this.parent().css("display", "none");
					else
						$this.parents("li:first").children("label:first").html($this.attr("item_name"));
				});

			var target_list	= ["ul.userinfo", "ul.function", "div.period", "ul.extra_vars", "div.thumbnail"];
			for(var i=0,loop=target_list.length; i<loop; i++)
			{
				var target = base_obj.find(target_list[i]);
				if(target.find(":input").not("[disabled]").size() > 0)
					target.css("visibility", "visible");
				else
					target.css("display", "none");
				target = null;
			}
		});

		/*** Attach File ***/
		if(json.config.file_limit>0)
			this.render_upfile(json);
		else
			base_obj.find("div.attach").remove();

		/*** keep Session ***/
		keep_session();

		/*** callback docWriteAfter ***/
		this._render_docWriteAfter(base_obj);
	},
	render_docWrite : function(json)
	{
		this._render_docWrite(json);
	},
	render_docUpdate : function(json)
	{
		this._render_docWrite(json);
	},
	render_docReply : function(json)
	{
		this._render_docWrite(json);
	},
	render_upfile : function(json)
	{
		if((typeof jf_dynamicItem) == "undefined")
			return;

		var base_obj = $("#docWrite");

		// create upload button
		createUploadButton($("#btn_upload").attr("sdir", "files").attr("filefilter", "*.*").get(0));
		// file list
		base_obj.find("div.attach ul > li")
					.mouseover(function(){$(this).addClass("on");})
					.mouseout(function(){$(this).removeClass("on");})
					.append($('<input type="hidden" class="filename">'))
					.append($('<input type="hidden" class="regdate">'))
					.append($('<input type="hidden" class="is_new">'))
					.end();

		this.DI_file = new jf_dynamicItem(base_obj.find("ul.files"));
		this.DI_file.setItemSelector("li");
		this.DI_file.setItemFormName("files");
		this.DI_file.setIsEmptyToHide(true);
		this.DI_file.setMinCount(0);
		this.DI_file.init();

		// add prevFiles
		if(json.files != null)
		{
			for(var i=0,loop=json.files.length; i<loop; i++)
			{
				this.onAddFile(json.files[i], 0);
			}
		}
	},
	onAddFile : function(json, is_new)
	{
		var this_c = this;

		var filesize = (isFinite(json.filesize) == true) ? toFileSize(json.filesize) : json.filesize;

		var obj = this.DI_file.add();
		obj.find("input.filename").val(json.filename).end()
			.find("input.regdate").val(json.regdate).end()
			.find("input.is_new").val(is_new).end()
			.find("button.addToContent").click(function(){this_c.onAddFileToContent(this); return false;}).end()
			.find("span.source_filename").html(json.source_filename).end()
			.find("span.filesize").html(filesize).end()
			;
	},
	onAddFileToContent : function(btn_element)
	{
		var filename = $(btn_element).parents("li:first").find("input.filename").val();

		var pointpos = filename.lastIndexOf(".");
		if(pointpos == -1)
			var extention = "";
		else
			var extention = filename.substr(pointpos+1);

		switch(extention)
		{
			case "jpg":case "gif":case "png":
				var html = '<img src="'+common_var.upfiles_url + filename+'" />';
				break;

			case "asx":case "asf":case "avi":case "wma":case "wmv":
			case "flv":case "mp3":case "swf":
			case "ra":case "ram":case "rm":case "rpm":case "rv":case "smi":case "smil":
				var html = '<img src="/r/common/images/blank.gif" href="'+common_var.upfiles_url + filename+'" class="media" style="border: 1px solid #eee" width="400" height="400" />';
				break;

			default:
				return;
		}

		var iframe = $("#docWrite textarea[name='content']").next("iframe");
		iframe[0].contentWindow.oApp.exec("PASTE_HTML", [html]);
	},

	on_openPassForm : function(after_fn)
	{
		if(this.passForm_modal == null)
		{
			this.passForm_modal
				= jQuery('<div class="passForm" style="margin: 15px 0;"><form><input type="password" name="pass" class="pass" /></form></div>')
					.dialog({
						modal: true,
						autoOpen : false,
						bgiframe: true,
						closeOnEscape: false,
						resizable: false,
						width: 300,
						height: 150,
						title: "비밀번호를 입력해주세요",
						buttons: {
								"취소": function(){
									$(this).dialog("close");
								},
								"확인": function(){
									$(this).find("form").submitAJAX();
								}
							}
					});
		}

		this.passForm_modal
			.dialog("open")
			.find("form")
				.attachFormAJAX(this.get_base_url()+this.get_board()+"/getDocAuthProc/"+this.get_document_id())
				.trigger("reset")
				.find("input[name='pass']").focus().end()
				.end();

		this.passForm_after_fn	= after_fn;
	},
	afterPassForm : function(is_ok)
	{
		if(is_ok)
		{
			this.passForm_modal.dialog("close");
			if(this.passForm_after_fn != null)
			{
				this.passForm_after_fn();
				this.passForm_after_fn	= null;
			}

		}
		else
		{
			alert("입력하신 비밀번호가 맞지 않습니다.");
		}
	},

	relisting_comments : function()
	{
		location.reload();
	},

	render_docsManage : function(json)
	{
	},

	afterdocsManageProc : function(action)
	{
		switch(action)
		{
			case "copy":
				alert("복사되었습니다.");
				break;

			case "move":
				alert("이동되었습니다.");
				break;

			case "delete":
				alert("삭제되었습니다.");
				break;
		}

		// reload
		location.href = location.href;
	}

};


//------------------------------------------------------------------------------------------------
/*** Uploader  ***/
jf_Uploader.afterAllComplete = function()
{
	for(k in jf_Uploader.completeData)
	{
		var row = jf_Uploader.completeData[k];

		switch(row.dir)
		{
			// attach Files
			case 'files':
				row.is_new = 1; // set new file
				jf_Board.onAddFile(row, 1);
				break;

			case 'images':
				// put filename to InputBox
				if(row.target_input_id)
					$("input#"+row.target_input_id).val(row.filename).trigger("change");
				break;

		}
	}
};


jQuery(document).ready(function(){


switch($("#wrap").attr("class"))
{
	case "en":
		/*** call by user ***/
		jf_Board.on_docDelete = function(document_id)
		{
			if(confirm("Do you want to delete?") == true)
			{
				this.proc_docDelete(document_id);
			}
		};
		jf_Board.on_docExpire = function(document_id)
		{
			if(confirm("Expiration manage this?") == true)
			{
				this.proc_docExpire(document_id);
			}
		};
		jf_Board.on_cmtDelete = function(comment_id)
		{
			if(confirm("Do you want to delete?") == true)
			{
				this.proc_cmtDelete(comment_id);
			}
		};

		/*** call by server ***/
		jf_Board.on_noAuthority = function(enable_auth_name)
		{
			if(enable_auth_name == null)
				alert("Do not have permission.");
			else
				alert(enable_auth_name + " page is available.");

			this.go_docsList();
		};
		jf_Board.on_write_limit = function(minute, count)
		{
			var time_str = "";
			if(60*24*7 <= minute)
			{
				time_str += Math.floor(minute/(60*24*7)) + "주 ";
				minute	%= 60*24*7;
			}
			if(60*24 <= minute)
			{
				time_str += Math.floor(minute/(60*24)) + "일 ";
				minute	%= 60*24;
			}
			if(60 <= minute)
			{
				time_str += Math.floor(minute/(60)) + "시간 ";
				minute	%= 60;
			}
			if(0 < minute)
			{
				time_str += minute + "분";
			}

			alert(time_str + " 이내에 " + count + "건의 글만 등록가능합니다.");

			this.go_docsList();
		};

		jf_Board.afterdocExpire = function()
		{
			alert("Ends have been processed.");
		};
		jf_Board.on_isExpireDoc = function()
		{
			alert("만료된 게시물은 열람하실 수 없습니다.");
		};
		jf_Board.on_cmtLimitCount = function(limit_count)
		{
			alert("해당 게시물에 대한 댓글은 "+limit_count+"회까지만 가능합니다");
		};
		break;

	case "cn":
		/*** call by user ***/
		jf_Board.on_docDelete = function(document_id)
		{
			if ( confirm("你要删除吗?")==true )
			{
				this.proc_docDelete(document_id);
			}
		};
		jf_Board.on_docExpire = function(document_id)
		{
			if ( confirm("过期管理呢?")==true )
			{
				this.proc_docExpire(document_id);
			}
		};
		jf_Board.on_cmtDelete = function(comment_id)
		{
			if ( confirm("你要删除吗?")==true )
			{
				this.proc_cmtDelete(comment_id);
			}
		};

		/*** call by server ***/
		jf_Board.on_noAuthority = function(enable_auth_name)
		{
			if(enable_auth_name == null)
				alert("没有权限");
			else
				alert(enable_auth_name + "页面可用");

			this.go_docsList();
		};
		jf_Board.on_write_limit = function(minute, count)
		{
			var time_str = "";
			if(60*24*7 <= minute)
			{
				time_str += Math.floor(minute/(60*24*7)) + "주 ";
				minute	%= 60*24*7;
			}
			if(60*24 <= minute)
			{
				time_str += Math.floor(minute/(60*24)) + "일 ";
				minute	%= 60*24;
			}
			if(60 <= minute)
			{
				time_str += Math.floor(minute/(60)) + "시간 ";
				minute	%= 60;
			}
			if(0 < minute)
			{
				time_str += minute + "분";
			}

			alert(time_str + " 이내에 " + count + "건의 글만 등록가능합니다.");

			this.go_docsList();
		};

		jf_Board.afterdocExpire = function()
		{
			alert("만료처리되었습니다.");
		};
		jf_Board.on_isExpireDoc = function()
		{
			alert("만료된 게시물은 열람하실 수 없습니다.");
		};
		jf_Board.on_cmtLimitCount = function(limit_count)
		{
			alert("해당 게시물에 대한 댓글은 "+limit_count+"회까지만 가능합니다");
		};
		break;

	default:
		/*** call by user ***/
		jf_Board.on_docDelete = function(document_id)
		{
			if ( confirm("삭제하시겠습니까?")==true )
			{
				this.proc_docDelete(document_id);
			}
		};
		jf_Board.on_docExpire = function(document_id)
		{
			if ( confirm("해당 게시물을 만료처리하시겠습니까?")==true )
			{
				this.proc_docExpire(document_id);
			}
		};
		jf_Board.on_cmtDelete = function(comment_id)
		{
			if ( confirm("삭제하시겠습니까?")==true )
			{
				this.proc_cmtDelete(comment_id);
			}
		};

		/*** call by server ***/
		jf_Board.on_noAuthority = function(enable_auth_name)
		{
			if(enable_auth_name == null)
				alert("권한이 없습니다.");
			else
				alert(enable_auth_name + "만 이용 가능한 페이지입니다.");

			this.go_docsList();
		};
		jf_Board.on_write_limit = function(minute, count)
		{
			var time_str = "";
			if(60*24*7 <= minute)
			{
				time_str += Math.floor(minute/(60*24*7)) + "주 ";
				minute	%= 60*24*7;
			}
			if(60*24 <= minute)
			{
				time_str += Math.floor(minute/(60*24)) + "일 ";
				minute	%= 60*24;
			}
			if(60 <= minute)
			{
				time_str += Math.floor(minute/(60)) + "시간 ";
				minute	%= 60;
			}
			if(0 < minute)
			{
				time_str += minute + "분";
			}

			alert(time_str + " 이내에 " + count + "건의 글만 등록가능합니다.");

			this.go_docsList();
		};

		jf_Board.afterdocExpire = function()
		{
			alert("만료처리되었습니다.");
		};
		jf_Board.on_isExpireDoc = function()
		{
			alert("만료된 게시물은 열람하실 수 없습니다.");
		};
		jf_Board.on_cmtLimitCount = function(limit_count)
		{
			alert("해당 게시물에 대한 댓글은 "+limit_count+"회까지만 가능합니다");
		};

		jf_Board.onSMS_auth_error = function()
		{
			alert("휴대폰 인증을 해주세요");
			$("#docWrite button.btn_sms_auth_number").focus();
		};

		break;
}

});
