PageSourceSearch

https://biosolutions.co.kr/js/module/forum.js

js biosolutions.co.kr collected 2026-09-29 08:59:07 UTC 321,955 bytes, 7,165 lines download raw bytes

1(function($) {
2	$doc = $(document);
3	var fmID = 0,
4		files = [],
5		pY = 0,
6		RELOAD = false, isOff = false,
7		upTYPE = 'image';
8	var user = {
9			'name' : '',
10			'pass' : '',
11			'key' : ''
12		},
13		groups = [],
14		select_group = 0;
15
16	var postUser = {
17		'name' : '',
18		'img' : '',
19		'option' : '',
20		'secret_display' : '',
21		'replied' : '',
22		'writeable'	: false,
23		'sid' : false
24	}
25
26	/* ie attach upload */
27	window.onload = function(){
28		setLanguage(LANG);
29
30		if(document.getElementById('uploadForm') != null) {
31		    document.getElementById('uploadForm').onsubmit = function(e) {
32		        document.getElementById('uploadForm').target = 'uploadIFrame';
33		    }
34		    document.getElementById('uploadIFrame').onload = function(e) {
35		        $('#forum-attach').modal('hide');
36		        var res = $.parseJSON($('#uploadIFrame').contents().find('body').text());
37		        if(typeof res.error != 'undefined' || res.error) {
38		            alert(res.error);
39		            $.processOFF();
40		            return;
41		        }
42		    	$.processOFF();
43		        $.forum.setfile(res.file, res.uploaded.file_name, res.uploaded.orig_name);
44		    }
45		    document.getElementById('uploadFile').onchange = function(e) {
46		    	$.processON();
47		        document.getElementById('uploadForm').submit();
48		    }
49		}
50	}
51    $(function () { 
52    	if(typeof LANG == 'undefined') LANG = getLanguage();
53    });
54
55	var resetObject = function(o) {
56		$.each(o,function(k,v) {
57			o[k] = '';
58		});
59		return o;
60	}
61	var uniqID = function() {
62		return Math.round(new Date().getTime() + (Math.random() * 100));
63	}
64
65	var forumSearchRegexp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+??>@\#$%&\'\"\\\(\=?쒋€?]/i;
66	var getForumPrevStx = function(id, sfl) {
67		var stx = (typeof $.cookie('forum_'+id+'_prev_stx') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_stx');
68		var search_field = (typeof sfl == 'undefined' || !sfl) ? $.cookie('forum_'+id+'_prev_sfl') : sfl;
69		if(stx && $.inArray(search_field, ['mb_id','nonmem']) < 0 && forumSearchRegexp.test(stx)) {
70			$.removeCookie('forum_'+id+'_stx',{path:'/'});
71			$.removeCookie('forum_'+id+'_prev_stx',{path:'/'});
72			return '';
73		}
74		return stx;
75	}
76
77	var getForumCategoryType = function(elsettings_or_el) {
78		var category_type = 'dropdown';
79		if(typeof elsettings_or_el != 'undefined') {
80			if(elsettings_or_el instanceof jQuery) category_type = elsettings_or_el.attr('data-forum-category-type') || category_type;
81			else if(typeof elsettings_or_el.forum_category_type != 'undefined') category_type = elsettings_or_el.forum_category_type;
82		}
83		return ($.inArray(category_type, ['dropdown','list']) > -1) ? category_type : 'dropdown';
84	}
85
86	var getForumCategoryAllLabel = function(block_lang) {
87		var lang = block_lang || LANG,
88			lang_data = $.lang[lang] || $.lang[LANG] || {};
89		return lang_data['config.label.dropdown.forum.all'] || lang_data['board.scate'] || 'All';
90	}
91
92	var getForumCategoryStyle = function(forum_el) {
93		var $forum_el = $(forum_el),
94			category_style = 'default',
95			style_options = ['default','delimiter1','delimiter2','line1','line2','fill1','fill2','fill3'];
96
97		if($forum_el.length > 0 && $forum_el[0]) {
98			category_style = $.trim(getComputedStyle($forum_el[0]).getPropertyValue('--gcate-style')) || category_style;
99		}
100
101		return ($.inArray(category_style, style_options) > -1) ? category_style : 'default';
102	}
103
104	var getForumCategoryNav = function(forum_el) {
105		var $forum_el = $(forum_el);
106		return $forum_el.find('.tpl-forum-category-nav');
107	}
108
109	var placeForumCategoryNav = function(forum_el, category_nav) {
110		var $forum_el = $(forum_el),
111			$category_nav = $(category_nav);
112
113		if($forum_el.length == 0 || $category_nav.length == 0) return $category_nav;
114
115		$forum_el.find('.tpl-forum-category-nav').not($category_nav).remove();
116
117		var $container = $forum_el.children('.container').first();
118		if($container.length > 0) {
119			$container.prepend($category_nav);
120			return $category_nav;
121		}
122
123		var $hidden_input = $forum_el.children('input[type="hidden"]').last();
124		if($hidden_input.length > 0) $hidden_input.after($category_nav);
125		else $forum_el.prepend($category_nav);
126
127		return $category_nav;
128	}
129
130	var getForumScate = function(forum_el) {
131		var $forum_el = $(forum_el),
132			$active_category = getForumCategoryNav($forum_el).find('.tpl-forum-category-item.active > a').first();
133
134		if($active_category.length > 0) return $active_category.attr('data-cate') || '';
135		return ($forum_el.find('.search-box #scate').length > 0) ? $forum_el.find('.search-box #scate').val() : '';
136	}
137
138	var setForumCategoryActive = function(forum_el, scate) {
139		var $forum_el = $(forum_el),
140			$category_nav = getForumCategoryNav($forum_el),
141			active_scate = (typeof scate != 'undefined' && scate) ? String(scate) : '';
142
143		$category_nav.find('.tpl-forum-category-item').removeClass('active');
144		var $active_item = $category_nav.find('.tpl-forum-category-item').filter(function() {
145			return String($(this).attr('data-cate') || '') == active_scate;
146		}).first();
147		if($active_item.length == 0) {
148			$active_item = $category_nav.find('.tpl-forum-category-item').first();
149			active_scate = $active_item.attr('data-cate') || '';
150		}
151		$forum_el.find('.search-box #scate').val(active_scate);
152		$active_item.addClass('active');
153		if(typeof syncForumCategoryCustomSelect == 'function') syncForumCategoryCustomSelect($forum_el);
154	}
155
156	var scrollToForumBlock = function(forum_el) {
157		var $forum_el = $(forum_el),
158			forum_id = $forum_el.attr('data-id');
159
160		if($forum_el.length == 0 || !forum_id) return false;
161		if(typeof scrollToBlock == 'function') {
162			scrollToBlock('.element[data-id="' + forum_id + '"]', 1000);
163			return true;
164		}
165		if($forum_el.offset()) {
166			$('html, body').animate({ scrollTop: $forum_el.offset().top }, 1000, 'easeInOutQuart');
167			return true;
168		}
169		return false;
170	}
171
172	var getForumSearchboxDisplay = function(elsettings_or_el) {
173		var searchbox_display = 'ON';
174		if(typeof elsettings_or_el != 'undefined') {
175			if(elsettings_or_el instanceof jQuery) searchbox_display = elsettings_or_el.attr('data-searchbox-display') || searchbox_display;
176			else if(typeof elsettings_or_el.searchbox_display != 'undefined') searchbox_display = elsettings_or_el.searchbox_display;
177		}
178		return (searchbox_display == 'OFF') ? false : true;
179	}
180
181	var getForumCategoryCustomMenu = function($custom) {
182		if(!$custom || $custom.length == 0) return $();
183
184		var $menu = $custom.children('.forum-category-custom-menu').first();
185		if($menu.length > 0) return $menu;
186
187		$('.forum-category-custom-menu-layer').each(function() {
188			var $layer = $(this),
189				$owner = $layer.data('forumCategoryOwner');
190
191			if($owner && $owner.length > 0 && $owner[0] == $custom[0]) {
192				$menu = $layer;
193				return false;
194			}
195		});
196		return $menu;
197	}
198
199	var getForumCategoryCustomOwner = function($target) {
200		var $custom = $target.closest('.forum-category-custom-select');
201		if($custom.length > 0) return $custom;
202
203		var $menu = $target.closest('.forum-category-custom-menu-layer');
204		if($menu.length == 0) return $();
205
206		$custom = $menu.data('forumCategoryOwner');
207		return ($custom && $custom.length > 0) ? $custom : $();
208	}
209
210	var copyForumCategoryCustomMenuVars = function($custom, $menu) {
211		if($custom.length == 0 || $menu.length == 0 || !window.getComputedStyle || !$menu[0].style || !$menu[0].style.setProperty) return;
212
213		var custom_style = window.getComputedStyle($custom[0]),
214			vars = [
215				'--searchbox-select-w',
216				'--fcategory-select-menu-w',
217				'--fcategory-select-fname',
218				'--fcategory-select-fsize',
219				'--fcategory-select-fweight',
220				'--fcategory-select-color',
221				'--fcategory-select-bgcolor',
222				'--fcategory-select-line',
223				'--fcategory-select-option-color',
224				'--fcategory-select-option-bgcolor'
225			];
226
227		$.each(vars, function(idx, key) {
228			var value = custom_style.getPropertyValue(key);
229			if(value) $menu[0].style.setProperty(key, value);
230		});
231		$menu.css('text-transform', $custom.css('text-transform'));
232	}
233
234	var positionForumCategoryCustomMenu = function($custom) {
235		var $menu = getForumCategoryCustomMenu($custom);
236		if($custom.length == 0 || $menu.length == 0 || !$custom.offset()) return;
237
238		var offset = $custom.offset(),
239			$win = $(window),
240			left = Math.round(offset.left),
241			top = Math.round(offset.top + $custom.outerHeight()),
242			scroll_left = $win.scrollLeft(),
243			win_width = $win.width(),
244			menu_width;
245
246		$menu.css({
247			'min-width': Math.ceil($custom.outerWidth()) + 'px',
248			'left': left + 'px',
249			'top': top + 'px'
250		});
251
252		menu_width = $menu.outerWidth();
253		if(left + menu_width > scroll_left + win_width) left = Math.max(scroll_left + 8, scroll_left + win_width - menu_width - 8);
254		if(left < scroll_left + 8) left = scroll_left + 8;
255
256		$menu.css({
257			'left': Math.round(left) + 'px',
258			'top': top + 'px'
259		});
260	}
261
262	var syncForumCategoryOptionWidth = function(forum_el) {
263		var $forum_el = $(forum_el),
264			$select = $forum_el.find('.search-box #scate').first();
265
266		if($select.length == 0) return;
267
268		$select.css('width','');
269		if($select.is('.hide, .hidden')) return;
270
271		var toNum = function(value) {
272				value = parseFloat(value);
273				return isNaN(value) ? 0 : value;
274			},
275			$wrap = $select.closest('.forum-category-select-wrap'),
276			$custom = $wrap.find('.forum-category-custom-select').first(),
277			$custom_menu = getForumCategoryCustomMenu($custom),
278			base_width = ($custom.length > 0) ? $custom.outerWidth() : $select.outerWidth(),
279			extra_width = toNum($select.css('padding-left')) + toNum($select.css('padding-right')) + toNum($select.css('border-left-width')) + toNum($select.css('border-right-width')) + 2,
280			text_width = 0,
281			$measure = $('<span></span>').css({
282				position: 'absolute',
283				visibility: 'hidden',
284				whiteSpace: 'nowrap',
285				top: '-9999px',
286				left: '-9999px',
287				fontFamily: $select.css('font-family'),
288				fontSize: $select.css('font-size'),
289				fontWeight: $select.css('font-weight'),
290				fontStyle: $select.css('font-style'),
291				letterSpacing: $select.css('letter-spacing'),
292				textTransform: $select.css('text-transform')
293			}).appendTo('body');
294
295		if($custom.length > 0 && $custom_menu.find('.forum-category-custom-option').length > 0) {
296			var $custom_option = $custom_menu.find('.forum-category-custom-option').first();
297			extra_width = toNum($custom_option.css('padding-left')) + toNum($custom_option.css('padding-right')) + toNum($custom_option.css('border-left-width')) + toNum($custom_option.css('border-right-width')) + 2;
298		}
299
300		$select.find('option').each(function() {
301			$measure.text($(this).text());
302			text_width = Math.max(text_width, $measure.outerWidth());
303		});
304		$measure.remove();
305		if($select[0].style && $select[0].style.setProperty) {
306			$select[0].style.setProperty('--fcategory-select-option-w', Math.ceil(Math.max(base_width, text_width + extra_width)) + 'px');
307		}
308		if($wrap.length > 0 && $wrap[0].style && $wrap[0].style.setProperty) {
309			$wrap[0].style.setProperty('--fcategory-select-menu-w', Math.ceil(Math.max(base_width, text_width + extra_width)) + 'px');
310		}
311	}
312
313	var closeForumCategoryCustomSelect = function($custom) {
314		$custom.each(function() {
315			var $this = $(this),
316				$menu = getForumCategoryCustomMenu($this);
317
318			$this.removeClass('open');
319			$this.find('.forum-category-custom-toggle').attr('aria-expanded','false');
320			if($menu.length > 0 && $menu.hasClass('forum-category-custom-menu-layer')) {
321				$menu
322					.removeClass('forum-category-custom-menu-layer')
323					.removeData('forumCategoryOwner')
324					.removeAttr('style')
325					.appendTo($this);
326			}
327		});
328	}
329
330	var openForumCategoryCustomSelect = function($custom) {
331		var $menu = getForumCategoryCustomMenu($custom);
332		if($custom.length == 0 || $menu.length == 0) return;
333
334		copyForumCategoryCustomMenuVars($custom, $menu);
335		$custom.addClass('open');
336		$custom.find('.forum-category-custom-toggle').attr('aria-expanded','true');
337		$menu
338			.addClass('forum-category-custom-menu-layer')
339			.data('forumCategoryOwner', $custom)
340			.appendTo('body');
341		positionForumCategoryCustomMenu($custom);
342	}
343
344	var syncForumCategoryCustomSelect = function(forum_el) {
345		var $forum_el = $(forum_el),
346			$select = $forum_el.find('.search-box #scate').first();
347
348		if($select.length == 0) return;
349
350		var $wrap = $select.closest('.forum-category-select-wrap'),
351			category_on = !$select.is('.hide, .hidden') && getForumCategoryType($forum_el) == 'dropdown';
352
353		if($wrap.length == 0) $wrap = $select.parent().addClass('forum-category-select-wrap');
354
355		if(!category_on) {
356			closeForumCategoryCustomSelect($wrap.find('.forum-category-custom-select'));
357			$wrap.removeClass('forum-category-customized');
358			$wrap.find('.forum-category-custom-select').remove();
359			$select.removeAttr('aria-hidden');
360			return;
361		}
362
363		$wrap.addClass('forum-category-customized');
364		$select.attr('aria-hidden','true');
365
366		var $custom = $wrap.children('.forum-category-custom-select').first();
367		if($custom.length == 0) {
368			$custom = $('<div class="forum-category-custom-select">')
369				.append(
370					$('<button type="button" class="forum-category-custom-toggle" aria-haspopup="listbox" aria-expanded="false">')
371						.append($('<span class="forum-category-custom-label">'))
372				)
373				.append($('<ul class="forum-category-custom-menu" role="listbox">'));
374			$select.after($custom);
375		}
376
377		var selected_value = (typeof $select.val() == 'undefined' || $select.val() == null) ? '' : String($select.val()),
378			selected_text = '',
379			$menu = getForumCategoryCustomMenu($custom).empty();
380
381		if($menu.length == 0) {
382			$menu = $('<ul class="forum-category-custom-menu" role="listbox">').appendTo($custom);
383		}
384
385		$select.find('option').each(function() {
386			var option_value = (typeof $(this).attr('value') == 'undefined') ? '' : String($(this).attr('value')),
387				option_text = $(this).text(),
388				is_selected = option_value == selected_value;
389
390			if(is_selected) selected_text = option_text;
391			$menu.append(
392				$('<li class="forum-category-custom-option" role="option" tabindex="-1">')
393					.attr('data-value', option_value)
394					.attr('aria-selected', is_selected ? 'true' : 'false')
395					.toggleClass('active', is_selected)
396					.text(option_text)
397			);
398		});
399
400		if(!selected_text) selected_text = $select.find('option').first().text() || '';
401		$custom.find('.forum-category-custom-label').text(selected_text);
402		syncForumCategoryOptionWidth($forum_el);
403	}
404
405	var syncForumSearchboxDisplay = function(forum_el, searchbox_on) {
406		var $forum_el = $(forum_el),
407			$search_box = $forum_el.find('.search-box'),
408			$search_controls = $(),
409			$category_select = $forum_el.find('#scate').first(),
410			category_type = getForumCategoryType($forum_el),
411			category_on = $category_select.length > 0 && !$category_select.is('.hide, .hidden'),
412			keep_category_select = category_on && category_type == 'dropdown',
413			list_category_search = category_on && category_type == 'list';
414
415		if(typeof searchbox_on == 'undefined') searchbox_on = getForumSearchboxDisplay($forum_el);
416		else searchbox_on = (searchbox_on == 'OFF' || searchbox_on === false) ? false : true;
417		$forum_el.attr('data-searchbox-display', searchbox_on ? 'ON' : 'OFF');
418		$search_box.find('#scate, #sfl').closest('.input-group-btn').attr('data-caret','arrow1');
419		$search_box.find('#sfl').closest('.input-group-btn').addClass('forum-search-field-select-wrap');
420
421		if($search_box.find('#sfl').length > 0) $search_controls = $search_controls.add($search_box.find('#sfl').closest('.input-group-btn'));
422
423		var $stx = $search_box.find('#stx, input[name="stx"]'),
424			$stx_wrap = $stx.closest('.input-search-box');
425
426		if($stx_wrap.length > 0 && !$stx_wrap.is('.search-box')) {
427			$search_controls = $search_controls.add($stx_wrap);
428		} else {
429			$search_controls = $search_controls.add($stx);
430			if($search_box.find('.search-btn').length > 0) $search_controls = $search_controls.add($search_box.find('.search-btn').closest('.input-group-btn'));
431		}
432
433		$search_box
434			.toggleClass('forum-category-select-only', !searchbox_on && keep_category_select)
435			.toggleClass('forum-category-select-hidden', searchbox_on && !category_on)
436			.toggleClass('forum-category-list-search', searchbox_on && list_category_search)
437			.toggleClass('hide hidden', !searchbox_on && !keep_category_select);
438		$search_controls.toggleClass('hide hidden', !searchbox_on);
439		syncForumCategoryOptionWidth($forum_el);
440		syncForumCategoryCustomSelect($forum_el);
441		}
442		window.syncForumSearchboxDisplay = syncForumSearchboxDisplay;
443
444		var syncForumCategoryDelimiterRows = function(forum_el) {
445			var $forum_el = $(forum_el),
446				$category_nav = getForumCategoryNav($forum_el).first(),
447				category_style = $forum_el.attr('data-gcate-style') || getForumCategoryStyle($forum_el),
448				prev_top = null;
449
450			$category_nav.find('.tpl-forum-category-item').removeClass('forum-category-row-start');
451			if($forum_el.length == 0 || $category_nav.length == 0 || category_style != 'delimiter2' || $category_nav.is('.hide, .hidden')) return;
452
453			$category_nav.find('.tpl-forum-category-item').not('.hide').each(function(idx) {
454				var item_top = Math.round($(this).position().top);
455				if(idx == 0 || prev_top === null || item_top > prev_top + 1) $(this).addClass('forum-category-row-start');
456				prev_top = item_top;
457			});
458		}
459		window.syncForumCategoryDelimiterRows = syncForumCategoryDelimiterRows;
460
461		var syncForumCategorySearchLayout = function(forum_el) {
462			var $forum_el = $(forum_el),
463				$category_nav = getForumCategoryNav($forum_el).first(),
464			$search_box = $forum_el.find('.search-box').first(),
465				$layout_wrap = $forum_el.find('.forum-category-searchbox-top-wrap').first(),
466				$search_origin = $forum_el.find('.forum-category-searchbox-origin').first(),
467				searchbox_top = false,
468				searchbox_top_position = false,
469				searchbox_layout_top = false,
470				category_list_bottom = false;
471
472		$forum_el.removeClass('forum-category-searchbox-top forum-category-searchbox-bottom');
473		$category_nav.removeClass('forum-category-searchbox-top-nav forum-category-searchbox-bottom-nav');
474		$search_box.removeClass('forum-category-searchbox-top-control');
475
476		if($category_nav.length > 0 && $search_box.length > 0) {
477			var $content = $forum_el.find('[data-loop="true"]').first(),
478				searchbox_before_content = false,
479				searchbox_position = $search_box.css('position'),
480				searchbox_top_value = $search_box.css('top'),
481				searchbox_bottom_value = $search_box.css('bottom'),
482				searchbox_css_top = ($.inArray(searchbox_position, ['absolute','fixed']) > -1 && searchbox_top_value != 'auto' && searchbox_bottom_value == 'auto');
483			if($content.length == 0) $content = $forum_el.find('.table-container, .layout-table, .tpl-forum-pagination').first();
484			if($content.length > 0) {
485				if(typeof $search_box[0].compareDocumentPosition == 'function') {
486					searchbox_before_content = !!($search_box[0].compareDocumentPosition($content[0]) & 4);
487				} else {
488					searchbox_before_content = $search_box.index() < $content.index();
489				}
490			}
491
492			searchbox_layout_top = (searchbox_before_content || searchbox_css_top);
493			searchbox_top_position = getForumSearchboxDisplay($forum_el)
494				&& !$search_box.is('.hide, .hidden')
495				&& searchbox_layout_top;
496			searchbox_top = getForumCategoryType($forum_el) == 'list'
497				&& !$category_nav.is('.hide, .hidden')
498				&& !$search_box.hasClass('forum-category-select-only')
499				&& searchbox_layout_top;
500			category_list_bottom = getForumCategoryType($forum_el) == 'list'
501				&& !$category_nav.is('.hide, .hidden')
502				&& !$search_box.hasClass('forum-category-select-only')
503				&& !searchbox_layout_top;
504		}
505
506		if(searchbox_top) {
507			if($layout_wrap.length == 0) {
508				$layout_wrap = $('<div class="forum-category-searchbox-top-wrap">');
509				$category_nav.before($layout_wrap);
510			}
511			if($search_origin.length == 0 && $search_box.parent()[0] !== $layout_wrap[0]) {
512				$search_origin = $('<span class="forum-category-searchbox-origin">').hide();
513				$search_box.before($search_origin);
514			}
515			$layout_wrap.append($category_nav).append($search_box);
516		} else if($layout_wrap.length > 0) {
517			if($search_box.length > 0 && $search_box.parent()[0] === $layout_wrap[0]) {
518				if($search_origin.length > 0) $search_origin.replaceWith($search_box);
519				else $layout_wrap.after($search_box);
520			}
521			if($category_nav.length > 0 && $category_nav.parent()[0] === $layout_wrap[0]) placeForumCategoryNav($forum_el, $category_nav);
522			$layout_wrap.remove();
523		} else if($search_origin.length > 0) {
524			$search_origin.remove();
525		}
526
527		$forum_el.toggleClass('forum-category-searchbox-top', searchbox_top);
528		$forum_el.toggleClass('forum-category-searchbox-bottom', category_list_bottom);
529		$category_nav.toggleClass('forum-category-searchbox-top-nav', searchbox_top);
530		$category_nav.toggleClass('forum-category-searchbox-bottom-nav', category_list_bottom);
531		$search_box.toggleClass('forum-category-searchbox-top-control', searchbox_top_position);
532		$search_box.toggleClass('forum-searchbox-top-position', searchbox_top_position);
533		$search_box.toggleClass('forum-searchbox-layout-top', searchbox_layout_top);
534	}
535
536	var syncForumCategoryTypeDisplay = function(forum_el) {
537		var $forum_el = $(forum_el),
538			category_type = getForumCategoryType($forum_el),
539			$category_select_wrap = $forum_el.find('.forum-category-select-wrap'),
540			$category_nav = getForumCategoryNav($forum_el).first(),
541			category_on = $forum_el.find('#scate').length > 0 && !$forum_el.find('#scate').is('.hide, .hidden'),
542			searchbox_on = getForumSearchboxDisplay($forum_el);
543
544		if($category_select_wrap.length == 0 && $forum_el.find('#scate').length > 0) {
545			$category_select_wrap = $forum_el.find('#scate').parent().addClass('forum-category-select-wrap');
546		}
547		if($category_nav.length > 0 && searchbox_on) $category_nav = placeForumCategoryNav($forum_el, $category_nav);
548
549		$category_select_wrap.toggleClass('hide', !category_on || category_type == 'list');
550		$forum_el.attr('data-gcate-style', getForumCategoryStyle($forum_el));
551			$category_nav
552				.removeAttr('data-sticky')
553				.toggleClass('hide', !category_on || category_type != 'list');
554			syncForumSearchboxDisplay($forum_el);
555			syncForumCategorySearchLayout($forum_el);
556			syncForumCategoryDelimiterRows($forum_el);
557		}
558		window.syncForumCategoryTypeDisplay = syncForumCategoryTypeDisplay;
559
560		var forum_category_row_timer = null;
561		$(window).on('resize', function() {
562			clearTimeout(forum_category_row_timer);
563			forum_category_row_timer = setTimeout(function() {
564				$('[data-type="forum"][data-gcate-style="delimiter2"]').each(function() {
565					syncForumCategoryDelimiterRows($(this));
566				});
567			}, 100);
568		});
569
570
571	function decodeUnicode(str) {
572		return str.replace(/\\u([0-9a-fA-F]{4})/g, function(match, grp) {
573			return String.fromCharCode(parseInt(grp, 16));
574		});
575	}
576
577	function insertHtmlAtCursor(html) {
578	    var sel, range, html;
579	    if (window.getSelection) {
580	        sel = window.getSelection();
581	        if (sel.getRangeAt && sel.rangeCount) {
582	            range = sel.getRangeAt(0);
583	            range.deleteContents();
584			    var htmlNode = document.createElement('p');
585			    htmlNode.innerHTML = html
586	            range.insertNode(htmlNode);
587	            sel.removeAllRanges();
588	            range = range.cloneRange();
589	            range.selectNode(htmlNode);
590	            range.collapse(false);
591	            sel.addRange(range);
592	        }
593	    } else if (document.selection && document.selection.createRange) {
594	        range = document.selection.createRange();
595	        range.pasteHTML(htmlNode);
596	        range.select();
597	    }
598	}
599
600	var setWriteUser = function(data, callback) {
601		resetObject(postUser);
602		postUser.name = data.name;
603		postUser.img = data.myimg;
604		postUser.option = data.option;
605		postUser.secret_display = data.settings.secret_display;
606		postUser.mgr = data.mgr;
607		postUser.replied = data.replied;
608		postUser.writeable = data.writeable;
609			
610		$.post('/fm/guest/login', { user : postUser, guest : user }, function(data2) {
611			if(typeof callback == 'function') {
612				callback();
613			}
614		});
615		return false;
616	}
617
618	var forumWriteform = function(id, pid, reply) {
619		var title 			= (id) ? $('.tpl-forum-title').text() : '',
620			content 		= (id) ? $('.tpl-forum-content .fr-view').html() : '<p><br></p>',
621			name 			= postUser.name,
622			date 			= (id) ? $('.tpl-forum-date').text() : 'now',
623			myimage 		= postUser.img,
624			option 			= postUser.option,
625			secret 			= (option == 'S') ? 'S' : '',
626			notice 			= (option == 'N') ? 'N' : '',
627			secret_display 	= postUser.secret_display,
628			mgr 			= postUser.mgr;
629
630		title = title.replace(/'/g,'&#39;');
631		var square_secret = (secret=='S') ? 'fa-check-square-o' : 'fa-square-o',
632			square_notice = (option=='N') ? 'fa-check-square-o' : 'fa-square-o',
633			secretClass = '',
634			noticeClass = '';
635
636		switch(secret_display) {
637			case 'N' : secretClass = 'hide'; break;
638			case 'A' : 
639				secretClass = 'hide';
640				secret = 'S';
641				break;
642			default : secretClass = 'always'; break;
643		}
644		noticeClass = (mgr==true) ? 'always' : 'hide';
645		if(postUser.replied || reply) noticeClass = 'hide';
646		if(secret=='S' && secret_display!='A') secretClass = '';
647		if(option=='N') noticeClass = '';
648
649		var str = '\
650			<div class="forum-write">\
651				<ul class="forum-user-info clearfix">\
652					<li class="user-image tpl-forum-myimage">\
653						<svg viewbox="0 0 40 40">\
654							<pattern id="forum-write-image" patternUnits="userSpaceOnUse" width="40" height="40">\
655								<image xlink:href="' + myimage + '?_' + new Date().getTime() + '" x="-10" width="60" height="40" />\
656							</pattern>\
657							<polygon points="20 0 37 10 37 30 20 40 3 30 3 10" fill="url(#forum-write-image)" />\
658						</svg>\
659					</li>\
660					<li class="user-info">\
661						<div class="tpl-forum-name">' + name + '</div>\
662						<div class="tpl-forum-date date">' + date + '</div>\
663					</li>\
664					<li class="user-ctrl">\
665						<span id="fm-notice" class="' + noticeClass + '" data-notice="' + notice + '"><i class="fa ' + square_notice + '"></i>' + $.lang[LANG]['board.public'] + '</span>\
666						<span id="fm-secret" class="' + secretClass + '" data-secret="' + secret + '"><i class="fa ' + square_secret + '"></i>' + $.lang[LANG]['board.private'] + '</span>\
667						<span id="fm-reserv" class="' + reservClass + '" data-reserv="' + reserv + '"><i class="fa ' + square_reserv + '"></i>' + $.lang[LANG]['board.reserv'] + '</span>\
668					</li>\
669				</ul>\
670				<input type="hidden" id="fm-id" value="' + id + '">\
671				<input type="hidden" id="fm-pid" value="' + pid + '">\
672				<input type="hidden" id="fm-reply" value="' + reply + '">\
673				<input type="hidden" id="hash" value="' + (($.cookie('hash')) ? $.cookie('hash') : '') + '">\
674				<input class="form-control tpl-forum-title" id="fm-title" value="' + title + '" placeholder="' + $.lang[LANG]['board.enter-title'] + '">\
675				<div class="fm-body fm-content fm-editor" id="fm-editor" data-placeholder="' + $.lang[LANG]['board.enter-content'] + '">' + content + '</div>\
676			</div>\
677			<div class="upload-files"></div>\
678		';
679
680		// $.removeCookie('hash', { path: '/' });
681		return str;
682	}
683
684	$doc.on('keypress','.modal[id*=flat-modal] #mb_id', function(e) {
685		if(e.keyCode == 13) {
686			$('.forum-login').click();
687		}
688	});
689
690	$doc.on('keypress','.modal[id*=flat-modal] #mb_password', function(e) {
691		if(e.keyCode == 13) {
692			$('.forum-login').click();
693		}
694	});
695
696	$doc.on('focus','#fm-title',function(e) {
697		$('.note-toolbar > .btn-group > button').addClass('disabled');
698	}).on('focus','.note-editable',function(e) {
699		$('.note-toolbar > .btn-group > button').removeClass('disabled');
700	});
701
702	$doc.on('click','.note-toolbar > .btn-group > button', function(e) {
703		if($(this).hasClass('disabled')) e.preventDefault();
704	});
705
706	$doc.on('click', '.forum-user-info li.user-ctrl .dropdown-menu', function(e){
707		e.stopPropagation();
708	});
709
710	$doc.on('change', '.tpl-forum-comment_display .comment-onoff', function() {
711		var sid = (typeof SID == 'undefined') ? property.SID : SID;
712		var view = (typeof VIEW == 'undefined') ? property.VIEW : VIEW;
713		var value = $(this).val();
714		if($(this).is('input[type="checkbox"]')) value = ($(this).prop('checked')) ? 'OFF' : 'ON';
715		var settings = {};
716		settings['comment_display'] = value; 
717		$.ajax({
718			url: '/fm/fmSettings/update',
719			data: {sid: sid, settings: JSON.stringify(settings), el: view},
720			method: 'POST',
721			dataType: 'json',
722			async: false,
723			success: function(data) {
724				// console.log(data);
725				checkError(data);
726				var settings = data;
727				if(settings.comment_display != 'OFF') {
728					$('.tpl-forum-comment_display').removeClass('on').addClass('off');
729					$.comment.init();
730				} else {
731					$('.tpl-forum-comment_display').removeClass('off').addClass('on');
732					$('.page-comments').remove();
733				}
734			}
735		});
736	});
737
738
739	var forumView = function(id) {
740		var fv_deferred = $.Deferred();
741
742		setViewPageStyle();
743
744		files = [];
745        $.ajax({
746            url: '/fm/view',
747            dataType: 'json',
748            type: 'POST',
749            data:  { id : id, sid : F_SID },
750            async: false,
751            cache: false,
752            success: function (data) {
753				if(typeof data.error != 'undefined' && data.error) {
754					alert(data.error);
755
756					var error_code = data.code || 0;
757					switch(error_code) {
758						case 404:
759							fv_deferred.reject(data.code);
760							break;
761
762						case 401:
763						case 403:
764							var error_msg = (error_code == 403) ? 'Forbidden' : 'Unauthorized';
765							fv_deferred.reject(`Error ${error_msg}`);
766
767							var umemberActivate = (PAGE_MODE == 'c')? Number(UMEMBER_ACTIVATE) : Number(property.UMEMBER_ACTIVATE);
768							var umember = (PAGE_MODE == 'c')? UMEMBER : property.UMEMBER;
769							var checkLogin = (PAGE_MODE == 'c')? true : umember.check_login;
770							if(umemberActivate == 0 && umember.id_type == 'creatorlink') { //creatorlink login
771								checkLogin = (umember.id !== undefined && umember.id)? true : false;
772							}
773							// $.cookie('gallery','.' + F_PARENT.element, { path: '/' });
774							$('.header.el-menu').hide();
775							$('.el-footer').hide();
776							$.processON('', '#fff');
777
778							if(PAGE_MODE != 'c') {
779								var url = (PAGE_MODE=='s') ? '/' : '/render/';
780								if(checkLogin) {
781									alert(data.error);
782									(F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);		
783								} else {
784									var action = (property.VALIDTYPE == 'SM')  ? '/_login' : '/_cllogin';
785									var url = $(location).attr('pathname');
786									var html = '<form name="write_login_form" id="write-login" method="post" action="' + action + '" style="display:none;">\
787													<input type="hidden" name="status" value="forum_view">\
788													<input type="hidden" name="sid" value="'+property.SID+'">\
789													<input type="hidden" name="page_mode" value="'+data.access+'">\
790													<input type="hidden" name="url" value="'+url+'">\
791												</form>';
792									$('body').append(html);
793									document.write_login_form.submit();
794								}
795							} else {
796								(F_ONE) ? location.replace('/'+CONFIG_URL+'config/page/index#' + F_PARENT.page) : location.replace('/'+CONFIG_URL+'config/page/' + F_PARENT.page);
797							}
798							break;
799
800						default:
801							fv_deferred.reject('Error Undefined');
802							break;
803					}
804
805					return false;
806				}
807
808				if($.inArray(data.fm_type, ['qna','faq']) > -1) {
809					var fm_id = (data.fm_reply!='0' && data.own)? data.fm_reply : data.id;
810					
811					$.cookie('forum-item',F_PARENT.pid, { path: '/' });
812					$.cookie('forum_content_view', F_PARENT.pid + '&' + fm_id, { path: '/', expires: 12 * 60 * 60 * 1000 });
813					$.forum.setForumCookie(F_PARENT.pid, data.page_num, '', '', '');
814
815					if(data.fm_type == 'qna') {
816						var str = '<div class="forum-view" data-forum-type="qna"></div>';
817						if($.clnav.check()) {
818							$('.dsgn-body').prepend(str);
819						} else {
820							$('.header.el-menu').last().after(str);
821						}
822						$('.header.el-menu').hide();
823						$('.el-footer').hide();
824						$.processON('', '#fff');
825					}
826
827					if(PAGE_MODE != 'c') {
828						var url = (PAGE_MODE=='s') ? '/' : '/render/';
829						(F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);
830					} else {
831						(F_ONE) ? location.replace('/'+CONFIG_URL+'config/page/index#' + F_PARENT.page) : location.replace('/'+CONFIG_URL+'config/page/' + F_PARENT.page);
832					}
833					
834					fv_deferred.reject('has error 2');
835					return false;
836				}
837				if(typeof data.fonts != 'undefined' && data.fonts && PAGE_MODE!='c') {
838					$.each(data.fonts, function(i,v) {
839						if(property.ELFONTS.indexOf(i) < 0) {
840							property.ELFONTS.push(i);
841							$('#loadfonts').append(v);
842						}
843					});
844				}
845
846				if(typeof data.webfonts != 'undefined' && data.webfonts && PAGE_MODE!='c') {
847					$.each(data.webfonts, function(i2,v2) {
848						if(property.ELFONTS.indexOf(i2) < 0 && v2) {
849							property.ELFONTS.push(i2);
850							WebFont.load({ google : { families : [ v2 ], display:'swap' }});
851						}
852					})
853				}
854
855				// QnA Block:: notice view page, comment_display: off
856				if(data.fm_type == 'qna' && data.option == 'N') $('.page-comments').hide();
857
858				var settings = (typeof data.fm_settings == 'undefined') ? {} : data.fm_settings,
859					p_settings = (typeof F_PARENT.settings == 'undefined' || F_PARENT.settings == '') ? {} : JSON.parse(F_PARENT.settings),
860					comment_display = (typeof settings.comment_display == 'undefined') ? ((data.check_comment)? 'ON' : 'OFF') : settings.comment_display,
861					wrap = (typeof settings.wrap == 'undefined') ? '' : 'w' + settings.wrap,
862					align = (typeof settings.align == 'undefined') ? 'left' : settings.align,
863					category = (typeof data.category_seq == 'undefined') ? '' : '<div class="tpl-forum-category" data-cate="' + data.category_seq + '">' + data.category_name + '</div>',
864					forum_validplan = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN;
865				// Category Display none case
866				// if(category && typeof p_settings.field_disable != 'undefined') {
867				// 	if($.inArray('category',p_settings.field_disable) > -1)  category = '';
868				// }
869				if(comment_display == 'OFF') $('.page-comments').remove();
870
871				files = data.files;		
872				p_settings.forum_email = ((typeof forum_validplan == 'undefined') || (!forum_validplan)) ? 
873										((typeof p_settings.forum_email == 'undefined') || (!p_settings.forum_email) ? p_settings.forum_email : p_settings.forum_email.split(',')[0]
874										) : p_settings.forum_email;
875
876				var siteSettings = (PAGE_MODE == 'c') ? SETTINGS : property.SETTINGS,
877					f_parallax = (typeof p_settings.parallax == 'undefined') ? false : p_settings.parallax,
878				 	f_type = (typeof p_settings.forum_type == 'undefined') ? '' : 'data-forum-type="' + p_settings.forum_type + '"',
879					forum_email = ((typeof p_settings.forum_email == 'undefined') || (p_settings.email_display == 'OFF')) ? '' : p_settings.forum_email,
880					forum_content = ($('<div>'+data.content+'</div>').find('img[src^="http://"]').length > 0) ? data.content.replace(/src\=\"http\:\/\//gi,'src\=\"\/\/') : data.content;
881				var f_lang = (typeof p_settings.chlang == 'undefined')? LANG : p_settings.chlang;
882				var del_display = (typeof p_settings.del_display == 'undefined' || PAGE_MODE == 'c')? 'ON' : p_settings.del_display,
883					f_b_title = (typeof p_settings.forum_block_title == 'undefined') ? '' : p_settings.forum_block_title;
884				data.f_lang = (f_lang)? f_lang : LANG;
885
886				var format_time = (data.reserved_format == '') ? data.date : data.reserved_format;
887
888				var fm_fonts = (typeof settings.fonts == 'undefined' || settings.fonts === null) ? {} : settings.fonts;
889				// fm_fonts = JSON.parse(fm_fonts);
890				var inline_style = '';
891
892				if(typeof fm_fonts.fontFamily != 'undefined') inline_style += ` font-family:${fm_fonts.fontFamily}; `;
893				if(typeof fm_fonts.fontSize != 'undefined') inline_style += ` font-size:${fm_fonts.fontSize}; `;
894				if(typeof fm_fonts.color != 'undefined') inline_style += ` color:${fm_fonts.color}; `;
895
896				var modoo_str = `
897					<div class="forum-view ${wrap}"  ${f_type} data-parallax="${f_parallax}">
898					<input type="hidden" id="fm-id" value="${data.id}">
899					<input type="hidden" id="fm-pid" value="${data.pid}">
900					<input type="hidden" id="forum-email" value="${forum_email}">
901					<div class="container">
902						<div class="forum-write ${wrap}">
903							<div class="row">
904								<div class="col-md-12 col-sm-12 col-xs-12">
905									<div class="tpl-forum-view-header">
906										<div class="forum-block-title">${f_b_title}</div>
907										<div class="user-ctrl">
908											${((del_display == 'OFF')? '' : postDropMenu(data))}
909										</div>
910									</div>
911									<div class="tpl-forum-view-info">
912										<div class="tpl-forum-title">${data.title}</div>
913										<div class="tpl-forum-info-detail">
914											<div class="tpl-forum-name">${data.name}</div>
915											<div class="tpl-forum-date date">${format_time}</div>
916											<div class="tpl-forum-hit hit">
917												<svg viewBox="0 0 14 12" width="14" height="12"><circle cx="7" cy="6" r="2"/><path d="M7 2C3.97 2 1.34 3.62 0 6c1.34 2.38 3.97 4 7 4s5.66-1.62 7-4C12.66 3.62 10.03 2 7 2zM7 9C5.34 9 4 7.66 4 6s1.34-3 3-3 3 1.34 3 3S8.66 9 7 9z"/></svg>
918												${data.hit}
919											</div>
920										</div>
921									</div>
922									<div class="tpl-forum-content fm-body fm-content fm-editor fr-box ${align}">
923										<div class="fr-wrapper" dir="auto">
924											<div class="fr-element fr-view" dir="auto" style="${inline_style}">${forum_content}</div>
925										</div>
926									</div>
927									<div class="tpl-forum-list-footer">
928										<div class="tpl-forum-control-wrap">
929											<button type="button" class="btn btn-default btn-list tpl-forum-list">${$.lang[f_lang]['board.button.list']}</button>
930											<div class="tpl-forum-modoo-prev-next tpl-forum-pn-row">
931											`;
932											if (typeof data.prev != 'undefined' && Object.keys(data.next).length > 0) {
933											modoo_str += `
934												<a href="${data.next.url}" data-option="${data.next.option}" data-id="${data.next.seq}">
935													<button type="button" class="btn btn-default">이전글</button>
936												</a>
937											`;
938											}
939											if (typeof data.prev != 'undefined' && Object.keys(data.prev).length > 0) {
940											modoo_str += `
941												<a href="${data.prev.url}" data-option="${data.prev.option}" data-id="${data.prev.seq}">
942													<button type="button" class="btn btn-default">다음글</button>
943												</a>
944											`;
945											}
946					modoo_str += `			</div>
947										</div>`;
948					modoo_str += `		<div class="tpl-forum-modoo-reply">
949												${replyPostbutton(data)}
950										</div>
951									</div><!--.tpl-forum-list-footer-->
952				`;
953
954				var str = '\
955				<div class="forum-view ' + wrap + '" ' + f_type + ' data-parallax="'+f_parallax+'">\
956					<input type="hidden" id="fm-id" value="' + data.id + '">\
957					<input type="hidden" id="fm-pid" value="' + data.pid + '">\
958					<input type="hidden" id="forum-email" value="' + forum_email + '">\
959					<div class="container">\
960						<div class="forum-write ' + wrap + '">\
961							<div class="row">\
962								<div class="col-md-12 col-sm-12 col-xs-12">\
963									<ul class="forum-user-info clearfix">\
964										<li class="user-image tpl-forum-myimage forum-image">\
965											<img src="' + data.myimg + '?_' + new Date().getTime() + '" />\
966										</li>\
967										<li class="user-info">\
968											<div class="tpl-forum-name">' + data.name + '</div>\
969											<div class="tpl-forum-date date">' + format_time + '</div>\
970											<div class="tpl-forum-hit hit">\
971												<svg viewBox="0 0 14 12" width="14" height="12"><circle cx="7" cy="6" r="2"/><path d="M7 2C3.97 2 1.34 3.62 0 6c1.34 2.38 3.97 4 7 4s5.66-1.62 7-4C12.66 3.62 10.03 2 7 2zM7 9C5.34 9 4 7.66 4 6s1.34-3 3-3 3 1.34 3 3S8.66 9 7 9z"/></svg>\
972												' + data.hit + '\
973											</div>\
974										</li>\
975										<li class="user-ctrl">\
976											' + ((del_display == 'OFF')? '' : postDropMenu(data)) + '\
977										</li>\
978									</ul>\
979									' + category + '\
980									<div class="tpl-forum-title">' + data.title + '</div>\
981									<div class="tpl-forum-content fm-body fm-content fm-editor fr-box ' + align + '">\
982										<div class="fr-wrapper" dir="auto">\
983											<div class="fr-element fr-view" dir="auto" style="' + inline_style + '">' + forum_content + '</div>\
984										</div>\
985									</div>\
986									<div class="tpl-forum-list-footer">\
987										<div class="tpl-forum-control-wrap">';
988									if(data.fm_type == 'qna') {
989										if(data.answer !== undefined && data.replied == true) {
990											str += '\
991											<button type="button" class="btn tpl-forum-list">&nbsp;' + $.lang[LANG]['board.button.list'] + '</button>';
992										} else {
993											str += '\
994											<button type="button" class="btn tpl-forum-list">&nbsp;' + $.lang[LANG]['board.button.list'] + '</button>\
995											' + replyPostbutton(data);
996										}	
997									} else {
998										str += '\
999											<button type="button" class="btn tpl-forum-list">&nbsp;' + $.lang[f_lang]['board.button.list'] + '</button>\
1000											' + replyPostbutton(data);
1001									}
1002									str += '\
1003										</div>\
1004									</div><!--.tpl-forum-list-footer-->\
1005									';
1006
1007								if(p_settings.forum_type == 'modoo') str = modoo_str;
1008
1009								if (p_settings.prevnext_display !== undefined && p_settings.prevnext_display == 'ON' && !['qna', 'faq', 'guestbook'].includes(data.fm_type)) {
1010									var hidden = (Object.keys(data.prev).length == 0 && Object.keys(data.next).length == 0) ? ' hidden' : '';
1011									var icon = '';
1012									var title_href = '';
1013									str += `
1014									<div class="tpl-forum-list-prev-next${hidden}">
1015									`;
1016
1017									if (Object.keys(data.next).length > 0) {
1018										if (data.next.option == 'N') icon = '<i class="cl-icon notice01" aria-hidden="true"></i>';
1019										if (data.next.option == 'S') icon = '<i class="cl-icon lock02" aria-hidden="true"></i>';
1020										if (data.next.title == '') {
1021										    title_href = `<a href="javascript:;" class="deleted" data-option="${data.next.option}" data-id="${data.next.seq}">${$.lang[LANG]['board.post.deleted']}</a>`;
1022										} else {
1023										    title_href = `<a href="${data.next.url}" data-option="${data.next.option}" data-id="${data.next.seq}">${data.next.title}</a>`;
1024										}
1025										str += `
1026									    <div class="tpl-forum-pn-row forum-next display-flex space-between align-items-center">
1027									    	<div class="tpl-forum-pn-num">${$.lang[LANG]['board.next']}</div>
1028									    	<div class="tpl-forum-pn-title">${icon}${title_href}</div>
1029									    	<div class="tpl-forum-pn-date">${data.next.date}</div>
1030									    </div>
1031										`;
1032									}
1033
1034									icon = '';
1035									if (Object.keys(data.prev).length > 0) {
1036										if (data.prev.option == 'N') icon = '<i class="cl-icon notice01" aria-hidden="true"></i>';
1037										if (data.prev.option == 'S') icon = '<i class="cl-icon lock02" aria-hidden="true"></i>';
1038										if (data.prev.title == '') {
1039										    title_href = `<a href="javascript:;" class="deleted" data-option="${data.prev.option}" data-id="${data.prev.seq}">${$.lang[LANG]['board.post.deleted']}</a>`;
1040										} else {
1041										    title_href = `<a href="${data.prev.url}" data-option="${data.prev.option}" data-id="${data.prev.seq}">${data.prev.title}</a>`;
1042										}
1043										str += `
1044									    <div class="tpl-forum-pn-row forum-prev display-flex space-between align-items-center">
1045									    	<div class="tpl-forum-pn-num">${$.lang[LANG]['board.prev']}</div>
1046									    	<div class="tpl-forum-pn-title">${icon}${title_href}</div>
1047									    	<div class="tpl-forum-pn-date">${data.prev.date}</div>
1048									    </div>
1049										`;
1050									}
1051
1052									str += `
1053									</div><!--tpl-forum-list-prev-next-->
1054									`;
1055								}
1056								str += '\
1057								</div>\
1058							</div>\
1059						</div>\
1060					</div><!--container-->\
1061				';
1062				if(data.mgr && data.fm_type != 'faq') {
1063					str += '\
1064					<div class="tpl-forum-comment_display container clear ' + wrap + ((comment_display == 'ON')? ' off':' on') + '" data-id="' + data.id + '" data-pid="' + data.pid + '">\
1065						<div class="display-flex align-items-center">\
1066							<div class="newcheckbox hand ">\
1067			                    <label>\
1068			                        <div class="newcheckboxSvg">\
1069			                            <input type="checkbox" class="comment-onoff" '+((comment_display == 'ON')? '':'checked')+'/>\
1070			                            <svg viewBox="0 0 16 16" width="16" height="16">\
1071			                                <path class="st6" d="M3 0h10c1.66 0 3 1.34 3 3v10c0 1.66-1.34 3-3 3H3c-1.66 0-3-1.34-3-3V3C0 1.34 1.34 0 3 0z"/>\
1072			                                <path class="st19" d="M13 1c1.1 0 2 0.9 2 2v10c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2H13M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0L13 0z"/>\
1073			                            </svg>\
1074			                            <svg class="active" viewBox="0 0 16 16" width="16" height="16">\
1075			                                <rect x="2" y="2" class="st6" width="12" height="12"/>\
1076			                                <path  class="st19" d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
1077			                            </svg>\
1078			                        </div>\
1079			                        <span class="tpl-forum-comment_display-label">'+ $.lang[LANG]['config.comment.title'] +'</span>\
1080			                    </label>\
1081			                </div>\
1082						</div>\
1083					</div>\
1084					';
1085				}
1086				str += '\
1087				</div>\
1088				';
1089
1090				if($.clnav.check()) {
1091					$('.dsgn-body').prepend(str);
1092				} else {
1093					$('.header.el-menu').last().after(str);
1094				}
1095				changeBrokenImages($('.fr-view'));
1096
1097				if(($('.fr-view').find('img[name^="target_resize_image[]"]').length > 0)) {
1098					$.each($('.fr-view').find('p'),function(){
1099						$(this).find('img[name^="target_resize_image[]"]').removeAttr('width')
1100																		.removeAttr('height');
1101					});
1102				}
1103
1104				// 주소 변경 복원
1105				$.each($('.fr-view').find('iframe'), function(idx,value) {
1106					var src = $(this).attr('src');
1107					if(src.indexOf('http://') > -1 && src.indexOf('youtube.com') > -1) {
1108						src = src.replace('http://','//');
1109						$(this).attr('src',src);
1110					}
1111				});
1112
1113				if(p_settings.field_disable) {
1114					$.each(p_settings.field_disable, function(i,v) {
1115						var tmp_v = (v == 'myimg') ? 'myimage' : v;
1116						$('.forum-write .row > div .tpl-forum-'+tmp_v).addClass('hidden');
1117					});
1118				}
1119
1120				// if($('.user-info > div.hidden').length > 0) $('.user-info > div').removeClass('mt-8').addClass('mt-8');
1121				if($('.tpl-forum-date').next('div').hasClass('hidden')) $('.tpl-forum-date').addClass('afterHide');
1122
1123				initViewPageToolbar(data.option, p_settings, data).then(function(){
1124					if(PAGE_MODE == 'c') setViewPageToolbar();
1125				});
1126				
1127				$.cookie('prev-forum-view',F_PAGE, { path: '/' });
1128				fv_deferred.resolve(data);
1129				// $.removeCookie('hash', { path: '/' });
1130			}
1131		},'json');
1132
1133		return fv_deferred.promise();
1134	}
1135
1136	var replyPostbutton = function(data) {
1137		if(data.is_reserved == 'Y') return '';
1138		var str = '\
1139					<button type="button" class="btn tpl-forum-write" data-pid="' + data.pid + '" data-reply="' + data.id + '">\
1140						&nbsp;' + $.lang[data.f_lang]['board.button.reply'] + '\
1141					</button>\
1142		';
1143
1144		var reply_hidden_case = ['faq'],
1145			reply_hidden =  (reply_hidden_case.indexOf(data.fm_type) > -1) ? true : false;
1146
1147		return (data.reply && data.option != 'N' && !reply_hidden) ? str : '';
1148	}
1149
1150	var postDropMenu = function(data) {
1151		var drop = false;
1152		var str_li = '';
1153		
1154		if((data.own || (data.sign == false && data.fmid == false)) && data.writeable == true || data.mgr_edit) {
1155			drop = true;
1156			str_li += '\
1157				<li><a href="#" class="tpl-forum-write" data-id="' + data.id + '" data-pid="' + data.pid + '">' + $.lang[data.f_lang]['board.button.modify'] + '</a></li>\
1158			';
1159		}
1160		// console.log('data', data);
1161		if(data.own || (data.sign == false && data.fmid == false) || data.mgr) {
1162			drop = true;
1163			str_li += '\
1164				<li><a href="#" class="tpl-forum-delete" data-id="' + data.id + '" data-pid="' + data.pid + '">' + $.lang[data.f_lang]['board.button.delete'] + '</a></li>\
1165			';
1166		}
1167
1168		var str = '\
1169		<ul class="tpl-forum-edit-menu">\
1170			' + str_li + '\
1171		</ul>\
1172		';
1173		return str;
1174	}
1175
1176
1177	var signForm = function(id,pid,access,token) {
1178		var mode = (access=='NM') ? 'nonmem' : 'default',
1179			F_VALIDPLAN = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN,
1180			F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE,
1181			F_SITEUM = (typeof SITEUM == 'undefined') ? property.SITEUM : SITEUM,
1182			F_SERVICE = (typeof SERVICE == 'undefined') ? property.SERVICE : SERVICE,
1183			isGabia = (F_SERVICE.indexOf('gabia') > -1) ? true : false,
1184			host_url = (isGabia) ? 'http://creatorlink-gabia.com' : 'http://creatorlink.net',
1185			classSet = {
1186				'default': ['default-mode','active', '', '', '', ''],
1187				'sitemember': ['sitemember-mode', '', 'active', '', '', 'hidden'],
1188				'nonmem' : ['nonmember-mode', '', '', 'active', '.nonmem', 'hidden'],
1189			},
1190			joinUrl = (LANG != 'ko') ? '//creatorlink.net/en/member/join' : '//creatorlink.net/member/join' ;
1191
1192		var signForm_str_nonmember = '',
1193			signForm_str_defult  = '';
1194
1195		if(F_VALIDTYPE != 'SM' && (F_VALIDTYPE != 'BN' && F_SITEUM > -1)) F_SITEUM = -1;
1196
1197		if((F_VALIDTYPE == 'SM' || (F_VALIDTYPE == 'BN' && F_SITEUM > 0)) && access != 'NM') {
1198			mode = 'sitemember';
1199		}
1200
1201
1202		if(isGabia) {
1203			if(access == 'ADM') {
1204				mode = 'sitemember';
1205			} else if(access == 'NM') {
1206				//
1207			} else {
1208				if((F_VALIDTYPE != 'BN' && F_VALIDTYPE != 'SM') || (F_VALIDTYPE == 'BN' && F_SITEUM < 1)) {
1209					mode = 'nonmem';
1210					access = 'NM';
1211				}
1212			}
1213		}
1214
1215		if (access=='NM') {
1216			signForm_str_nonmember = '' + 
1217			'<ul class="comment-signForm nav ' + classSet[mode][0] + '" role="tablist">';
1218
1219				if(isGabia || (!isGabia && F_SITEUM > 0)) {
1220					signForm_str_nonmember += '' + 
1221					'<li class="signType ' + classSet[mode][2] + '" role="presentation"><a href="#sitemember" aria-controls="sitemember" role="tab" data-toggle="tab">' + $.lang[LANG]['config.creatorlink.text-adm'] + '</a></li>';
1222					
1223				} else {
1224					signForm_str_nonmember += '' +
1225					'<li class="signType ' + classSet[mode][1] + '" role="presentation"><a href="#creatorlink" aria-controls="creatorlink" role="tab" data-toggle="tab">' + $.lang[LANG]['config.creatorlink.text-adm'] + '</a></li>';
1226				}
1227				signForm_str_nonmember += '' + 
1228				'<li class="signType ' + classSet[mode][3] + '" role="presentation"><a href="#anonymous" aria-controls="anonymous" role="tab" data-toggle="tab">' +  $.lang[LANG]['config.anonymous'] + '<svg viewBox=\"0 0 6 8\" width=\"6\" height=\"8\"><polygon points=\"2 0 0 0 4 4 0 8 2 8 6 4 \"/></svg></a></li>' +
1229			'</ul>';
1230		} else {
1231			signForm_str_defult = '' + 
1232				'<ul class="comment-signForm nav ' + classSet[mode][0] + '" role="tablist">';
1233			if(mode == 'sitemember') {
1234				signForm_str_defult += '' + 
1235				'<li class="signType ' + classSet[mode][2] + '" role="presentation"><a href="#sitemember" aria-controls="sitemember" role="tab" data-toggle="tab">' + $.lang[LANG]['siteum.login.member'] + '</a></li>';
1236			} else {
1237				var tab_str = (isGabia) ? $.lang[LANG]['siteum.login.member'] : $.lang[LANG]['config.creatorlink'];
1238				if((F_VALIDTYPE == 'BN' || F_VALIDTYPE == 'SM') && access == 'ADM' ) {
1239					tab_str = '<br>' + $.lang[LANG]['config.creatorlink.text-adm2'];
1240					classSet[mode][5] = 'hidden';
1241				}
1242				signForm_str_defult += '' + 
1243					'<li class="signType ' + classSet[mode][1] + '" role="presentation"><a href="#creatorlink" aria-controls="creatorlink" role="tab" data-toggle="tab">' + tab_str + '</a></li>';
1244			}
1245			if(access=='A') {
1246				var icon_str = (mode == 'sitemember') ? '' : '<img src="//storage.googleapis.com/i.addblock.net/icon/icon-sign-anonymous.png"><br><br>';
1247				signForm_str_defult += '' + 
1248				'<li class="signType ' + classSet[mode][3] + '" role="presentation"><a href="#anonymous" aria-controls="anonymous" role="tab" data-toggle="tab">' +  $.lang[LANG]['config.anonymous'] + '</a></li>';
1249			}
1250			signForm_str_defult += '' + 
1251			'</ul>';
1252		}
1253
1254
1255
1256
1257		var str = signForm_str_defult +  signForm_str_nonmember +
1258			'<div class="tab-content">' +
1259				'<div role="tabpanel" class="tab-pane ' + classSet[mode][1] + '" id="creatorlink">' +
1260			        '<div class="form-inline comment-addform input-text">' +
1261			        	'<div class="cl-s-form-wrap">' +
1262							'<div class="cl-s-form-group">' +
1263								'<input type="text" class="cl-s-form-control" id="mb_forum_id" name="mb_id" required="required" value="">' +
1264								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.emailaddress'] + '</label>' +
1265							'</div>' +
1266						'</div>' +
1267			        	'<div class="cl-s-form-wrap mt-10">' +
1268							'<div class="cl-s-form-group">' +
1269								'<input type="password" class="cl-s-form-control" id="mb_forum_password" name="mb_password" required="required" value="">' +
1270								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.password'] + '</label>' +
1271							'</div>' +
1272						'</div>' +
1273			        '</div>' +
1274			        '<div class="bottom-box text-right ' + LANG + ' ' + classSet[mode][5] + '">' +
1275						'<span>' +  $.lang[LANG]['page.member.login-modal.jointext'] + '</span>&nbsp;&nbsp;&nbsp;<a href="' + joinUrl + '" target="_blank"><b>' +  $.lang[LANG]['page.member.login-modal.join2'] + '<svg viewBox=\"0 0 6 8\" width=\"6\" height=\"8\"><polygon points=\"2 0 0 0 4 4 0 8 2 8 6 4 \"/></svg></b></a>' +
1276					'</div>' +
1277			        '<div class="btn-wrap comment-addform mt-30">' +
1278			        	'<a href="#" class="btn btn-primary btn-lg btn-block forum-login" data-id="' + id + '" data-pid="' + pid + '">' +  $.lang[LANG]['config.modal.login'] + '</a>' +
1279			        	'<button type="button" class="btn-modal-cancel" data-dismiss="modal">' +  $.lang[LANG]['config.cancel'] + '</button>' +
1280			        '</div>' +
1281				'</div>' +
1282				'<div role="tabpanel" class="tab-pane ' + classSet[mode][2] + '" id="sitemember">' +
1283			        '<div class="form-inline comment-addform input-text">' +
1284			        	'<div class="cl-s-form-wrap">' +
1285							'<div class="cl-s-form-group">' +
1286								'<input type="text" class="cl-s-form-control" id="um_forum_id" name="um_id" required="required" value="">' +
1287								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['siteum.login.id'] + '</label>' +
1288							'</div>' +
1289						'</div>' +
1290			        	'<div class="cl-s-form-wrap mt-10">' +
1291							'<div class="cl-s-form-group">' +
1292								'<input type="password" class="cl-s-form-control" id="um_forum_password" name="um_password" required="required" value="">' +
1293								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['siteum.login.password'] + '</label>' +
1294							'</div>' +
1295						'</div>' +
1296			        '</div>' +
1297			        '<div class="bottom-box text-right ' + LANG + ' ' + classSet[mode][5] + '">' +
1298						'<span>' +  $.lang[LANG]['page.member.login-modal.jointext'] + '</span>&nbsp;&nbsp;&nbsp;<a href="' + joinUrl + '" target="_blank"><b>' +  $.lang[LANG]['page.member.login-modal.join2'] + '<svg viewBox=\"0 0 6 8\" width=\"6\" height=\"8\"><polygon points=\"2 0 0 0 4 4 0 8 2 8 6 4 \"/></svg></b></a>' +
1299					'</div>' +
1300			        '<div class="btn-wrap comment-addform mt-30">' +
1301			        	'<a href="#" class="btn btn-primary btn-lg btn-block forum-login" data-id="' + id + '" data-pid="' + pid + '">' +  $.lang[LANG]['config.modal.login'] + '</a>' +
1302			        	'<button type="button" class="btn-modal-cancel" data-dismiss="modal">' +  $.lang[LANG]['config.cancel'] + '</button>' +
1303			        '</div>' +
1304					'<br>' +
1305				'</div>' +
1306				'<div role="tabpanel" class="tab-pane ' + classSet[mode][3] + '" id="anonymous">' +
1307					'<div class="form-inline comment-addform input-text">' +
1308			        	'<div class="cl-s-form-wrap">' +
1309							'<div class="cl-s-form-group">' +
1310								'<input type="text" class="cl-s-form-control" id="comm-name" required="required" value="">' +
1311								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.name'+classSet[mode][4]] + '</label>' +
1312							'</div>' +
1313						'</div>' +
1314			        	'<div class="cl-s-form-wrap mt-10">' +
1315							'<div class="cl-s-form-group">' +
1316								'<input type="password" class="cl-s-form-control" id="comm-pass" required="required" value="">' +
1317								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.password'+classSet[mode][4]] + '</label>' +
1318							'</div>' +
1319						'</div>' +
1320					'</div>' +
1321					'<div class="kcaptcha-box comment-addform input-text mt-30">' +
1322						'<div class="col-xs-12 col-sm-5 col-md-5 no-padding text-left kcaptcha-img">' +
1323							'<p id="write_option">' +
1324								'<img src="" id="kcaptcha" alt="' +  $.lang[LANG]['config.captcha-alt'] + '"/>' +
1325							'</p>' +
1326						'</div>' +
1327						'<div class="col-xs-12 col-sm-7 col-md-7 no-padding text-left kcaptcha-text">' +
1328							'<input type="text" id="wr_key" name="wr_key" class="col-sm-12 form-control" placeholder="' +  $.lang[LANG]['config.enter-captcha'] + '"/>' +
1329							'<a class="kcaptcha-change hand"><svg viewBox="0 0 24 24" width="24" height="24">
1329<path d="M12 5c-3.64 0-6.63 2.78-6.97 6.33L3.35 9.65l-0.71 0.71 2.85 2.85 2.85-2.85L7.65 9.65l-1.59 1.59C6.43 8.29 8.95 6 12 6c3.31 0 6 2.69 6 6s-2.69 6-6 6c-1.66 0-3.17-0.68-4.26-1.78l-0.71 0.71C8.3 18.21 10.06 19 12 19c3.87 0 7-3.13 7-7S15.87 5 12 5z"/></svg><span>' +  $.lang[LANG]['config.change-captcha'] + '</span></a>' +
1330						'</div>' +
1331					'</div>' +
1332				'</div>' +
1333			'</div>';
1334
1335
1336		return str;
1337	}
1338	var forumWrite = function(id,pid,reply) {
1339		reply = (typeof reply == 'undefined') ? '' : reply;
1340	}
1341
1342
1343	$(document).on('click','.tb-attach-file',function(e) {
1344		// $('#forum-attach').modal('show');
1345      	isReplace = false;
1346		upTYPE = 'image';
1347		$('#file_type').val(upTYPE);
1348	    $('#file_multiple').val(false);
1349		$('#uploadFile').val('').removeAttr('multiple').attr('accept','image/gif,image/jpg,image/jpeg,image/png,image/ico');
1350		$('#uploadFile').trigger('click');
1351		// $('.modal-backdrop').last().removeClass('fade');
1352	});
1353	$(document).on('click','.tb-file-insert', function(e) {
1354		// $('#forum-attach').modal('show');
1355		upTYPE = 'file';
1356		$('#file_type').val(upTYPE);
1357	    $('#file_multiple').val(false);
1358		$('#uploadFile').val('').removeAttr('multiple').removeAttr('accept');
1359		$('#uploadFile').trigger('click');
1360		// $('.modal-backdrop').last().removeClass('fade');
1361	});
1362	$(document).on('click','.tb-video-insert', function(e) {
1363		$('#fm-editor').froalaEditor('selection.save');
1364		var modal = $(this).showModalFlat('INSERT VIDEO',videoForm(),true,true,function() {
1365			$('.error').remove();
1366			var url = $('#video-url').val();
1367			if(!url) {
1368				$('#video-url').after('<label class="error">' +  $.lang[LANG]['config.link-to-go'] + '</label>').focus();
1369				return;
1370			}
1371			var video = insertVideo(url,'src'),
1372				frVideo = '<span class="fr-video fr-dvb fr-draggable" contenteditable="false" draggable="true">' +
1373						'<iframe width="720" height="405" src="' + video + '" frameborder="0" allowfullscreen="true"></iframe>' +
1374						'</span>';
1375
1376			$('#fm-editor').froalaEditor('selection.restore');
1377			$('#fm-editor').froalaEditor('html.insert', frVideo , true);
1378			modal.modal('hide');
1379
1380		},'cancel','','w480 video-modal');
1381		$('.flat-modal').css({
1382			'position' : 'absolute',
1383			'z-index' : '1051'
1384		});
1385		$('.flat-modal').next().css('z-index','1050');
1386	});
1387
1388	$doc.on('click','#insert-forum-attach', function(e) {
1389		var file = $('#uploadFile').val();
1390		if(file=='') {
1391			alert('파일을 입력/선택하세요');
1392			$.processOFF();
1393			return false;
1394		}
1395		$('#forum-attach').modal('hide');
1396	});
1397	
1398	$doc.on('click','#fm-secret', function(e) {
1399		$target = $(this).find('.fa');
1400		if($target.hasClass('fa-square-o')) {
1401			$target.removeClass('fa-square-o').addClass('fa-check-square-o');
1402			$(this).attr('data-secret','S');
1403
1404			$('#fm-notice').find('.fa').removeClass('fa-check-square-o').addClass('fa-square-o');
1405			$('#fm-notice').attr('data-notice','');
1406		} else {
1407			$target.removeClass('fa-check-square-o').addClass('fa-square-o');
1408			$(this).attr('data-secret','');
1409		}
1410	});
1411
1412	$doc.on('click','#fm-notice', function(e) {
1413		$target = $(this).find('.fa');
1414		if($target.hasClass('fa-square-o')) {
1415			$target.removeClass('fa-square-o').addClass('fa-check-square-o');
1416			$(this).attr('data-notice','N');
1417
1418			$('#fm-secret').find('.fa').removeClass('fa-check-square-o').addClass('fa-square-o');
1419			$('#fm-secret').attr('data-secret','');
1420		} else {
1421			$target.removeClass('fa-check-square-o').addClass('fa-square-o');
1422			$(this).attr('data-notice','');
1423		}
1424	});
1425
1426	$doc.on('click',`
1427		.tpl-forum-list-arrow, .tpl-forum-list-toggle,
1428		[data-ver="1"][data-type2="faq"] .tpl-forum-list-icon
1429	`, function(e) {
1430		$(this).closest('tr').find('.tpl-forum-list-title').click();
1431	});
1432
1433	$doc.on('click','*[class*=tpl-forum-list-] a.deleted', function(e) {
1434		e.preventDefault();
1435		$(this).showModalFlat('', $.lang[LANG]['board.post.deleted'], true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn');
1436		return false;
1437	});
1438
1439	$doc.on('click','.tpl-toolbar-question-del, .tpl-toolbar-answer-del', function(e) {
1440		e.preventDefault();
1441		var option = $(this).attr('data-option'),
1442			id = $(this).attr('data-id'),
1443			target_type = $(this).closest('.tpl-qna-toolbar').attr('data-list-option');
1444
1445		var question_del_modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
1446				question_del_modal.modal('hide');
1447				$.forum.delete(id);
1448				if(target_type == 'a') {
1449					location.reload();
1450				}
1451			}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');
1452		// if(target_type == 'q') {
1453		// 	var question_del_modal = $(this).showModalFlat('POST DELETE', $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
1454		// 		question_del_modal.modal('hide');
1455		// 		$.forum.delete(id);
1456		// 	}, 'cancel');
1457		// }
1458		// else if(target_type == 'a') {
1459		// 	$.comment.delete(id);
1460		// }
1461	});
1462
1463	$doc.on('click', '.tpl-forum-pn-row a', function(e){
1464		e.preventDefault();
1465		if ($(this).hasClass('deleted')) {
1466		    return false;
1467		}
1468
1469		var fmViewUrl = $(this).attr('href');
1470		var option = $(this).attr('data-option');
1471		var id = $(this).attr('data-id');
1472
1473		var url = forumUrl();
1474		var href = url + fmViewUrl;
1475		
1476		if (option == 'S') {
1477		    $.ajax({
1478		        url: '/fm/access',
1479		        type: 'POST',
1480		        data: {id: id, sid: F_SID},
1481		        dataType: 'json',
1482		        success: function(data) {
1483		            if (data.access == false) {
1484		                if ((data.sign == false && data.fmid == true) || (data.sign == true && data.fmid == true) || (data.sign == true && data.fmid == false)) {
1485		                    $(this).showModalFlat('INFORMATION', $.lang[LANG]['board.read-not-allowed'], true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
1486		                } else {
1487		                	$(this).showModalFlat($.lang[LANG]['board.secret-password'],passwdForm(),true,true,function() {
1488								var $pass = $('#comm-pass'),
1489									isSubmit = true,
1490									userInput = $pass.val();
1491								$('label.error').remove();
1492								if($pass.val().length<4) {
1493									$pass.closest('.cl-s-form-wrap').addClass('error');
1494									$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
1495									$pass.focus();
1496									isSubmit = false;
1497								}
1498
1499								if(isSubmit) {
1500									$('.comment-addform.password').removeClass('error');
1501									$.ajax({
1502									    type: 'POST',
1503									    url: '/fm/password',
1504									    data: {
1505									        id: id,
1506									        passwd: hex_md5($pass.val())
1507									    },
1508									    dataType: 'json',
1509									    success: function(data) {
1510									        if(typeof data.error != 'undefined' && data.error) {
1511									            $pass.closest('.cl-s-form-wrap').addClass('error');
1512									            $pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
1513									            return false;
1514									        }
1515
1516									        var date = new Date(),
1517											cookietime = 20 * 60 * 1000;
1518								            date.setTime(date.getTime() + cookietime);
1519								            
1520											$.removeCookie('checkPostHighWriter',{path:'/'});
1521								            $.cookie('checkPostWriter', id, { path: '/' , expires: date});
1522											$.cookie('hash', data.hash, { path: '/' , expires: date});
1523											$('.modal[id*=flat-modal]').modal('hide');
1524											
1525									        if(typeof MODE == 'undefined') {
1526								                RENDER.history.pushState(null, property.TITLE, href);
1527								            } else {
1528								                location.href = href;
1529								            }
1530									    },
1531									    error: function(xhr, textStatus, errorThrown) {
1532									        console.log('Error: ' + errorThrown);
1533									    }
1534									});
1535
1536								}
1537								modalEmptyCheck();
1538							},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', false, '', function() {
1539								$('.board-password .board-secret-info').remove();
1540								$('.comment-addform.password').before('<div class="board-secret-info">' + $.lang[LANG]['board.writer.password.title'] + '</div>');
1541            				});
1542		                }
1543		            } else {
1544		                if (typeof MODE == 'undefined') {
1545		                    RENDER.history.pushState(null, property.TITLE, href);
1546		                } else {
1547		                    location.href = href;
1548		                }
1549		            }
1550		            return false;
1551		        }
1552		    });
1553		} else {
1554		    if (typeof MODE == 'undefined') {
1555		        RENDER.history.pushState(null, property.TITLE, href);
1556		    } else {
1557		        location.href = href;
1558		    }
1559		}
1560		
1561		return false;
1562	});
1563	
1564	$doc.off('click','.tpl-forum-list-title, .tpl-forum-list-cont, .tpl-forum-list-thumb, .tpl-forum-list-more, .tpl-toolbar-question-answer, .tpl-forum-list-content');
1565	$doc.on('click','.tpl-forum-list-title, .tpl-forum-list-cont, .tpl-forum-list-thumb, .tpl-forum-list-more, .tpl-toolbar-question-answer, .tpl-forum-list-content', function(e) {
1566
1567		var click_this = $(this),
1568			click_tr = ($(this).closest('tr').length > 0) ? $(this).closest('tr') : $(this).closest('.item'),
1569			option = $(this).attr('data-option'),
1570			id = $(this).attr('data-id'),
1571			forum_el = $(this).closest('.element'),
1572			type = $(forum_el).attr('data-forum-type'),
1573			pid = $(forum_el).attr('data-id'),
1574			page_num = $(forum_el).find('.tpl-forum-page.active').attr('data-page-num'),
1575			stx = getForumPrevStx(pid),
1576			sfl = ($(forum_el).find('#sfl').length > 0) ? $(forum_el).find('#sfl').val() : '',
1577			scate = ($(forum_el).find('#scate').length > 0) ? $(forum_el).find('#scate').val() : '';
1578		
1579		var checkOldVerForum = (forum_el.is('[data-ver="1"]')) ? true : false;
1580
1581		if($.inArray(type, ['faq','guestbook']) > -1
1582			|| click_this.find('.tpl-forum-list-title').length > 0
1583			|| (type=='qna' && !click_this.is('.tpl-forum-list-title'))
1584			|| ($(e.target).hasClass('tpl-forum-list-title') && $(e.target).find('a.deleted').length)
1585		) {
1586			if($.inArray(type, ['faq', 'qna']) > -1 && click_this.is('.tpl-forum-list-cont:has(a[rel])')) return true;
1587			else return false;
1588		}
1589
1590		if($(e.target).hasClass('tpl-forum-list-reply-name') ){
1591			var del_chk = $(e.target).next();
1592			if(del_chk.is('a.deleted')) {
1593				$(e.target).next().click();
1594				return false;
1595			}
1596		}
1597
1598		e.preventDefault();
1599
1600		if($(forum_el).find('input[name="user_stx"]').length > 0 && $(forum_el).find('input[name="user_sfl"]').length > 0) {
1601			stx = $(forum_el).find('input[name="user_stx"]').val();
1602			sfl = $(forum_el).find('input[name="user_sfl"]').val();
1603		}
1604		
1605		if($(this).closest('#element-display').length > 0) return false;
1606		if($(this).closest('[data-loop="true"]').hasClass('sample-loop')) return false;
1607		if($(this).closest('tr.active').length > 0 && $(this).closest('.element.page-bottomlist').length > 0) return false;
1608		
1609		F_SID = (typeof SID == 'undefined') ? property.SID : SID;
1610
1611		var checkQnAForum = (type=='qna' && !$(this).hasClass('tpl-qna-toolbar-button')) ? true : false,
1612			click_el = $(this).closest('.item');
1613
1614		if(checkOldVerForum) click_el = (checkQnAForum) ? $(this).closest('.qna-item') : $(this);
1615
1616		if(option=='S') {
1617			e.preventDefault();
1618			var checkhigh_onoff = (typeof click_tr.attr('data-checkhigh') != 'undefined' && click_tr.attr('data-checkhigh')) ? true : false,
1619				checkhigh_mode = (checkhigh_onoff) ? click_tr.attr('data-checkhigh') : '';
1620
1621			$.post('/fm/access',{id:id, sid : F_SID}, function(data) {
1622				if(data.access == false) {
1623					if(((data.sign == false && data.fmid == true) || (data.sign == true && data.fmid == true) || (data.sign == true && data.fmid == false)) && !checkhigh_onoff) {
1624						
1625						if(data.sign == false && data.checkhigh != '') {
1626							var checkhigh_v = (data.checkhigh == 'onlyparent') ? 'parent' : data.checkhigh,
1627								checkhigh_str = '<span class="btn-fm-change-checkhigh" data-checkhigh="'+checkhigh_v+'">' + $.lang[LANG]['board.goto-checkhigh.'+checkhigh_v] + '</span>';
1628							if(data.checkhigh == 'parent') checkhigh_str += '<span class="btn-fm-change-checkhigh" data-checkhigh="reply">' + $.lang[LANG]['board.goto-checkhigh.reply'] + '</span>';
1629
1630							var fmAcc_str = $.lang[LANG]['board.read-not-allowed'] + '<div class="clearfix"></div><div class="wrap-fm-change-checkhigh">' + checkhigh_str + '</div>';
1631							var fmAccModal = $(this).showModalFlat('INFORMATION',fmAcc_str,true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title','','',function() {
1632								fmAccModal.find('.btn-fm-change-checkhigh').on('click', function() {
1633									var tmp_v = $(this).attr('data-checkhigh');
1634									click_tr.attr('data-checkhigh',tmp_v);
1635									click_this.click();
1636									fmAccModal.modal('hide');
1637								});
1638							});
1639						} else {
1640							$(this).showModalFlat('INFORMATION',$.lang[LANG]['board.read-not-allowed'],true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
1641						}
1642
1643					} else {
1644						var fmAccModal_title = $.lang[LANG]['board.secret-password'];
1645						if(checkhigh_onoff) {
1646							click_tr.removeAttr('data-checkhigh');
1647							fmAccModal_title = $.lang[LANG]['board.goto-checkhigh.'+checkhigh_mode+'.title'];
1648						}
1649						var fmAccModal2 = $(this).showModalFlat(fmAccModal_title,passwdForm(checkhigh_mode),true,true,function() {
1650							var $pass = $('#comm-pass'),
1651								isSubmit = true,
1652								userInput = $pass.val();
1653							$('label.error').remove();
1654							if($pass.val().length<4) {
1655								//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
1656								$pass.closest('.cl-s-form-wrap').addClass('error');
1657								$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13">
1657<path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
1658								$pass.focus();
1659								isSubmit = false;
1660							}
1661
1662							if(isSubmit) {
1663								//$('.comment-addform.password').parent().find('.error').remove();
1664								$('.comment-addform.password').removeClass('error');
1665								$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()), checkhigh: $pass.attr('data-checkhigh')  }, function(pwdata) {
1666									if(typeof pwdata.error != 'undefined' && pwdata.error) {
1667										//$('.comment-addform.password').before('<label class="error">' + pwdata.error + '</label>');
1668										$pass.closest('.cl-s-form-wrap').addClass('error');
1669										$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+pwdata.error+'</label>');
1670										return false;
1671									}
1672									var date = new Date(),
1673										cookietime = 20 * 60 * 1000;
1674									date.setTime(date.getTime() + cookietime);
1675									
1676									$.removeCookie('checkPostHighWriter',{path:'/'});
1677									$.cookie('checkPostWriter', id, { path: '/' , expires: date});
1678									$.cookie('hash', pwdata.hash, { path: '/' , expires: date});
1679
1680									var tmp_v = $pass.attr('data-checkhigh');
1681									if($pass.is('[data-checkhigh]') && typeof tmp_v != 'undefined' && tmp_v) {
1682										$.cookie('checkPostHighWriter'+id, tmp_v+','+pwdata.checkhigh_val, { path: '/' , expires: date});
1683									} else {
1684										$.removeCookie('checkPostHighWriter',{path:'/'});
1685									}
1686									$('.modal[id*=flat-modal]').modal('hide');
1687
1688									$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
1689									if(checkQnAForum) showQnAForumAnswer(F_SID,id,option,$(click_el),checkOldVerForum);
1690									else {
1691										var url = forumUrl(),
1692											href = url + '/forum/view/' + id;
1693
1694										if(typeof MODE == 'undefined') RENDER.history.pushState(null,property.TITLE,href);											
1695										else location.href = href;
1696									}
1697								},'json');
1698							}
1699							modalEmptyCheck();
1700						},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', false, '', function() {
1701							$('.board-password .board-secret-info').remove();
1702							$('.comment-addform.password').before('<div class="board-secret-info">' + $.lang[LANG]['board.writer.password.title'] + '</div>');
1703
1704							if(!checkhigh_onoff) {
1705								if(data.checkhigh != '') {
1706									var checkhigh_v = (data.checkhigh == 'onlyparent') ? 'parent' : data.checkhigh,
1707										checkhigh_str = '<span class="btn-fm-change-checkhigh" data-checkhigh="'+checkhigh_v+'">' + $.lang[LANG]['board.goto-checkhigh.'+checkhigh_v] + '</span>';
1708									if(data.checkhigh == 'parent') checkhigh_str += '<span class="btn-fm-change-checkhigh" data-checkhigh="reply">' + $.lang[LANG]['board.goto-checkhigh.reply'] + '</span>';
1709									
1710									$('.comment-addform.password').after('<div class="clearfix"></div><div class="wrap-fm-change-checkhigh">' + checkhigh_str + '</div>');
1711								}
1712							}
1713
1714							fmAccModal2.find('.btn-fm-change-checkhigh').on('click', function() {
1715								var tmp_v = $(this).attr('data-checkhigh');
1716								click_tr.attr('data-checkhigh',tmp_v);
1717								click_this.click();
1718								fmAccModal2.modal('hide');
1719							});
1720						});
1721					}
1722				} else {
1723					$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
1724
1725					var cookie_date = new Date();
1726					cookie_date.setTime(cookie_date.getTime() + (60*60*1000));
1727					$.cookie('checkPostWriter',id,{ expires: cookie_date, path:'/'});
1728					$.removeCookie('checkPostHighWriter',{path:'/'});
1729
1730					if(checkQnAForum) showQnAForumAnswer(F_SID,id,option,$(click_el),checkOldVerForum);
1731					else {
1732						var url = forumUrl();
1733						var href = url + '/forum/view/' + id;
1734						if(typeof MODE == 'undefined') RENDER.history.pushState(null,property.TITLE,href);
1735						else location.href = href;
1736					}
1737				}
1738			}, 'json');
1739		} else {
1740			$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
1741			if(checkQnAForum) showQnAForumAnswer(F_SID,id,option,$(click_el),checkOldVerForum);
1742			else {
1743				var url = forumUrl();
1744				var href = url + '/forum/view/' + id;
1745				if(typeof MODE == 'undefined') RENDER.history.pushState(null,property.TITLE,href);
1746				else location.href = href;
1747			}
1748		}
1749
1750	});
1751
1752	var showQnAForumAnswer = function(sid,id,option,qnaitem,isOldVer) {
1753
1754		var checkNotice = $(qnaitem).hasClass('n'),
1755			checkOpen = !$(qnaitem).hasClass('open'),
1756			state = $(qnaitem).find('.tpl-forum-list-state').hasClass('active');
1757
1758		if(isOldVer) {
1759			checkNotice = ($(qnaitem).find('.tpl-forum-list-title').hasClass('n')) ? true : false;
1760			checkOpen = ($(qnaitem).hasClass('qna-item') && $(qnaitem).next('.qna-details').css('display') == 'none') ? true : false;
1761			state = $(qnaitem).find('.tpl-forum-list-state[data-state="true"]').length > 0 ? true : false;
1762		}
1763
1764		if(checkOpen) {
1765
1766			$.ajax({
1767				url: '/fm/view',
1768				dataType: 'json',
1769				type: 'POST',
1770				data: { id : id, sid : sid },
1771				async: false,
1772				cache: false,
1773				success: function(data) {
1774					var umemberActivate = (PAGE_MODE == 'c')? Number(UMEMBER_ACTIVATE) : Number(property.UMEMBER_ACTIVATE);
1775					var umember = (PAGE_MODE == 'c')? UMEMBER : property.UMEMBER;
1776					var checkLogin = (PAGE_MODE == 'c')? true : umember.check_login;
1777					if(umemberActivate == 0 && umember.id_type == 'creatorlink') { //creatorlink login
1778						checkLogin = (umember.id !== undefined && umember.id)? true : false;
1779					}
1780
1781					if(typeof data.error != 'undefined' && data.error) {
1782						var url = (PAGE_MODE=='s') ? '/' : '/render/';
1783						if(checkLogin) {
1784							alert(data.error);
1785							(F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);		
1786						} else {
1787							var action = (property.VALIDTYPE == 'SM')  ? '/_login' : '/_cllogin';
1788							var url = forumUrl() + '/forum/view/'+ id;
1789							var html = '<form name="write_login_form" id="write-login" method="post" action="' + action + '" style="display:none;">\
1790											<input type="hidden" name="status" value="forum_view">\
1791											<input type="hidden" name="sid" value="'+property.SID+'">\
1792											<input type="hidden" name="page_mode" value="'+data.access+'">\
1793											<input type="hidden" name="url" value="'+url+'">\
1794										</form>';
1795							$('body').append(html);
1796							document.write_login_form.submit();
1797						}
1798						// alert(data.error);
1799						// location.reload();
1800						return false;
1801					}
1802				
1803					if(typeof data.fonts != 'undefined' && data.fonts && PAGE_MODE!='c') {
1804						$.each(data.fonts, function(i,v) {
1805							if(property.ELFONTS.indexOf(i) < 0) {
1806								property.ELFONTS.push(i);
1807								$('#loadfonts').append(v);
1808							}
1809						});
1810					}
1811
1812					if(typeof data.webfonts != 'undefined' && data.webfonts && PAGE_MODE!='c') {
1813						$.each(data.webfonts, function(i2,v2) {
1814							if(property.ELFONTS.indexOf(i2) < 0 && v2) {
1815								property.ELFONTS.push(i2);
1816								WebFont.load({ google : { families : [ v2 ], display:'swap' }});
1817							}
1818						})
1819					}
1820
1821					var checkState = data.replied ? true : false;
1822					var answer = {
1823						...data.answer || {},
1824						secret: (checkState && data.answer.fm_option == 'S') ? true : false,
1825						title: checkState ? decodeUnicode(data.answer.fm_title) : '',
1826						cont: checkState ? decodeUnicode(data.answer.fm_content) : '',
1827					};
1828
1829					if(data.own && !checkLogin && data.fmid) data.own = false;
1830
1831					var btns = {
1832						q: {
1833							del: (!checkState && (data.own || (data.sign == false && data.fmid == false) || data.mgr)) ? `
1834									<li class="tpl-qna-toolbar-button tpl-toolbar-question-del" data-id="${id}" data-option="${option}">
1835										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.delete']}</span></button>
1836									</li>
1837								` : '',
1838							edit: (!checkState && ((data.own || (data.sign == false && data.fmid == false)) && data.writeable == true || data.mgr_edit)) ? `
1839									<li class="tpl-qna-toolbar-button tpl-toolbar-question-edit" data-id="${id}" data-option="${option}" data-pid="${data.pid}">
1840										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.modify']}</span></button>
1841									</li>
1842								` : '',
1843							answer: (!checkState && data.mgr && option!= 'N') ? `
1844									<li class="tpl-qna-toolbar-button tpl-toolbar-question-edit" data-id="${id}" data-option="${option}" data-reply="${id}" data-pid="${data.pid}">
1845										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['forum.qna.answer.write.btn']}</span></button>
1846									</li>
1847								` : '',
1848						},
1849						a: {
1850							del: (checkState && (answer.own || data.mgr)) ? `
1851									<li class="tpl-qna-toolbar-button tpl-toolbar-answer-del" data-id="${answer.seq}" data-option="${option}" >
1852										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.delete']}</span></button>
1853									</li>
1854								` : '',
1855							edit: (checkState && answer.own) ? `
1856									<li class="tpl-qna-toolbar-button tpl-toolbar-question-edit" data-id="${answer.seq}" data-option="${option}" data-pid="${data.pid}">
1857										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.modify']}</span></button>
1858									</li>
1859								` : '',
1860						}
1861					};
1862					var question_toolbar = `
1863							<ul class="tpl-qna-toolbar clearfix" data-list-option="q">
1864								${btns.q.answer} ${btns.q.edit} ${btns.q.del}
1865							</ul>
1866						`,
1867						answer_toolbar = `
1868							<ul class="tpl-qna-toolbar clearfix" data-list-option="a">
1869								${btns.a.edit} ${btns.a.del}
1870							</ul>
1871					`;
1872
1873
1874					if(answer.secret) {
1875						var icon_secret = '<i class="tpl-forum-list-secret-icon cl-icon lock02" aria-hidden="true"></i>&nbsp;';
1876						answer.title = icon_secret + ((btns.a.del != '' || checkState) ? answer.title : $.lang[LANG]['forum.qna.content.secret']);
1877						answer.cont = (btns.a.del != '' || checkState) ? answer.cont : '';
1878					}
1879
1880					if($(question_toolbar).html().trim() == '') question_toolbar = '';
1881					if($(answer_toolbar).html().trim() == '') answer_toolbar = '';
1882
1883					if(isOldVer) {
1884						var hasAnswer = $(qnaitem).next().hasClass('qna-details');
1885						if(!hasAnswer) {
1886							var qna_container_default = '\
1887										<div class="tpl-qna-question">\
1888											<div class="tpl-qna-question-content"></div>\
1889										</div>\
1890										<div class="tpl-qna-answer">\
1891											<div class="tpl-qna-answer-title-wrap display-flex space-between">\
1892												<div class="tpl-qna-answer-title"></div>\
1893												<div class="tpl-qna-answer-name"></div>\
1894												<div class="tpl-qna-answer-date"></div>\
1895											</div>\
1896											<div class="tpl-qna-answer-content"></div>\
1897										</div>\
1898								',
1899								detail_html = $(qnaitem).clone(),
1900								detail = document.createElement('div');
1901							$(detail).html(detail_html);
1902							
1903							if($(detail).children().first().is('tr')) {
1904								$(detail).find('.qna-details *[class*=tpl-forum-list-]:not(.tpl-forum-list-content)').html('');
1905								$(detail).find('.qna-details .tpl-forum-list-content').addClass('tpl-qna-container').html(qna_container_default);
1906								$(detail).find('.qna-details').hide();
1907							} else {
1908								$(detail).children().first().addClass('tpl-qna-container').html(qna_container_default);
1909							}
1910
1911							$(qnaitem).after($(detail).html()).hide();
1912							$(detail).remove();
1913						}
1914
1915						$(qnaitem).next('.qna-details').find('.tpl-qna-question-content').html(data.content);
1916						if($(qnaitem).next('.qna-details').find('.tpl-qna-toolbar[data-list-option="q"]').length == 0 ) $(qnaitem).next('.qna-details').find('.tpl-qna-question').append(question_toolbar);
1917						else $(qnaitem).next('.qna-details').find('.tpl-qna-question .tpl-qna-toolbar').replaceWith(question_toolbar);
1918
1919						if(data.replied) {
1920							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-title').html(answer.title);
1921							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-content').html(answer.cont);
1922							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-name').html(answer.fm_name);
1923							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-date').html(answer.fm_re_datetime);
1924							if($(qnaitem).parents().hasClass('newqna')) {
1925								if($(qnaitem).next('.qna-details').find('.tpl-qna-toolbar[data-list-option="a"]').length == 0 ) $(qnaitem).next('.qna-details').find('.tpl-qna-answer-content').append(answer_toolbar);
1926								else $(qnaitem).next('.qna-details').find('.tpl-qna-answer .tpl-qna-toolbar').replaceWith(answer_toolbar);
1927							} else {
1928								if($(qnaitem).next('.qna-details').find('.tpl-qna-toolbar[data-list-option="a"]').length == 0 ) $(qnaitem).next('.qna-details').find('.tpl-qna-answer').after(answer_toolbar);
1929								else $(qnaitem).next('.qna-details').find('.tpl-qna-answer .tpl-qna-toolbar').replaceWith(answer_toolbar);
1930							}
1931						} else {
1932							$(qnaitem).next('.qna-details').find('.tpl-qna-answer').hide();
1933						}
1934
1935						var colspan = $(qnaitem).parents('.table').find('th.tpl-forum-header-row:not(.hide)').length;
1936						if($(qnaitem).next('.qna-details').find('td').length > 1) {
1937							$(qnaitem).next('.qna-details').find('td').each(function() {
1938								if($(this).text().trim() === '') $(this).remove();
1939							});
1940						}
1941						$(qnaitem).next('.qna-details').find('td').attr('colspan', colspan);
1942						$(qnaitem).next('.qna-details').show().siblings('.qna-details').hide();
1943
1944					} else {
1945						var qnaQuestion = $(qnaitem).find(`.tpl-forum-qna-row.question`),
1946							qnaAnswer = $(qnaitem).find(`.tpl-forum-qna-row.answer`);
1947
1948						qnaQuestion.find('.tpl-forum-list-cont').html(data.content);
1949						qnaQuestion.find('.tpl-qna-toolbar').remove();
1950						qnaQuestion.find('.tpl-forum-qna-details').append(question_toolbar);
1951
1952						if(data.replied) {
1953							qnaAnswer.find('.tpl-forum-list-title').html(answer.title);
1954							qnaAnswer.find('.tpl-forum-list-cont').html(answer.cont);
1955							qnaAnswer.find('.tpl-forum-list-name').html(answer.fm_name);
1956							qnaAnswer.find('.tpl-forum-list-date').html(answer.fm_re_datetime);
1957							qnaAnswer.find('.tpl-qna-toolbar').remove();
1958							qnaAnswer.find('.tpl-forum-qna-details').append(`<div class="tpl-forum-qna-row toolbar">${answer_toolbar}</div>`);
1959							$(qnaitem).removeClass('w');
1960						} else {
1961							$(qnaitem).addClass('w');
1962						}
1963
1964						$(qnaitem).addClass('open').siblings().removeClass('open');
1965					}
1966				}
1967			});
1968
1969		} else {
1970			if(isOldVer) $(qnaitem).next('.qna-details').hide();
1971			else $(qnaitem).removeClass('open');
1972		}
1973
1974	}
1975
1976
1977    $(document).on('paste','.note-editable',function(event) {
1978        event.preventDefault();
1979        if(window.clipboardData) {
1980            var text = window.clipboardData.getData('Text');
1981            if (window.getSelection) { // IE11
1982                window.getSelection().getRangeAt(0).insertNode(document.createTextNode(text));
1983            } else if (document.selection && document.selection.createRange) { // old IE
1984                text = text.replace(/\n/g, "<br />");
1985                document.selection.createRange().pasteHTML(text);
1986            }
1987        } else {
1988            var text = (event.originalEvent || event).clipboardData.getData('text/plain') || prompt('Paste something..');
1989            text = text.replace(/\n/g, '<br />');
1990            window.document.execCommand('insertHtml', false, text);
1991        }
1992    });
1993
1994	$(document).on('mousedown mouseup keydown keyup','.fr-view',function(e) {
1995		selRange = saveSelection();
1996	});
1997	
1998	$(document).on('click','button[data-event="showLinkDialog"]', function(e) {
1999		restoreSelection(selRange);
2000	});
2001
2002	$(document).on('click','.set-image', function(e) {
2003		var src = $(this).closest('.result-file').attr('data-file');
2004		$('.fr-view').focus();
2005		if(!$('.fr-view').is(':focus')) {
2006			// placeCaretAtEnd($('.fr-view').get(0));
2007		}
2008
2009		if(upTYPE == 'image') $('#fm-editor').froalaEditor('image.insert', 'http:' + file, true);
2010		else $('#fm-editor').froalaEditor('file.insert', 'http:' + file, orig_name, { 'link' : 'http:' + file, 'target': '_blank' });
2011	});
2012
2013	$(document).on('click','.file-delete', function(e){
2014		var select_file = $(this).parent().attr('data-file-name'),
2015			click_file = $(this).parent().attr('data-file'),
2016			user_file = $('.result-file').map(function() {
2017							return $(this).attr('data-file-name');
2018						}).get().join(',');
2019			$file = $(this).parent();
2020
2021		var modal = $(this).showModalFlat('INFORMATION',$.lang[LANG]['board.ask-delete-attached-file'], true, true, function() {
2022			$.post('/fm/attach_delete',{ select_file : select_file, user_file : user_file, sid : SID }, function(data){
2023				$('.flat-modal').next().remove();
2024				$('.flat-modal').remove();
2025				$file.fadeOut().remove();
2026				$('img[src="' + click_file + '"]').fadeOut('fast',function() { $(this).remove(); });
2027			}, 'json');
2028		}, 'cancel');
2029	});
2030
2031	$(document).on('focus','#fm-editor',function(e) {
2032		$(this).removeClass('content-empty');
2033		// placeCaretAtEnd($('.fr-view').get(0));
2034	}).on('focusout','#fm-editor', function(e) {
2035		setPlaceholder($(this));
2036	});
2037
2038	var setPlaceholder = function($editor) {
2039		var empty = ($editor.find('.fr-view').html()=="<p><br></p>") ? true : false;
2040		(empty) ? $editor.addClass('content-empty') : $editor.removeClass('content-empty');
2041	}
2042
2043	var updateForumPost = function(id,pid) {
2044
2045		var idstr = (id) ? '/m/u/id/' + id : '';
2046		$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
2047			if(typeof data.error != 'undefined' && data.error) {
2048				$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2049				return false;
2050			}
2051			var post_data = data;
2052			if(data.fmid && data.sign == false) {
2053				userLogin();
2054				return false;
2055			}
2056
2057			if(data.sign == false) {
2058				$(this).showModalFlat($.lang[LANG]['board.button.modify.password'],passwdForm(),true,true,function() {
2059					var $pass = $('#comm-pass'),
2060						isSubmit = true,
2061						userInput = $pass.val();
2062					$('label.error').remove();
2063					if($pass.val().length<4) {
2064						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2065						$pass.closest('.cl-s-form-wrap').addClass('error');
2066						$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
2067						$pass.focus();
2068						isSubmit = false;
2069					}
2070
2071					if(isSubmit) {
2072						//$('.comment-addform.password').parent().find('.error').remove();
2073						$.post('/fm/password',{ id: id, passwd : hex_md5($pass.val()) }, function(data) {
2074							if(typeof data.error != 'undefined' && data.error) {
2075								//$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2076								//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
2077								$pass.closest('.cl-s-form-wrap').addClass('error');
2078								$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
2079								return false;
2080							}
2081							var date = new Date(),
2082								cookietime = 20 * 60 * 1000;
2083				            date.setTime(date.getTime() + cookietime);
2084
2085							$.cookie('hash', data.hash, { path: '/' , expires: date});
2086							$('.modal[id*=flat-modal]').modal('hide');
2087							setWriteUser(post_data, function() {
2088								location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid;
2089								// forumWrite(id,pid);
2090							});
2091						},'json');
2092					}
2093					modalEmptyCheck();
2094				},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password');
2095			} else if(data.own == true || data.mgr_edit == true) {
2096				setWriteUser(data, function() {
2097					location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid;
2098					// forumWrite(id,pid);
2099				});
2100			} else alert($.lang[LANG]['board.not-own-no-edit']);
2101
2102		}, 'json');
2103	}
2104
2105	var userLogin = function() {
2106		var id = $('#fm-id').val(),
2107			pid = $('#fm-pid').val(),
2108			info = $.lang[LANG]['re-login.info'];
2109
2110		$.post('/fm/checkUser', { pid : pid }, function(data) {
2111			if(!data.user || typeof data.user == 'undefined') {
2112				if(typeof data.error != 'undefined' && data.error) {
2113					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2114					return false;
2115				}
2116				var modal = $(this).showModalFlat($.lang[LANG]['config.postforum'], info + signForm(id,pid,data.access,data.stoken),true,true,function() {
2117					var isSubmit = true;
2118					$('.error').remove();
2119
2120					var $name = $('#comm-name'),
2121						$pass = $('#comm-pass'),
2122						$key = $('#wr_key'),
2123						nameLength = getBytes( $name.val() );
2124
2125					if( nameLength==0) {
2126						$name.after('<label class="error">' +  $.lang[LANG]['config.enter-name'] + '</label>').focus();
2127						isSubmit = false;
2128					}
2129					else if ( nameLength > 20 ) {
2130						$name.after('<label class="error">' +  $.lang[LANG]['config.guest-id-max-length'] + '</label>').focus();
2131						isSubmit = false;
2132					}
2133					if($pass.val().length<4) {
2134						$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2135						isSubmit = false;
2136					}
2137
2138					if($key.val().length==0) {
2139						$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
2140						isSubmit = false;
2141					}
2142
2143					if($key.val() && (Base64.encode($key.val().trim()) != md5_norobot_key)) {
2144						$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2145						isSubmit = false;
2146					}
2147
2148					// var key = '';
2149					// if(isSubmit == true) {
2150					// 	key = checkCaptcha();
2151					// 	if(!key.success) {
2152					// 		$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2153					// 		isSubmit = false;
2154					// 	}
2155					// }
2156
2157					resetObject(user);
2158					if(isSubmit==true) {
2159						modal.modal('hide');
2160						user.name = data.name = $name.val();
2161						user.nameLength = nameLength;
2162						user.pass = hex_md5( $pass.val() );
2163						user.key = $key.val().trim();
2164						setWriteUser(data);
2165					}
2166				},'cancel','','w450',true,'',function() {
2167					// loadCaptcha();
2168					load_kcaptcha();
2169				});
2170				$('.flat-modal .modal-body').addClass('comment');
2171				$('.flat-modal .modal-footer').hide();
2172				$('.modal[id*=flat-modal]').css('z-index','1040');
2173				$('.flat-modal').next('.modal-backdrop').css('z-index','1039');
2174				if(!user.pass) $('.flat-modal .signType').last().hide();
2175				// $('#kcaptcha').click();
2176			} else {
2177				// resetObject(user);
2178				setWriteUser(data);
2179			}
2180		},'json');
2181	}
2182
2183	var passwdForm = function(checkhigh) {
2184		if(typeof checkhigh == 'undefined') checkhigh = '';
2185		return '' +
2186			'<div class="cl-s-form-wrap comment-addform password">' +
2187				'<div class="cl-s-form-group">' +
2188					'<input type="password" class="cl-s-form-control" id="comm-pass" name="comm-pass" required="required" value="" data-checkhigh="' + checkhigh + '">' +
2189					'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.password'] + '</label>' +
2190				'</div>' +
2191			'</div>';
2192	}
2193	var videoForm = function() {
2194		return '' +
2195			'<div class="form-inline comment-addform video">' + 
2196			  	'<div class="form-group">' +
2197			  		'<p><b>Video URL?</b> (YouTube, Vimeo, SoundCloud, Metacafe or DailyMotion)</p>' + 
2198			    	'<label class="sr-only" for="label-video">' +  $.lang[LANG]['config.modal.password'] + '</label>' +
2199			    	'<input type="text" class="form-control" id="video-url" placeholder="http(s)://">' +
2200			  	'</div>' +
2201			'</div>';
2202	}
2203
2204
2205	var modalEmptyCheck = function() {
2206		$('.cl-s-form-control').off().on({
2207			keyup: function(e) {
2208				if(e.keyCode === 13) {
2209					if($(this).closest('.cl-s-form-wrap').next('.cl-s-form-wrap').length > 0) {
2210						$(this).closest('.cl-s-form-wrap').next('.cl-s-form-wrap').find('.cl-s-form-control').focus();
2211					} else if($(this).closest('.cl-s-form-wrap').next('#captcha:not(:empty)').length > 0) {
2212						$('#wr_key').focus();
2213					}
2214				}
2215			},
2216			focus: function(e) {
2217				$(this).closest('.cl-s-form-wrap').addClass('active');
2218			},
2219			blur: function(e) {
2220				var inputEL = $(this),
2221					type = $(this).attr('id'),
2222					val = $(this).val().trim(),
2223					error_str = '';
2224
2225				inputEL.closest('.cl-s-form-wrap').removeClass('active');
2226				if(val.length == 0) {
2227					inputEL.closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
2228					inputEL.closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
2229					return false;
2230				} else {
2231					inputEL.closest('.cl-s-form-wrap').removeClass('empty');
2232					var error_str = '';
2233					if(type == 'comm-pass') {
2234						if(val.length<4) {
2235							error_str = '<svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>
2235' + $.lang[LANG]['config.pass-min-length'];
2236						}
2237					}
2238					if(error_str.length > 0) {
2239						inputEL.closest('.cl-s-form-wrap').addClass('error');
2240						if(inputEL.parent().parent().find('.cl-s-control-label.error').length > 0) {
2241							inputEL.parent().parent().find('.cl-s-control-label.error').html(error_str);
2242						} else {
2243							inputEL.parent().parent().next('.cl-s-control-label.error').remove();
2244							inputEL.parent().parent().after('<label for="input" class="cl-s-control-label error">'+error_str+'</label>');
2245						}
2246						return false;
2247					}
2248				}
2249				inputEL.closest('.cl-s-form-wrap').removeClass('error').removeClass('empty');
2250				inputEL.parent().parent().next('.cl-s-control-label.error').remove();
2251				if($('.error_login').length > 0) $('.error_login').remove();
2252			}
2253		});
2254		$('#wr_key').off().on({
2255			keyup: function(e) {
2256				$(this).closest('.kcaptcha-box').removeClass('empty').removeClass('error');
2257			},
2258			focus: function(e) {
2259				$(this).closest('.kcaptcha-box').addClass('active');
2260			},
2261			blur: function(e) {
2262				if($(this).val().trim().length == 0) {
2263					$(this).closest('.kcaptcha-box').removeClass('active');
2264				} else {
2265					$(this).closest('.kcaptcha-box').removeClass('empty').removeClass('error').removeClass('active');
2266				}
2267				$(this).closest('.kcaptcha-box').parent().find('.kcaptcha-error').remove();
2268			}
2269		});
2270	}
2271
2272	$(document).on('click', '.tpl-guestbook-write', function(e) {
2273		if(PAGE_MODE == 'r') return false;
2274		var id = '';
2275		var element = $(this).parents('.element');
2276		var sid = (typeof property == 'undefined') ? SID : property.SID,
2277			pid = element.attr('data-id');
2278		
2279		var content = '', passwd = '', captcha = '', secret = 'N', writer = '';
2280
2281			
2282		var validation_flag = true;
2283		element.find('.error-box').remove();
2284		if($(this).attr('data-id')) {//if는 수정창 등록 버튼
2285			id = $(this).attr('data-id');
2286			var edit_box = element.find('.guestbook-edit');
2287			content = edit_box.find('.input-content').val();
2288			secret = edit_box.find('.secret-check input[type="checkbox"]').prop('checked') ? 'S' : 'N';
2289			if($.trim(content) == '' || $.trim(content).length < 2) {
2290				edit_box.find('.input-content').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.content'] + '</div>');
2291				validation_flag = false;
2292			}
2293		} else {
2294			
2295			//element.find('.list-area').find('.editing,.hide').removeClass('editing hide');			
2296			element.find('.guestbook-edit').parents('.list-item').find('.editing.hide').removeClass('editing hide');			
2297			$('.guestbook-edit').remove();
2298			
2299			
2300			
2301			writer = element.find('.input-name').val();
2302			content = element.find('.input-content').val();
2303			passwd = element.find('.input-pw').val();
2304			captcha = element.find('input[name="wr_key"]').val();
2305			secret = element.find('.secret-check input[type="checkbox"]').prop('checked') ? 'S' : 'N';
2306			
2307			if(PAGE_MODE != 'c' ) {
2308				if((!RENDER.b.UMEMBER.id || (RENDER.b.UMEMBER.id_type == 'creatorlink' && !RENDER.b.UMEMBER.check_adm && !RENDER.b.UMEMBER.check_adm)) && $.trim(writer) == '') {
2309					element.find('.input-name').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.name'] + '</div>');
2310					validation_flag = false;
2311				}
2312				if((!RENDER.b.UMEMBER.id || (RENDER.b.UMEMBER.id_type == 'creatorlink' && !RENDER.b.UMEMBER.check_adm && !RENDER.b.UMEMBER.check_adm)) && $.trim(passwd) == '') {
2313					element.find('.input-pw').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.passwd'] + '</div>');
2314					validation_flag = false;
2315				} else if((!RENDER.b.UMEMBER.id || (RENDER.b.UMEMBER.id_type == 'creatorlink' && !RENDER.b.UMEMBER.check_adm && !RENDER.b.UMEMBER.check_adm)) && $.trim(passwd).length < 4) {
2316					element.find('.input-pw').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.passwd.length'] + '</div>');
2317					validation_flag = false;
2318				}
2319				if(element.find('.kcaptcha-key-wrap:visible').length > 0 && $.trim(captcha) == '') {
2320					element.find('.captcha').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.captcha'] + '</div>');
2321					validation_flag = false;
2322				}
2323			}
2324			if($.trim(content) == '' || $.trim(content).length < 2) {
2325				//방명록 블럭 디자인 5,6번
2326				if (element.find('.guestbook-design5-bgcolor').is('.guestbook-design5-bgcolor') || element.hasClass('guestbook-fr-35')) {				
2327					element.find('.input-content').parent().after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.content'] + '</div>');
2328					validation_flag = false;
2329				}
2330				else{
2331					element.find('.input-content').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.content'] + '</div>');
2332					validation_flag = false;
2333				}
2334			}
2335		}
2336
2337
2338		if(!validation_flag) return false;
2339
2340		$.ajax({
2341			url:'/fm/guestbook',
2342			type:'post',
2343			dataType:'json',
2344			data:{
2345				'id' : id,
2346				'sid' : sid,
2347				'pid' : pid,
2348				'writer' : writer,
2349				'content' : content,
2350				'passwd' : hex_md5(passwd),
2351				'captcha' : captcha,
2352				'secret' : secret,
2353				'mode' : PAGE_MODE,
2354			},
2355			success:function(data) {		
2356				if(data.error) {
2357					alert(data.error);
2358				} else {	
2359					page = 1,
2360					page_num = 1,
2361					view = element.find('[data-view]').attr('data-view'),
2362					sfl = "",
2363					stx = "",
2364					scate = "";
2365
2366					$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
2367					cookie_page_num = $.cookie('forum_'+pid);
2368					$.forum.init(pid,page,view,cookie_page_num,sfl,stx,scate);
2369				}
2370			}
2371		});
2372	});
2373
2374	$(document).on('click', '.tpl-guestbook-more-menu', function(e) {
2375		if($(this).next('.tpl-guestbook-more-menu-area').length) {
2376			$('.tpl-guestbook-more-menu-area').remove();
2377			return false;
2378		}
2379		$('.tpl-guestbook-more-menu-area').remove();
2380		var html = '';
2381		html += '\
2382		<div class="tpl-guestbook-more-menu-area">\
2383		';
2384		var fm_mb_id = $(this).parents('.list-item').find('.tpl-forum-list-cont').attr('data-fm_mb_id');
2385		if((PAGE_MODE != 'c' && (RENDER.b.UMEMBER.check_adm != true && RENDER.b.UMEMBER.check_uadm != true)) || 
2386				(PAGE_MODE != 'c' && (RENDER.b.UMEMBER.check_adm == true || RENDER.b.UMEMBER.check_uadm == true) && fm_mb_id == RENDER.b.UMEMBER.id)
2387			|| (PAGE_MODE == 'c' && fm_mb_id == MB_ID)) {
2388			html += '<div data-oper="U">' + $.lang[LANG]['forum.guestbook.btn.modify'] + '</div>';
2389		}
2390		html += '\
2391			<div data-oper="D">' + $.lang[LANG]['forum.guestbook.btn.delete'] + '</div>\
2392		</div>\
2393		';
2394		var $box = $(html);
2395		$(this).after($box);
2396		var top = $(this).position().top + $(this).outerHeight();
2397		var left = $(this).position().left + $(this).outerWidth() / 2;
2398		left -= $box.outerWidth() / 2;
2399		$box.css('top', top);
2400		$box.css('left', left);
2401	});
2402
2403	$(document).on('click', '.tpl-guestbook-cancel', function(e) {
2404		$(this).parents('.list-item').find('.tpl-forum-list-cont').removeClass('editing hide');
2405		$(this).parents('.list-item').find('.tpl-guestbook-more-menu').removeClass('editing hide');
2406		$(this).parents('.list-item').find('.tpl-guestbook-more-menu-area-el2').removeClass('editing hide');
2407		$(this).parents('.list-item').find('.guestbook-edit').remove();
2408		$('.tpl-guestbook-more-menu-area-el2').css('display','');		
2409	});
2410
2411
2412	//guest book2
2413	$(document).on('click', '.tpl-guestbook-more-menu-area-el2 div', function(e) {
2414	
2415		var $cont_box = $(this).parents('.list-item').find('.tpl-forum-list-cont');		
2416		var check_text = $(this).parents('.btn-area2').parents('.list-item').find('.content').text();	
2417		var $btn = $(this);
2418		var element = $(this).parents('.element');
2419		var oper = $btn.attr('data-oper');
2420		var fm_id = $cont_box.attr('data-fm_mb_id');
2421		var id = $cont_box.attr('data-id');
2422		var element = $(this).closest('.element');
2423		var pid = element.attr('data-id');
2424		var $list_item = $btn.parents('.list-item');
2425
2426		if (element.find('.fr34').hasClass('fr34')) {
2427		var chk_delete_first = check_text.substr(1);		
2428		var chk_delete_last = chk_delete_first.slice(0, -1);
2429		}
2430
2431		var makeUpdateForm = function() {
2432			$('.guestbook-edit').remove();
2433			$('.editing.hide').removeClass('editing hide');
2434
2435			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
2436				if(typeof data.error != 'undefined' && data.error) {
2437					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2438					return false;
2439				} else {
2440					if(data.own) {
2441						$list_item.find('.tpl-guestbook-more-menu-area-el2').addClass('editing hide');
2442						var text = $.trim($cont_box.text());
2443						var button_area = element.find('.button-area').clone();						
2444						button_area.find('.tpl-guestbook-write').before('<button type="button" class="btn tpl-guestbook-cancel">' + element.find('.tpl-guestbook-cancel:first').text() + '</button>');
2445						
2446					var hasTextClass = button_area[0].classList.contains('fr34-input-height');
2447					var fr35_hasTextClass = button_area[0].classList.contains('guestfr35');
2448					if(hasTextClass === false){
2449						if(fr35_hasTextClass === true){ //forum35							
2450						var html = '\
2451							<div class="guestbook-edit">\
2452							<div class="textarea-wrap-error" style="position:relative;">\
2453								<textarea class="input-content form-control input-bg-opacity keyup-check" style="height: 91px;"maxlength="300" ></textarea><div class="textcount edit-text-check" style="position: absolute;right:63px;top:63px;">'+check_text.length+'/300</div>\
2454								</div>\
2455								' + button_area.outerHTML() + '\
2456							</div>\
2457						';	
2458						}else{//forum29,32,33
2459							
2460						var html = '\
2461							<div class="guestbook-edit">\
2462								<textarea class="input-content form-control input-bg-opacity"></textarea>\
2463								' + button_area.outerHTML() + '\
2464							</div>\
2465						';}
2466					}else if(fr35_hasTextClass === false ){//forum34
2467
2468						var html = '\
2469							<div class="guestbook-edit">\
2470								<div class="textarea-wrap-error " style="position:relative;">\
2471								<textarea class="input-content form-control input-bg-opacity keyup-check" style="height:140px;" maxlength="300"></textarea><div class="textcount edit-text-check" >'+chk_delete_last.length+'/300</div>\
2472								</div>\
2473								' + button_area.outerHTML() + '\
2474							</div>\
2475						';						
2476						text = text.replace(/^"*/,"").replace(/"*$/,"");
2477					} 
2478					var $html = $(html);
2479						$cont_box.before($html);
2480						$html.find('.input-content').val(text);
2481						if(data.option == 'S') $cont_box.prev('.guestbook-edit').find('.secret-check input[type="checkbox"]').prop('checked', true);
2482						$cont_box.prev('.guestbook-edit').find('.tpl-guestbook-write').attr('data-id', id);
2483						$cont_box.addClass('editing hide');
2484					}
2485					var header_check = $("header").attr("data-fh-type");										
2486					 var editor_height = ( $(".editor-navbar").hasClass("editor-navbar")) ? $(".editor-navbar").outerHeight(true) : 0 ;
2487					
2488					
2489
2490					if (header_check != "sidebar") { 
2491						var header_height = $("header").outerHeight(true); 
2492					}else{
2493						var header_height = 0;
2494					}
2495					
2496					
2497					if ( PAGE_MODE == ('c')) {						
2498						$('.dsgn-body').scrollTop($('.dsgn-body').scrollTop() + $cont_box.closest('.list-item').offset().top  - editor_height - header_height );
2499								
2500					} else if (PAGE_MODE == ('s')) {							
2501						//$(document).scrollTop($(document).scrollTop() + $cont_box.closest('.list-item').offset().top  -  header_height );
2502						$(document).scrollTop ($cont_box.closest('.list-item').offset().top - header_height - 200 )
2503						
2504					}	
2505							
2506				}
2507			}, 'json');
2508		};
2509
2510		if(oper == 'D') { // 삭제
2511			if(PAGE_MODE == 'c' || RENDER.b.UMEMBER.check_adm == true || RENDER.b.UMEMBER.check_uadm == true) {
2512				var modal = $(this).showModalFlat('', $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
2513					modal.modal('hide');
2514					deleteGuestbook(pid, id);
2515				}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');
2516			} else {
2517				$.forum.deleteGuestbook(pid, id);
2518			}
2519		} else if(oper == 'U') { // 수정
2520			if(PAGE_MODE == 'c' || (PAGE_MODE != 'c' && fm_id != '' && fm_id == RENDER.b.UMEMBER.id)) {
2521				makeUpdateForm();
2522			} else {
2523
2524				var modal = $(this).showModalFlat($.lang[LANG]['forum.guestbook.title.edit'], passwdForm(), true, true, function() {
2525					var $pass = $('#comm-pass'),
2526						isSubmit = true;
2527					$('label.error').remove();
2528					if($pass.val().length<4) {
2529						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2530						$pass.closest('.cl-s-form-wrap').addClass('error');
2531						$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13">
2531<path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
2532						$pass.focus();
2533						isSubmit = false;
2534					}
2535
2536					if(isSubmit) {
2537						//$('.comment-addform.password').parent().find('.error').remove();
2538						$('.comment-addform.password').removeClass('error');
2539						$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()) }, function(data) {
2540							if(typeof data.error != 'undefined' && data.error) {
2541								//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
2542								$pass.closest('.cl-s-form-wrap').addClass('error');
2543								$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
2544								return false;
2545							}
2546							var date = new Date(),
2547								cookietime = 20 * 60 * 1000;
2548							date.setTime(date.getTime() + cookietime);
2549							
2550							$.removeCookie('checkPostHighWriter',{path:'/'});
2551							$.cookie('checkPostWriter', id, { path: '/' , expires: date});
2552							$.cookie('hash', data.hash, { path: '/' , expires: date});
2553							$('.modal[id*=flat-modal]').modal('hide');
2554
2555							
2556							makeUpdateForm();
2557						},'json');
2558					}
2559					modalEmptyCheck();
2560					
2561				}, 'cancel', 'ok','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
2562					modal.find('#comm-pass').addClass('guestbook-pass');
2563				});
2564				
2565			}
2566		}
2567		// $(this).parents('.tpl-guestbook-more-menu-area-el2').css('display','none');
2568	});
2569
2570
2571
2572
2573	$(document).on('click', '.tpl-guestbook-more-menu-area div', function(e) {
2574		var $cont_box = $(this).parents('.list-item').find('.tpl-forum-list-cont');
2575		var $btn = $(this);
2576		var element = $(this).parents('.element');
2577		var oper = $btn.attr('data-oper');
2578		var fm_id = $cont_box.attr('data-fm_mb_id');
2579		var id = $cont_box.attr('data-id');
2580		var element = $(this).closest('.element');
2581		var pid = element.attr('data-id');
2582		var $list_item = $btn.parents('.list-item');
2583		var makeUpdateForm = function() {
2584			$('.guestbook-edit').remove();
2585			$('.editing.hide').removeClass('editing hide');
2586
2587			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
2588				if(typeof data.error != 'undefined' && data.error) {
2589					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2590					return false;
2591				} else {
2592					if(data.own) {
2593						$list_item.find('.tpl-guestbook-more-menu').addClass('editing hide');
2594						var text = $.trim($cont_box.text());
2595						var button_area = element.find('.button-area').clone();
2596						
2597						button_area.find('.tpl-guestbook-write').before('<button type="button" class="btn tpl-guestbook-cancel">' + element.find('.tpl-guestbook-cancel:first').text() + '</button>');
2598
2599						$cont_box.before(`
2600							<div class="guestbook-edit">
2601								<textarea class="input-content form-control ${(element.hasClass('versioncheck')) ? 'input-bg-opacity' : ''}">${text}</textarea>
2602								${button_area.outerHTML()}
2603							</div>
2604						`);
2605						if(data.option == 'S') $cont_box.prev('.guestbook-edit').find('.secret-check input[type="checkbox"]').prop('checked', true);
2606						$cont_box.prev('.guestbook-edit').find('.tpl-guestbook-write').attr('data-id', id);
2607						$cont_box.addClass('editing hide');
2608					}
2609				}
2610			}, 'json');
2611		};
2612
2613		if(oper == 'D') { // 삭제
2614			if(PAGE_MODE == 'c' || RENDER.b.UMEMBER.check_adm == true || RENDER.b.UMEMBER.check_uadm == true) {
2615				var modal = $(this).showModalFlat('', $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
2616					modal.modal('hide');
2617					deleteGuestbook(pid, id);
2618				}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');
2619			} else {
2620				$.forum.deleteGuestbook(pid, id);
2621			}
2622		} else if(oper == 'U') { // 수정
2623			if(PAGE_MODE == 'c' || (PAGE_MODE != 'c' && fm_id != '' && fm_id == RENDER.b.UMEMBER.id)) {
2624				makeUpdateForm();
2625			} else {
2626
2627				var modal = $(this).showModalFlat($.lang[LANG]['forum.guestbook.title.edit'], passwdForm(), true, true, function() {
2628					var $pass = $('#comm-pass'),
2629						isSubmit = true;
2630					$('label.error').remove();
2631					if($pass.val().length<4) {
2632						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2633						$pass.closest('.cl-s-form-wrap').addClass('error');
2634						$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13">
2634<path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
2635						$pass.focus();
2636						isSubmit = false;
2637					}
2638
2639					if(isSubmit) {
2640						//$('.comment-addform.password').parent().find('.error').remove();
2641						$('.comment-addform.password').removeClass('error');
2642						$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()) }, function(data) {
2643							if(typeof data.error != 'undefined' && data.error) {
2644								//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
2645								$pass.closest('.cl-s-form-wrap').addClass('error');
2646								$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
2647								return false;
2648							}
2649							var date = new Date(),
2650								cookietime = 20 * 60 * 1000;
2651							date.setTime(date.getTime() + cookietime);
2652
2653							$.removeCookie('checkPostHighWriter',{path:'/'});
2654							$.cookie('checkPostWriter', id, { path: '/' , expires: date});
2655							$.cookie('hash', data.hash, { path: '/' , expires: date});
2656							$('.modal[id*=flat-modal]').modal('hide');
2657
2658							
2659							makeUpdateForm();
2660						},'json');
2661					}
2662					modalEmptyCheck();
2663					
2664				}, 'cancel', 'ok','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
2665					modal.find('#comm-pass').addClass('guestbook-pass');
2666				});
2667			}
2668		}
2669		$(this).parents('.tpl-guestbook-more-menu-area').remove();
2670	});
2671
2672	$(document).on('click', '[data-type="forum"] .list-item.blind', function(e) {
2673		e.preventDefault();
2674		e.stopPropagation();
2675		var $list_item = $(this);
2676		var $cont_box = $(this).find('.tpl-forum-list-cont');
2677		var element = $(this).parents('.element');
2678		var fm_id = $cont_box.attr('data-fm_mb_id');
2679		var id = $cont_box.attr('data-id');
2680		var element = $(this).closest('.element');
2681		var pid = element.attr('data-id');
2682
2683		var modal = $(this).showModalFlat($.lang[LANG]['forum.guestbook.title.secret'], passwdForm(), true, true, function() {
2684			var $pass = $('#comm-pass'),
2685				isSubmit = true;
2686			$('label.error').remove();
2687			if($pass.val().length<4) {
2688				//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2689				$pass.closest('.cl-s-form-wrap').addClass('error');
2690				$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
2691				$pass.focus();
2692				isSubmit = false;
2693			}
2694
2695			if(isSubmit) {
2696				//$('.comment-addform.password').parent().find('.error').remove();
2697				$('.comment-addform.password').removeClass('error');
2698				$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()) }, function(data) {
2699					if(typeof data.error != 'undefined' && data.error) {
2700						//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
2701						$pass.closest('.cl-s-form-wrap').addClass('error');
2702						$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>
2702'+data.error+'</label>');
2703						return false;
2704					}
2705					var date = new Date(),
2706						cookietime = 20 * 60 * 1000;
2707					date.setTime(date.getTime() + cookietime);
2708					
2709					$.removeCookie('checkPostHighWriter',{path:'/'});
2710					$.cookie('checkPostWriter', id, { path: '/' , expires: date});
2711					$.cookie('hash', data.hash, { path: '/' , expires: date});
2712
2713					$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
2714						if(typeof data.error != 'undefined' && data.error) {
2715							$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2716							return false;
2717						} else {
2718							$cont_box.html(nl2br(data.content));
2719							$list_item.removeClass('blind');
2720							$list_item.find('.tpl-guestbook-more-menu').removeClass('hide');
2721							$list_item.find('.tpl-guestbook-more-menu-area-el2').removeClass('hide');
2722						}
2723					}, 'json');
2724
2725
2726					$('.modal[id*=flat-modal]').modal('hide');
2727
2728				},'json');
2729			}
2730			modalEmptyCheck();
2731			
2732		}, 'cancel', 'ok','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
2733			modal.find('#comm-pass').addClass('guestbook-pass');
2734		});
2735	});
2736
2737	$(document).on('click', function(e) {
2738		var container = $('.tpl-guestbook-more-menu-area');
2739		if(container.has(e.target).length == 0 && container.get(0) != e.target && $('.tpl-guestbook-more-menu').has(e.target).length == 0 && !$(e.target).hasClass('tpl-guestbook-more-menu')) {
2740			container.hide();
2741			//버그수정
2742			container.remove();
2743
2744		}
2745
2746		if($('.search-forum-user-posts').length > 0 && !$(e.target).is('.tpl-forum-list-name')) {
2747			$('.tpl-forum-list-name').removeClass('search-on');
2748			$('.search-forum-user-posts').remove();
2749		}
2750	});
2751	$(document).on('keyup keydown','.keyup-check',function(e) {	
2752	if (e.keyCode == 13) {e.preventDefault();} 
2753		var content = $(this).val();
2754          $($(this).next('.textcount, .textarea-height')).text(""+ content.length + "/300");
2755        if (content.length >= 300) {
2756        	$(this).val($(this).val().substring(0, 300)); 
2757         	$($(this).next('.textcount,.textarea-height')).text(""+ "300" + "/300");   
2758         } 
2759	});
2760	$(document).on('click','.tpl-forum-write',function(e) {
2761		var sid = (typeof property == 'undefined') ? SID : property.SID;
2762		var pid = $(this).attr('data-pid');
2763		var id = (typeof $(this).attr('data-id') != 'undefined') ? $(this).attr('data-id') : '';
2764		var reply = (typeof $(this).attr('data-reply') != 'undefined') ? $(this).attr('data-reply') : '';
2765		var one = (typeof ONE == 'undefined') ? property.ONE : ONE;
2766		var page = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
2767
2768		try {
2769			var validType = property['VALIDTYPE'];
2770		} catch (err) {
2771			var validType = '';
2772		}
2773
2774		var idstr = (id) ? '/m/u/id/' + id : '';
2775		var replystr = (reply) ? '/reply/' + reply : '';
2776
2777		if(id) {
2778			updateForumPost(id,pid);
2779			return false;
2780		}
2781
2782		var url = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
2783		var is_new = (id != '') ? 'false' : 'true';
2784		$.post('/fm/checkUser', { pid : pid, reply : reply, id : id, isnew : is_new }, function(data) {
2785			if(!data.user || typeof data.user == 'undefined') {
2786				if(typeof data.error != 'undefined' && data.error) {
2787					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2788					return false;
2789				}
2790				
2791				var base_url = (PAGE_MODE=='s') ? '/' : '/render/';
2792				if(PAGE_MODE == 'c') {
2793					base_url = '/'+CONFIG_URL+'config/page/'
2794				}
2795
2796				var page_url = (one) ? base_url + 'index#' + page : base_url + page;
2797				var action = (validType == 'SM') ? '/_login' : '/_cllogin',
2798					html = '\
2799						<form name="write_login_form" id="write_login_form" method="post" action="' + action + '" style="display:none;">\
2800							<input type="hidden" name="status" value="write">\
2801							<input type="hidden" name="sid" value="'+sid+'">\
2802							<input type="hidden" name="type" value="F">\
2803							<input type="hidden" name="pid" value="'+pid+'">\
2804							<input type="hidden" name="page_url" value="'+page_url+'">\
2805							<input type="hidden" name="page_mode" value="'+data.access+'">\
2806							<input type="hidden" name="url" value="'+url+'">\
2807							<input type="hidden" name="reply" value="'+reply+'">\
2808							<input type="hidden" name="id" value="'+id+'">\
2809						</form>\
2810					';
2811
2812				$('body').append(html);
2813				document.write_login_form.submit();
2814
2815				/*
2816				if (validType == 'SM') {
2817					var html = '<form name="write_login_form" id="write_login_form" method="post" action="/_login" style="display:none;">\
2818									<input type="hidden" name="status" value="write">\
2819									<input type="hidden" name="url" value="'+url+'">\
2820									<input type="hidden" name="pid" value="'+pid+'">\
2821									<input type="hidden" name="pid_type" value="forum">\
2822									<input type="hidden" name="reply" value="'+reply+'">\
2823									<input type="hidden" name="id" value="'+id+'">\
2824									<input type="hidden" name="page_mode" value="'+data.access+'">\
2825								</form>';
2826
2827					$('body').append(html);
2828					document.write_login_form.submit();
2829				} else {
2830					// FREE or BN login
2831					var html = '<form name="write_cllogin_form" id="write_cllogin_form" method="post" action="/_cllogin" style="display:none;">\
2832									<input type="hidden" name="status" value="write">\
2833									<input type="hidden" name="sid" value="'+F_SID+'">\
2834									<input type="hidden" name="url" value="'+url+'">\
2835									<input type="hidden" name="pid" value="'+pid+'">\
2836									<input type="hidden" name="pid_type" value="forum">\
2837									<input type="hidden" name="reply" value="'+reply+'">\
2838									<input type="hidden" name="id" value="'+id+'">\
2839									<input type="hidden" name="page_mode" value="'+data.access+'">\
2840								</form>';
2841
2842					$('body').append(html);
2843					document.write_cllogin_form.submit();
2844				}
2845				*/
2846
2847			} else { //login user
2848				if(data.writeable == false) {
2849					var access = data.access;
2850					var message = 'error';
2851					
2852					switch (access) {
2853						// case 'NM':
2854						// 	message = $.lang[LANG]['board.nonmembers-can-write'];
2855						// 	break;
2856						case 'G':
2857							message = $.lang[LANG]['board.group-can-write'];
2858							break;
2859						case 'ADM':
2860							message = $.lang[LANG]['board.admin-can-write'];
2861							break;
2862						default:
2863							break;
2864					}
2865
2866					$(this).showModalFlat('INFORMATION', message, true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
2867					return false;
2868				}
2869				setWriteUser(data, function() {
2870					location.href = url;
2871				});
2872			}
2873		},'json');
2874//asdf
2875
2876
2877	
2878				// return false;
2879
2880
2881				// var modal_str = signForm(id,pid,data.access,data.stoken);
2882				// if(typeof modal_str != 'string') return false;
2883				// var modal = $(this).showModalFlat($.lang[LANG]['config.postforum'],modal_str,true,true,function() {
2884
2885				// 	var isSubmit = true;
2886				// 	//$('.error').remove();
2887				// 	var $name = $('#comm-name'),
2888				// 		$pass = $('#comm-pass'),
2889				// 		$key = $('#wr_key'),
2890				// 		nameLength = getBytes( $name.val() );
2891
2892				// 	$('.kcaptcha-error').remove();
2893				// 	$('label.error').remove();
2894
2895				// 	if( nameLength==0) {
2896				// 		//$name.after('<label class="error">' +  $.lang[LANG]['config.enter-name'] + '</label>').focus();
2897				// 		$name.closest('.cl-s-form-wrap').addClass('empty');
2898				// 		$name.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.enter-name']+'</label>');
2899				// 		isSubmit = false;
2900				// 	}
2901				// 	else if ( nameLength > 20 ) {
2902				// 		//$name.after('<label class="error">' +  $.lang[LANG]['config.guest-id-max-length'] + '</label>').focus();
2903				// 		$name.closest('.cl-s-form-wrap').addClass('empty');
2904				// 		$name.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.guest-id-max-length']+'</label>');
2905				// 		isSubmit = false;
2906				// 	}
2907				// 	if($pass.val().length<4) {
2908				// 		//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2909				// 		$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
2910				// 		$pass.closest('.cl-s-form-wrap').addClass('empty');
2911				// 		isSubmit = false;
2912				// 	}
2913				// 	// if($('#recaptcha').attr('data-res')=='') {
2914				// 	// 	$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
2915				// 	// 	isSubmit = false;
2916				// 	// }
2917
2918				// 	if($key.val().length==0) {
2919				// 		//$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
2920				// 		$key.closest('.kcaptcha-box').addClass('empty');
2921				// 		$key.closest('.kcaptcha-box').after('<label class="error kcaptcha-error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2922				// 		isSubmit = false;
2923				// 	}
2924
2925				// 	if($key.val() && (Base64.encode($key.val().trim()) != md5_norobot_key)) {
2926				// 		//$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2927				// 		$key.closest('.kcaptcha-box').addClass('error');
2928				// 		$key.closest('.kcaptcha-box').after('<label class="error kcaptcha-error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2929				// 		// console.log('input value :' + $key.val());
2930				// 		// console.log('hex_md5 : ' + Base64.encode($key.val().trim()));
2931				// 		// console.log('key : ' + md5_norobot_key);
2932				// 		isSubmit = false;
2933				// 	}
2934
2935				// 	// var key = '';
2936				// 	// if(isSubmit == true) {
2937				// 	// 	key = checkCaptcha();
2938				// 	// 	if(!key.success) {
2939				// 	// 		$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2940				// 	// 		isSubmit = false;
2941				// 	// 	}
2942				// 	// }
2943
2944				// 	modalEmptyCheck();
2945
2946				// 	if($('.tab-pane.active .empty, .tab-pane.active .error').length > 0) {
2947				// 		$('.tab-pane.active .empty').find('input').eq(0).focus();
2948				// 		isSubmit = false;
2949				// 		return false;
2950				// 	}
2951
2952
2953				// 	resetObject(user);
2954				// 	if(isSubmit==true) {
2955				// 		$('.modal[id*=flat-modal]').modal('hide');
2956				// 		user.name = data.name = $name.val();
2957				// 		user.nameLength = nameLength;
2958				// 		user.pass = hex_md5( $pass.val() );
2959				// 		user.key = $key.val().trim();
2960				// 		setWriteUser(data,function() {
2961				// 			location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
2962				// 			// forumWrite(id,pid,reply);
2963				// 		});
2964				// 	}
2965				// },'cancel','','cl-modal cl-cmmodal cl-p130 cl-s-btn cl-close-btn w560 block-write','','',function() {
2966				// 	// loadCaptcha();
2967				// 	load_kcaptcha();
2968				// });
2969				// $('.flat-modal .modal-body').addClass('comment');
2970				// $('body').addClass('no-fixed');
2971				// if($('.flat-modal .modal-body .comment-signForm').hasClass('default-mode') || $('.flat-modal .modal-body .comment-signForm').hasClass('sitemember-mode')) 
2972				// 	$('.flat-modal .modal-footer').hide();
2973				// // $('#kcaptcha').click();
2974
2975	});
2976
2977	// $(document).on('click','.tpl-forum-write, .tpl-toolbar-question-edit',function(e) {
2978	$(document).off('click', '.tpl-toolbar-question-edit').on('click','.tpl-toolbar-question-edit',function(e) {
2979		var id = $(this).attr('data-id'),
2980			pid = $(this).attr('data-pid'),
2981			reply = $(this).attr('data-reply');
2982		try {
2983			var validType = property['VALIDTYPE'];
2984		} catch (err) {
2985			var validType = '';
2986		}
2987		
2988		id = (typeof id == 'undefined') ? '' : id;
2989		reply = (typeof reply == 'undefined') ? '' :reply;
2990
2991		var idstr = (id) ? '/m/u/id/' + id : '',
2992			replystr = (reply) ? '/reply/' + reply : '';
2993
2994		if(reply) {
2995			idstr = '';
2996			// location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
2997			// return false;
2998		}
2999		// location.href = '/post/t/' + F_MODE + idstr + '/pid/' + pid + replystr;
3000
3001		if(id && !reply) {
3002			updateForumPost(id,pid);
3003			return false;
3004		}
3005
3006		$.post('/fm/checkUser', { pid : pid, reply : reply, id : id }, function(data) {
3007			if(!data.user || typeof data.user == 'undefined') {
3008				if(typeof data.error != 'undefined' && data.error) {
3009					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
3010					return false;
3011				}
3012
3013				if (validType == 'SM') {
3014					var url = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
3015					var status = 'write';
3016
3017					var html = '<form name="write_login_form" id="write_login_form" method="post" action="/_login" style="display:none;">\
3018									<input type="hidden" name="status" value="'+status+'">\
3019									<input type="hidden" name="url" value="'+url+'">\
3020									<input type="hidden" name="pid" value="'+pid+'">\
3021									<input type="hidden" name="page_mode" value="'+data.access+'">\
3022									<input type="hidden" name="reply" value="'+reply+'">\
3023									<input type="hidden" name="id" value="'+id+'">\
3024								</form>';
3025
3026					$('body').append(html);
3027					document.write_login_form.submit();
3028					return false;
3029				}
3030
3031				var modal_str = signForm(id,pid,data.access,data.stoken);
3032				if(typeof modal_str != 'string') return false;
3033				var modal = $(this).showModalFlat($.lang[LANG]['config.postforum'],modal_str,true,true,function() {
3034
3035					var isSubmit = true;
3036					//$('.error').remove();
3037					var $name = $('#comm-name'),
3038						$pass = $('#comm-pass'),
3039						$key = $('#wr_key'),
3040						nameLength = getBytes( $name.val() );
3041
3042					$('.kcaptcha-error').remove();
3043					$('label.error').remove();
3044
3045					if( nameLength==0) {
3046						//$name.after('<label class="error">' +  $.lang[LANG]['config.enter-name'] + '</label>').focus();
3047						$name.closest('.cl-s-form-wrap').addClass('empty');
3048						$name.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.enter-name']+'</label>');
3049						isSubmit = false;
3050					}
3051					else if ( nameLength > 20 ) {
3052						//$name.after('<label class="error">' +  $.lang[LANG]['config.guest-id-max-length'] + '</label>').focus();
3053						$name.closest('.cl-s-form-wrap').addClass('empty');
3054						$name.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.guest-id-max-length']+'</label>');
3055						isSubmit = false;
3056					}
3057					if($pass.val().length<4) {
3058						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
3059						$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
3060						$pass.closest('.cl-s-form-wrap').addClass('empty');
3061						isSubmit = false;
3062					}
3063					// if($('#recaptcha').attr('data-res')=='') {
3064					// 	$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
3065					// 	isSubmit = false;
3066					// }
3067
3068					if($key.val().length==0) {
3069						//$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
3070						$key.closest('.kcaptcha-box').addClass('empty');
3071						$key.closest('.kcaptcha-box').after('<label class="error kcaptcha-error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
3072						isSubmit = false;
3073					}
3074
3075					if($key.val() && (Base64.encode($key.val().trim()) != md5_norobot_key)) {
3076						//$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
3077						$key.closest('.kcaptcha-box').addClass('error');
3078						$key.closest('.kcaptcha-box').after('<label class="error kcaptcha-error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
3079						// console.log('input value :' + $key.val());
3080						// console.log('hex_md5 : ' + Base64.encode($key.val().trim()));
3081						// console.log('key : ' + md5_norobot_key);
3082						isSubmit = false;
3083					}
3084
3085					// var key = '';
3086					// if(isSubmit == true) {
3087					// 	key = checkCaptcha();
3088					// 	if(!key.success) {
3089					// 		$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
3090					// 		isSubmit = false;
3091					// 	}
3092					// }
3093
3094					modalEmptyCheck();
3095
3096					if($('.tab-pane.active .empty, .tab-pane.active .error').length > 0) {
3097						$('.tab-pane.active .empty').find('input').eq(0).focus();
3098						isSubmit = false;
3099						return false;
3100					}
3101
3102
3103					resetObject(user);
3104					if(isSubmit==true) {
3105						$('.modal[id*=flat-modal]').modal('hide');
3106						user.name = data.name = $name.val();
3107						user.nameLength = nameLength;
3108						user.pass = hex_md5( $pass.val() );
3109						user.key = $key.val().trim();
3110						setWriteUser(data,function() {
3111							location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
3112							// forumWrite(id,pid,reply);
3113						});
3114					}
3115				},'cancel','','cl-modal cl-cmmodal cl-p130 cl-s-btn cl-close-btn w560 block-write','','',function() {
3116					// loadCaptcha();
3117					load_kcaptcha();
3118				});
3119				$('.flat-modal .modal-body').addClass('comment');
3120				$('body').addClass('no-fixed');
3121				if($('.flat-modal .modal-body .comment-signForm').hasClass('default-mode') || $('.flat-modal .modal-body .comment-signForm').hasClass('sitemember-mode')) 
3122					$('.flat-modal .modal-footer').hide();
3123				// $('#kcaptcha').click();
3124			} else {
3125				// resetObject(user);
3126
3127				setWriteUser(data, function() {
3128					location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
3129					// forumWrite(id,pid,reply);
3130				});
3131			}
3132		},'json');
3133	});
3134
3135	$(document).off('click', '.tpl-forum-list').on('click','.tpl-forum-list',function(e) {
3136		// $.cookie('gallery','.' + F_PARENT.element, { path: '/' });
3137		$.cookie('forum-item',F_PARENT.pid, { path: '/' });
3138		
3139		if(PAGE_MODE != 'c') {
3140			var url = (PAGE_MODE=='s') ? '/' : '/render/',
3141				uri = (F_ONE) ? url + 'index#' + F_PARENT.page : url + F_PARENT.page;
3142
3143			var hash = uri.split('#');
3144			if(hash.length>1) {
3145				RENDER.history.pushState(null,property.TITLE,hash[0]);
3146				history.pushState('', '', hash[0] + '#' + hash[1]);
3147			} else {
3148				RENDER.history.pushState(null,property.TITLE,uri);
3149			}
3150			// (F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);	
3151			// (F_ONE) ? location.replace('/' + url + '/index#') + F_PARENT.page : location.replace('/' + url + '/' + F_PARENT.page);	
3152		} else {
3153			(F_ONE) ? location.replace('/'+CONFIG_URL+'config/page/index#') + F_PARENT.page : location.replace('/'+CONFIG_URL+'config/page/' + F_PARENT.page);
3154		}
3155	});
3156
3157	$(document).off('click', '.tpl-forum-delete').on('click','.tpl-forum-delete',function(e) {
3158		var id = $(this).attr('data-id');
3159		// if($('.cm-row ').length >= 1) {
3160			$.forum.delete(id);			
3161		// } else {
3162			// var modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
3163			// modal.modal('hide');
3164			// $.forum.delete(id);			
3165			// }, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');
3166		// }
3167	});
3168
3169	$(document).off('click', '.tpl-forum-page').on('click','.tpl-forum-page', function(e) {
3170		e.preventDefault();
3171		if($(this).closest('.element').find('[data-loop="true"]').hasClass('sample-loop')) return false;
3172		var id = $(this).attr('data-id'),
3173			page = $(this).attr('data-page'),
3174			page_num = $(this).attr('data-page-num'),
3175			view = $(this).attr('data-view'),
3176			forum_el = $(this).closest('.element'),
3177			sfl = $.cookie('forum_' + id + '_prev_sfl') ? $.cookie('forum_' + id + '_prev_sfl') : "",
3178			stx = getForumPrevStx(id),
3179			scate = getForumScate(forum_el);
3180		
3181		var regexp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+┼<>@\#$%&\'\"\\\(\=“‘,]/gi;
3182		if(regexp.test(stx) || regexp.test(scate)) {
3183			$(this).showModalFlat('ERROR', '특수문자를 입력할 수 없습니다.', true , false, '', 'close');
3184			return false;
3185		}
3186
3187		if($(forum_el).find('input[name="user_stx"]').length > 0 && $(forum_el).find('input[name="user_sfl"]').length > 0) {
3188			stx = $(forum_el).find('input[name="user_stx"]').val();
3189			sfl = $(forum_el).find('input[name="user_sfl"]').val();
3190		}
3191		
3192		$.forum.setForumCookie(id,page_num,stx,sfl,scate);
3193		cookie_page_num = $.cookie('forum_'+id);
3194		
3195		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
3196		activeEL('userEL'+id);
3197	});
3198
3199	$(document).on('click','.forum-login',function(e) {
3200
3201		var forumLoginModal = $(this).closest('.modal'),
3202			id = $(this).attr('data-id'),
3203			pid = $(this).attr('data-pid'),
3204			F_SERVICE = (typeof SERVICE == 'undefined') ? property.SERVICE : SERVICE,
3205			F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE,
3206			F_SITEUM = (typeof SITEUM == 'undefined') ? property.SITEUM : SITEUM,
3207			isGabia = (F_SERVICE.indexOf('gabia') > -1) ? true : false,
3208			login_type = (isGabia || F_VALIDTYPE=='SM' || (F_VALIDTYPE=='BN' && F_SITEUM > 0)) ? 'um' : 'mb';
3209
3210		$('.comment .error').remove();
3211
3212		var $input_id = $('#'+login_type+'_forum_id'),
3213			$input_password = $('#'+login_type+'_forum_password'),
3214			isSubmit = true,
3215			idErrorTxt = (isGabia || F_VALIDTYPE=='SM' || (F_VALIDTYPE=='BN' && F_SITEUM > 0)) ? $.lang[LANG]['config.enter-id'] : $.lang[LANG]['config.enter-email'];
3216
3217		if($input_id.val().length==0) {
3218			//$input_id.after('<label class="error">! ' +  $.lang[LANG]['config.enter-id'] + '</label>').focus();
3219			//$input_id.closest('.cl-s-form-wrap').addClass('empty');
3220			$input_id.closest('.cl-s-form-wrap').addClass('empty');
3221			$input_id.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+idErrorTxt+'</label>');
3222			isSubmit = false;
3223		}
3224
3225		if($input_password.val().length==0) {
3226			//$input_password.after('<label class="error">! ' +  $.lang[LANG]['config.enter-password'] + '</label>').focus();
3227			//$input_password.closest('.cl-s-form-wrap').addClass('empty');
3228			$input_password.closest('.cl-s-form-wrap').addClass('empty');
3229			$input_password.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.enter-password']+'</label>');
3230			isSubmit = false;
3231		}
3232
3233		modalEmptyCheck();
3234
3235		if($('.tab-pane.active .empty, .tab-pane.active .error').length > 0) {
3236			$('.tab-pane.active .empty').find('input').eq(0).focus();
3237			isSubmit = false;
3238			return false;
3239		}
3240
3241		if(isSubmit) {
3242			var sid = (typeof MODE == 'undefined') ? '' : SID; //config outlogin limit
3243			var login_success_fnc = function() {
3244				$('button.close').click();
3245				if(RELOAD) {
3246					// $.cookie('gallery','.' + F_PARENT.element, { path: '/' });
3247					location.reload();
3248				}
3249				if(typeof MODE == 'undefined') RENDER.setLoginout(property.LOGINOUT, property.SID, 1, property.PROFILEIMG);
3250				//forumWrite(id,pid);
3251			}
3252
3253			if(login_type == 'mb') {
3254				$.post('/member/login/outlogin', { mb_id : $input_id.val(), mb_password : $input_password.val(), sid : sid}, function(data) {
3255					if(typeof data.error != 'undefined' && data.error) {
3256						$('.tab-pane.active').find('.bottom-box.text-right').before('<label class="error text-center error_login"><svg viewBox="0 0 13 13" width="13" height="13">
3256<path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg><span>' + data.error + '</span></label>');
3257						$('.cl-s-form-group input').val('');
3258						$('.tab-pane.active').find('.cl-s-form-wrap').addClass('empty');
3259						return false;
3260					}
3261					login_success_fnc();
3262				}, 'json');
3263
3264			} else {
3265
3266				var input_data = {
3267					'id' : $input_id.val().toLowerCase(),
3268					'password' : hex_md5($input_password.val()),
3269				};
3270
3271				$.post('/umember/login/in', { sid : sid, data : JSON.stringify(input_data) }, function(data) {
3272
3273					if (typeof data.result != 'undefined' && data.result == 'fail') {
3274						alert(data.message);
3275						return false;
3276					} else {
3277						$.umember.init();
3278						login_success_fnc();
3279
3280						if(typeof data.result != 'undefined' && data.result == 'success') {
3281							if(typeof data.ss_url != 'undefined' && data.ss_url) {
3282								$.each(data.ss_url, function(i,url) {
3283									$('.dsgn-body').after('<img class="auth-img" src="' + ss_url + '">');
3284								});
3285							}
3286
3287							if(typeof data.ga_uid != 'undefined' && data.ga_uid) {
3288								localStorage.setItem('googleAnalyticsUID'+sid, data.ga_uid);
3289							}
3290						}
3291					}
3292					/*
3293					if(typeof data.error != 'undefined' && data.error) {
3294						$.each(data.error, function(key,str) {
3295							if(forumLoginModal.find('#um_forum_'+key).length > 0 ) {
3296								forumLoginModal.find('#um_forum_'+key).after('<span class="error">' + str + '</span>');
3297							} else { 
3298								$('.comment-signForm').after("<label class='error text-center'>" + str + "</label>"); 
3299							}
3300						});
3301						if(forumLoginModal.find('.error').length > 0) return false;
3302					}
3303
3304					$.umember.init();
3305					login_success_fnc();
3306
3307					if(data.member.check_login) {
3308						if(typeof data.ss_url != 'undefined' && data.ss_url) {
3309							$.each(data.ss_url, function(i,url) {
3310								$('.dsgn-body').after('<img class="auth-img" src="' + ss_url + '">');
3311							});
3312						}
3313					}
3314					*/					
3315
3316				},'json');
3317
3318			}
3319		}
3320	});	
3321
3322	$doc.off('click', '[data-loop]:not(.sample-loop) .tpl-forum-list-name:not(.namemask)')
3323		.on('click', '[data-loop]:not(.sample-loop) .tpl-forum-list-name:not(.namemask)', function(e){
3324		e.stopPropagation();
3325		
3326		var parentEl = $(this).parents('.element');
3327		if(parentEl.attr('data-type') != 'forum' || parentEl.attr('data-type2') == 'guestbook') return false;
3328
3329		var userid = ($(this).attr('data-userid') !== undefined)? $(this).attr('data-userid') : '';
3330		var username = $(this).contents().filter(function() {
3331					return this.nodeType === 3; // 텍스트 노드만 선택
3332				}).text().trim();
3333		var langClass = (LANG == 'ko')? 'ko':'en';
3334		// console.log(userid);
3335		if($(this).hasClass('search-on')) {
3336			$('.tpl-forum-list-name').removeClass('search-on');
3337			$('.search-forum-user-posts').remove();
3338		} else {
3339			$('.tpl-forum-list-name').removeClass('search-on');
3340			$('.search-forum-user-posts').remove();
3341			$(this).addClass('search-on');
3342			var searchBox = '<div class="search-forum-user-posts tpl-forum-list-etc '+langClass+'" data-userid="'+userid+'" data-username="'+username+'"><span>'+$.lang[LANG]['board.search.user.posts']+'</span></div>';
3343
3344			var text = $(this).text().trim();
3345			var fontSize = parseFloat($(this).css("font-size"));
3346			
3347			var span = $('<span>').css({
3348				'display': 'inline-block',
3349				'font-family': $(this).css('font-family'),
3350				'font-size': fontSize + 'px',
3351				'font-weight': $(this).css('font-weight'),
3352				'visibility': 'hidden'
3353			}).text(text);
3354
3355			// 가상 요소를 body에 추가한 후, 너비를 가져오기
3356			$('body').append(span);
3357			var textWidth = parseFloat(span.width());
3358			// 가상 요소 삭제하기
3359			span.remove();
3360
3361			var textHeight = parseFloat($(this).css("line-height"));
3362			var height = $(this)[0].getBoundingClientRect().height;
3363			var width = $(this)[0].getBoundingClientRect().width;
3364			var translateX = (langClass == 'en')? 61 : 46;
3365
3366			var offset = $(this).offset();
3367			var parentOffset = parentEl.offset();
3368			var paddingTop = (height - $(this).height()) * 0.5;
3369			var paddingLeft = ($(this).is('td') || $(this).css('text-align') == 'center')? (width - textWidth) * 0.5 : (width - $(this).width()) * 0.5;
3370			if($(this).css('text-align') == 'right') paddingLeft = width - textWidth;
3371			if(paddingTop < 0) paddingTop = 0;
3372			if(paddingLeft < 0) paddingLeft = 0;
3373			
3374			var top = offset.top - parentOffset.top + paddingTop + textHeight + 5;
3375			var left = ($('.dsgn-body').hasClass('sidebar'))? offset.left + paddingLeft + textWidth*0.5 - parentOffset.left - translateX : offset.left + paddingLeft + textWidth*0.5 - translateX;
3376			// console.log(offset, parentOffset);
3377			parentEl.append(searchBox);
3378			$('.search-forum-user-posts').css({'top': top, 'left': left});
3379
3380			var $searchBtn = $('.search-forum-user-posts');
3381			if($('.dsgn-body').hasClass('sidebar')) {
3382				if($searchBtn.offset().left < parentOffset.left) {
3383					left = 0;
3384					$searchBtn.css({'top': top, 'left': left});
3385				}
3386			} else {
3387				if($searchBtn.offset().left < 0) {
3388					left -= $searchBtn.offset().left;
3389					$searchBtn.css({'top': top, 'left': left});
3390				}
3391			}
3392			if($('header .navbar-toggle').css('display') == 'block' && ($searchBtn.offset().left + $searchBtn.width() > $('.dsgn-body').width())) {
3393				left = $('.dsgn-body').width() - $searchBtn.width();
3394				$searchBtn.css({'top': top, 'left': left});
3395			}
3396		}
3397	});
3398
3399	$(document).on('click','.forum-type-btn',function(e) {
3400		if($(this).parents('.element').attr('data-type') != 'forum') return false;
3401		e.preventDefault();
3402
3403		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
3404		var typeCheck = $(this).attr('data-type'),
3405			$elementCheck = $(this).parents('.element');
3406
3407		if($elementCheck.attr('data-list-type') == typeCheck) return false;
3408		
3409		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
3410		var data_sfl = $(this).parents('.search-box').find('#sfl').val(),
3411			data_stx = '',
3412			data_scate = getForumScate($elementCheck),
3413			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
3414			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
3415			data_page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
3416			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
3417		
3418		var F_PARENT = (typeof PARENT == 'undefined') ? property.PARENT : PARENT;
3419			F_ONE = (typeof ONE == 'undefined') ? property.ONE : ONE;
3420			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
3421			F_PAGE = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
3422
3423		var page_num = (typeof data_page_num != 'undefined' && data_page_num) ? data_page_num : -1,
3424			sfl = (typeof data_sfl == 'undefined') ? 'all' : data_sfl, 
3425			stx = (typeof data_stx == 'undefined') ? '' : data_stx,
3426			scate = (typeof data_scate == 'undefined') ? '' : data_scate;
3427
3428			if(page_num < 0) {
3429				page_num = (typeof $.cookie('forum_'+id) != 'undefined' && $.cookie('forum_'+id)) ? $.cookie('forum_'+id) : 1;
3430				$.removeCookie('forum_'+id,{path:'/'});
3431			}
3432			if(!stx) stx = getForumPrevStx(id);
3433			if(sfl=='all' && typeof $.cookie('forum_'+id+'_sfl') != 'undefined') sfl = $.cookie('forum_'+id+'_sfl');
3434			if(!scate && typeof $.cookie('forum_'+id+'_scate') != 'undefined') scate = $.cookie('forum_'+id+'_scate');
3435			$.forum.setForumCookie(id,page_num,stx,sfl,scate);
3436			cookie_page_num = $.cookie('forum_'+id);
3437			$.cookie('forum_'+id+'_type', typeCheck);
3438
3439			$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
3440			activeEL('userEL'+id);
3441
3442			// fmID = id;
3443   //          $.ajax({
3444   //              url: '/fm/lists/pid/' + id + '/sid/' + F_SID + '/page/' + F_PAGE + '/view/' + view + '/page_num/' + page_num,
3445   //              dataType: 'json',
3446   //              type: 'POST',
3447   //              data: { sfl: sfl, stx: stx, scate: scate},
3448   //              async: false,
3449   //              cache: false,
3450   //              success: function (data) {
3451   //              	if(typeof data.error != 'undefined' && data.error) {
3452   //              		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
3453   //              		return false;
3454   //              	}
3455			// 		displayTypeForum(data,$elementCheck,typeCheck,view,page_num,id);
3456   //      		}
3457
3458   //          });
3459	});
3460
3461	$('.tpl-forum-my').live('click', function(e) {
3462		if($(this).parents('.element').attr('data-type') != 'forum') return false;
3463		e.preventDefault();
3464		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
3465		
3466		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
3467		var umember = (PAGE_MODE == 'c') ? UMEMBER : property.UMEMBER,
3468			sfl ='mb_id',
3469			stx = umember.id,
3470			scate = getForumScate($(this).parents('.element')),
3471			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
3472			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
3473			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
3474			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
3475
3476		$.forum.setForumCookie(id,page_num,stx,sfl,scate);
3477		cookie_page_num = $.cookie('forum_'+id);
3478		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
3479		activeEL('userEL'+id);
3480	});
3481
3482	$.forum = {
3483		modoo_loop_card : `
3484			<div class="table" data-loop="true">
3485				<div class="col-xs-12 col-sm-6 col-md-4 item">
3486	                <div class="item-inner op_itemline10">
3487	                    <div class="thumb-wrap">
3488	                        <div class="tpl-forum-list-thumb">
3489	                            <img src="//storage.googleapis.com/i.addblock.net/sample/forum_thumb_4_1.jpg" class="img-responsive">
3490	                        </div>
3491	                        <div class="tpl-forum-list-num"><i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i></div>
3492	                    </div>
3493	                    <div class="cont-wrap">
3494	                        <div class="tpl-forum-list-content">
3495	                            <span class="tpl-forum-list-title" data-selector=".tpl-forum-list-title" data-font="true" data-title="title font">작업의 페이지 및 모든 프로세스에 대해 궁금한 점, 질문 드립니다.</span>
3496	                        </div>
3497	                        <div class="tpl-forum-list-cont" data-selector=".tpl-forum-list-cont" data-font="true" data-title="content font">항상 배우는 마음으로 보고 있습니다. 이번 프로젝트도 꼭 따라해보고 싶어요. 프로젝트를 보면서 디자인에 궁금한 점이 있습니다. 프로젝트 작업하실 때 주로 어디서 영감을 얻으시나요?</div>
3498	                        <ul>
3499	                            <div>
3500	                            <li class="tpl-forum-list-name tpl-forum-list-etc">데이비드 제임스</li>
3501	                            <li class="tpl-forum-list-date tpl-forum-list-etc">방금 전</li>
3502	                            </div>
3503	                            <div>
3504	                            <li class="tpl-forum-list-comment tpl-forum-list-etc">25</li>
3505	                            </div>
3506	                        </ul>
3507	                        <ul>
3508	                            <li class="tpl-forum-list-category tpl-forum-list-etc">카테고리</li>
3509	                            <li class="tpl-forum-list-hit tpl-forum-list-etc">1486</li>
3510	                            <li class="tpl-forum-list-like tpl-forum-list-etc hidden"><svg viewBox="0 0 28 28" width="28" height="28"><path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path><path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path></svg><span class="forum-like-cnt">0</span></li>
3511	                        </ul>
3512	                    </div>
3513	                </div>
3514	            </div>
3515            </div>
3516		`,
3517		modoo_loop_list : `
3518			<table class="table">
3519				<thead>
3520					<tr class="thead-bottom-line tpl-forum-header-row" data-selector=".tpl-forum-header-row" data-font="true" data-title="header row font">
3521						<th class="ntpl-forum-num tpl-forum-num tpl-forum-header-row">no</th>
3522						<th class="ntpl-forum-category tpl-forum-category tpl-forum-header-row">카테고리</th>
3523						<th class="ntpl-forum-content tpl-forum-content tpl-forum-header-row">제목</th>
3524						<th class="ntpl-forum-name tpl-forum-name tpl-forum-header-row">작성자</th>
3525						<th class="ntpl-forum-date tpl-forum-date tpl-forum-header-row">작성일</th>
3526						<th class="ntpl-forum-hit tpl-forum-hit tpl-forum-header-row">조회수</th>
3527						<th class="ntpl-forum-like tpl-forum-like tpl-forum-header-row">좋아요</th>
3528					</tr>
3529				</thead>
3530				<tbody data-loop="true">
3531					<tr class="op_itemline10">
3532						<td scope="row" class="tpl-forum-list-num tpl-forum-list-etc config-font-etc" data-selector=".tpl-forum-list-etc" data-font="true" data-title="others"><i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i></td>
3533						<td class="tpl-forum-list-category tpl-forum-list-etc config-font-etc">카테고리</td>
3534						<td class="tpl-forum-list-content" data-selector=".tpl-forum-list-content" data-font="true" data-title="title font"><span class="tpl-forum-list-title">작업의 페이지 및 모든 프로세스에 대해 궁금한 점, 질문 드립니다.</span> <span class="tpl-forum-list-comment"><i class="fa fa-comment-o tpl-forum-list-comment-icon"></i> <span class="forum-comment-cnt">7</span></span></td>
3535						<td class="tpl-forum-list-name tpl-forum-list-etc config-font-etc">작성자</td>
3536						<td class="tpl-forum-list-date tpl-forum-list-etc config-font-etc">방금 전</td>
3537						<td class="tpl-forum-list-hit tpl-forum-list-etc config-font-etc">50</td>
3538						<td class="tpl-forum-list-like tpl-forum-list-etc config-font-etc" data-selector=".tpl-forum-list-like" data-font="true" data-title="like">0</td>
3539					</tr>
3540				</tbody>
3541			</table>
3542		`,
3543		init : function(id, page, view, page_num, sfl, stx, scate) {
3544			F_PARENT = (typeof PARENT == 'undefined') ? property.PARENT : PARENT;
3545			F_ONE = (typeof ONE == 'undefined') ? property.ONE : ONE;
3546			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
3547			F_PAGE = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
3548
3549			// var page_num = (typeof page_num == 'undefined' || page_num == 'NaN') ? 1 : page_num,
3550			var page_num = (typeof page_num != 'undefined' && page_num) ? page_num : -1,
3551				sfl = (typeof sfl == 'undefined') ? 'all' : sfl, 
3552				stx = (typeof stx == 'undefined') ? '' : stx,
3553				scate = (typeof scate == 'undefined') ? '' : scate;
3554
3555			if(page_num < 0) {
3556				page_num = (typeof $.cookie('forum_'+id) != 'undefined' && $.cookie('forum_'+id)) ? $.cookie('forum_'+id) : 1;
3557				$.removeCookie('forum_'+id,{path:'/'});
3558				$.removeCookie('forum_'+id+'_type');
3559			}
3560
3561			if(!stx) stx = getForumPrevStx(id);
3562			if(sfl=='all' && typeof $.cookie('forum_'+id+'_sfl') != 'undefined') sfl = $.cookie('forum_'+id+'_sfl');
3563			if(!scate && typeof $.cookie('forum_'+id+'_scate') != 'undefined') scate = $.cookie('forum_'+id+'_scate');
3564			$.forum.setForumCookie(id,page_num,stx,sfl,scate);
3565			
3566			fmID = id;
3567            $.ajax({
3568                url: '/fm/lists/pid/' + id + '/sid/' + F_SID + '/page/' + F_PAGE + '/view/' + view + '/page_num/' + page_num,
3569                dataType: 'json',
3570                type: 'POST',
3571                data: { sfl: sfl, stx: stx, scate: scate},
3572                async: false,
3573                cache: false,
3574                success: function (data) {
3575                	if(typeof data.error != 'undefined' && data.error) {
3576                		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
3577                		return false;
3578                	}
3579
3580					$.forum.set(id,page_num,view,F_PAGE,sfl,stx,scate,data);
3581                }
3582            });
3583		},
3584		update_ver1 : function(id,page_num,view,page,sfl,stx,scate,data) {
3585			var modoo_login_check;
3586        	var source = (typeof data.source == 'undefined') ? '' : data.source;
3587        	var $source = $(htmlspecialchars_decode(source)),
3588        		type = (typeof $source.attr('data-forum-type') == 'undefined' || !$source.attr('data-forum-type')) ? '' : $source.attr('data-forum-type'),
3589	        	elsetting = (typeof data.elsettings != 'undefined' && data.elsettings) ? $.parseJSON(data.elsettings) : {};
3590
3591        	if(elsetting.forum_type == 'modoo') {
3592        		//모두 게시판 source 교체
3593				var $loopElement,
3594					data_view = $source.find('[data-loop="true"]').attr('data-view');
3595				if(typeof $.cookie('forum_'+id+'_type') != 'undefined' && $.cookie('forum_'+id+'_type') == 'card' ||
3596					typeof $.cookie('forum_'+id+'_type') == 'undefined' && $source.attr('data-list-type') == 'card') {
3597					$loopElement = $source.clone();
3598					$loopElement.find('.table-container').empty().append($.forum.modoo_loop_card);
3599					$loopElement.find('[data-loop="true"]').attr('data-view',data_view);
3600					$source = $loopElement;
3601					type = 'thumb';
3602				} else {
3603					if(typeof $.cookie('forum_'+id+'_type') != 'undefined' && $.cookie('forum_'+id+'_type') == 'list' && $source.find('table.table').length < 1) {
3604						$loopElement = $source.clone();
3605						$loopElement.find('.table-container').empty().append($.forum.modoo_loop_list);
3606						$loopElement.find('[data-loop="true"]').attr('data-view',data_view);
3607						$source = $loopElement;
3608					}
3609				}
3610				$source.find('.forum-title').empty().text(elsetting.forum_block_title);
3611				modoo_login_check = (PAGE_MODE != 'c') ? property.UMEMBER.check_login : true;
3612
3613				if(!modoo_login_check) $source.find('.tpl-forum-my').css('visibility','hidden');
3614			}
3615
3616        	var $first = (type == 'qna') ? $source.find('[data-loop="true"]').children('.qna-item').eq(0).clone() : $source.find('[data-loop="true"]').children().eq(0).clone(),
3617        		F_SID = (typeof SID == 'undefined') ? property.SID : SID,
3618	        	F_VALIDPLAN = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN,
3619	        	F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE;
3620        	var field_lang = (typeof elsetting.field_lang != 'undefined') ? elsetting.field_lang : (typeof elsetting.blocklang != 'undefined' && elsetting.blocklang ? elsetting.blocklang : LANG);
3621        	var is_templates = checkTemplateSite(F_SID);
3622        	if($.inArray(type, ['qna', 'faq', 'guestbook']) == -1 && F_VALIDPLAN && $first.find('.tpl-forum-list-like').length == 0) {
3623				if((elsetting.like_display != undefined && elsetting.like_display == 'ON') || (elsetting.likeComment_display != undefined && elsetting.likeComment_display == 'ON')) {
3624					if($source.find('table').length > 0) { //table
3625						if($source.find('thead').length > 0) { //thead
3626							$source.find('thead tr').append('<th class="ntpl-forum-like tpl-forum-like tpl-forum-header-row op_itemline10 hidden" width="100">'+$.lang[field_lang.toLowerCase()]['forum.field.tpl-forum-like']+'</th>');
3627		        			$first.append('<td class="tpl-forum-list-like tpl-forum-list-etc old-fm op_itemline10" data-selector=".tpl-forum-list-like" data-font="true" data-title="like">0</td>');
3628		        			if(data.total == 0) {
3629		        				$source.find('tbody tr').append('<td class="tpl-forum-list-like tpl-forum-list-etc old-fm op_itemline10" data-selector=".tpl-forum-list-like" data-font="true" data-title="like">0</td>');
3630		        			}
3631		        		} else {
3632		        			$first.append('<td class="tpl-forum-list-like tpl-forum-list-etc old-fm op_itemline10" data-selector=".tpl-forum-list-like" data-font="true" data-title="like">0</td>');
3633		        			if(data.total == 0) {
3634		        				$source.find('tbody tr').append('<td class="tpl-forum-list-like tpl-forum-list-etc old-fm op_itemline10" data-selector=".tpl-forum-list-like" data-font="true" data-title="like">0</td>');
3635		        			}
3636		        		}
3637					} else {
3638						if(data.total == 0) {
3639							$source.find('.item ul').each(function(idx, v){
3640								if($(v).find('.tpl-forum-list-like').length > 0) return true;
3641								if(idx == 0) $(v).append('<li class="tpl-forum-list-like tpl-forum-list-etc old-fm" data-selector=".tpl-forum-list-like" data-font="true" data-title="like"><svg viewBox="0 0 28 28" width="28" height="28"><path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path><path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path></svg><span class="forum-like-cnt">0</span></li>');
3642								else $(v).append('<li class="tpl-forum-list-like tpl-forum-list-etc old-fm"><svg viewBox="0 0 28 28" width="28" height="28"><path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path><path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path></svg><span class="forum-like-cnt">0</span></li>');
3643							});
3644
3645							$source.find('.b_txt ul').each(function(idx, v){
3646								if($(v).find('.tpl-forum-list-like').length > 0) return true;
3647								if(idx == 0) $(v).append('<li class="tpl-forum-list-like tpl-forum-list-etc old-fm" data-selector=".tpl-forum-list-like" data-font="true" data-title="like"><svg viewBox="0 0 28 28" width="28" height="28"><path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path><path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path></svg><span class="forum-like-cnt">0</span></li>');
3648								else $(v).append('<li class="tpl-forum-list-like tpl-forum-list-etc old-fm"><svg viewBox="0 0 28 28" width="28" height="28"><path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path><path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path></svg><span class="forum-like-cnt">0</span></li>');
3649							});
3650						}
3651					}
3652				}
3653			}
3654
3655        	var first_html = $first.prop('outerHTML'),
3656        		$bbs = $('.element[data-id="' + id + '"]');
3657
3658        	var d = document.createElement('div');
3659        	$(d).html(first_html);
3660
3661			$source.find('thead tr th').each(function() {
3662				var field_text = (typeof $(this).attr('class') != 'undefined') ? $(this).attr('class') : 'tpl-forum-title';
3663				if(field_text.indexOf('ntpl') > -1) field_text = field_text.split(' ')[1];  //게시판 폰트설정 -  기존, 새 코드 블럭 구분
3664
3665				if(field_text.indexOf('title') > -1 || field_text.indexOf('content') > -1) $(this).text($.lang[field_lang.toLowerCase()]['forum.field.tpl-forum-title']);
3666				else $(this).text($.lang[field_lang.toLowerCase()]['forum.field.' + field_text]);
3667				if($source.find('.tpl-forum-num').hasClass('num-ko') && field_text.indexOf('num') > -1) $(this).text($.lang[field_lang.toLowerCase()]['forum.field.' + field_text +'.ko']);
3668			});
3669
3670			if($source.find('tr.tpl-forum-header-row').length > 0) {
3671				var checkHeaderOnlyTitle = ($source.find('tr.tpl-forum-header-row th:not(.hide)').length === 1) ? true : false;
3672				if(checkHeaderOnlyTitle) $source.find('tr.tpl-forum-header-row').addClass('hide');
3673				else $source.find('tr.tpl-forum-header-row').removeClass('hide');
3674			}
3675			var answer	= (type == 'qna') ? $source.find('[data-loop="true"]').children('.qna-details').eq(0).clone().prop('outerHTML') : '';
3676
3677			var loop = $(d).html() + '\
3678    				'+ answer;
3679    		$(d).remove();
3680        	$bbs.html($source.html());
3681
3682        	var	$row = $bbs.find('[data-loop="true"]'),
3683        		$pagination = $bbs.find('.tpl-forum-pagination'),
3684        		$write = $bbs.find('.tpl-forum-write').attr('data-pid',id),
3685        		css_id = $bbs.attr('data-el'),
3686        		block_lang = ($bbs.attr('data-blocklang')) ? $bbs.attr('data-blocklang') : LANG;
3687
3688        	var data_el = $bbs.attr('data-el');
3689
3690        	if(data.total > 0) {
3691				$bbs.find('[data-loop="true"]').removeClass('sample-loop');
3692           		$row.html('');
3693
3694				if(typeof elsetting.forum_type !== "undefined" && elsetting.forum_type == "modoo") {
3695					var typeCookieCheck;
3696					if(typeof $.cookie('forum_'+id+'_type') == 'undefined') typeCookieCheck = $source.attr('data-list-type');
3697						else typeCookieCheck = $.cookie('forum_'+id+'_type');
3698						
3699		    		if(typeCookieCheck == 'list') {
3700		    			$bbs.attr('data-list-type','list');
3701		    			$bbs.attr('data-msny', false);
3702		    		} else if(typeCookieCheck == 'card') {
3703		    			$bbs.attr('data-list-type','card');
3704		    			$bbs.attr('data-msny', true);
3705		    		}
3706				}
3707
3708                // if(typeof elsetting.forum_type !== "undefined" && elsetting.forum_type == "modoo") {
3709                //     if($source.attr('data-list-type') == 'card') {
3710                //         displayTypeForum(data,$source,'card',view,page_num,id);
3711                //         return false;
3712                //     }
3713                // }
3714
3715				if(data.total<=((view*page_num)-view)) {
3716					page_num = page_num-1;
3717					if(page_num==0) page_num=1;
3718				}
3719
3720        		$.each(data.list, function(i,v) {
3721        			var num = data.total - (view * (page_num-1)) - i;
3722					$row.append(forumRow(v, num, page_num, id, loop, data.config, type, $source));
3723        		});
3724
3725			}
3726
3727        	var field_disable = getOrDefault(elsetting,'field_disable',[]),
3728				check_faq = (type == 'faq' && $(d).find('.tpl-forum-list-content .inner-box').length > 0) ? true : false;
3729        	if(check_faq) {
3730        		if($.inArray('name',field_disable) > -1 && $.inArray('date',field_disable) > -1) {
3731					$bbs.find('[data-loop="true"] .tpl-forum-list-name').removeClass('removeBar');
3732				} else if($.inArray('date',field_disable) > -1) {
3733					$bbs.find('[data-loop="true"] .tpl-forum-list-name').addClass('removeBar');
3734				}
3735			}
3736
3737		},
3738		view : function(id) {
3739		    var deferred = $.Deferred();
3740			F_PARENT = (typeof PARENT == 'undefined') ? property.PARENT : PARENT;
3741			F_ONE = (typeof ONE == 'undefined') ? property.ONE : ONE;
3742			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
3743			F_PAGE = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
3744			F_VIEW = id;
3745
3746			var ps_forumview = forumView(id);
3747			ps_forumview.done(function(data) {
3748				setForumWrap();
3749				if(typeof MODE != 'undefined' && (MODE=='config' || MODE=='demo')) displayComment(data);
3750
3751				deferred.resolve(data);
3752			}).fail(function(error_msg) {
3753				deferred.reject(error_msg);
3754
3755				if(error_msg == 404) show404();
3756			});
3757
3758		    return deferred.promise();
3759		},
3760		delete : function(id) {
3761			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
3762				if(typeof data.error != 'undefined' && data.error) {
3763					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
3764					return false;
3765				}
3766				if(data.fmid && data.sign == false) {
3767					userLogin();
3768					return false;
3769				}
3770				if(data.comment_count > 0) {
3771					$(this).showModalFlat('ERROR', $.lang[LANG]['config.forum.delete.alert1'], true, false, '', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
3772					return false;
3773				}
3774
3775
3776				if(data.sign == false) {
3777					var passwordModal = $(this).showModalFlat($.lang[LANG]['board.button.delete.password'],passwdForm(),true,true,function() {
3778						var $pass = $('#comm-pass'),
3779							isSubmit = true,
3780							userInput = $pass.val();
3781						$('label.error').remove();
3782						if($pass.val().length<4) {
3783							//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
3784							$pass.closest('.cl-s-form-wrap').addClass('error');
3785							$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
3786							$pass.focus();
3787							isSubmit = false;
3788						}
3789
3790						if(isSubmit) {
3791							//$('.comment-addform.password').parent().find('.error').remove();
3792							$.post('/fm/password',{ id: id, passwd : hex_md5($pass.val()) }, function(data) {
3793								if(typeof data.error != 'undefined' && data.error) {
3794									//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
3795									$pass.closest('.cl-s-form-wrap').addClass('error');
3796									$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
3797									return false;
3798								}
3799								var date = new Date(),
3800									cookietime = 20 * 60 * 1000;
3801					            date.setTime(date.getTime() + cookietime);
3802
3803								$.cookie('hash', data.hash, { path: '/' , expires: date});
3804								$('.modal[id*=flat-modal]').modal('hide');
3805								resetObject(user);
3806								user.pass = hex_md5($pass.val());
3807								if(data.fm_type && data.fm_type == 'qna' ) {
3808									deleteForumPost(id);
3809								} else {
3810									var modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {			
3811									deleteForumPost(id);
3812									modal.modal('hide');												
3813									}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');												
3814								}
3815
3816								passwordModal.modal('hide');
3817							},'json');
3818						}
3819						modalEmptyCheck();
3820					},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password');
3821				} else if(data.own == true || data.mgr == true) {
3822					if(data.fm_type && $.inArray(data.fm_type, ['qna','faq']) > -1) {
3823						deleteForumPost(id);
3824					} else {
3825						var modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {			
3826						deleteForumPost(id);
3827						modal.modal('hide');												
3828						}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');												
3829					}
3830				} else {
3831					 alert( $.lang[LANG]['board.not-own-no-delete'] );
3832				}
3833			}, 'json');
3834		},
3835		deleteGuestbook : function(pid, id) {
3836			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
3837				if(typeof data.error != 'undefined' && data.error) {
3838					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
3839					return false;
3840				}
3841				if(data.fmid && data.sign == false) {
3842					userLogin();
3843					return false;
3844				}
3845
3846				if(data.sign == false) {
3847					var passwordModal = $(this).showModalFlat($.lang[LANG]['guestbook.button.delete.password'],passwdForm(),true,true,function() {
3848						var $pass = $('#comm-pass'),
3849							isSubmit = true,
3850							userInput = $pass.val();
3851						$('label.error').remove();
3852						if($pass.val().length<4) {
3853							//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
3854							$pass.closest('.cl-s-form-wrap').addClass('error');
3855							$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
3856							$pass.focus();
3857							isSubmit = false;
3858						}
3859
3860						if(isSubmit) {
3861							//$('.comment-addform.password').parent().find('.error').remove();
3862							$.post('/fm/password',{ id: id, passwd : hex_md5($pass.val()) }, function(data) {
3863								if(typeof data.error != 'undefined' && data.error) {
3864									//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
3865									$pass.closest('.cl-s-form-wrap').addClass('error');
3866									$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
3867									return false;
3868								}
3869								var date = new Date(),
3870									cookietime = 20 * 60 * 1000;
3871					            date.setTime(date.getTime() + cookietime);
3872
3873								$.cookie('hash', data.hash, { path: '/' , expires: date});
3874								$('.modal[id*=flat-modal]').modal('hide');
3875								resetObject(user);
3876								user.pass = hex_md5($pass.val());
3877								deleteGuestbook(pid, id);
3878								passwordModal.modal('hide');
3879							},'json');
3880						}
3881						modalEmptyCheck();
3882					},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
3883						passwordModal.find('#comm-pass').addClass('guestbook-pass');
3884					});
3885				} else if(data.own == true || data.mgr == true) {
3886					deleteGuestbook(pid, id);
3887				} else {
3888					 alert( $.lang[LANG]['board.not-own-no-delete'] );
3889				}
3890			}, 'json');
3891		},
3892		setForumCookie : function(id,page_num,stx,sfl,scate) {
3893			// Recent  forum only
3894			// var cookies = $.cookie();
3895			// for(var cookie in cookies) {
3896			// 	if( cookie.indexOf($.cookie('forum')) == -1 && cookie.indexOf('forum') > -1) {
3897			// 		$.removeCookie(cookie);
3898			// 	}
3899			// }
3900			// console.log('setForumCookie', id,page_num,stx,sfl,scate);
3901			var prev_sfl = (typeof $.cookie('forum_'+id+'_prev_sfl') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_sfl'),
3902				prev_stx = (typeof $.cookie('forum_'+id+'_prev_stx') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_stx'),
3903				prev_scate = (typeof $.cookie('forum_'+id+'_prev_scate') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_scate'),
3904				change_stx = (prev_stx != stx) ? true : false,
3905				change_sfl = (prev_sfl != sfl && stx.length > 0) ? true : false,
3906				change_scate = (prev_scate != scate) ? true : false;
3907			if(change_stx || (!change_stx && (change_sfl || change_scate))) page_num = 1;
3908			// console.log(prev_sfl, prev_stx, prev_scate);
3909			// console.log(change_stx, change_sfl, change_scate, page_num);
3910			$.cookie('forum',id,{path:'/'});
3911			$.cookie('forum_'+id, page_num,{path:'/'});
3912			if(typeof stx != 'undefined' && stx) {
3913				$.cookie('forum_'+id+'_sfl',sfl,{path:'/'});
3914				$.cookie('forum_'+id+'_stx',stx,{path:'/'});
3915			} else {
3916				$.removeCookie('forum_'+id+'_stx',{path:'/'});
3917			}
3918
3919			if(typeof scate != 'undefined' && scate) {
3920				$.cookie('forum_'+id+'_scate',scate,{path:'/'});
3921			} else {
3922				$.removeCookie('forum_'+id+'_scate',{path:'/'});
3923			}
3924
3925			// console.log($.cookie('forum_'+id+'_sfl'), $.cookie('forum_'+id+'_stx'), $.cookie('forum_'+id));
3926			if(stx || sfl) {
3927				$.cookie('forum_'+id+'_prev_sfl', sfl, {path:'/'});
3928				if(stx) {
3929					$.cookie('forum_'+id+'_prev_stx', stx, {path:'/'});
3930				} else {
3931					$.removeCookie('forum_'+id+'_prev_stx', {path:'/'});
3932				}
3933				$.cookie('forum_'+id+'_prev_scate', scate, {path:'/'});
3934			} else {
3935				$.removeCookie('forum_'+id+'_prev_sfl', {path:'/'});
3936				$.removeCookie('forum_'+id+'_prev_stx', {path:'/'});
3937				$.removeCookie('forum_'+id+'_prev_scate', {path:'/'});
3938			}
3939		},
3940		setDefaultConfig : function(config) {
3941			var defaultConfig = {
3942				group 			: '',
3943				write_level 	: (PLAN || SERVICE.indexOf('gabia') > -1) ? 'NM' : 'M',
3944				reply_level		: (PLAN || SERVICE.indexOf('gabia') > -1) ? 'NM' : 'A',
3945				view_level		: 'A',
3946				list_level		: 'A',
3947				modify			: 0,
3948				delete 			: 0,
3949				page_row		: 10,
3950				secret_display	: 'U',
3951				comment_display : 'OFF',
3952				secretComment_display: 'U',
3953				sns_share_display	: 'OFF',
3954				bottomlist_display	: 'OFF',
3955				forum_count		: 0,
3956				comment_count	: 0,
3957				field_lang		: 'en',
3958				field_disable	: [],
3959				searchbox_display : 'ON',
3960				writebtn_display : 'ON',
3961				forum_category_type : 'dropdown',
3962			}
3963			if(config==null) config = defaultConfig;
3964			$.each(defaultConfig, function(k,v) {
3965				if(typeof config[k] == 'undefined') config[k] = v;
3966			});
3967			return config;
3968		},
3969		groupconfig : function(id) {
3970			$('.config-modal').remove();
3971
3972			if(typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == id) {
3973				var modal = $(this).showModalFlat($.lang[LANG]['board.manage-groups'],groupConfigForum(bc_fr.config,id,bc_fr.group),true,false,'','close', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 gc-modal',true).attr({'data-fid':id, 'id':''}).closest('.flat-modal').addClass('flat-gc-modal'); 
3974			} else {
3975				$.post('/fm/config', { id : id }, function(data) {
3976					if(typeof data.error != 'undefined' && data.error) {
3977						$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
3978						return false;
3979					}
3980					var modal = $(this).showModalFlat($.lang[LANG]['board.manage-groups'],groupConfigForum(data.config,id,data.group),true,false,'','close', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 gc-modal',true).attr({'data-fid':id, 'id':''}).closest('.flat-modal').addClass('flat-gc-modal'); 
3981				},'json');
3982			}
3983		},
3984		getgroupdata : function(id) {
3985			if(typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == id) {
3986				str = '', groups = bc_fr.group;
3987				for(var i=0; i<groups.length; i++) {
3988					str = str + getGroupList(groups[i].id, groups[i].name, groups[i].member_count);
3989				}
3990				$('#group-accordion').html(str);
3991			} else {
3992				$.post('/fm/config', { id : id }, function(data) {
3993					if(typeof data.error != 'undefined' && data.error) {
3994						return false;
3995					}
3996					str = '', groups = data.group;
3997					for(var i=0; i<groups.length; i++) {
3998						str = str + getGroupList(groups[i].id, groups[i].name, groups[i].member_count);
3999					}
4000					$('#group-accordion').html(str);
4001				},'json');
4002			}
4003		},
4004		getGroupNameList : function(fid) {
4005			var str = '';
4006			if(typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == fid) {
4007				groups = bc_fr.group;
4008				for(var i=0; i<groups.length; i++) {
4009					str = str + '<option value="' + groups[i].name + '" data-id="' + groups[i].id + '" data-member-count="' + groups[i].member_count + '">' + groups[i].name + '</option>';
4010				}
4011				return str;
4012			} else {
4013				$.post('/fm/config', { id : fid }, function(data) {
4014					if(typeof data.error != 'undefined' && data.error) {
4015						return false;
4016					}				
4017					groups = data.group;
4018					for(var i=0; i<groups.length; i++) {
4019						str = str + '<option value="' + groups[i].name + '" data-id="' + groups[i].id + '" data-member-count="' + groups[i].member_count + '">' + groups[i].name + '</option>';
4020					}
4021					return str;
4022				}, 'json');
4023			}
4024		},
4025		setfile : function (file,file_name,orig_name) {
4026			var $file = $('<div class="result-file" data-file="' + file + '" data-file-name="' + file_name + '">'),
4027				$result = $('<span><i class="fa fa-paperclip"></i></span> <span class="set-image hand"><i class="fa fa-arrow-circle-up"></i></span> <span>'+ orig_name + '</span>');
4028				$del = $('<span class="file-delete hand"><i class="fa fa-times"></i></span>');
4029
4030			$file.append($result).append($del);
4031			$file.appendTo('.upload-files');
4032			
4033			$('#fm-editor').froalaEditor('selection.restore');
4034
4035			if(upTYPE == 'image') {
4036				if(isReplace == true) editorImageReplace('http:' + file, orig_name);
4037				else $('#fm-editor').froalaEditor('image.insert', 'http:' + file, true);
4038			} else $('#fm-editor').froalaEditor('file.insert', 'http:' + file, orig_name, { 'link' : 'http:' + file, 'target': '_blank' });
4039		},
4040		drawSelboxCategory : function(sel_replace,pid) {
4041			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
4042
4043			var str = '',
4044				block_lang = ($(sel_replace).attr('data-blocklang')) ? $(sel_replace).attr('data-blocklang') : LANG,
4045				block_content = (typeof SID == 'undefined') ? property.CONTENTS['el'+pid] : {};
4046
4047			if(block_content === undefined || block_content.category === undefined) {
4048				$.ajax({
4049	                url: '/fm/category/list',
4050	                dataType: 'json',
4051	                type: 'POST',
4052	                data: { pid: pid, sid: F_SID },
4053	                async: true,
4054	                cache: false,
4055	                success: function (list_data) {
4056						if(typeof list_data.error != 'undefined' && list_data.error) {
4057							$(this).showModalFlat('ERROR',list_data.error,true,false,'','ok');
4058							return false;
4059						}
4060						displayCategoryHtml(pid,list_data,sel_replace,block_lang);
4061					}
4062				});
4063			} else displayCategoryHtml(pid,block_content.category,sel_replace,block_lang);
4064		},
4065		callOpenForumCategoryConfig : function(pid) {
4066			openForumCategoryConfig(pid);
4067		},
4068		set : function(id,page_num,view,page,sfl,stx,scate,data) {
4069			var F_SID = (typeof SID == 'undefined') ? property.SID : SID,
4070				F_VALIDPLAN = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN,
4071				F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE;
4072
4073			var _fu = {
4074				pid: id,
4075				sid: F_SID,
4076				validplan: F_VALIDPLAN,
4077				validtype: F_VALIDTYPE,				
4078				elname: data.elname,
4079				eltag: (typeof data.source == 'undefined') ? '' : data.source,
4080				elcss: (typeof data.css != 'undefined') ? CSSJSON.toJSON(htmlspecialchars_decode(data.css)) : CSSJSON.toJSON(),
4081				elsettings: (typeof data.elsettings != 'undefined' && data.elsettings) ? $.parseJSON(data.elsettings) : {},
4082				config: (typeof data.config != 'undefined' && data.config) ? data.config : {},
4083				check: {
4084					templateview: (window.location != window.parent.location) ? true : false,
4085					demo: data.demo,
4086					notsupported: false,
4087				},
4088			};
4089
4090			_fu.elstyle =  style.get(_fu.elcss,`.${_fu.elname}`);
4091			_fu.sampleEL =  $(htmlspecialchars_decode(_fu.eltag));
4092			_fu.blockEL = $(`.element[data-id="${id}"]`);
4093
4094			_fu.el = _fu.blockEL.attr('data-el');
4095			_fu.elname = _fu.blockEL.attr('data-name');
4096			_fu.eltype = _fu.blockEL.attr('data-type');
4097			_fu.eltype2 = _fu.blockEL.attr('data-type2');
4098			_fu.elmsny = _fu.blockEL.is('[data-msny="true"]');
4099			_fu.field_lang = (_fu.elsettings.field_lang || _fu.elsettings.blocklang || LANG).toLowerCase();
4100			_fu.block_lang = (_fu.elsettings.blocklang || LANG).toLowerCase();
4101
4102        	if(!checkTemplateSite(F_SID) 
4103				&& (!F_VALIDPLAN || F_VALIDTYPE == 'PK') 
4104				&& $.inArray(_fu.eltype2, ['qna', 'faq']) > -1
4105			) {
4106				_fu.check.notsupported = true;
4107				if(PAGE_MODE != 'c') {
4108					_fu.blockEL.empty().addClass('hide');
4109					return false;
4110				}
4111			}
4112
4113			if(_fu.elcss === CSSJSON.toJSON()) {
4114				if(typeof data.msg == 'undefined') _fu.blockEL.empty().addClass('hide');
4115			} else {
4116				_fu.blockEL.removeClass('hide');
4117				$(`#${_fu.el}css`).text(data.css);
4118			}
4119
4120			var $current_category_nav = getForumCategoryNav(_fu.blockEL).first().clone();
4121
4122			initForumField(_fu.sampleEL);
4123			_fu.sampleEL.find('.tpl-forum-category-nav').remove();
4124			_fu.sampleEL.find('#scate option:not(:first)').remove();
4125			_fu.sampleEL.find('#scate').val('');
4126			_fu.blockEL.html(_fu.sampleEL.html()).attr('data-init',true);
4127			_fu.blockEL.attr('data-forum-category-type', getForumCategoryType(_fu.elsettings));
4128			_fu.blockEL.removeAttr('data-forum-category-sticky');
4129			_fu.blockEL.attr('data-gcate-style', getForumCategoryStyle(_fu.blockEL));
4130			if(getForumCategoryType(_fu.elsettings) == 'list' && $current_category_nav.length > 0) {
4131				placeForumCategoryNav(_fu.blockEL, $current_category_nav);
4132				if(typeof scate != 'undefined') setForumCategoryActive(_fu.blockEL, scate);
4133				syncForumCategoryTypeDisplay(_fu.blockEL);
4134			}
4135			_fu.blockLoop = _fu.blockEL.find('[data-loop="true"]');
4136
4137			if(_fu.check.notsupported) $.notSupported.set(F_SID, id, _fu.eltype2, true);
4138
4139			if(_fu.eltype2) _fu.blockEL.attr('data-forum-type',_fu.eltype2);
4140			else _fu.blockEL.removeAttr('data-forum-type');
4141
4142			// [data-ver="1"] add default init root css 
4143			if(_fu.blockEL.length > 0) {
4144				if(getOrDefault(_fu.elstyle,'__forum_color','') == '') {
4145					var forum_color = (typeof _fu.elsettings.forum_color != 'undefined') ? _fu.elsettings.forum_color : ((typeof _fu.blockEL.attr('data-fcolor') != 'undefined') ? _fu.blockEL.attr('data-fcolor') : '#191919');
4146					if($.inArray(forum_color, ['black','white']) > -1) forum_color = (forum_color == 'black') ? '#191919' : '#ffffff';
4147					_fu.blockEL.attr('data-fcolor',forum_color);
4148
4149					if(document.querySelector(`.${_fu.elname}`)) {
4150						document.querySelector(`.${_fu.elname}`).style.setProperty('--forum-color', forum_color, null);
4151						document.querySelector(`.${_fu.elname}`).style.setProperty('--forum-color-rgb', Coloris.getChangeColorVal(forum_color,'rgb_str'), null);
4152						document.querySelector(`.${_fu.elname}`).style.setProperty('--searchbox-option-color', forum_color, null);
4153						document.querySelector(`.${_fu.elname}`).style.setProperty('--searchbox-option-bgcolor', _fu.blockEL.css('background-color'), null);
4154					}
4155				}
4156				if(_fu.blockEL.is('[data-fcolor]')) _fu.blockEL.attr('data-ver','1');
4157			}
4158
4159			if(data.total == 0) {
4160        		if(data.msg) {
4161        			RELOAD = true;
4162        			if(data.sign == false) _fu.blockEL.find('.tpl-forum-write').text($.lang[_fu.field_lang]['config.comment.login-modal']);
4163        		}
4164
4165				if(!_fu.check.templateview 
4166					&& !_fu.check.demo
4167					&& (typeof MODE == 'undefined' || typeof $.cookie(`forum_${id}_stx`) != 'undefined' || typeof $.cookie(`forum_${id}_scate`) != 'undefined')
4168				) {
4169					if(data.msg) _fu.blockEL.find('.search-box').addClass('hide');
4170					_fu.blockEL.find('.table thead').addClass('hide');
4171
4172					var msg = data.msg;
4173					if (msg && /<br\s*\/?>/i.test(msg)) {
4174						msg = msg.replace(/<br\s*\/?>/gi, '\n');   // 개행 처리
4175						_fu.blockLoop.addClass('has-multiline-desc');
4176					}					
4177
4178					_fu.blockLoop.empty().attr('data-description',msg ? msg : $.lang[_fu.block_lang]['board.no-posts']
4179					);
4180
4181					// Fix : html content="" 값으로 <br> 태그 들어가는 경우 개행 처리가 되지 않아 위와 같이<br> 예외 처리 수정
4182					//_fu.blockLoop.empty().attr('data-description',(data.msg) ? data.msg : $.lang[_fu.block_lang]['board.no-posts']);
4183					_fu.blockEL.find('.tpl-forum-pagination').empty().attr({'data-page':page, 'data-view':view});
4184				} else {
4185					// view sample block
4186					_fu.blockLoop.addClass('sample-loop');
4187					_fu.blockLoop.find(`
4188								.tpl-guestbook-more-menu, 
4189								.tpl-guestbook-more-menu-area-el2
4190					`).remove();
4191				}
4192			} else {
4193				
4194				if(	_fu.eltype2 == 'guestbook'
4195					|| _fu.blockEL.is('[data-ver="1"]')
4196				) {
4197					$.forum.update_ver1(id,page_num,view,page,sfl,stx,scate,data);
4198				} else {
4199					_fu.blockLoop.empty();
4200
4201					if(data.total<=((view*page_num)-view)) {
4202						page_num = page_num-1;
4203						if(page_num==0) page_num=1;
4204					}
4205	
4206					$.each(data.list, function(post_i,post) {
4207						var num = data.total - (view * (page_num-1)) - post_i;
4208						var item_tag = getForumListItem(num,post,_fu);
4209						_fu.blockLoop.append(item_tag);
4210	
4211					});
4212					if(_fu.sampleEL.find('.layout-table .tpl-forum-header-row').length > 0) {
4213						_fu.blockLoop.prepend(_fu.sampleEL.find('.layout-table .tpl-forum-header-row').prop('outerHTML'));
4214					}
4215				}
4216			}
4217
4218			showHideForumField(_fu.blockEL, _fu.elsettings, true);
4219
4220			// 검색창
4221			var searchbox_onoff = (typeof _fu.elsettings.searchbox_display != 'undefined' && _fu.elsettings.searchbox_display == 'OFF') ? false : true;
4222			if(!searchbox_onoff) {
4223				syncForumSearchboxDisplay(_fu.blockEL, false);
4224				if(!_fu.blockEL.find('#scate').hasClass('hide')) $.forum.drawSelboxCategory(_fu.blockEL,id);
4225				syncForumCategoryTypeDisplay(_fu.blockEL);
4226			} else {
4227				syncForumSearchboxDisplay(_fu.blockEL, true);
4228				if(!_fu.blockEL.find('#scate').hasClass('hide')) $.forum.drawSelboxCategory(_fu.blockEL,id);
4229	
4230				if(typeof scate != 'undefined' && scate) scate = data.scate;
4231				if(typeof stx != 'undefined' && stx) stx = data.stx;
4232				$.forum.setForumCookie(id,page_num,stx,sfl,scate);
4233	
4234				if($.inArray(sfl, ['mb_id','nonmem']) > -1) {
4235					_fu.blockEL.remove('input[name="user_sfl"], input[name="user_stx"]');
4236					_fu.blockEL.append(`<input type="hidden" name="user_sfl" value="${sfl}"><input type="hidden" name="user_stx" value="${stx}">`);
4237				} else {
4238					var prev_stx = getForumPrevStx(id);
4239					_fu.blockEL.find('.search-box #sfl').val(sfl);
4240					_fu.blockEL.find('.search-box #stx, .serach-box #stx, .search-box input[name="stx"], .serach-box input[name="stx"]').attr('autocomplete','off').val(prev_stx);
4241					_fu.blockEL.find('.search-box #sfl option').map( function() {
4242						var sfl = $(this).attr('value');
4243						$(this).text($.lang[_fu.block_lang][`board.sfl.${sfl}`]);
4244					});
4245
4246					if($.inArray(sfl, ['mb_id','nonmem']) < 0
4247						&& stx.length > 0 
4248						&& _fu.blockLoop.find(`.tpl-forum-list-title a:contains("${stx}")`).length > 0
4249					) {
4250						_fu.blockLoop.find(`.tpl-forum-list-title a:contains("${stx}")`).each(function() {
4251							var title_txt = $(this).text(),
4252								regex = new RegExp(stx,'gi'),
4253								new_title_txt = title_txt.replace(regex, `<strong class="search-txt">${stx}</strong>`);
4254							$(this).html(new_title_txt);
4255						});
4256					}
4257				}
4258	
4259				if(!sfl) _fu.blockEL.find('.search-box select').children().first().attr('selected','selected');
4260				if(!stx || stx.length==0) _fu.blockEL.find('.search-box #sfl').val($('.search-box #sfl').children().first().attr('value'));
4261	
4262				_fu.blockEL.find('.search-box #scate').val(scate);
4263				if(!scate || scate.length==0) _fu.blockEL.find('.search-box #scate').val('');
4264				setForumCategoryActive(_fu.blockEL, scate);
4265				syncForumCategoryTypeDisplay(_fu.blockEL);
4266			}
4267
4268			// 항목 > 언어
4269			_fu.blockEL.find('.tpl-forum-header-row').children('[class*="tpl-forum-"]').each(function(idx, v) {
4270				var tmp_cls = $(this).attr('class'),
4271				tmp_matches = [...tmp_cls.matchAll(/tpl-forum-(\w+)/g)].map(match => match[1])[0];
4272				if(tmp_matches == 'content') tmp_matches = 'title';
4273				else if(tmp_matches == 'num' && $(this).hasClass('num-ko')) tmp_matches += '.ko';
4274				if(typeof $.lang[_fu.field_lang][`forum.field.tpl-forum-${tmp_matches}`] != 'undefined') $(this).text($.lang[_fu.field_lang][`forum.field.tpl-forum-${tmp_matches}`]);
4275			});
4276
4277            // 버튼 > 텍스트 
4278            var btn_arr = (_fu.eltype2 == 'guestbook') ? ['write','cancel'] : ['write'];
4279            $.each(btn_arr, function(i,k) {
4280                var tmp_k = (_fu.eltype2 == 'guestbook') ? _fu.eltype2 : 'forum',
4281                    tmp_selector = `.tpl-${tmp_k}-${k}`,
4282                    tmp_custom = `btn${i > 0 ? k.charAt(0).toUpperCase() + k.slice(1) : ''}Text`,
4283                    tmp_text = _fu.elsettings[tmp_custom] ?? $.lang[_fu.block_lang][`forum.field${tmp_selector}`] ?? _fu.blockEL.find(tmp_selector).text().trim();
4284
4285				_fu.blockEL.find(tmp_selector).text(tmp_text).attr('data-pid',id);
4286            });
4287
4288			// 페이지네이션
4289			if(!_fu.blockEL.find('[data-loop="true"]').is('.sample-loop')) {
4290				setForumPagination(_fu.blockEL.find('.tpl-forum-pagination'),data.total,view,page_num,id,page);
4291				if(Number(data.total) <= Number(view)) _fu.blockEL.find('.tpl-forum-pagination').addClass('hide');
4292				else _fu.blockEL.find('.tpl-forum-pagination').removeClass('hide');
4293			}
4294
4295			switch(_fu.eltype2) {
4296				case 'faq':
4297					if(typeof MODE == 'undefined') _fu.blockEL.find('.tpl-forum-write').remove();
4298					break;
4299				
4300				default:
4301					 break;
4302			}
4303
4304			// 방명록 캡챠
4305			if(_fu.eltype2 == 'guestbook') {
4306				var captcha_onoff = (getOrDefault(_fu.elsettings,'captcha_display','OF
4306F') == 'ON') ? true : false;
4307				if(captcha_onoff) {
4308					_fu.blockEL.find('.kcaptcha-box img').attr('src', '//storage.googleapis.com/i.addblock.net/js/load_kcaptcha.gif');
4309					$.post(rt_path + '/check/kcaptcha/session/' + id + '?_' + new Date().getTime(), function(data) {
4310						// md5_norobot_key = data;
4311						var tmpImg = new Image();
4312						tmpImg.src = rt_path + '/check/kcaptcha/image/' + id;
4313						tmpImg.onload = function() {
4314							_fu.blockEL.find('.kcaptcha-box img').attr('src', rt_path + '/check/kcaptcha/image/' + id + '?_' + new Date().getTime());
4315						};          
4316					});
4317		
4318					_fu.blockEL.find('.kcaptcha.small').off('click').on('click', function() {
4319						_fu.blockEL.find('.kcaptcha-box img').attr('src', '//storage.googleapis.com/i.addblock.net/js/load_kcaptcha.gif');
4320						$.post(rt_path + '/check/kcaptcha/session/' + id + '?_' + new Date().getTime(), function(data) {
4321							// md5_norobot_key = data;
4322							var tmpImg = new Image();
4323							tmpImg.src = rt_path + '/check/kcaptcha/image/' + id;
4324							tmpImg.onload = function() {
4325								_fu.blockEL.find('.kcaptcha-box img').attr('src', rt_path + '/check/kcaptcha/image/' + id + '?_' + new Date().getTime());
4326							};          
4327						});
4328					});
4329				} else {
4330					_fu.blockEL.find('.captcha').hide();
4331				}
4332		
4333				_fu.blockEL.find('.default_top, .default_bottom').removeClass('flex-value-order1 flex-value-order2');
4334				var guestbook_input_updown = getOrDefault(_fu.elsettings,'input_updown','U');
4335				if(guestbook_input_updown == 'U') {
4336					_fu.blockEL.find('.default_top').addClass('flex-value-order1');
4337					_fu.blockEL.find('.default_bottom').addClass('flex-value-order2');
4338				} else {
4339					_fu.blockEL.find('.default_top').addClass('flex-value-order2');
4340					_fu.blockEL.find('.default_bottom').addClass('flex-value-order1');
4341				}
4342			}
4343
4344			var writebtn_onoff = (typeof _fu.elsettings.writebtn_display !='undefined' && _fu.elsettings.writebtn_display == 'OFF') ? false : true;
4345			if(typeof MODE == 'undefined' && !writebtn_onoff) {
4346				_fu.blockEL.find('.tpl-forum-write[data-disabled="true"]').remove();
4347			}
4348			
4349			_fu.blockEL.removeClass('preloading');
4350		},
4351	};
4352
4353	$.forumChangeList = {
4354		init : function(id){
4355
4356		},
4357		makeList : function(F_SID,id){
4358			var listStr = '';
4359
4360			$.ajax({
4361                url: '/fm/ChangeList/type/get',
4362                dataType: 'json',
4363                type: 'POST',
4364                data: { sid: F_SID, pid : id},
4365                async: false,
4366                cache: false,
4367                success: function (data) {
4368
4369                	if(typeof data.error != 'undefined' && data.error) {
4370                		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
4371                		return false;
4372                	}
4373
4374                	var notice_list = [],
4375                		general_list = [];
4376
4377            		$.each(data,function(f,g){
4378            			if(g.fm_option=='N') notice_list.push(g);
4379            			else general_list.push(g);
4380            		});
4381                	
4382
4383                	listStr += '\
4384                		<div class="change-list-box">\
4385                		';
4386                	
4387                	if(notice_list.length>0) {		
4388                	listStr +='\
4389                			<h3>'+$.lang[LANG]['editor.forum.faqChangeList.config.notice']+'</h3>\
4390                			';
4391            		}
4392
4393            		listStr +='\
4394            				<ul class="ui-sortable change-list" data-listtype="notice">\
4395	            				';
4396        					$.each(notice_list,function(i,v){
4397					listStr += '\
4398								<li data-num="'+v.fm_num+'" data-seq="'+v.seq+'">\
4399									<div class="change-list-move hand cl-sort-handle change-list-handle-notice">\
4400									' + clSVG('move_handle', 20, 20) + '\
4401									</div>\
4402									<div class="change-list-text">\
4403										' + initSVGIcon('item_forum_notice','bc-svg-notice') + '\
4404										<span class="change-fmtitle">'+v.fm_title+'</span>\
4405									</div>\
4406								</li>\
4407								';
4408							});
4409            		listStr += '\
4410            				</ul>\
4411                		';
4412
4413            		if(general_list.length>0) {		
4414            		listStr += '\
4415            				<h3>'+$.lang[LANG]['editor.forum.faqChangeList.config.normal']+'</h3>\
4416            				';
4417    				}
4418            		
4419            		listStr += '\
4420		            		<ul class="ui-sortable change-list" data-listtype="general">\
4421            				';
4422        					$.each(general_list,function(s,d){
4423					listStr += '\
4424								<li data-num="'+d.fm_num+'" data-seq="'+d.seq+'">\
4425									<div class="change-list-move hand cl-sort-handle change-list-handle-normal">\
4426									' + clSVG('move_handle', 20, 20) + '\
4427									</div>\
4428									<div class="change-list-text">\
4429										' + (d.fm_option=='S' ? initSVGIcon('item_forum_secret','bc-svg-secret') : '') + '\
4430										<span class="change-fmtitle">'+d.fm_title+'</span>\
4431									</div>\
4432								</li>\
4433								';
4434							});
4435            		listStr += '\
4436            				</ul>\
4437            			</div>\
4438            		';
4439
4440                }
4441            });		
4442
4443			return listStr;
4444
4445		},
4446		open : function(id){
4447			//$.forumChangeList.init(id);			
4448			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
4449			
4450			var listStr = $.forumChangeList.makeList(F_SID,id),
4451				modal = $(this).showModalFlat($.lang[LANG]['editor.forum.faqChangeList.config'],listStr,true,true,function(){
4452
4453				$.progressON($.lang[LANG]['editor.forum.faqChangeList.config.changing'],'','',true);
4454				
4455				var updateList = {},
4456					updateList_notice = {},
4457					updateList_general = {};
4458
4459				$.each($('.change-list'),function(z,x){
4460					var listType = $(this).attr('data-listtype');
4461
4462					if(listType=='notice') {
4463					 	updateList_notice = $(this).find('li').map(function(i,v) {
4464							var dataNum = $(this).attr('data-num'),
4465								dataSeq = $(this).attr('data-seq');
4466
4467							return {
4468								dataNum : dataNum,
4469								dataSeq : dataSeq
4470							}
4471						}).get();
4472					} else {
4473						updateList_general = $(this).find('li').map(function(i,v) {
4474							var dataNum = $(this).attr('data-num'),
4475								dataSeq = $(this).attr('data-seq');
4476
4477							return {
4478								dataNum : dataNum,
4479								dataSeq : dataSeq
4480							}
4481						}).get();
4482					}
4483
4484					updateList = updateList_notice.concat(updateList_general);
4485					$('.progress-bar').css('width','40%');
4486				});
4487
4488				$.ajax({
4489	                url: '/fm/ChangeList/type/update',
4490	                dataType: 'json',
4491	                type: 'POST',
4492	                data: { sid: F_SID, pid : id, updateList : updateList },
4493	                async: false,
4494	                cache: false,
4495	                success: function (data) {
4496	                	if(typeof data.error != 'undefined' && data.error) {
4497	                		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
4498	                		return false;
4499	                	}
4500	                	$('.progress-bar').css('width','100%');
4501	                	setTimeout(function() {		                		
4502                			modal.modal('hide');
4503		                  	$.progressOFF();
4504		                  	showPageCallback(showPage);	
4505		                },'650');
4506	                }
4507                });	
4508
4509                var type = getElementType();
4510                setLogs(type,'forum.faq.sort','block-sort', type);
4511				
4512			},'config.close','config.save', 'cl-cmmodal cl-cmwide cl-s-btn w700 cl-p70 cl-p0 cl-forum-changeList',true,'',function(){			
4513				var num_array = [];
4514				$('.change-list').each(function(){
4515					$(this).sortable({
4516						placeholder:'chage-list-move-placeholder',
4517						connectWith: $(this),
4518		                handle : '.change-list-move',
4519		                revert :50,
4520		                tolerance: 'pointer',
4521						helper : 'clone',
4522		                update : function(e,ui){
4523		                	$(this).find('li').removeClass('chage-list-move-placeholder');
4524		                	num_array = $(this).sortable( "toArray", { attribute : 'data-num' });
4525		                	num_array.sort(function(q,w){
4526		                		return q - w;
4527		                	});
4528
4529		                	var listType = $(this).attr('data-listtype');
4530
4531		                	$.each(num_array,function(a,b){
4532								$.each($('.change-list[data-listtype="'+listType+'"] li'),function(n,m){
4533									if(a==n) $(this).attr('data-num',b);
4534								});
4535							});
4536		                }
4537		            }).disableSelection();
4538				});
4539			});
4540		},
4541	};
4542
4543	var getConfigChecked = function (value,select,valstr) {
4544		valstr = (typeof valstr == 'undefined') ? 'selected' : valstr;
4545		var check = [];
4546
4547		$.each(select, function(i,v) {
4548			check.push((value.toUpperCase()==v) ? valstr : '');
4549		});
4550		return check;
4551	}
4552
4553	var groupConfigForum = function(config,id,group) {
4554		config = $.forum.setDefaultConfig(config);
4555
4556		var tpUser = ['ADM','A','M','N','G'],
4557			tpOnoff = ['ON','OFF'],
4558			tpSecret = ['N','U','A'],
4559			tpSecretComment = ['N','U','A'],
4560			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
4561			group_member = 0,
4562			groups = group,
4563			select_group = config.group,
4564			select_group_str = '';
4565
4566		var preference = { group : '', write : [], view : [], reply : [], list : [], modify : config.modify, delete : config.delete, row : config.page_row, secret : [], sns : [], comment : []}
4567		preference.write 	= getConfigChecked(config.write_level,tpUser);
4568		preference.view 	= getConfigChecked(config.view_level,tpUser);
4569		preference.reply 	= getConfigChecked(config.reply_level,tpUser);
4570		preference.list 	= getConfigChecked(config.list_level,tpUser);
4571		preference.secret 	= getConfigChecked(config.secret_display,tpSecret,'checked');
4572		preference.secretComment = getConfigChecked(config.secretComment_display,tpSecretComment,'checked');
4573		preference.comment 	= getConfigChecked(config.comment_display,tpOnoff,'checked');
4574
4575		var namelist_str = $.forum.getGroupNameList(id);
4576
4577		var str = '\
4578		<div class="clearwrap">\
4579			<div class="forum-member-search">\
4580				<div class="select-wrap">\
4581					<select class="hand" id="g-sfl" name="g-sfl" placeholder="' + $.lang[LANG]['board.g-sfl.all'] + '">\
4582						<option value="all" data-id="all" selected>' + $.lang[LANG]['board.g-sfl.all'] + '</option>\
4583						' + namelist_str + '\
4584					</select>\
4585				</div>\
4586				<div class="cl-common-form-wrap nonplace-holder">\
4587                    <div class="cl-common-form-group">\
4588    					<input id="g-stx" name="g-stx" class="config-input member-search" placeholder="' + $.lang[LANG]['board.search.userid.'+mtype] + '">\
4589                        <label class="lock-input-error"></label>\
4590                    </div>\
4591                    <span class="btn btn-xs btn-forum-config btn-forum-group-search" data-toggle="tooltip" data-placement="top" data-id="' + SID + '">\
4592	                	<svg viewBox="0 0 13 13" width="13" height="13">\
4593	                		<path d="M13 12.29L9.73 9.02C10.52 8.06 11 6.84 11 5.5 11 2.46 8.54 0 5.5 0 2.46 0 0 2.46 0 5.5 0 8.54 2.46 11 5.5 11c1.34 0 2.57-0.48 3.52-1.27L12.29 13 13 12.29zM1 5.5C1 3.02 3.02 1 5.5 1S10 3.02 10 5.5 7.98 10 5.5 10 1 7.98 1 5.5z"/>\
4594	                	</svg>\
4595	                </span>\
4596                </div>\
4597			</div>\
4598		</div>\
4599		<div class="config-wrap">';
4600		if(groups.length == 0) {
4601			str = str + '<div class="forum-settings group empty"><p>그룹이 없습니다.</p></div>';
4602		} else {
4603			str = str + '\
4604			<div class="panel-group forum-settings group" id="group-accordion">\
4605			';
4606			for(var i=0; i<groups.length; i++) {
4607				if(select_group == groups[i].id) {
4608					selected = 'selected';
4609					group_member = groups[i].member_count;
4610					select_group_str = ' - ' + groups[i].name;
4611				} else {
4612					selected = '';
4613				}
4614				
4615				str = str + getGroupList(groups[i].id, groups[i].name, groups[i].member_count);
4616			}
4617
4618			str = str + '\
4619			</div>\
4620		';
4621		}
4622		str = str + '\
4623		</div>\
4624		<div class="froum-group-add">\
4625			<span class="btn btn-group-add">\
4626				<span><svg viewBox="0 0 12 12" width="12" height="12"><polygon points="12 5 7 5 7 0 5 0 5 5 0 5 0 7 5 7 5 12 7 12 7 7 12 7 "/></svg></span>\
4627			' + $.lang[LANG]['board.add-group'] + '</span>\
4628		</div>\
4629		';
4630		return str;
4631	}
4632
4633
4634	var getGroupList = function (gid, gname, gmcount) {
4635		var str =  '\
4636				<div class="panel">\
4637					<div class="panel-heading">\
4638						<div class="panel-title">\
4639							<a class="accordion-toggle group-item hand" data-id="' + gid + '" data-member-count="' + gmcount + '">\
4640								<label class="group-name hand">' + gname + '</label>\
4641								<span class="group-member-count">' + gmcount + '</span>\
4642								<svg viewBox="0 0 8 4" width="8" height="4"><polygon points="0 0 4 4 8 0 "/></svg>\
4643							</a>\
4644							<div class="content">\
4645								<span>\
4646									<svg viewBox="0 0 13 13" width="13" height="13" class="group-user-add hand">\
4647										<polygon points="13 2 11 2 11 0 10 0 10 2 8 2 8 3 10 3 10 5 11 5 11 3 13 3 "/>\
4648										<path d="M6.83 8.36C7.54 7.81 8 6.96 8 6c0-1.66-1.34-3-3-3S2 4.34 2 6c0 0.96 0.46 1.81 1.17 2.36C1.31 9.09 0 10.89 0 13h1c0-2.21 1.79-4 4-4s4 1.79 4 4h1C10 10.89 8.69 9.09 6.83 8.36zM3 6c0-1.1 0.9-2 2-2 1.1 0 2 0.9 2 2S6.1 8 5 8C3.9 8 3 7.1 3 6z"/>\
4649									</svg>\
4650								</span>\
4651								<span>\
4652									<svg viewBox="0 0 13 13" width="13" height="13" class="group-name-edit hand">\
4653										<path d="M4.32 8.05C4.2 8.39 4.46 8.71 4.79 8.71c0.05 0 0.11-0.01 0.16-0.03L7 8l6-6-2-2L5 6 4.32 8.05zM5.87 6.54L11 1.41 11.59 2 6.46 7.13 5.58 7.42 5.87 6.54z"/>\
4654										<path d="M9 11c0 0.55-0.45 1-1 1H2c-0.55 0-1-0.45-1-1V4c0-0.55 0.45-1 1-1h3V2H2C0.9 2 0 2.9 0 4v7c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V8H9V11z"/>\
4655									</svg>\
4656								</span>\
4657								<span>\
4658									<svg viewBox="0 0 12 13" width="12" height="13" class="group-delete hand">\
4659										<path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/>\
4660										<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
4661									</svg>\
4662								</span>\
4663							</div>\
4664						</div>\
4665					</div>\
4666					<div id="group-list-' + gid + '" class="panel-collapse" style="display:none;" data-load="'+((gmcount > 0) ? 'true' : 'false')+'">\
4667						<div class="panel-body">\
4668						</div>\
4669					</div>\
4670				</div>\
4671		';
4672		return str;
4673	}
4674
4675	var getGroupMemberList = function (id,userid) {
4676
4677		var userid = (typeof userid == 'undefined' || !userid) ? '' : userid, 
4678			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
4679			str = '';
4680
4681		$.post('/fm/group/member', { id : id, page : 1, userid : userid, mtype:mtype }, function(data) {
4682			if(typeof data.error != 'undefined' && data.error) {
4683				return false;
4684			}
4685
4686			if(data.total>0) {
4687				str = '		<ul class="group-member-list">';
4688				$.each(data.list, function(i,v) {
4689					str = str + '\
4690								<li class="gm-item">\
4691									<div>\
4692										<div class="gmi-img">\
4693											<span class="hexagon">\
4694												<img src="'+v.img+'" alt="" class="img-responsive">\
4695											</span>\
4696										</div>\
4697										<div class="gmi-info">\
4698					';
4699					if(v.name != v.id && v.name) {
4700						str = str + '\
4701											<span class="gmi-name">' + v.name + '</span>\
4702						';
4703					}
4704						str = str + '\
4705											<span class="gmi-id">' + v.id + '</span>\
4706										</div>\
4707										<div class="gmi-btn">\
4708											<svg viewBox="0 0 12 13" width="12" height="13" class="gmi-del hand" data-userid="' + v.id + '" data-id="' + v.fg_id + '">\
4709												<path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/>\
4710												<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
4711											</svg>\
4712										</div>\
4713									</div>\
4714								</li>';
4715				});
4716				str = str + '</ul>';
4717			} else {
4718				str = '		<div class="empty">' + $.lang[LANG]['board.group-no-members'] + '</div>';
4719			}
4720
4721		}, 'json');
4722		return str;
4723	}
4724
4725	var settingEditMode = function(mode) {
4726		if(mode) {
4727			$('.forum-member-search, .froum-group-add').css('pointer-events','none');
4728			$('#group-accordion').find('.forum-group-update').css('pointer-events','auto').find('input').focus();
4729			$('#group-accordion').find('.forum-group-user-add').css('pointer-events','auto').find('input').focus();
4730		} else {
4731			$('.forum-member-search, .froum-group-add').css('pointer-events','auto');
4732			$('#group-accordion').find('.config-error').remove();
4733		}
4734	}
4735
4736	var addForumGroupUpdateInput = function(gid, gname) {
4737		var gid = (typeof gid=='undefined' || !gid) ? '' : gid,
4738			gname = (typeof gname=='undefined' || !gname) ? '' : gname,
4739			str = '\
4740			<div class="forum-group-update">\
4741				<div class="input-group">\
4742					<input type="text" class="forum-group-name hand forum-control" placeholder="' + $.lang[LANG]['board.enter-group-name'] + '" value="' + gname + '"/>\
4743					<div class="input-group-btn hand ga-save" data-id="' + gid + '">\
4744						<svg viewBox="0 0 15 10" width="15" height="10" class="">\
4745							<path d="M14.29 0L5.5 8.79 0.71 4 0 4.71l5.15 5.15C5.24 9.95 5.37 10 5.5 10s0.26-0.05 0.35-0.15L15 0.71 14.29 0z"/>\
4746						</svg>\
4747					</div>\
4748					<div class="ga-cancel">\
4749						<svg viewBox="0 0 12 12" width="12" height="12">\
4750							<polygon points="12 0.71 11.29 0 6 5.29 0.71 0 0 0.71 5.29 6 0 11.29 0.71 12 6 6.71 11.29 12 12 11.29 6.71 6 "/>\
4751						</svg>\
4752					</div>\
4753				</div>\
4754			</div>\
4755		';
4756		return str;
4757	}
4758
4759
4760	$doc.on('hidden.bs.modal','.flat-gc-modal .modal', function (e) {
4761		var ctrlChmodSelectGroup = $('#el-blockConfig .ctrl-chmod-select[data-mode="group"]'),
4762			gid = ctrlChmodSelectGroup.find('option:selected').attr('data-id'),
4763			str = $.forum.getGroupNameList(selectID);
4764		settingEditMode(false);
4765
4766		ctrlChmodSelectGroup.html(str);
4767		var selectGroup = (ctrlChmodSelectGroup.find('option[data-id="' + gid + '"]').length > 0) ? ctrlChmodSelectGroup.find('option[data-id="' + gid + '"]') : ctrlChmodSelectGroup.find('option:first-child');
4768		selectGroup.attr('selected',true);
4769
4770		$('#el-blockConfig .ctrl-chmod-select option[value="G"]').each(function() {
4771			$(this).text($.lang[LANG]['board.access-group-label'] + ' - ' + selectGroup.val());
4772		});
4773		$('.flat-gc-modal').remove();
4774	});
4775
4776
4777	$doc.on('click','.btn-group-add', function (e) {
4778		if($('#group-accordion').find('.forum-group-update').length > 0) return false;
4779
4780		$('#g-stx').val('');
4781		$('#g-sfl option:first-child').attr('selected',true);
4782		$.forum.getgroupdata($('.flat-gc-modal .modal').attr('data-fid'));
4783
4784		var input_text = addForumGroupUpdateInput();
4785		$(input_text).appendTo($('#group-accordion'));
4786		settingEditMode(true);
4787	});
4788
4789	$doc.on('click','.ga-cancel',function (e) {
4790		settingEditMode(false);
4791		$('#group-accordion').find('.forum-group-update').remove();
4792	});	
4793
4794
4795	$doc.on('click','.ga-save', function (e) {
4796		if($(this).hasClass('clicked')) return false;
4797		else $(this).addClass('clicked');
4798
4799		var group_name = $('.forum-group-name').val();
4800		var id = $(this).attr('data-id');
4801		var categoryRegexp =  /[\[\]|,'"<>{}\/\\:;%&@$!*?\^]/;
4802		var special_pattern = /[~!?@\#$%<>^&*\(){}\-\[\]\\:;=+_\’'"]/gi;
4803		var editgroupname = (id) ? 'g-edit' : '';
4804		$position = (id) ? $('.group-item[data-id="'+id+'"]').parents('.panel-title') : $('#group-accordion');
4805
4806		$('.config-error').remove();
4807		var show_error_ga_save = function(error_message) {
4808			$position.find('.forum-group-update').removeClass('error-forum').addClass('error-forum');
4809			$position.append('\
4810				<div class="config-error '+editgroupname+'">\
4811					' + clSVG('info',13,13) +'\
4812					<span>' + error_message + '</span>\
4813				</div>\
4814		    ');
4815		    $('.ga-save').removeClass('clicked');
4816		}
4817
4818		if($('.group-item[data-id="'+id+'"] .group-name').text() == group_name) {
4819			settingEditMode(false);
4820			$('#group-accordion').find('.forum-group-update').remove();
4821			$('.ga-save').removeClass('clicked');
4822			return false;
4823		}
4824
4825		if(!group_name.trim()) {
4826			show_error_ga_save($.lang[LANG]['board.allowed-chars.none']);
4827			return false;
4828		}
4829		if(checkEmojis(group_name.trim())) {
4830			show_error_ga_save($.lang[LANG]['config.unable.emoji']);
4831			return false;
4832		}
4833		if((special_pattern.test(group_name.trim()) == true)) {
4834			show_error_ga_save($.lang[LANG]['board.allowed-chars']);
4835            return false;
4836        }
4837		if(group_name.length<1) {
4838			show_error_ga_save($.lang[LANG]['board.enter-group-name']);
4839			return false;
4840		}
4841		if(group_name.length>60) {
4842			show_error_ga_save($.lang[LANG]['board.enter-max-chars.60']);
4843			return false;
4844		}
4845
4846		$.post('/fm/group/update', { sid : F_SID, id : id, name : encodeURIComponent(group_name) }, function(data) {
4847			if(typeof data.error != 'undefined' && data.error) {
4848				show_error_ga_save(data.error);
4849				return false;
4850			}
4851
4852			$('#group-accordion').find('.forum-group-update').remove();
4853			settingEditMode(false);
4854			if(id) {
4855				var str = '\
4856					<label class="group-name">' + data.name + '</label>\
4857					<span class="group-member-count">' + $('#group-accordion .group-item[data-id="' + data.id + '"]').attr('data-member-count') + '</span>\
4858					<svg viewBox="0 0 8 4" width="8" height="4"><polygon points="0 0 4 4 8 0 "/></svg>\
4859				';
4860				$('#group-accordion .group-item[data-id="' + data.id + '"]').html(str);
4861				$('.flat-gc-modal #g-sfl option[data-id="' + data.id + '"]').attr('value',data.name).text(data.name);
4862			} else {
4863				var newgroup = getGroupList(data.id, data.name, 0);
4864				$('#group-accordion').append(newgroup);
4865				$('#group-accordion .group-item[data-id="' + data.id + '"]').click();
4866				$('.flat-gc-modal #g-sfl').append('<option value="'+data.name+'" data-id="'+data.id+'" data-member-count="'+data.member_count+'">'+data.name+'</option>');
4867			}
4868
4869			groups = getForumGroupObject();
4870			if($('#el-blockConfig.open').length > 0 && (typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == selectID)) {
4871				bc_fr.group = groups;
4872			}
4873			$('.ga-save').removeClass('clicked');
4874
4875		}, 'json');
4876	});
4877
4878	$doc.on('click','.group-user-add, .group-item', function (e) {
4879		if($('#group-accordion').find('.forum-group-user-add').length > 0) return false;
4880		$select_group = $(this).parents('.content').prev('.group-item');
4881
4882		var gid = ($(this).hasClass('group-item')) ? $(this).attr('data-id') : $select_group.attr('data-id'),
4883			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
4884			group_member_list_check = $(this).parents('.panel').find('.group-member-list').length,
4885			display_check = $('#group-list-'+gid).css('display');
4886
4887		var input_text = '\
4888			<li class="gm-item forum-group-user-add-li">\
4889				<div class="forum-group-user-add">\
4890					<div class="input-group">\
4891						<input type="text" class="gua-userid forum-control" placeholder="' + $.lang[LANG]['board.enter-member-email.'+mtype] + '"/>\
4892						<span class="input-group-btn hand gua-save" data-id="' + gid + '" data-mtype="' + mtype + '">\
4893							<svg viewBox="0 0 15 10" width="15" height="10" >\
4894								<path d="M14.29 0L5.5 8.79 0.71 4 0 4.71l5.15 5.15C5.24 9.95 5.37 10 5.5 10s0.26-0.05 0.35-0.15L15 0.71 14.29 0z"/>\
4895							</svg>\
4896						</span>\
4897						<div class="gua-cancel">\
4898							<svg viewBox="0 0 12 12" width="12" height="12">\
4899								<polygon points="12 0.71 11.29 0 6 5.29 0.71 0 0 0.71 5.29 6 0 11.29 0.71 12 6 6.71 11.29 12 12 11.29 6.71 6 "/>\
4900							</svg>\
4901						</div>\
4902					</div>\
4903				</div>\
4904			</li>\
4905		',
4906		member_list = '\
4907			<ul class="group-member-list">\
4908			' + input_text + '\
4909			</ul>\
4910			';
4911
4912		if(display_check=='none') {
4913			if($(this).hasClass('group-item')=== false) {
4914		 		groupAddClass(group_member_list_check,$(this),input_text,member_list);
4915			} else {
4916
4917				if($('#group-list-'+gid).is('[data-load="true"]')) {
4918					var glist_html = getGroupMemberList(gid);
4919					$('#group-list-'+gid+' .panel-body').html(glist_html);
4920					$('#group-list-'+gid).removeAttr('data-load');
4921				}
4922			}
4923
4924			$('#group-list-'+gid).slideDown();
4925			$(this).addClass('glOpen');
4926
4927		} else {			
4928			if($(this).hasClass('group-item')===false) {
4929				groupAddClass(group_member_list_check,$(this),input_text,member_list);
4930			} else {
4931				$(this).removeClass('glOpen');
4932				$('#group-list-'+gid).slideUp();
4933			}
4934		}
4935	});
4936	
4937
4938	$doc.on('click','.gua-cancel',function (e) {
4939		var empty_check = $(this).parents('.panel-body').find('.empty').css('display');
4940		if(empty_check == 'none') {
4941			$(this).parent('.panel').find('.group-member-list').remove();
4942			$(this).parents('.panel').find('.empty').show();  
4943		}	
4944		settingEditMode(false);
4945		$('#group-accordion').find('.forum-group-user-add-li').remove();
4946	});
4947
4948	$doc.on('click','.gua-save',function (e) {
4949		if($(this).hasClass('clicked')) return false;
4950		else $(this).addClass('clicked');
4951
4952		var $select_group = $(this).parents('.panel').find('.group-item'),
4953			$add_error = $(this).parents('.gm-item'),
4954			$userid = $('.gua-userid'),
4955			id = $(this).attr('data-id'),
4956			mtype = $(this).attr('data-mtype');
4957
4958		$('.config-error').remove();
4959		var show_error_gua_save = function(error_message) {
4960			$add_error.append('\
4961				<div class="config-error">\
4962					' + clSVG('info',13,13) +'\
4963					<span>' + error_message + '</span>\
4964				</div>\
4965		    ');
4966		    $('.gua-save').removeClass('clicked');
4967		}
4968
4969		if(!$userid.val().trim()) {
4970			show_error_gua_save($.lang[LANG]['board.enter-member-email.um']);
4971			return false;
4972		}
4973		if(checkEmojis($userid.val().trim())) {
4974			show_error_gua_save($.lang[LANG]['config.unable.emoji']);
4975			return false;
4976		}
4977		if(typeof id == 'undefined' || id==null || !id) {
4978			show_error_gua_save('Invalid variable');
4979			return false;
4980		}
4981		$.post('/fm/group/useradd', { id:id, userid:$userid.val().trim().toLowerCase(), mtype:mtype }, function(data) {
4982			if(typeof data.error != 'undefined' || data.error) {
4983				show_error_gua_save(data.error);
4984				return false;
4985			}
4986
4987			if($('.member-search').val()) {
4988				$('#g-stx').val('');
4989				$('#g-sfl option:first-child').attr('selected',true);
4990				$.forum.getgroupdata($('.flat-gc-modal .modal').attr('data-fid'));
4991			}
4992			$select_group.attr('data-member-count',data.count);
4993			$select_group.find('.group-member-count').text(data.count);
4994
4995			settingEditMode(false);
4996
4997			$('#group-accordion').find('.forum-group-user-add-li').remove();
4998			groups = getForumGroupObject();
4999			if($('#el-blockConfig.open').length > 0 && (typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == selectID)) {
5000				bc_fr.group = groups;
5001			}
5002
5003			getGroupMembers(id);
5004			$('.gua-save').removeClass('clicked');
5005
5006		},'json');
5007	});
5008
5009	$doc.on('click','.group-name-edit',function (e) {
5010		$select_group = $(this).parents('.content').prev('.group-item');
5011		var gid = $select_group.attr('data-id'),
5012			gname = $select_group.find('.group-name').text();
5013		if($('#group-accordion').find('.forum-group-update').length > 0) return false;
5014
5015		var input_text = addForumGroupUpdateInput(gid, gname);
5016		$(input_text).appendTo($select_group.closest('.panel-title'));
5017		settingEditMode(true);
5018	});
5019
5020	$doc.on('click','.group-delete',function (e) {
5021		$select_group = $(this).parents('.content').prev('.group-item');
5022		var gid =  $select_group.attr('data-id'),
5023			gname = $select_group.find('.group-name').text();
5024
5025		if($('#group-accordion .group-item').length==1) {
5026			if($('#group-accordion .group-item').find('.config-error').length==0)
5027				$select_group.parents('.panel-title').append('<div class="config-error managegroups-error">\
5028						<svg viewBox="0 0 13 13" width="13" height="13">\
5029		                    <path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
5030		                    <rect x="6" y="3" width="1" height="5"/>\
5031		                    <rect x="6" y="9" width="1" height="1"/>\
5032		                </svg>\
5033	                <span>' + $.lang[LANG]['board.min-num-groups'] + '</span></div>');
5034			return false;
5035		}
5036		var str = $.lang[LANG]['board.ask-delete-group-2'] + "\
5037		";
5038
5039		$('.modal.modal-default.fade.in').css('zIndex','1029');
5040		var gd_modal = $(this).showModalFlat($.lang[LANG]['board.ask-delete-group.title'], str, true, true, function() {
5041			$.post('/fm/group/delete', { id : gid }, function(data) {
5042				if(typeof data.error != 'undefined' || data.error) {
5043					$('.forum-group-delete .content').append('<div class="config-error">' + data.error + '</div>');
5044					return false;
5045				}
5046				$('#group-accordion .group-item[data-id="' + data.id + '"]').parents('.panel').remove();
5047				$('.flat-gc-modal #g-sfl option[data-id="' + data.id + '"]').remove();
5048				groups = getForumGroupObject();
5049				if($('#el-blockConfig.open').length > 0 && (typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == selectID)) {
5050					bc_fr.group = groups;
5051				}
5052				gd_modal.modal('hide');
5053			},'json');
5054
5055		}, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0','','','',function(){
5056			$('.modal.modal-default.fade.in').css('zIndex','');
5057		});
5058		$('#delete-group-name').text(gname);
5059	});
5060
5061	$doc.on('click','.gmi-del', function (e) {
5062		var userid = $(this).attr('data-userid'),
5063			id = $(this).attr('data-id'),
5064			mtype = $(this).attr('data-mtype'),
5065			$select_group = $('.group-item[data-id="'+id+'"]'),
5066			gmcount = parseInt($select_group.find('.group-member-count').text()),
5067			str = userid + $.lang[LANG]['board.ask-delete-member-from-group'];
5068
5069		$('.modal.modal-default.fade.in').css('zIndex','1029');
5070		var gmid_modal = $(this).showModalFlat($.lang[LANG]['config.information'], str, true, true, function() {
5071			$.post('/fm/group/userdel', { id : id, userid : userid, mtype : mtype }, function(data) {
5072				if(typeof data.error != 'undefined' && data.error) {
5073					$select_group.append('<div class="config-error">' + data.error + '</div>');
5074					return false;
5075				}
5076
5077				$select_group.attr('data-member-count',gmcount-1);
5078				$select_group.find('.group-member-count').text(gmcount-1);
5079
5080				getGroupMembers(id);
5081				gmid_modal.modal('hide');
5082			},'json');
5083		},'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0','','','',function(){
5084			$('.modal.modal-default.fade.in').css('zIndex','');
5085		});
5086	});
5087
5088
5089	$doc.on('click','#ctrl-forum-group', function(e) {
5090		var id = $(this).attr('data-id');
5091		$.forum.groupconfig(id);
5092	});
5093
5094	$doc.on('click','#bc-default-forum-chlistmod', function(e) {
5095		var id = $('.forum-change-list').attr('data-id'),
5096			hasNoList = $('.forum-change-list').hasClass('noList') ? true : false,
5097			hasDisabled = $('.forum-change-list').hasClass('disabled') ? true : false,
5098			check_count_txt = (hasNoList) ? $.lang[LANG]['editor.forum.faqChangeList.config.noList'] : $.lang[LANG]['editor.forum.faqChangeList.config.disabled'];
5099
5100		if(hasNoList || hasDisabled) {
5101			$(this).showModalFlat($.lang[LANG]['config.information'],check_count_txt,true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70');
5102		} else $.forumChangeList.open(id);
5103	});
5104
5105	$doc.on('change','.property-form-wrap select, #prop-forum-etcmod .switch-input', function(e) {
5106		var id =  $(this).attr('data-id'),
5107			mode = $(this).attr('data-mode'),
5108			value = (mode == 'group') ? $(this).find('option:selected').attr('data-id') : $(this).val();
5109
5110		if(typeof id == 'undefined' || id==null || id=='') {
5111			$(this).showModalFlat('ERROR', $.lang[LANG]['board.error-setting-value'], true, false, '', 'ok');
5112			return false;
5113		}
5114
5115		if(value != 'undefined' && value == 'NULL') {
5116			e.preventDefault();
5117
5118            var upgrade_text = (SERVICE.indexOf('gabia') > -1) ? ((VALIDPLAN && VALIDTYPE == 'BN') ? $.lang[LANG]['board.chmod.upgrade-plan.gabia-bn'] : $.lang[LANG]['board.chmod.upgrade-plan.gabia']) : $.lang[LANG]['board.chmod.upgrade-plan'];
5119			$(this).showModalFlat('INFORMATION', upgrade_text, true, false, '', 'close');
5120            $(this).val( $(this).data('choice') );
5121			return false;
5122		}
5123
5124		if(mode == 'comment') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
5125		if(mode == 'sns') 	  value = ($(this).prop('checked')) ? 'ON' : 'OFF';
5126		if(mode == 'bottomlist') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
5127		if(mode == 'searchbox') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
5128		if(mode == 'captcha') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
5129
5130		var modetype = {
5131			'group' : 'group',
5132			'write'	: 'write_level',
5133			'view'	: 'view_level',
5134			'reply'	: 'reply_level',
5135			'list'	: 'list_level',
5136			'secret' : 'secret_display',
5137			'comment': 'comment_display',
5138			'like': 'like_display',
5139			'sns'	: 'sns_share_display',
5140			'bottomlist': 'bottomlist_display',
5141			'fieldlang' : 'field_lang',
5142			'searchbox': 'searchbox_display',
5143			'date' : 'date',
5144			'captcha' : 'captcha_display',
5145		}, settings = {};
5146
5147		settings[modetype[mode]] = value;
5148
5149
5150		$.post('/template/settings', { sid : F_SID, settings : JSON.stringify(settings), el : id }, function(data) {
5151			if(typeof data.error != 'undefined' && data.error) {
5152				$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
5153				return false;
5154			}
5155			var block_lang = ($('.element[data-id="' + id + '"]').attr('data-blocklang')) ? $('.element[data-id="' + id + '"]').attr('data-blocklang') : LANG;
5156
5157			if(mode == 'fieldlang') {
5158				$('.element[data-id="' + id + '"]').attr('data-fieldlang',value.toLowerCase());
5159				$('.element[data-id="' + id + '"] thead tr th').each(function() {
5160					var field_text = (typeof $(this).attr('class') != 'undefined') ? $(this).attr('class') : 'tpl-forum-title';
5161					if(field_text.indexOf('title') > -1 || field_text.indexOf('content') > -1) $(this).text($.lang[value.toLowerCase()]['forum.field.tpl-forum-title']);
5162					else $(this).text($.lang[value.toLowerCase()]['forum.field.' + field_text]);
5163				});
5164
5165				if($('.element[data-id="' + id + '"]').attr('data-type') == 'forum' && $('.element[data-id="' + id + '"]').attr('data-type2') == 'qna') {
5166					$('.element[data-id="' + id + '"] .qna-item .tpl-forum-list-state').each(function(i) {
5167                        if($(this).closest('.qna-item').find('.tpl-forum-list-num').hasClass('n')) $(this).text('');
5168                        else if(typeof $(this).attr('data-state') != 'undefined' && $(this).attr('data-state') == 'true') $(this).text($.lang[block_lang]['forum.qna.state.replied']);
5169						else $(this).text($.lang[block_lang]['forum.qna.state.waiting']);
5170					});
5171				}
5172	
5173				$('.element[data-id="' + id + '"]').find('.tpl-forum-write').text($.lang[value.toLowerCase()]['forum.field.tpl-forum-write']);
5174			}
5175			if(mode == 'searchbox') {
5176				var $forum_el = $('.element[data-id="' + id + '"]');
5177				syncForumSearchboxDisplay($forum_el, value == 'ON');
5178				syncForumCategoryTypeDisplay($forum_el);
5179			}
5180			if(mode == 'date') {
5181				var page = F_PAGE,
5182					page_num = 1,
5183					view = $('.element.active').find('.tpl-forum-pagination li').first().attr('data-view'),
5184					sfl = '',
5185					stx = '',
5186					scate = '';
5187
5188				$.forum.setForumCookie(id,page_num,stx,sfl,scate);
5189				cookie_page_num = $.cookie('forum_'+id);
5190				$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
5191				activeEL('userEL'+id);
5192			}
5193
5194		}, 'json');
5195	});
5196	
5197	var getForumGroupObject = function() {
5198		var $select = $('#group-accordion .group-item');
5199		groups = [];
5200		$.each($select,function(i,v) {
5201			groups[i] = {
5202				'id' : $(this).attr('data-id'),
5203				'name' : $(this).find('.group-name').text(),
5204				'member_count' : $(this).attr('data-member-count')
5205			}
5206		});
5207		return groups;
5208	}
5209
5210	var deleteForumPost = function(id) {
5211
5212			$.post('/fm/delete', { id : id, user : user }, function(data) {
5213				if(typeof data.error != 'undefined' && data.error) {
5214					$('.flat-modal .modal').modal('hide');
5215					var modal = $(this).showModalFlat('ERROR', data.error, true, false, '', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
5216					return false;
5217				}
5218
5219				//this case:: forum QnA / FAQ block, answer delete =>> page refresh
5220				var checkPageReload = (	$('.element[data-type="forum"][data-type2="qna"] .qna-details .tpl-toolbar-question-del[data-id="' + id + '"]').length > 0 
5221										|| $('.fctrl-item[data-cmd="del"]').attr('data-seq') == id
5222										|| $(`.element[data-type="forum"][data-type2="faq"] .tpl-forum-faq-ctrl [data-id="${id}"]`).length > 0
5223									) ? true : false;
5224
5225				if( $('.page-bottomlist').length > 0 && $('.page-bottomlist').attr('data-pid') === id ) {
5226					checkPageReload = false;				
5227				}
5228				
5229				if(checkPageReload) location.reload();
5230				else $('.tpl-forum-list').click();
5231
5232				// modal.modal('hide');
5233			},'json');
5234
5235	}
5236
5237	var deleteGuestbook = function(pid, id) {
5238		$.post('/fm/delete', { id : id, user : user }, function(data) {
5239			if(typeof data.error != 'undefined' && data.error) {
5240				$('.flat-modal .modal').modal('hide');
5241				var modal = $(this).showModalFlat('ERROR', data.error, true, false, '', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
5242				return false;
5243			} else {
5244				var view = $('.element[data-id="' + pid + '"]').find('[data-view]').attr('data-view');
5245				$.forum.init(pid, 1, view);
5246			}
5247		},'json');
5248	}
5249
5250	var setForumPagination = function($obj, total, view, page_num, id, page) {
5251		var page_view = 5,
5252		    start = Math.floor((page_num-1) / page_view) * page_view,
5253		    pages = Math.ceil(total/view),
5254		    end = (Math.floor((page_num-1) / page_view) + 1) * page_view,
5255		    end = (end>pages) ? pages : end,
5256		    prev = (start > 0) ? start : 1,
5257		    next = ((end+1) > pages) ? pages : end+1;
5258		$obj.find('li').addClass('tpl-forum-page');
5259
5260		var arrow_selector = `.userEL${$obj.parents('.element').data('id')}`,
5261			arrow_str = (document.querySelector(arrow_selector) != null) ? getComputedStyle(document.querySelector(arrow_selector)).getPropertyValue('--pagination-arrow') : '',
5262			arrow_arr = arrow_str.trim().split(','),
5263			arrow_obj = {
5264				check: arrow_arr[0] ? true : false,
5265				type: arrow_arr[0] || '1',
5266				w: arrow_arr[1] || '12',
5267				h: arrow_arr[2] || '12',
5268			};
5269
5270		if(!arrow_obj.check && $obj.children().first().find('svg').length == 0) {
5271			arrow_obj.arrow = [`<i class="fa fa-angle-double-left"></i>`,`<i class="fa fa-angle-double-right"></i>`];
5272		} else {
5273			arrow_obj.arrow = [clSVG(`forum_arrow${arrow_obj.type}_2`, arrow_obj.w, arrow_obj.h),clSVG(`forum_arrow${arrow_obj.type}_2`, arrow_obj.w, arrow_obj.h)];
5274		}
5275
5276		var $prev = $obj.children().first().clone(),
5277			$next = $obj.children().last().clone();
5278		$prev.attr({'data-page': page, 'data-id': id, 'data-view': view, 'data-page-num':prev});
5279		$next.attr({'data-page': page, 'data-id': id, 'data-view': view, 'data-page-num':next});
5280
5281		var $first = $prev.clone(),
5282			$last = $next.clone();
5283		$first.attr({'data-page-num':'1'}).find('a').empty().append(arrow_obj.arrow[0]);
5284		$last.attr({'data-page-num':pages}).find('a').empty().append(arrow_obj.arrow[1]);
5285
5286		$obj.empty().append($prev).append($next);
5287
5288		for(i=start;i<end;i++) {
5289			var active = ((i+1) == page_num) ? 'active' : '';
5290			$obj.children().last().before($(`
5291					<li class="tpl-forum-page ${active}" data-id="${id}" data-page="${page}" data-view="${view}" data-page-num="${i+1}" data-pid="${id}">
5292						<a href="#">${i+1}</a>
5293					</li>
5294				`));
5295		}
5296
5297		if(pages>1 && pages>=page_num && pages>page_view) $obj.prepend($first).append($last);
5298	}
5299
5300
5301	var getGroupMembers = function(id, userid) {
5302		userid = (typeof userid == 'undefined' || !userid) ? '' : userid;
5303		var $grouplist = $('#group-list-'+id+' .panel-body');
5304		$grouplist.find('.empty').remove();
5305		$grouplist.find('.group-member-list').remove();
5306
5307		$grouplist.append(getGroupMemberList(id,userid));
5308	}
5309
5310	var setMemberPagination = function($obj,total,page_num,id) {
5311		var page_view = 10, view = 10,
5312		    start = Math.floor((page_num-1) / page_view) * page_view,
5313		    pages = Math.ceil(total/view),
5314		    end = (Math.floor((page_num-1) / page_view) + 1) * page_view,
5315		    end = (end>pages) ? pages : end,
5316		    prev = (start > 0) ? start : 1,
5317		    next = ((end+1) > pages) ? pages : end+1;
5318
5319		var $prev = $('<li class="forum-group-member-pagination" data-id="' + id + '" data-view="' + page_view + '" data-page-num="' + prev + '"><a href="#"><i class="fa fa-angle-left"></i></a></li>'),
5320			$next = $('<li class="forum-group-member-pagination" data-id="' + id + '" data-view="' + page_view + '" data-page-num="' + next + '"><a href="#"><i class="fa fa-angle-right"></i></a></li>');
5321			
5322		$obj.empty();
5323		$obj.append($prev);
5324		for(i=start;i<end;i++) {
5325			var active = ((i+1) == page_num) ? 'active' : '';
5326			$obj.append($('<li class="forum-group-member-pagination ' + active + '" data-id="' + id + '" data-view="' + page_view + '" data-page-num="' + (i+1) + '"><a href="#">' + (i+1) + '</a></li>'));
5327		}
5328		if(end==0) { 
5329			$obj.append($('<li class="forum-group-member-pagination" data-id="' + id + '" data-view="' + page_view + '" data-page-num="0"><a href="#">1</a></li>'));
5330		}
5331		$obj.append($next);
5332	}
5333
5334	$doc.on('click','.forum-group-member-pagination', function(e) {
5335		var id = $(this).attr('data-id'),
5336			page = $(this).attr('data-page-num');
5337		if(page==0) return false;
5338	});
5339
5340	var tplmemberSearch = function(id) {
5341		var str = '\
5342			<div class="forum-member-search">\
5343				<input type="text" class="config-input member-search" placeholder="' + $.lang[LANG]['board.enter-member-id'] + '">\
5344				<span class="btn btn-forum-config btn-forum-group-search" data-toggle="tooltip" data-placement="top" title="SEARCH" data-id="' + id + '" style="margin-top:-3px;height:39px;"><i class="fa fa-check"></i></span>\
5345			</div>\
5346		';
5347		return str;
5348	}
5349
5350	$doc.on('change','#g-sfl',function(e) {
5351		$('.btn-forum-group-search').click();
5352	});
5353
5354	$doc.on('click','.btn-forum-group-search',function(e) {
5355		if($(this).hasClass('clicked')) return false;
5356		else $(this).addClass('clicked');
5357
5358		var id = $(this).attr('data-id'),
5359			gsfl = $('#g-sfl option:selected').attr('data-id'),
5360			gstx = $('#g-stx').val().toLowerCase().trim(),
5361			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
5362			str = '';
5363
5364		if(checkEmojis(gstx)) {
5365			e.preventDefault();
5366			$('.btn-forum-group-search').removeClass('clicked');
5367			errorEmojisModal();
5368			return false;
5369		}
5370
5371		$.post('/fm/group/membersearch', { id : id, gsfl : gsfl, gstx : gstx, mtype:mtype }, function(data) {
5372			if(typeof data.error != 'undefined' && data.error) {
5373				$('#group-accordion').html('<div class="empty">' + data.error + '</div>');
5374				$('.btn-forum-group-search').removeClass('clicked');
5375				return false;
5376			}
5377			if(!$.isNumeric(gsfl) && !gstx) {
5378				$('#g-stx').val('');
5379				$('#g-sfl option:first-child').attr('selected',true);
5380				$.forum.getgroupdata($('.flat-gc-modal .modal').attr('data-fid'));
5381				$('.btn-forum-group-search').removeClass('clicked');
5382				return false;
5383			}
5384
5385			if(data.total>0) {
5386				var group = '',
5387					mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink';
5388
5389				$.each(data.list, function(i,v) {
5390					if(group != v.fg_id) {
5391						group = v.fg_id;
5392						str = (group=='') ? '' : str + '\
5393									</ul>\
5394								</div>\
5395							</div>\
5396						</div>\
5397						';
5398						str = str + '\
5399						<div class="panel">\
5400							<div class="panel-heading">\
5401								<div class="panel-title">\
5402									<a class="accordion-toggle collapsed group-item" data-id="' + group + '" data-member-count="' + v.fg_member_count + '">\
5403										<label class="group-name hand">' + v.fg_name + '</label>\
5404										<span class="group-member-count">' + v.fg_member_count + '</span>\
5405										<svg viewBox="0 0 8 4" width="8" height="4"><polygon points="0 0 4 4 8 0 "/></svg>\
5406									</a>\
5407									<div class="content">\
5408										<span>\
5409											<svg viewBox="0 0 13 13" width="13" height="13" class="group-user-add hand">\
5410												<polygon points="13 2 11 2 11 0 10 0 10 2 8 2 8 3 10 3 10 5 11 5 11 3 13 3 "/>\
5411												<path d="M6.83 8.36C7.54 7.81 8 6.96 8 6c0-1.66-1.34-3-3-3S2 4.34 2 6c0 0.96 0.46 1.81 1.17 2.36C1.31 9.09 0 10.89 0 13h1c0-2.21 1.79-4 4-4s4 1.79 4 4h1C10 10.89 8.69 9.09 6.83 8.36zM3 6c0-1.1 0.9-2 2-2 1.1 0 2 0.9 2 2S6.1 8 5 8C3.9 8 3 7.1 3 6z"/>\
5412											</svg>\
5413										</span>\
5414										<span>\
5415											<svg viewBox="0 0 13 13" width="13" height="13" class="group-name-edit hand">\
5416												<path d="M4.32 8.05C4.2 8.39 4.46 8.71 4.79 8.71c0.05 0 0.11-0.01 0.16-0.03L7 8l6-6-2-2L5 6 4.32 8.05zM5.87 6.54L11 1.41 11.59 2 6.46 7.13 5.58 7.42 5.87 6.54z"/>\
5417												<path d="M9 11c0 0.55-0.45 1-1 1H2c-0.55 0-1-0.45-1-1V4c0-0.55 0.45-1 1-1h3V2H2C0.9 2 0 2.9 0 4v7c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V8H9V11z"/>\
5418											</svg>\
5419										</span>\
5420										<span>\
5421											<svg viewBox="0 0 12 13" width="12" height="13" class="group-delete hand">\
5422												<path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/>\
5423												<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
5424											</svg>\
5425										</span>\
5426									</div>\
5427								</div>\
5428							</div>\
5429							<div id="group-list-' + group + '" class="panel-collapse" style="display:none;">\
5430								<div class="panel-body">\
5431									<ul class="group-member-list">\
5432						';
5433					}
5434					if(v.fg_member_count!=0) {
5435						str += '\
5436										<li class="gm-item">\
5437											<div>\
5438												<div class="gmi-img">\
5439													<span class="hexagon">\
5440														<img src="'+v.img+'" alt="" class="img-responsive">\
5441													</span>\
5442												</div>\
5443					                			<div class="gmi-info">\
5444					    ';
5445					    if(v.name != v.id && v.name) {
5446						    str += '\
5447						                			<span class="gmi-name">' + v.name + '</span>\
5448							';
5449						}
5450						str += '\
5451						                			<span class="gmi-id">' + v.id + '</span>\
5452					                			</div>\
5453					                			<div class="gmi-btn">\
5454													<svg viewBox="0 0 12 13" width="12" height="13" class="gmi-del hand" data-userid="' + v.id + '" data-id="' + v.fg_id + '">\
5455														<path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/>\
5456														<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
5457													</svg>\
5458												</div>\
5459											</div>\
5460										</li>\
5461						';
5462					} else {
5463						str = str + '<div class="empty">' + $.lang[LANG]['board.group-no-members'] + '</div>';
5464					}
5465				});
5466				str = str + '\
5467									</ul>\
5468								</div>\
5469							</div>\
5470						</div>\
5471				';
5472			}
5473			//  else {
5474			// 	str = '<div class="empty">' + $.lang[LANG]['board.empty-member-in-group'] + '</div>';
5475			// }
5476			$('#group-accordion').html(str);
5477			$('.btn-forum-group-search').removeClass('clicked');
5478
5479		}, 'json');
5480	});
5481
5482	var displayMember = function(mb) {
5483		var str = '\
5484			<li>\
5485				<span class="userimg"><img src="' + mb.img + '"></span>\
5486				<span class="user-info"><div class="user-name">' + mb.name + '</div><div class="user-id">' + mb.id + '</div></span>\
5487				<div class="userdel" data-userid="' + mb.id + '" data-id="' + mb.fg_id + '"><i class="fa fa-trash-o"></i></div>\
5488			</li>\
5489		';
5490		return str;
5491	}
5492
5493	$doc.on('click','.member .userdel', function(e) {
5494		var userid = $(this).attr('data-userid'),
5495			id = $(this).attr('data-id'),
5496			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink';
5497
5498		initControlForm();
5499		$('.delete-member-userid').text(userid);
5500		$('.btn-forum-group-delete-member-ok').attr('data-userid',userid).attr('data-id',id).attr('data-mtype',mtype);
5501		$('.forum-group-delete-member-confirm').show();
5502	});
5503
5504	$doc.on('click','.btn-forum-group-delete-member-ok',function(e) {
5505		var userid = $(this).attr('data-userid'),
5506			id = $(this).attr('data-id'),
5507			mtype = $(this).attr('data-mtype');
5508
5509		$.post('/fm/group/userdel', { id : id, userid : userid, mtype : mtype }, function(data) {
5510			if(typeof data.error != 'undefined' && data.error) {
5511				$('.forum-group-delete-member-confirm .content').append('<div class="config-error">' + data.error + '</div>')
5512				return false;
5513			}
5514		},'json');
5515	});
5516
5517
5518	$doc.on('click','.forum-category-custom-toggle', function(e) {
5519		e.preventDefault();
5520		e.stopPropagation();
5521
5522		var $custom = $(this).closest('.forum-category-custom-select'),
5523			is_open = $custom.hasClass('open');
5524
5525		closeForumCategoryCustomSelect($('.forum-category-custom-select.open').not($custom));
5526		if(is_open) closeForumCategoryCustomSelect($custom);
5527		else openForumCategoryCustomSelect($custom);
5528	});
5529
5530	$doc.on('click','.forum-category-custom-option', function(e) {
5531		e.preventDefault();
5532		e.stopPropagation();
5533
5534		var $option = $(this),
5535			$custom = getForumCategoryCustomOwner($option),
5536			$select = $custom.siblings('#scate').first(),
5537			value = (typeof $option.attr('data-value') == 'undefined') ? '' : $option.attr('data-value');
5538
5539		closeForumCategoryCustomSelect($custom);
5540		if($select.length == 0 || String($select.val()) == String(value)) return false;
5541
5542		$select.val(value).trigger('change');
5543	});
5544
5545	$doc.on('keydown','.forum-category-custom-toggle', function(e) {
5546		if(e.which == 13 || e.which == 32 || e.which == 40) {
5547			e.preventDefault();
5548			$(this).trigger('click');
5549			getForumCategoryCustomMenu($(this).closest('.forum-category-custom-select')).find('.forum-category-custom-option.active').focus();
5550		}
5551	});
5552
5553	$doc.on('keydown','.forum-category-custom-option', function(e) {
5554		var $option = $(this),
5555			$custom = getForumCategoryCustomOwner($option);
5556
5557		if(e.which == 13 || e.which == 32) {
5558			e.preventDefault();
5559			$option.trigger('click');
5560		} else if(e.which == 27) {
5561			e.preventDefault();
5562			closeForumCategoryCustomSelect($custom);
5563			$custom.find('.forum-category-custom-toggle').focus();
5564		} else if(e.which == 38 || e.which == 40) {
5565			e.preventDefault();
5566			var $options = getForumCategoryCustomMenu($custom).find('.forum-category-custom-option'),
5567				idx = $options.index($option),
5568				next_idx = (e.which == 38) ? idx - 1 : idx + 1;
5569
5570			if(next_idx < 0) next_idx = $options.length - 1;
5571			if(next_idx >= $options.length) next_idx = 0;
5572			$options.eq(next_idx).focus();
5573		}
5574	});
5575
5576	$doc.on('click', function(e) {
5577		if($(e.target).closest('.forum-category-custom-select, .forum-category-custom-menu-layer').length == 0) {
5578			closeForumCategoryCustomSelect($('.forum-category-custom-select.open'));
5579		}
5580	});
5581
5582	$(window).on('scroll.forumCategoryCustomSelect resize.forumCategoryCustomSelect', function() {
5583		closeForumCategoryCustomSelect($('.forum-category-custom-select.open'));
5584	});
5585	$('.dsgn-body').on('scroll.forumCategoryCustomSelect', function() {
5586		closeForumCategoryCustomSelect($('.forum-category-custom-select.open'));
5587	});
5588
5589	$doc.on('change','#scate', function(e) {
5590		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
5591		
5592		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
5593		var sfl = $(this).parents('.search-box').find('#sfl').val(),
5594			stx = '',
5595			scate = $(this).find('option:selected').val(),
5596			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
5597			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
5598			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
5599			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
5600
5601		stx = getForumPrevStx(id);
5602		setForumCategoryActive($(this).parents('.element'), scate);
5603		$.forum.setForumCookie(id,page_num,stx,sfl,scate);
5604		cookie_page_num = $.cookie('forum_'+id);
5605		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
5606		activeEL('userEL'+id);
5607		scrollToForumBlock($(this).parents('.element'));
5608	});
5609
5610	$doc.on('click','.tpl-forum-category-nav .tpl-forum-category-item', function(e) {
5611		e.preventDefault();
5612		if($(this).closest('.element').attr('data-type') != 'forum') return false;
5613
5614		var $forum_el = $(this).closest('.element'),
5615			scate = $(this).attr('data-cate') || $(this).find('> a').attr('data-cate') || '';
5616
5617		if($(this).hasClass('active')) return false;
5618
5619		var dataCheck = ($forum_el.find('.tpl-forum-pagination').children().length > 0) ? true : false;
5620		$this_pagination = $forum_el.find('.tpl-forum-pagination li.active');
5621
5622		var sfl = $forum_el.find('.search-box #sfl').val(),
5623			stx = '',
5624			id = (dataCheck) ? $this_pagination.attr('data-id') : $forum_el.attr('data-id'),
5625			page = (dataCheck) ? $this_pagination.attr('data-page') : $forum_el.find('.tpl-forum-pagination').attr('data-page'),
5626			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
5627			view = (dataCheck) ? $this_pagination.attr('data-view') : $forum_el.find('.tpl-forum-pagination').attr('data-view');
5628
5629		stx = getForumPrevStx(id);
5630		setForumCategoryActive($forum_el, scate);
5631		$.forum.setForumCookie(id,page_num,stx,sfl,scate);
5632		cookie_page_num = $.cookie('forum_'+id);
5633		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
5634		activeEL('userEL'+id);
5635		scrollToForumBlock($forum_el);
5636	});
5637
5638	$('.search-btn').live('click', function(e) {
5639		if($(this).parents('.element').attr('data-type') != 'forum') return false;
5640		e.preventDefault();
5641		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
5642		
5643		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
5644		var sfl = $(this).parents('.search-box').find('#sfl').val(),
5645			stx = $(this).parents('.search-box').find('#stx').val(),
5646			scate = getForumScate($(this).parents('.element')),
5647			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
5648			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
5649			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
5650			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
5651
5652		var regexp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+┼<>@\#$%&\'\"\\\(\=“‘,]/gi;
5653		if(regexp.test(stx) || regexp.test(scate)) {
5654			$(this).showModalFlat('ERROR', '특수문자를 입력할 수 없습니다.', true , false, '', 'close');
5655			return false;
5656		}
5657
5658    	$.forum.setForumCookie(id,page_num,stx,sfl,scate);
5659		cookie_page_num = $.cookie('forum_'+id);
5660		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
5661		activeEL('userEL'+id);
5662	});
5663
5664	$doc.on('keypress','input#stx', function (e) {
5665		if(e.which == 13 && $(this).val().length>0) $(this).closest('.search-box').find('.search-btn').click();
5666	});
5667
5668	$('.element[data-type="forum"]:not([data-type2="guestbook"]) .search-forum-user-posts').die('click');
5669	$('.element[data-type="forum"]:not([data-type2="guestbook"]) .search-forum-user-posts').live('click', function(e) {
5670		e.stopPropagation();
5671		var parentEl = $(this).parents('.element');
5672		var dataCheck =  (parentEl.find('.tpl-forum-pagination').children().length > 0) ? true :  false;
5673		
5674		$this_pagination = parentEl.find('.tpl-forum-pagination li.active');
5675		var stx = $(this).attr('data-userid'),
5676			sfl = (stx)? 'mb_id' : 'nonmem',
5677			scate = '',
5678			id = (dataCheck) ? $this_pagination.attr('data-id') : parentEl.attr('data-id'),
5679			page = (dataCheck) ? $this_pagination.attr('data-page') : parentEl.find('.tpl-forum-pagination').attr('data-page'),
5680			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
5681			view = (dataCheck) ? $this_pagination.attr('data-view') : parentEl.find('.tpl-forum-pagination').attr('data-view');
5682		if(!stx) {
5683			stx = $(this).attr('data-username');
5684		}
5685
5686    	$.forum.setForumCookie(id,page_num,stx,sfl,scate);
5687		cookie_page_num = $.cookie('forum_'+id);
5688		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
5689		activeEL('userEL'+id);
5690	});
5691
5692	$(document).on('mousedown','.fr-file',function(e) {
5693		if(PAGE_MODE!='c') {
5694			var url = new getLocation($(this).closest('[data-href]').attr('data-href')),
5695				file_name = encodeURIComponent($(this).find('.fr-file-nm').text().trim() + $(this).find('.fr-file-ext').text().trim());
5696			file_name = file_name == '' ? $(this).text().trim() : file_name;
5697			var go = '/down?n=' + file_name + '&s=' + (url.pathname).replace('/cr-resource/forum/','').replace('/','&f=');
5698			window.open(go,'_blank');
5699		}
5700	});
5701
5702
5703	function groupAddClass(group_member_list_check, $select, input_text, member_list) {
5704
5705		$select.parents('.panel').find('.empty').hide();
5706		if(group_member_list_check > 0) $select.parents('.panel').find('.group-member-list').prepend(input_text);		
5707		else $select.parents('.panel').find('.panel-body').append(member_list);
5708		settingEditMode(true);
5709	}
5710
5711
5712
5713
5714		var bindForumCategorySortable = function() {
5715			$('.forum-category-content:not(.empty)').sortable({
5716				items: '.forum-category-item',
5717				cancel: '.forum-category-update-cancel, button, .forum-category-update-name',
5718				handle: '.forum-category-info > .icons.cl-sort-handle svg',
5719				update: function (event, ui) {
5720					var pid = $(this).closest('.flat-forum-category-modal').find('.modal[id*=flat-modal]').attr('data-pid');
5721					if(!pid && typeof selectEL != 'undefined') pid = $('.'+selectEL).attr('data-id');
5722
5723					$(this).children().each(function(i,o) {
5724						var cate = $(this).attr('data-cate');
5725						$(this).attr('id','forumCateSort'+i).attr('data-idx',i);
5726						$(this).find('[data-idx]').each(function() { $(this).attr('data-idx',i); });
5727						if(!cate) return true;
5728
5729						$.post('/fm/category/replace', { sid : F_SID, pid : pid, cate : cate, code : i+1 }, function(data) {
5730							if(typeof data.error != 'undefined' && data.error) {
5731								$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
5732								return false;
5733							}
5734						},'json');
5735					});
5736				}
5737			}).disableSelection();
5738		}
5739
5740		$doc.on('hidden.bs.modal', '.flat-forum-category-modal', function() {
5741			var fcategory_str = '';
5742			$(this).find('.forum-category-name').each(function(idx) {
5743				fcategory_str += (idx == 0) ? $(this).text() : ', '+$(this).text();
5744			});
5745
5746			var pid = $(this).find('.modal[id*=flat-modal]').attr('data-pid'),
5747				$forum_el = $('.element[data-id="' + pid + '"]');
5748			if($forum_el.find('#scate').length > 0 && !$forum_el.find('#scate').hasClass('hide')) {
5749				$.forum.drawSelboxCategory($forum_el,pid);
5750			}
5751
5752		if(!fcategory_str) fcategory_str = $.lang[LANG]['editor.category.empty'];
5753		if($('#el-blockConfig').length > 0) $('#ctrl-card-list-category .selected-category').text(fcategory_str);
5754		$(this).remove();
5755	});
5756
5757	var openForumCategoryConfig = function(id) {
5758		var str = '';
5759		if(typeof id == 'undefined' && typeof selectID != 'undefined') id = selectID;
5760
5761		$.post('/fm/category/list', { pid: id, sid: F_SID }, function(data) {
5762			if(typeof data.error != 'undefined' && data.error) {
5763				$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
5764				return false;
5765				}
5766				var forum_cate_modal = $(this).showModalFlat($.lang[LANG]['editor.forum.category.config'], categoryConfigForum(data,id),true,false,'','close', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 forum-category-modal',true).attr({'data-pid':id}).closest('.flat-modal').addClass('flat-forum-category-modal');
5767				bindForumCategorySortable();
5768			}, 'json');
5769		};
5770
5771	$doc.on('click','#el-blockConfig .forum-category-config',function(e) {
5772		openForumCategoryConfig(selectID);
5773	});
5774
5775        
5776
5777	//forum category Config (Add.Edit.Remove)
5778	var categoryConfigForum = function (data,id) {
5779		var empty = (data.length > 0) ? '' : 'empty',
5780			forum_category_list = '',
5781			str = '';
5782
5783		$.each(data, function(i,v) {
5784			if(v) forum_category_list = forum_category_list + forumCategoryItem(v.fca_name.trim(), i,v.seq);
5785		});
5786
5787		forum_category_list = (empty) ? '<p>' + $.lang[LANG]['editor.category.empty'] + '</p>' : forum_category_list;
5788
5789		str = '\
5790        <div class="forum-category-header">\
5791            <p>' + $.lang[LANG]['editor.category.description'] + '</p>\
5792        </div>\
5793        <div class="forum-category-content ' + empty + '">\
5794            ' + forum_category_list + '\
5795        </div>\
5796        <div class="btn-wrap">\
5797        	<span class="btn forum-category-add">\
5798				<svg viewBox="0 0 12 12" width="12" height="12"><polygon points="12 5 7 5 7 0 5 0 5 5 0 5 0 7 5 7 5 12 7 12 7 7 12 7 "/></svg>\
5799				' + $.lang[LANG]['config.gallery.add'] + '\
5800			</span>\
5801        </div>\
5802        ';
5803		return str;
5804	}
5805
5806	var forumCategoryItem = function(name,idx,seq) {
5807		var categoryAdd = (!name) ? 'additem' : '',
5808			cate_seq = (!seq) ? '' : seq;
5809
5810		var str = '\
5811			<div class="forum-category-item ' + categoryAdd + '" id="forumCateSort' + idx + '" data-idx="' + idx + '" data-cate="' + cate_seq + '">\
5812				<div class="forum-category-info">\
5813					<span class="icons cl-sort-handle">\
5814						' + clSVG('move_handle', 20, 20) + '\
5815					</span>\
5816					<span class="forum-category-name">' + name + '</span>\
5817				</div>\
5818				<div class="forum-config-icons">\
5819					<div class="icons hand">\
5820						<svg viewBox="0 0 13 13" width="13" height="13" class="forum-category-edit" data-idx="' + idx + '">\
5821							<path d="M4.32 8.05C4.2 8.39 4.46 8.71 4.79 8.71c0.05 0 0.11-0.01 0.16-0.03L7 8l6-6-2-2L5 6 4.32 8.05zM5.87 6.54L11 1.41 11.59 2 6.46 7.13 5.58 7.42 5.87 6.54z"/><path d="M9 11c0 0.55-0.45 1-1 1H2c-0.55 0-1-0.45-1-1V4c0-0.55 0.45-1 1-1h3V2H2C0.9 2 0 2.9 0 4v7c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V8H9V11z"/>\
5822						</svg>\
5823					</div>\
5824					<div class="icons hand">\
5825						<svg viewBox="0 0 12 13" width="12" height="13" class="forum-category-delete hand" data-idx="' + idx + '">\
5826							<path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
5827						</svg>\
5828					</div>\
5829				</div>\
5830			</div>\
5831		';
5832		return str;
5833	}
5834
5835	var forumCategoryItemEmptyCheck = function() {
5836		if($('.forum-category-content').find('.forum-category-item').length == 0) {
5837			$('.forum-category-content').addClass('empty').html('<p>' + $.lang[LANG]['editor.category.empty'] + '</p>');
5838			} else {
5839				$('.forum-category-content').removeClass('empty').find('p').remove();
5840				bindForumCategorySortable();
5841			}
5842		}
5843
5844	var addForumCategoryInput = function(cateidx, catename, cateseq) {
5845		var cateidx = (typeof cateidx == 'undefined' || !cateidx) ? $('.forum-category-content .forum-category-item').length : cateidx;
5846		var cateseq = (typeof cateseq == 'undefined' || !cateseq) ? '' : cateseq;
5847		var catename = (typeof catename == 'undefined' || !catename) ? '' : catename;
5848		// var catecode = (typeof catecode == 'undefined' || !catecode) ? Number($('.forum-category-content .forum-category-item').last().attr('data-code')) + 1 : catecode;
5849
5850		return `
5851				<div class="forum-category-update">
5852					<div class="input-group">
5853						<input type="text" class="forum-category-update-name forum-control" placeholder="${$.lang[LANG]['editor.gallery.category.enter-name']}" value="${catename}"/>
5854						<span class="input-group-btn">
5855							<button class="forum-category-update-save btn btn-active" data-id="${selectID}" data-idx="${cateidx}" data-cate="${cateseq}">
5856								<svg viewBox="0 0 15 10" width="15" height="10"><path d="M14.29 0L5.5 8.79 0.71 4 0 4.71l5.15 5.15C5.24 9.95 5.37 10 5.5 10s0.26-0.05 0.35-0.15L15 0.71 14.29 0z"/></svg>
5857							</button>
5858						</span>
5859						<div class="forum-category-update-cancel">
5860							<svg viewBox="0 0 12 12" width="12" height="12"><polygon points="12 0.71 11.29 0 6 5.29 0.71 0 0 0.71 5.29 6 0 11.29 0.71 12 6 6.71 11.29 12 12 11.29 6.71 6 "/></svg>
5861						</div>
5862					</div>
5863				</div>
5864		`;
5865	}
5866
5867	$doc.on('click', '.forum-category-delete', function(e) {
5868		// var checkLast = ($(this).closest('.forum-category-content').find('.forum-category-item').length <= 1) ? true : false;
5869		// if(checkLast) {
5870		// 	$(this).showModalFlat($.lang[LANG]['config.information'], $.lang[LANG]['editor.gallery.category.delete.last'], true, false, '', 'ok','', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70');
5871		// 	return false;
5872		// }
5873		
5874        var idx = $(this).attr('data-idx');
5875        var cate = $('.forum-category-content #forumCateSort'+idx).attr('data-cate');
5876        var category_del_modal = $(this).showModalFlat($.lang[LANG]['editor.gallery.category.delete.title'], $.lang[LANG]['editor.gallery.category.delete'], true, true, function() {
5877
5878			$.post('/fm/category/delete', {  sid : F_SID, pid : selectID, cate: cate}, function(data) {
5879				if(typeof data.error != 'undefined' && data.error) {
5880					return false;
5881				}
5882					$('.forum-category-content #forumCateSort'+idx).remove();
5883					$('.'+selectEL).find('#scate option[value="' + data.seq + '"]').remove();
5884					$('.'+selectEL).find('.tpl-forum-category-item[data-cate="' + data.seq + '"]').remove();
5885					if($('.'+selectEL).find('.tpl-forum-category-item.active').length == 0) setForumCategoryActive($('.'+selectEL), '');
5886					$('.'+selectEL).find('.tpl-forum-list-category[data-cate="' + cate + '"]').text('');
5887					syncForumCategoryOptionWidth($('.'+selectEL));
5888					syncForumCategoryCustomSelect($('.'+selectEL));
5889					syncForumCategoryDelimiterRows($('.'+selectEL));
5890
5891				$('.forum-category-content .forum-category-item').each(function(i) {
5892					$(this).attr('id','forumCateSort'+i).attr('data-idx',i);
5893					$(this).find('[data-idx]').each(function() { $(this).attr('data-idx',i); });
5894				});
5895
5896				forumCategoryItemEmptyCheck();
5897				category_del_modal.modal('hide');
5898			},'json');
5899
5900        },'cancel','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 zindex1046');
5901
5902	});
5903
5904	$doc.on('click', '.forum-category-add', function(e) {
5905		if($('.forum-category-content').find('.forum-category-update').length > 0 ) {
5906			$('.forum-category-content').find('.forum-category-update-name').focus();
5907			return false;
5908		}
5909		
5910        var idx = $('.forum-category-content .forum-category-item').length;
5911        var str = forumCategoryItem('',idx,'');
5912		// var code = (idx > 0) ? Number($('.forum-category-content .forum-category-item').last().attr('data-code')) + 1 : 1,
5913
5914        $('.forum-category-content').append(str);
5915
5916        forumCategoryItemEmptyCheck();
5917        $('.forum-category-edit[data-idx=' +idx +']').click();
5918	});
5919
5920	$doc.on('click', '.forum-category-edit', function(e) {
5921        if($('.forum-category-content').find('.forum-category-update').length>0) return false;
5922
5923        var cate_idx = $(this).attr('data-idx');
5924        var $category_item = $('.forum-category-content').find('#forumCateSort'+cate_idx);
5925		var cate_seq = $category_item.attr('data-cate');
5926		var cate_name = $category_item.find('.forum-category-name').text();
5927
5928        var input_text = addForumCategoryInput(cate_idx,cate_name,cate_seq);
5929
5930        $(input_text).appendTo($category_item.find('.forum-category-info'));
5931
5932        $('.forum-category-content').find('.forum-category-item').removeClass('editing').css('pointer-events','none');
5933        $category_item.addClass('editing').css('pointer-events','auto');
5934        $('.forum-category-content').find('.forum-category-update-cancel, .forum-category-update-save, .forum-category-update-name').css('pointer-events','auto');
5935        $('.forum-category-update .forum-category-update-name').focus();
5936	});
5937
5938	$doc.on('click', '.forum-category-update-cancel', function(e) {
5939		if(!$(this).closest('.forum-category-info').find('.forum-category-name').text()) {
5940			$(this).closest('.forum-category-item').remove();
5941			forumCategoryItemEmptyCheck();
5942		}
5943		$('.forum-category-content').find('.config-error').remove();
5944		$('.forum-category-content').find('.forum-category-item').removeClass('editing').removeAttr('style');
5945		$('.forum-category-content').find('.forum-category-update').remove();
5946	});
5947
5948	$doc.on('click', '.forum-category-update-save', function(e) {
5949		if($(this).hasClass('clicked')) return false;
5950		else $(this).addClass('clicked');
5951
5952        var pid = $(this).attr('data-id');
5953        var idx = $(this).attr('data-idx');
5954        var cate_seq = $('.forum-category-content').find('#forumCateSort'+idx).attr('data-cate');
5955        var position = $('.forum-category-content');
5956        var category_name = $('.forum-category-update-name').val().trim();
5957        var category_prev = position.find(`#forumCateSort${idx} .forum-category-name`).text().trim();
5958		var categoryRegexp =  /[\[\]|,'"<>{}\/\\:;%&@$!*?\^]/;
5959
5960        $position = (position.find('.forum-category-item').length > idx) ? position.find(`#forumCateSort${idx}`) : position;
5961
5962        $('.config-error').remove();
5963		var show_error_fc_save = function(error_message) {
5964			$position.append('\
5965				<div class="config-error">\
5966					' + clSVG('info',13,13) +'\
5967					<span>' + error_message + '</span>\
5968				</div>\
5969		    ');
5970		    $('.forum-category-update-save').removeClass('clicked');
5971		}
5972
5973        if(category_prev == category_name) {
5974            if($('.forum-category-content #forumCateSort'+idx).hasClass('additem')) {
5975            	show_error_fc_save($.lang[LANG]['editor.gallery.category.enter-name']);
5976            } else {
5977	                $('.forum-category-content').find('.forum-category-item').removeClass('editing').removeAttr('style');
5978	                $('.forum-category-content').find('.forum-category-update').remove();
5979                $('.forum-category-update-save').removeClass('clicked');
5980            }
5981            return false;
5982        }
5983        if(categoryRegexp.test(category_name)) {
5984        	show_error_fc_save($.lang[LANG]['board.allowed-chars']);
5985            return false;
5986        }
5987        if(category_name.length<1) {
5988        	show_error_fc_save($.lang[LANG]['board.enter-group-name']);
5989            return false;
5990        }
5991        if(category_name.length>30) {
5992        	show_error_fc_save($.lang[LANG]['board.enter-max-chars.30']);
5993            return false;
5994        }
5995        var list =  position.find('.forum-category-item .forum-category-name').map(function() { return $(this).text().trim(); }).get();
5996        if($.inArray(category_name,list) > -1 ) {
5997        	show_error_fc_save($.lang[LANG]["editor.gallery.category.inuse-name"]);
5998        	return false;
5999        }
6000
6001
6002		$.post('/fm/category/update', {  sid : F_SID, pid : pid, cate: cate_seq, name : encodeURIComponent(category_name) }, function(data) {
6003			if(typeof data.error != 'undefined' && data.error) {
6004				show_error_fc_save(data.error);
6005				return false;
6006			}
6007
6008			if($('#forumCateSort'+idx).hasClass('additem')) $('#forumCateSort'+idx).removeClass('additem');
6009			$('#forumCateSort'+idx).attr('data-cate',data.seq);
6010			$('#forumCateSort'+idx).find('.forum-category-name').text(category_name);
6011
6012				position.find('.forum-category-item').removeClass('editing').removeAttr('style');
6013				position.find('.forum-category-update').remove();
6014
6015				if($('.'+selectEL).find('#scate option[value="' + data.seq + '"]').length > 0 ) $('.'+selectEL).find('#scate option[value="' + data.seq + '"]').text(category_name);
6016				else $('.'+selectEL).find('#scate').append($('<option>').attr('value', data.seq).text(category_name));
6017
6018				if($('.'+selectEL).find('.tpl-forum-category-item[data-cate="' + data.seq + '"]').length > 0 ) {
6019					$('.'+selectEL).find('.tpl-forum-category-item[data-cate="' + data.seq + '"] > a').text(category_name);
6020				} else {
6021					$('.'+selectEL).find('.tpl-forum-category-list').append(
6022						$('<li class="tpl-forum-category-item">').attr('data-cate',data.seq).append(
6023							$('<a href="javascript:;">').attr('data-cate',data.seq).text(category_name)
6024						)
6025					);
6026				}
6027
6028				$('.'+selectEL).find('.tpl-forum-list-category[data-cate='+data.seq+']').text(category_name);
6029				syncForumCategoryOptionWidth($('.'+selectEL));
6030				syncForumCategoryCustomSelect($('.'+selectEL));
6031				syncForumCategoryDelimiterRows($('.'+selectEL));
6032			
6033			$('.forum-category-update-save').removeClass('clicked');
6034		},'json');
6035	});
6036
6037		var displayCategoryHtml = function(id,list_data,sel_replace,block_lang) {
6038			var $forum_el = $(sel_replace),
6039				category_hidden = $forum_el.find('#scate').hasClass('hide'),
6040				scate = '',
6041			$select = $('<select id="scate" class="form-control" name="scate">').attr('placeholder', $.lang[block_lang]['board.scate']),
6042			$category_nav = $('<div class="tpl-forum-category-nav">'),
6043			$category_list = $('<ul class="tpl-forum-category-list">'),
6044			all_label = getForumCategoryAllLabel(block_lang);
6045
6046		if(typeof $.cookie('forum_'+id+'_scate') != 'undefined' && $.cookie('forum_'+id+'_scate')) scate = $.cookie('forum_'+id+'_scate');
6047
6048		$select.append($('<option>').attr('value','').text($.lang[block_lang]['board.scate']));
6049		$category_list.append(
6050			$('<li class="tpl-forum-category-item">').attr('data-cate','').append(
6051				$('<a href="javascript:;">').attr('data-cate','').text(all_label)
6052			)
6053		);
6054
6055		$.each(list_data, function(i,v) {
6056			var cate_seq = (typeof v['seq'] != 'undefined') ? String(v['seq']) : '',
6057				cate_name = (typeof v['fca_name'] != 'undefined') ? v['fca_name'] : '';
6058
6059			$select.append($('<option>').attr('value',cate_seq).prop('selected', scate == cate_seq).text(cate_name));
6060			$category_list.append(
6061				$('<li class="tpl-forum-category-item">').attr('data-cate',cate_seq).append(
6062					$('<a href="javascript:;">').attr('data-cate',cate_seq).text(cate_name)
6063				)
6064			);
6065		});
6066
6067		$category_nav.append($category_list);
6068		$forum_el.find('#scate').replaceWith($select);
6069		$forum_el.find('#scate').parent().removeClass('hidden').addClass('forum-category-select-wrap');
6070		if(category_hidden) $forum_el.find('#scate').addClass('hide');
6071
6072		placeForumCategoryNav($forum_el, $category_nav);
6073
6074		setForumCategoryActive($forum_el, scate);
6075		syncForumCategoryTypeDisplay($forum_el);
6076	}
6077
6078	var displayTypeForum = function(data,$el,typeCheck,view,page_num,id) {
6079		var isMasonry = (typeCheck == 'card') ? true : false,
6080			forum_item = '';
6081
6082		$el.attr('data-list-type',typeCheck);
6083		if(isMasonry) $el.attr('data-msny', true);
6084		else $el.attr('data-msny', false);
6085
6086		$el.find('.table-container').empty();
6087		if(typeCheck == 'card') {
6088			$el.find('.table-container').append('<div class="table" data-loop="true"></div>');
6089		} else {
6090			$el.find('.table-container').append($(data.source).find('table'));
6091			$el.find('.table [data-loop="true"]').empty();
6092		}
6093
6094		var $row = $el.find('[data-loop="true"]'),
6095			loop = $(data.source).find('[data-loop="true"]').children().eq(0).clone();
6096
6097		$.each(data.list, function(i,v) {
6098			var num = data.total - (view * (page_num-1)) - i;
6099			if(isMasonry) {
6100				forum_item = forum_item + forumRow(v, num, page_num, id, $.forum.modoo_card, data.config, 'thumb', $(data.source));
6101			} else {
6102				$row.append(forumRow(v, num, page_num, id, loop, data.config, '', $(data.source)));
6103			}
6104		});
6105
6106		if(isMasonry) {
6107			$el.find('.table').attr('data-view',view);
6108
6109			var $forum_items = ($(forum_item).find('.item').length) ? $(forum_item) : $('<div>'+forum_item+'</div>');
6110			$forum_items.hide();
6111
6112			$row.before("<div class='forum-loading-status'><div class='loading-dots'></div></div>");
6113			var f_items = data.list.length;
6114			var f_process_index = 0;
6115
6116			$forum_items.children().imagesLoaded().progress(function(imgload, image) {
6117				f_process_index++;
6118				var $item = $(image.img).parents('.item');
6119				$item.show();
6120
6121				if(f_items == f_process_index) {
6122					var reload_forum_items = $forum_items.html();
6123					forumReloadMasonry($row,$(reload_forum_items));
6124				}
6125			});
6126		}
6127	}
6128
6129
6130	
6131	$doc.on('click', `
6132			[data-ver="1"][data-type="forum"][data-type2="faq"] tr .tpl-forum-list-title
6133		`, function(e) {
6134
6135		var isElview = ($('.elviewcss').length > 0) ? true : false;
6136		if(!isElview) {
6137			$(this).closest('tr').addClass('this');
6138			$(this).closest('[data-loop="true"]').find('tr').each(function() {
6139				var checkClick = $(this).hasClass('this'),
6140					checkClose = (!checkClick && $(this).find('.toggle').hasClass('open')) ? true : false;
6141
6142				if(checkClick || checkClose) {
6143					$(this).find('.toggle').toggleClass('open');
6144					$(this).toggleClass('open');
6145					$(this).next().toggle();
6146				}
6147			});
6148
6149			$(this).closest('[data-loop="true"]').find('tr.this').removeClass('this');
6150		}
6151	});
6152
6153	$doc.on('click', `
6154			[data-type="forum"][data-type2="faq"] .item .question .tpl-forum-list-title,
6155			[data-type="forum"][data-type2="faq"] .item .question .tpl-forum-list-faq-toggle
6156		`, function(e) {
6157
6158		var isElview = ($('.elviewcss').length > 0) ? true : false;
6159		if(!isElview) $(this).closest('.item').toggleClass('open').siblings().removeClass('open');
6160	});
6161
6162	$doc.on('click', `
6163			[data-type="forum"][data-type2="faq"] .tpl-forum-faq-edit,
6164			[data-type="forum"][data-type2="faq"] .tpl-forum-faq-del
6165		`, function(e) {
6166		var ctrlBtn = $(this),
6167			ctrlUL = ctrlBtn.closest('ul[data-id]');
6168
6169		if(ctrlBtn.hasClass('clicked')) return;
6170		ctrlBtn.addClass('clicked');
6171
6172		var pid = ctrlUL.attr('data-pid'),
6173			id = ctrlUL.attr('data-id'),
6174			mode = (ctrlBtn.is('.tpl-forum-faq-del')) ? 'del' : 'edit';
6175
6176		switch(mode) {
6177			case 'edit':
6178				ctrlBtn.removeClass('clicked');
6179				updateForumPost(id,pid);
6180				break;
6181
6182			case 'del':
6183				var faqdelModal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
6184					faqdelModal.modal('hide');
6185					$.forum.delete(id);
6186				}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn', true, '', '', function() {
6187					ctrlBtn.removeClass('clicked');
6188				});
6189				break;
6190
6191			default:
6192				ctrlBtn.removeClass('clicked');
6193				break;
6194		}
6195
6196	// 	var view = $(this).parent('ul[data-id]').attr('data-id');
6197	// 	location.replace(forumUrl() + '/forum/view/' + view);
6198	});
6199
6200
6201}(jQuery));
6202
6203
6204var forumRow = function(row,num,page_num,pid,loop_item,config,type,$source) {
6205	var forum_row = document.createElement('div');
6206	$(forum_row).html(loop_item);
6207	$(forum_row).children().removeClass('active');
6208
6209	var checkNotice	= (row.option == 'N') ? true : false,
6210		checkSecret	= (row.option == 'S') ? true : false,
6211		checkNew	= (row.new) ? true : false,
6212		checkEmpty	= (row.title == '' && row.content == '') ? true : false,
6213		checkNamemask = (row.namemask) ? true : false;
6214
6215	var row_settings = getOrDefault(row,'settings',{})
6216		field_lang	= getOrDefault(config,'field_lang','EN'),
6217		max_title	= getOrDefault(config,'max_title',150),
6218		max_cont	= getOrDefault(config,'max_cont',300);
6219
6220	var url	= forumUrl(),
6221		href = $.inArray(type, ['faq','qna','guestbook']) > -1 ? 'javascript:void(0);' : url + '/forum/view/' + row.id,
6222		icon_notice	= (checkNotice) ? '<i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i>' : '',
6223		icon_secret	= (checkSecret) ? '<i class="tpl-forum-list-secret-icon cl-icon lock02" aria-hidden="true"></i>&nbsp;' : '',
6224		icon_new	= (checkNew) ? '<img src="//storage.googleapis.com/i.addblock.net/icon/icon_new_forum.png" title="new" alt="new">' : '';
6225
6226	var title_str	= (row.title) ? ((type == 'faq') ? row.title : htmlEntities(cutStrInBytes(htmlspecialchars_decode(row.title),max_title))) : '',
6227		title_href	= (title_str == '') ? '<a href="javascript:void(0);" class="deleted">' + $.lang[LANG]['board.post.deleted'] + '</a>' : '<a href="' + href + '">' + title_str + '</a> ' + icon_new,
6228		is_Masonry = ($('.element[data-id="' + pid + '"]').attr('data-msny') == 'true') ? true : false,
6229		block_lang = ($('.element[data-id="' + pid + '"]').attr('data-blocklang')) ? $('.element[data-id="' + pid + '"]').attr('data-blocklang') : LANG;
6230
6231	if($.cookie('forum_'+pid+'_type') == 'card' ||
6232		typeof $.cookie('forum_'+pid+'_type') == 'undefined' && $source.attr('data-list-type') == 'card') is_Masonry = true;
6233
6234	var icon_span_class = (typeof $source.find('.tpl-forum-list-num span').attr('class') != 'undefined') ? $(forum_row).find('.tpl-forum-list-num span').attr('class') : '';
6235	
6236	$(forum_row).find('.tpl-forum-list-num').text(num).attr('data-fm-num', num);
6237	if($(forum_row).find('.tpl-forum-list-num.two-digit-number').length){
6238		if($(forum_row).find('.tpl-forum-list-num').text() <= 9) {
6239			var two_count = $(forum_row).find('.tpl-forum-list-num').text()
6240			$(forum_row).find('.tpl-forum-list-num').text('0'+two_count)
6241		}
6242	}
6243	$(forum_row).find('.tpl-forum-list-hit').text(row.hit);
6244	$(forum_row).find('.tpl-forum-list-date').text(row.datetime);
6245	$(forum_row).find('.tpl-forum-list-name').attr('data-userid', row.fm_mb_id).text(row.name);
6246	$(forum_row).find('.tpl-forum-list-title').html(icon_secret + title_href).attr('data-option',row.option).attr('data-id',row.id
6246);
6247	if($(forum_row).find('.tpl-forum-list-title').hasClass('tpl-forum-list-notice')) $(forum_row).find('.tpl-forum-list-title').attr('class','').addClass('tpl-forum-list-title');
6248	$(forum_row).find('.sample-notice').remove();
6249
6250	if(row.fm_mb_id) $(forum_row).find('.tpl-forum-list-name').addClass('is-user');
6251	
6252	if(row.depth > 0 && !checkNotice) {
6253		if($(forum_row).find('.tpl-forum-list-name').hasClass('tpl-sync-reply')) $(forum_row).find('.tpl-forum-list-name').addClass('reply');
6254
6255		$(forum_row).find('.tpl-forum-list-title').addClass('reply');
6256		$(forum_row).find('.tpl-forum-list-title').prepend('<span class="tpl-forum-list-reply-name">' + row.reply_name + '</span>');
6257	}
6258	
6259	if(checkNamemask) {
6260		$(forum_row).find('.tpl-forum-list-name').addClass('namemask');
6261	}
6262
6263	if($(forum_row).find('.tpl-forum-list-cont').length > 0) {
6264		var row_content = row.content.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim,' ');
6265
6266		var cont_txt = (row.content.length > 0) ? row_content.replace(/(<([^>]+)>)/ig,' ') : '',
6267			cont_str = (cont_txt.length > 0) ? cutStrInBytes(cont_txt,max_cont) : '',
6268			cont_str = (type == 'guestbook' ? cont_txt : cont_str),
6269			cont_href = (title_str == '') ? '<a href="javascript:;" class="deleted"></a>' : '<a href="' + href + '">' + cont_str + '</a>';
6270		
6271		if(type == 'guestbook') {
6272			if($('.element[data-id="' + pid + '"]').find('.fr34-input-height').length) cont_str = '\"' + cont_str + '\"';
6273			cont_href = icon_secret + nl2br(cont_str);
6274		}
6275
6276		if($(forum_row).find('.tpl-forum-list-cont').find('.tpl-forum-list-more').length > 0) {
6277			var contmore_str = $(forum_row).find('.tpl-forum-list-cont').find('.tpl-forum-list-more').html();
6278			cont_href += '<div class="tpl-forum-list-more forum-contmore"><a href="' + href + '">' + contmore_str + '</a></div>';
6279			$(forum_row).find('.tpl-forum-list-cont').find('.tpl-forum-list-more').html('<a href="' + href + '">' + more_str + '</a>' ).attr('data-option',row.option).attr('data-id',row.id);
6280		} 
6281		
6282		$(forum_row).find('.tpl-forum-list-cont').html(cont_href).attr('data-option',row.option).attr('data-id',row.id);
6283	}
6284	if($(forum_row).find('.tpl-forum-list-myimg').length > 0) {
6285		if($(forum_row).find('.tpl-forum-list-myimg').hasClass('hexagon')) {
6286			var hexagon = '<svg viewbox="0 0 40 40"><pattern id="forum-list-image-' + row.id + '" patternUnits="userSpaceOnUse" width="40" height="40"><image xlink:href="' + row.myimg + '?_' + new Date().getTime() + '" x="-10" width="60" height="40" /></pattern><polygon points="20 0 37 10 37 30 20 40 3 30 3 10" fill="url(#forum-list-image-' + row.id + ')"/></svg>';
6287			$(forum_row).find('.tpl-forum-list-myimg').html(hexagon);
6288		} else {
6289			$(forum_row).find('.tpl-forum-list-myimg').html('<img src="' + row.myimg + '?_' + new Date().getTime() + '">');
6290		}
6291	}
6292
6293	if($(forum_row).find('.tpl-forum-list-category').length > 0 && $(forum_row).find('.tpl-forum-list-category').hasClass('.forum-contmore')==false) {
6294		var cate_name	= (row.category_name) ? row.category_name : '';
6295		$(forum_row).find('.tpl-forum-list-category').removeAttr('data-cate').empty();
6296		if(row.category_seq) $(forum_row).find('.tpl-forum-list-category').text(cate_name).attr('data-cate',row.category_seq);
6297	}
6298
6299	if($(forum_row).find('.tpl-forum-list-more').length > 0) {
6300		var more_str = $(forum_row).find('.tpl-forum-list-more').html();
6301		$(forum_row).find('.tpl-forum-list-more').html('<a href="' + href + '">' + more_str + '</a>' ).attr('data-option',row.option).attr('data-id',row.id);
6302	}
6303
6304	var comment_str = (row.comment > 0) ? row.comment : '';
6305	$(forum_row).find('.tpl-forum-list-comment').html(comment_str);
6306	if(!comment_str) {
6307		 $(forum_row).find('.tpl-forum-list-comment-icon').remove();
6308		 $(forum_row).find('.tpl-forum-list-comment').addClass('empty');
6309	} else {
6310		if($(forum_row).find('.tpl-forum-list-comment').length < 1) {
6311			var comment_icon = $source.find('.tpl-forum-list-comment-icon').clone();
6312			$(forum_row).find('.tpl-forum-list-comment').prev(comment_icon);
6313		}
6314		$(forum_row).find('.tpl-forum-list-comment').removeClass('empty');
6315	}
6316
6317	if(checkNotice) {
6318		var isMobileWidth = (isMobile() || (PAGE_MODE == 'r' && window.innerWidth <= 767))? true : false;
6319
6320		$(forum_row).find('.tpl-forum-list-num').addClass('n');
6321		if($(forum_row).find('[data-notice-type="text"]').length > 0) {
6322			icon_notice = '<span class="tpl-forum-list-notice">'+$.lang[block_lang]['forum.forum.notice.text']+'</span>';
6323			$(forum_row).find('.tpl-forum-list-title').addClass('tpl-forum-list-notice');
6324		}
6325		if($(forum_row).find('.tpl-forum-list-num').hasClass('notice-svg')) { //notice icon svg
6326			icon_notice = $source.find('.tpl-forum-list-num').find('.tpl-forum-list-notice-icon').outerHTML();
6327		}
6328
6329		$(forum_row).find('.tpl-forum-list-num').html(icon_notice);
6330		$(forum_row).find('.tpl-forum-list-title .tpl-forum-list-notice-icon, .tpl-forum-list-title .tpl-forum-list-notice').remove();
6331		$(forum_row).find('.tpl-forum-list-title').prepend(icon_notice);
6332	}
6333
6334	if($(forum_row).find('.tpl-forum-list-like').length > 0) {
6335
6336		var like_cnt = (row.like !== undefined && row.like.cnt !== undefined)? row.like.cnt : 0;
6337		$(forum_row).find('.tpl-forum-list-like').attr('data-id', row.id);
6338		if($(forum_row).find('.tpl-forum-list-like').is('td') && $(forum_row).find('.tpl-forum-list-like .forum-like-cnt').length == 0) {
6339			$(forum_row).find('.tpl-forum-list-like').text(like_cnt);
6340		} else {
6341			$(forum_row).find('.tpl-forum-list-like .forum-like-cnt').text(like_cnt);
6342		}
6343
6344		if(row.like !== undefined  && row.like.cnt !== undefined && row.like.own) $(forum_row).find('.tpl-forum-list-like').addClass('active');
6345		else $(forum_row).find('.tpl-forum-list-like').removeClass('active');
6346	}
6347
6348	switch(type) {
6349		case 'thumb':
6350			if($(forum_row).find('.tpl-forum-list-thumb').length > 0) {
6351				var f_color = ($('.element[data-id="' + pid + '"]').attr('data-fcolor')) ? $('.element[data-id="' + pid + '"]').attr('data-fcolor') : '#000000',
6352					ffolder = $('.element[data-id="' + pid + '"]').attr('data-width'),
6353					thumb_empty = (row.thumb == '' || row.title == '') ? true : false,
6354					content_noimage_img = (thumb_empty && row.content_noimage_img) ? setResizeImageFolder(ffolder,row.content_noimage_img) : row.content_noimage_img,
6355					thumb_src = (thumb_empty) ? ((row.content_noimage_img) ? content_noimage_img : '//storage.googleapis.com/i.addblock.net/icon/noimage_' + ffolder +'.png?' + new Date().getTime()) : row.thumb.replace('\/60\/','\/' + ffolder + '\/'),
6356					thumb_href = (title_str == '') ? '<a href="javascript:;" class="deleted"></a>' : '<a href="' + href + '"></a>';
6357
6358				$(forum_row).find('.tpl-forum-list-thumb img').attr('src',thumb_src).wrap(thumb_href).attr('alt',row.title.replace(/\s/g,'-'));
6359
6360				if(thumb_empty) {
6361					if(!is_Masonry && !row.content_noimage_img) {
6362						var text = '<p class="noimage_text">no image</p>';
6363						$(forum_row).find('.tpl-forum-list-thumb').append(text);
6364						$(forum_row).find('.tpl-forum-list-thumb').css('background-color',Coloris.getChangeColorVal(f_color,'a',0.1));
6365						$(forum_row).find('.noimage_text').css('color',Coloris.getChangeColorVal(f_color,'a',0.15));
6366					}	
6367
6368					$(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').addClass('empty');
6369					$(forum_row).find('.tpl-forum-list-thumb').attr('data-option',row.option).attr('data-id',row.id);
6370				} else {
6371					$(forum_row).find('.noimage_text').remove();
6372					$(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').removeClass('empty');
6373					$(forum_row).find('.tpl-forum-list-thumb').attr('data-option',row.option).attr('data-id',row.id);
6374				}
6375
6376				if(content_noimage_img) $(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').addClass('empty_con_img');
6377				else $(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').removeClass('empty_con_img');
6378
6379				//$(forum_row).find('.tpl-forum-list-thumb.empty.empty_con_img img').css('display','block');
6380				if(is_Masonry && $(forum_row).find('.tpl-forum-list-thumb').not('.empty_con_img').hasClass('empty')) $(forum_row).find('.item-inner').addClass('msny_10');
6381			}
6382			break;
6383
6384		case 'faq': 
6385			var colspan = $(forum_row).find('th').length,
6386				settings = (typeof row.settings == 'undefined') ? {} : row.settings,
6387				wrap = (typeof settings.wrap != 'undefined') ? 'w' + settings.wrap : '',
6388				align = (typeof settings.align != 'undefined') ? settings.align : '',
6389				align_class = (align != '') ? 'text-'+align : '',
6390				list_no = $(forum_row).find('.tpl-forum-list-num').hasClass('fl-num'),
6391				icon_wrap = $(forum_row).find('.tpl-forum-list-num').data('icon-wrap'),
6392				unit_icon = $(forum_row).find('.tpl-forum-list-etc').data('uniticon') ? clSVG($(forum_row).find('.tpl-forum-list-etc').data('uniticon'),16,16) : '',
6393				unit = ($(forum_row).find('.tpl-forum-list-num').hasClass('unit-empty')) ? { 'question':unit_icon, 'answer':'' } : { 'question':'Q', 'answer':'A' };
6394
6395			colspan = colspan + $(forum_row).find('td').length;
6396
6397			var answer_len = $source.find('.answer').length,
6398				an_class = (typeof $source.find('.answer').attr('class') != 'undefined') ? $source.find('.answer').attr('class') : '',
6399				an_th_class = 'tpl-forum-list-num tpl-forum-list-etc';
6400
6401			var $answer = $('<tr class="'+an_class+'">');
6402			if(answer_len > 0) {
6403				var an_html = $source.find('.answer:eq(0)').outerHTML();
6404				var $an_html2 = $(htmlspecialchars_decode(an_html));
6405				an_th_class = (typeof $an_html2.find('th').attr('class') != 'undefined') ? $an_html2.find('th').attr('class') : '';
6406				$an_html2.empty();
6407				$answer = $an_html2.attr('style','');
6408			}
6409
6410			var answerClass = ($source) ? (($source.find('.tpl-forum-list-cont').length > 0) ? $source.find('.tpl-forum-list-cont').attr('class').replace(/fsize\d+/gi,'') : '') : '',
6411				toggleOpenContent = ($source.find('.answer').length>0) ? '' : 'toggleOpenContent',
6412				answer_col = $source.find('.tpl-forum-list-cont').data('answer-col'),
6413				answer_colspan = (answer_col) ? colspan : colspan-1;
6414
6415			$answer.append('<th scope="row" class="'+an_th_class+'">' + unit['answer'] + '</th>');
6416			$answer.append('<td class="'+answerClass+' '+toggleOpenContent+'" colspan="' + answer_
6416colspan + '">' + ((typeof config.faq_view_msg != 'undefined' && config.faq_view_msg) ? config.faq_view_msg : row.content) + '</td>');
6417			$answer.hide();
6418
6419			if(checkNotice) {
6420				$answer.find('.tpl-forum-list-num').text('');
6421				$(forum_row).find('.question').addClass('notice');
6422			} else {
6423				var f_num = $(forum_row).find('.tpl-forum-list-num').data('fm-num');
6424				$(forum_row).find('.tpl-forum-list-num').removeClass('n').html(unit['question']);
6425				if(list_no) $(forum_row).find('.tpl-forum-list-num').append(f_num);
6426			}
6427
6428			if(icon_wrap) {
6429				$(forum_row).find('.tpl-forum-list-num').wrapInner('<span class="'+icon_span_class+'"></span>');
6430				$answer.find('.tpl-forum-list-num').wrapInner('<span class="'+icon_span_class+'"></span>');
6431			}
6432
6433			if(row_settings.fonts) {
6434				if(row_settings.fonts.color) $(forum_row).find('.tpl-forum-list-cont').css('color', row_settings.fonts.color);
6435				if(row_settings.fonts.fontFamily) $(forum_row).find('.tpl-forum-list-cont').css('font-family', row_settings.fonts.fontFamily);
6436				if(row_settings.fonts.fontSize) $(forum_row).find('.tpl-forum-list-cont').css('font-size', row_settings.fonts.fontSize);
6437			}
6438
6439			$answer.find('.tpl-forum-faq-ctrl').remove();
6440			if(row.check_ctrl) {
6441				$answer.find('.tpl-forum-list-cont').append(`
6442					<div class="tpl-forum-faq-ctrl auto">
6443						<ul data-pid="${pid}" data-id="${row.id}">
6444							<li class="tpl-forum-faq-edit">${$.lang[block_lang]['board.button.modify']}</li>
6445							<li class="tpl-forum-faq-del">${$.lang[block_lang]['board.button.delete']}</li>
6446						</ul>
6447					</div>
6448				`);
6449			}
6450			break;
6451
6452		case 'qna':
6453			$(forum_row).find('.tpl-forum-list-state').text('');
6454			if((row.reply_name == null || !row.reply_name) && $(forum_row).find('.tpl-forum-list-num.n').length == 0) {
6455				if($('.element[data-id="' + pid + '"]').hasClass('newqna')) {
6456					var state_false_fsize = ($source.find('.tpl-forum-list-state span').attr('class')) ? $source.find('.tpl-forum-list-state span').attr('class') : '',
6457						state_true_fsize = ($source.find('.tpl-forum-list-state.true span').attr('class')) ? $source.find('.tpl-forum-list-state.true span').attr('class') : '',
6458						state_fsize = (row.replied == true) ? state_true_fsize : state_false_fsize;
6459
6460					$(forum_row).find('.tpl-forum-list-state').append('<span></span>');
6461
6462					if(row.replied == true) $(forum_row).find('.tpl-forum-list-state').addClass('true').attr('data-state',true).find('span').text($.lang[block_lang]['forum.qna.state.replied']).addClass(state_fsize);
6463					else $(forum_row).find('.tpl-forum-list-state').removeAttr('data-state').find('span').text($.lang[block_lang]['forum.qna.state.waiting']).addClass(state_fsize);
6464				} else {
6465					if(row.replied == true) $(forum_row).find('.tpl-forum-list-state').attr('data-state',true).text($.lang[block_lang]['forum.qna.state.replied']);
6466					else $(forum_row).find('.tpl-forum-list-state').removeAttr('data-state').text($.lang[block_lang]['forum.qna.state.waiting']);
6467				}
6468			}
6469			
6470			$(forum_row).find('.qna-details *[class*=tpl-forum-list-]').not('.tpl-forum-list-content, .tpl-forum-list-like').html('');
6471			$(forum_row).find('.qna-details *[class*=tpl-qna-answer-]').html('');
6472			
6473			var replyBtn = '<button type="button" class="btn btn-default btn-round btn-modal btn-list tpl-forum-write" data-pid="'+pid+'" data-reply="'+row.id+'">답글</button>';
6474			var forum_img = $(forum_row).find('.qna-details img');
6475			forum_img.each(function(idx, v){
6476				var src = $(v).attr('src');
6477				$(v).wrap('<a href="'+src+'" target="_blank"></a>')
6478			});
6479
6480			
6481			if(row_settings.fonts) {
6482				if(row_settings.fonts.color) $(forum_row).find('.tpl-qna-question-content').css('color', row_settings.fonts.color);
6483				if(row_settings.fonts.fontFamily) $(forum_row).find('.tpl-qna-question-content').css('font-family', row_settings.fonts.fontFamily);
6484				if(row_settings.fonts.fontSize) $(forum_row).find('.tpl-qna-question-content').css('font-size', row_settings.fonts.fontSize);
6485			}
6486
6487			$(forum_row).find('.qna-details').hide();
6488			break;
6489		case 'guestbook':
6490			// 관리자
6491			if(PAGE_MODE == 'c' || (PAGE_MODE != 'c' && row.fm_mb_id == (RENDER.b.UMEMBER.id_type == 'creatorlink' ? '' : RENDER.b.UMEMBER.id)) || RENDER.b.UMEMBER.check_adm == true || RENDER.b.UMEMBER.check_uadm == true) {
6492				if((PAGE_MODE != 'c' && (row.fm_mb_id != (RENDER.b.UMEMBER.check_adm != true && RENDER.b.UMEMBER.check_uadm != true && RENDER.b.UMEMBER.id_type == 'creatorlink' ? '' : RENDER.b.UMEMBER.id))
6493					) || (PAGE_MODE == 'c' && row.id_type != 'A')) {
6494					$(forum_row).find('[data-oper="U"]').hide();
6495					$(forum_row).find('[data-oper="U"]').next().hide();
6496				}
6497			} else {
6498				$(forum_row).find('.tpl-guestbook-more-menu').addClass('hide');
6499				//guest book2 fm29 렌더에서 기능 동작 x
6500				$(forum_row).find('.tpl-guestbook-more-menu-area-el2').addClass('hide');
6501			}
6502			if(row.fm_mb_id == '' && row.option == 'S' && PAGE_MODE != 'c' && RENDER.b.UMEMBER.id == '') {
6503				$(forum_row).find('.list-item').addClass('blind');
6504				$(forum_row).find('.tpl-guestbook-more-menu').addClass('hide');
6505				//guest book2 fm29 렌더에서 기능 동작 x
6506				$(forum_row).find('.tpl-guestbook-more-menu-area-el2').addClass('hide');
6507			}
6508			$(forum_row).find('.tpl-forum-list-cont').attr('data-fm_mb_id', row.fm_mb_id
6508);
6509			break;
6510		default: //normal
6511			break;
6512	}
6513
6514	var forum_row_html = $(forum_row).html();
6515	$(forum_row).remove();
6516
6517	return (type == 'faq') ? forum_row_html + $answer.outerHTML() : forum_row_html;
6518}
6519
6520var forumUrl = function() {
6521	if(PAGE_MODE != 'c') {
6522		var url = (PAGE_MODE=='s') ? '' : '/render';
6523	} else {
6524		var url = '/'+CONFIG_URL+'config/page';
6525	}
6526	return url;		
6527}
6528
6529// NEW
6530var getForumListItem = function(num,data,_fu) {
6531	// console.log('getForumListItem','num',num,`data`,data,`_fu`,_fu);
6532
6533	var fields = {
6534		normal: ['title','num','category','name','date','hit','comment','like','myimg'],
6535		thumb: ['title','cont','thumb','num','category','name','date','hit','comment','like'],
6536		faq: ['title','cont','faq-icon','faq-toggle'],
6537		qna: ['title','num','category','name','date','state','cont'],
6538		guestbook: ['cont','name','date'],
6539	};
6540	fields.all = [...new Set([...fields.normal, ...fields.thumb, ...fields.qna, ...fields.faq, ...fields.guestbook])];
6541
6542	var item = {
6543		pid: _fu.pid,
6544		id: data.id,
6545		link: {
6546			active: (data.title == '') ? false : true,
6547			val: ($.inArray(_fu.eltype2, ['faq','qna','guestbook']) > -1) ? 'javascript:void(0);' : `${forumUrl()}/forum/view/${data.id}`,
6548			cls: ``,
6549			attr: {},
6550		},
6551		new: data.new ? true : false,
6552		option: {
6553			val: data.option,
6554			notice: data.option == 'N' ? true : false,
6555			secret: data.option == 'S' ? true : false,
6556		},
6557		reply: {
6558			active: data.depth > 0 && data.option != 'N' ? true : false,
6559			name: data.reply_name || '',
6560		},
6561
6562		selector: '.item',
6563
6564		// field
6565		title: {
6566			val: data.title || '',
6567			max: _fu.elsettings.max_title || 150,
6568		},
6569		cont: {
6570			val: (_fu.eltype2 == 'faq' && _fu.config.faq_view_msg) ? _fu.config.faq_view_msg : data.content,
6571			more: _fu.sampleEL.find('.tpl-forum-list-cont .forum-cont-more').length  > 0 ? _fu.sampleEL.find('.tpl-forum-list-cont .forum-cont-more').eq(0).prop('outerHTML') : '',
6572			max: _fu.elsettings.max_cont || 300,
6573		},
6574		thumb: {
6575			val: data.thumb || '',
6576			ffolder: _fu.blockEL.attr('data-width'),
6577			alt: data.title.replace(/\s/g,'-'),
6578			noimg: setResizeImageFolder(_fu.blockEL.attr('data-width'),data.content_noimage_img) || `//storage.googleapis.com/i.addblock.net/icon/noimage_${_fu.blockEL.attr('data-width')}.png?${new Date().getTime()}`,
6579		},
6580		num: {
6581			val: num,
6582			isThumb: _fu.sampleEL.find('.tpl-forum-list-thumb .tpl-forum-list-num').length > 0 ? true : false,
6583		},
6584		cateogry: {
6585			seq: data.category_seq, 
6586			name: data.category_name
6587		},
6588		name: {
6589			val: data.name || '',
6590			mask: (_fu.elsettings.namemask_display == 'ON') ? true : false,
6591		},
6592		date: data.datetime,
6593		hit: data.hit,
6594		comment: {
6595			val: Number(data.comment) || 0,
6596		},
6597		like: {
6598			val: Number(data.like.cnt) || 0,
6599			active: data.like.own || false,
6600		},
6601		myimg: {
6602			val: data.myimg,
6603		},
6604		state: data.replied || false,
6605	};
6606	// console.log('data',data,'item',item);
6607
6608	var icon = {
6609		new: `<img src="//storage.googleapis.com/i.addblock.net/icon/icon_new_forum.png" title="new" alt="new">`,
6610		notice: `<i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i>`,
6611		secret: `<i class="tpl-forum-list-secret-icon cl-icon lock02" aria-hidden="true"></i>&nbsp;`,
6612	};
6613
6614	var tag = _fu.sampleEL.find(item.selector).eq(0).clone();
6615	tag.removeClass('active n s w');
6616	if(item.option.notice) tag.addClass('n');
6617	if(item.option.secret) tag.addClass('s');
6618	// w - qna block (state waiting)
6619
6620	$.each(fields.all, function(i,field_k) {
6621		var field_selector = `.tpl-forum-list-${field_k}`,
6622			unused = ($.inArray(field_k, fields[_fu.eltype2]) > -1) ? false : true,
6623			htmlField = '';
6624
6625		if(unused) {
6626			tag.find(field_selector).remove();
6627			return true;
6628		}
6629
6630		switch(field_k) {
6631			// .tpl-forum-list-title
6632			case 'title': 
6633				item.title.txt = item.title.val;
6634				if(item.title.txt) {
6635					if(_fu.eltype2 != 'faq') item.title.txt = htmlEntities(cutStrInBytes(htmlspecialchars_decode(item.title.txt), item.title.max));
6636					htmlField = `<a>${item.title.txt}</a> ${item.new ? icon.new : ''}`;
6637				} else {
6638					htmlField = `<a>${$.lang[LANG]['board.post.deleted']}</a>`;
6639				}
6640				if(item.option.secret) htmlField = `${icon.secret} ${htmlField}
6640`;
6641				var titleField = tag.find(field_selector);
6642				titleField.removeClass('reply').html(htmlField);
6643				if($.inArray(_fu.eltype2, ['normal','thumb']) > -1 && item.reply.active) {
6644					titleField.addClass('reply').prepend(`<span class="tpl-forum-list-reply-name">${item.reply.name}</span>`);
6645				}
6646				break;
6647
6648			// .tpl-forum-list-cont
6649			case 'cont':
6650				if(item.cont.val) {
6651					if(_fu.eltype2 == 'qna' && item.option.secret) {
6652						htmlField = `${icon.secret} ${$.lang[LANG]['forum.qna.content.secret']}`;
6653					} else {
6654						if($.inArray(_fu.eltype2, ['faq','guestbook']) > -1) {
6655							item.cont.txt = item.cont.val.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim,' ');
6656						} else {
6657							// item.cont.txt = item.cont.val.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim,' ');
6658							// item.cont.txt = item.cont.txt.replace(/(<([^>]+)>)/ig,' ');
6659							// item.cont.txt = cutStrInBytes(item.cont.txt,item.cont.max);
6660							
6661							// 다른 폰트 적용 시 공백 생기는 문제로 인해 아래 코드로 교체
6662							item.cont.txt = item.cont.val.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim, ' ');
6663							item.cont.txt = item.cont.txt.replace(/<[^>]+>/g, '');
6664							item.cont.txt = cutStrInBytes(item.cont.txt, item.cont.max);							
6665						}
6666						if(item.cont.more) {
6667							htmlField = `
6668								<div class="forum-cont-val"><a>${item.cont.txt}</a></div>
6669								${$(item.cont.more).find('a').length == 0 ? $(item.cont.more).wrapInner('<a></a>').prop('outerHTML') : item.cont.more}
6670							`;
6671						} else {
6672							htmlField = item.cont.txt;
6673						}
6674					}
6675				}
6676				tag.find(field_selector).html(htmlField);
6677
6678				if($.inArray(_fu.eltype2, ['faq','qna']) > -1) {
6679					var tmp_style = data.settings.fonts || { fontFamily: 'Noto Sans KR', fontSize: '13px', fontWeight: '300', color: '#000000'};
6680					tag.find(field_selector).css({
6681						'font-family': tmp_style.fontFamily,
6682						'font-size': tmp_style.fontSize,
6683						'font-weight': tmp_style.fontWeight,
6684						'color': tmp_style.color,
6685					});
6686				}
6687
6688				if(_fu.eltype2 == 'faq') {
6689					if(data.check_ctrl) {
6690						var faqCtrlAuto = (tag.find('.answer .tpl-forum-faq-ctrl').length > 0) ? false : true;
6691						if(faqCtrlAuto) {
6692							tag.find('.answer').append(`
6693								<div class="tpl-forum-faq-ctrl auto">
6694									<ul data-pid="" data-id="">
6695										<li class="tpl-forum-faq-edit"></li>
6696										<li class="tpl-forum-faq-del"></li>
6697									</ul>
6698								</div>
6699							`);
6700						}
6701
6702						tag.find('.answer .tpl-forum-faq-ctrl [data-id]').attr('data-id',item.id);
6703						tag.find('.answer .tpl-forum-faq-ctrl [data-pid]').attr('data-pid',item.pid);
6704						tag.find('.answer .tpl-forum-faq-ctrl .tpl-forum-faq-edit').html($.lang[_fu.block_lang]['board.button.modify']);
6705						tag.find('.answer .tpl-forum-faq-ctrl .tpl-forum-faq-del').html($.lang[_fu.block_lang]['board.button.delete']);
6706					} else {
6707						tag.find('.answer .tpl-forum-faq-ctrl').remove();
6708					}
6709				}
6710				break;
6711
6712			// .tpl-forum-list-thumb
6713			case 'thumb':
6714				if(item.thumb.val == '' && item.cont.val) {
6715					item.thumb.val = (item.thumb.noimg.includes('noimage')) ? '' : item.thumb.noimg;
6716				}
6717
6718				if(item.thumb.val) {
6719					item.src = item.thumb.val.replace('\/60\/','\/' + item.thumb.ffolder + '\/');
6720					tag.find(`${field_selector} img`).attr({'src':item.src, 'alt':item.thumb.alt});
6721					tag.find(field_selector).wrapInner('<a></a>');
6722				} else {
6723					tag.find(field_selector).empty();
6724				}
6725				break;
6726	
6727			// .tpl-forum-list-num
6728			case 'num': 
6729				item.num.isSingle = (tag.find('.tpl-forum-list-num').length > 1) ? false : true;
6730				if(item.option.notice) {
6731					htmlField = (tag.find('.tpl-forum-list-notice').length > 0) ? `<span class="tpl-forum-list-notice">${$.lang[_fu.block_lang]['forum.forum.notice.text']}</span>` : icon.notice;
6732				} else {
6733					var tmp_num = item.num.val,
6734						tmp_digitlen = tag.find(field_selector).attr('data-digitlen') || 1;
6735
6736					htmlField = String(tmp_num).padStart(Number(tmp_digitlen), '0');
6737				}
6738				tag.find(field_selector).html(htmlField);
6739				break;
6740			
6741			// .tpl-forum-list-faq-state
6742			case 'state':
6743				// "forum.qna.state.replied":                  "답변완료",
6744				// "forum.qna.state.waiting":                  "답변대기",
6745				var tmp_state = (item.state) ? $.lang[_fu.block_lang]['forum.qna.state.replied'] : $.lang[_fu.block_lang]['forum.qna.state.waiting'];
6746				tag.find(field_selector).html(`<span>${tmp_state}</span>`);
6747
6748				if(item.state) tag.find(field_selector).addClass('active');
6749				else tag.find(field_selector).removeClass('active');
6750				
6751				if(item.option.notice) tag.find(field_selector).empty().removeClass('active');
6752				break;
6753
6754			// .tpl-forum-list-faq-icon
6755			case 'faq-icon':
6756				if(_fu.sampleEL.find(`${field_selector}.notice`).length > 0) icon.notice = _fu.sampleEL.find(`${field_selector}.notice`).html();
6757				icon.question = (_fu.sampleEL.find(`${field_selector}.question`).length > 0) ? _fu.sampleEL.find(`${field_selector}.question`).html() : false;
6758				icon.answer = (_fu.sampleEL.find(`${field_selector}.answer`).length > 0) ? _fu.sampleEL.find(`${field_selector}.answer`).html() : false;
6759
6760				tag.find(field_selector).removeClass('notice question answer');
6761				if(item.option.notice) {
6762					tag.find(`.question ${field_selector}`).addClass('notice').html(icon.notice);
6763				} else {
6764					if(icon.question === false) {
6765						tag.find(`.question ${field_selector}`).remove();
6766					} else if(icon.question) {
6767						var tmp_q = icon.question;
6768						if(_fu.sampleEL.find(`${field_selector}.question`).is('[data-num="true"]')) tmp_q = tmp_q.replace(/\d+/gi,'') + num;
6769						tag.find(`.question ${field_selector}`).addClass('question').html(tmp_q);
6770					} else {
6771						tag.find(`.question ${field_selector}`).empty();
6772					}
6773				}
6774				
6775				if(icon.answer === false) tag.find(`.answer ${field_selector}`).remove();
6776				else if(icon.answer) tag.find(`.answer ${field_selector}`).addClass('answer').html(icon.answer);
6777				else tag.find(`.answer ${field_selector}`).empty();
6778				break;
6779
6780			// .tpl-forum-list-faq-toggle
6781			case 'faq-toggle':
6782				var tmp_faqtoggle_selector = `.item${item.option.notice ? '.n' : ''} ${field_selector}`;
6783				icon.toggle = (_fu.sampleEL.find(tmp_faqtoggle_selector).length > 0) ? _fu.sampleEL.find(tmp_faqtoggle_selector).eq(0).outerHTML() : '';
6784				if(icon.toggle && tag.find(field_selector).length == 0) {
6785					if(_fu.sampleEL.find(field_selector).eq(0).next('.tpl-forum-list-content').length > 0) tag.find(`.tpl-forum-list-content`).before(icon.toggle);
6786				}
6787				break;
6788			
6789			// .tpl-forum-list-category
6790			case 'category': 
6791				if(item.cateogry.seq) {
6792					tag.find(field_selector).text(item.cateogry.name).attr('data-cate',item.cateogry.seq);
6793				} else {
6794					tag.find(field_selector).removeAttr('data-cate').empty();
6795				}
6796				break;
6797
6798			case 'name':
6799				// tpl-forum-list-name
6800				var nameField = tag.find(field_selector);
6801				nameField.removeClass('reply').text(item.name.val);
6802				if($.inArray(_fu.eltype2, ['normal','thumb']) > -1 && item.reply.active && nameField.hasClass('tpl-sync-reply')) nameField.addClass('reply');
6803				break;
6804				
6805			case 'date':
6806				// tpl-forum-list-date
6807				tag.find(field_selector).text(item.date);
6808				break;
6809				
6810			case 'hit':
6811				// tpl-forum-list-hit
6812				if(tag.find(`${field_selector} .forum-hit-cnt`).length > 0) tag.find(`${field_selector} .forum-hit-cnt`).text(item.hit);
6813				else tag.find(field_selector).text(item.hit);
6814				break;
6815				
6816			case 'comment':
6817				// tpl-forum-list-comment
6818				if(_fu.eltype2 == 'qna') tag.find(`${field_selector}, ${field_selector}-icon`).remove();
6819				else if(item.comment.val > 0) tag.find(`${field_selector} .forum-comment-cnt`).text(item.comment.val);
6820				else tag.find(field_selector).empty();
6821
6822				break;
6823				
6824			case 'like':
6825				// tpl-forum-list-like
6826				if(tag.find(`${field_selector} .forum-like-cnt`).length > 0) tag.find(`${field_selector} .forum-like-cnt`).text(item.like.val);
6827				else tag.find(field_selector).text(item.like.val);
6828
6829				if(item.like.active) tag.find(field_selector).addClass('active');
6830				else tag.find(field_selector).removeClass('active');
6831				break;
6832				
6833			case 'myimg':
6834				// tpl-forum-list-myimg
6835				if(item.myimg.val) {
6836					item.src = item.myimg.val.replace('\/60\/','\/' + item.myimg.ffolder + '\/');
6837
6838					// tag.find(`${field_selector} img`).attr({'src':item.src}); forum3은 프로필 적용 되는데 forum2만 적용 안 되어서 아래와 같이 수정
6839
6840					if (tag.find(`${field_selector} img`).length > 0) {
6841						tag.find(`${field_selector} img`).attr({'src':item.src});
6842					} else {
6843						if (tag.find(field_selector).hasClass('hexagon')) {
6844							const $hex = tag.find(field_selector);
6845							if ($hex.hasClass('hexagon')) {
6846								const $img = $hex.find('image');
6847								if ($img.length > 0) {
6848									$img.attr('xlink:href', item.src);
6849								}
6850							}
6851						} 
6852					}
6853				}
6854				break;
6855
6856			default:
6857				break;
6858		}
6859	});
6860
6861	switch(_fu.eltype2) {
6862		case 'qna':
6863			tag.find(`.tpl-forum-qna-row > *:not(.tpl-forum-qna-details):not(.tpl-forum-list-content)`).empty();
6864			tag.find(`.tpl-forum-qna-row.answer .tpl-forum-list-cont`).removeAttr('style');
6865			break;
6866		case 'faq':
6867			if(_fu.config.faq_view_msg) {
6868				if(tag.find('.answer .tpl-forum-list-cont').length > 0) {
6869					tag.find('.answer .tpl-forum-list-cont').html(_fu.config.faq_view_msg);
6870				} else if(tag.find('.answer .inner-box').length > 0) {
6871					tag.find('.answer .inner-box').html(_fu.config.faq_view_msg);
6872				} else {
6873					tag.find('.answer .tpl-forum-list-content').html(_fu.config.faq_view_msg);
6874				}
6875			}
6876			break;
6877		default:
6878			break;
6879	}
6880
6881	if(item.link.active) tag.find('a:not([rel])').attr({href:item.link.val, class:item.link.cls, ...item.link.attr});
6882	else tag.find('a:not([rel])').attr({href:'javascript:void(0);', class:'deleted'});
6883	tag.find(`.tpl-forum-list-title,.tpl-forum-list-cont,.tpl-forum-list-thumb`).attr({'data-id':item.id,'data-option':item.option.val});
6884
6885	return tag.prop('outerHTML');
6886}
6887var initForumField = function(tmpEL) {
6888    if(tmpEL.is('[data-init="true"]')) return true;
6889    tmpEL.attr('data-init','true');
6890
6891	tmpEL.find('[data-loop="true"]').removeClass('sample-loop');
6892	if(tmpEL.is('[data-list-type]')) {
6893		tmpEL.attr('data-type2', tmpEL.is('[data-list-type="card"]') ? 'thumb' : 'normal');
6894	}
6895
6896	var eltype2 = 'normal';
6897	if(tmpEL.is('[data-type2]')) eltype2 = tmpEL.attr('data-type2');
6898	else if(tmpEL.is('[data-forum-type]').length > 0) eltype2 = tmpEL.attr('data-forum-type');
6899	else if(tmpEL.find('.tpl-forum-guestbook-area').length > 0) eltype2 = 'guestbook';
6900	else if(tmpEL.find('.tpl-forum-qna').length > 0) eltype2 = 'qna';
6901	else if(tmpEL.find('.question').length > 0) eltype2 = 'faq';
6902	else if(tmpEL.find('.thumb-wrap').length > 0) eltype2 = 'thumb';
6903
6904    var verOlder = (tmpEL.is('[data-fcolor]') || tmpEL.is('[data-ver="1"]')) ? true : false;
6905    if(verOlder) {
6906    } else {
6907
6908		var fields = {
6909			normal: ['hit','comment','like'],
6910			thumb: ['hit','comment','like'],
6911			faq: ['faq-toggle'],
6912			qna: ['cont'],
6913			guestbook: [],
6914		};
6915		fields.all = [...new Set([...fields.normal, ...fields.thumb, ...fields.qna, ...fields.faq, ...fields.guestbook])];
6916
6917		var fitem_selector = '.item';
6918		if(tmpEL.find(fitem_selector).length == 0 && tmpEL.find('tbody[data-loop="true"]').length > 0) tmpEL.find('tbody > tr').addClass('item');
6919		if(tmpEL.find(fitem_selector).length == 0) return false;
6920
6921		var fitem = tmpEL.find(fitem_selector).eq(0);
6922		if(fitem.length === 0 || fitem.find('[class*="tpl-forum-list-"]').length === 0) return false;
6923        var target = fitem.find('[class*="tpl-forum-list-"]').last().attr('class').trim().replace(/ /gi,'.');
6924
6925        $.each(fields[eltype2], function(i,k) {
6926			var tmpField = (fitem.find(`.tpl-forum-list-${k}`).length > 0) ? fitem.find(`.tpl-forum-list-${k}`) : tmpEL.find(`.tpl-forum-list-${k}`);
6927            var tmp_check = (tmpField.length > 0) ? true : false;
6928			if(tmp_check) {
6929				var tmp_iconstyle = tmpField.attr('data-style'),
6930					tmp_svg = '';
6931				if(typeof tmp_iconstyle != 'undefined' && tmp_iconstyle) {
6932					tmp_svg = clSVG(`field_${k.replace(/-/gi,'_')}_${tmp_iconstyle}`,16,16);
6933				}
6934
6935				if(tmp_svg != '') {
6936					tmpEL.find(`.tpl-forum-list-${k} > svg, .tpl-forum-list-${k} > .forum-${k}-icon`).remove();
6937					tmpEL.find(`.tpl-forum-list-${k}`).attr('data-style',tmp_iconstyle).prepend(`<span class="forum-${k}-icon">${tmp_svg}</span>`);
6938				}
6939
6940				if(k == 'cont' && eltype2 == 'qna') {
6941					var $tmp_qna_view = tmpEL.find(`.tpl-forum-qna.view`).eq(0).clone();
6942					tmpEL.find(`.tpl-forum-qna.view`).remove();
6943					tmpEL.find(`.tpl-forum-qna.list`).after($tmp_qna_view);
6944				}
6945			}
6946        });
6947    }
6948}
6949var showHideForumField = function(elObj, elsettings, skip_category_sync) {
6950	// console.log('showHideForumField', elObj.attr('data-name'), elObj.attr('data-ver'));
6951    /*
6952        - 설정에서 항목 OFF → .hidden 추가
6953		- 설정에서 항목 ON + empty or 0  → :empty 처리
6954
6955        - 폰트 반응형 설정 (fsize class 추가)
6956    */
6957
6958	initForumField(elObj);
6959
6960	if (typeof elsettings == 'undefined' ||
6961		$.isEmptyObject(elsettings)
6962	) {
6963		return false;
6964	}
6965
6966	var fields = {
6967		normal: ['title','num','category','name','myimg','date','hit','comment','like'],
6968		thumb: ['title','cont','thumb','num','category','name','date','hit','comment','like'],
6969		faq: ['title','cont'],
6970		qna: ['title','num','state','category','name','date','cont'],
6971		guestbook: ['cont','name','date'],
6972	};
6973	fields.all = [...new Set([...fields.normal, ...fields.thumb, ...fields.qna, ...fields.faq, ...fields.guestbook])];
6974
6975	if(elObj.is('[data-list-type]')) {
6976		elObj.attr('data-type2', elObj.is('[data-list-type="card"]') ? 'thumb' : 'normal');
6977	}
6978
6979    var _CMODE = (PAGE_MODE == 'c') ? true : false,
6980		_VALIDTYPE = (_CMODE) ? VALIDTYPE : property.VALIDTYPE,
6981		// el_seq = elObj.attr('data-id'),
6982		elid = elObj.attr('data-id') || '',
6983		eltype2 = elObj.attr('data-type2') || 'normal',
6984		isSample = elObj.find('.sample-loop').length > 0 ? true : false,
6985		isVer = elObj.attr('data-ver') || '',
6986		like_onoff = (typeof elsettings.like_display != 'undefined' && elsettings.like_display != 'N') ? true : false,
6987		comment_onoff = (typeof elsettings.comment_display != 'undefined' && elsettings.comment_display == 'OFF') ? false : true,
6988		namemask_onoff = (typeof elsettings.namemask_display != 'undefined' && elsettings.namemask_display == 'ON') ? true : false,
6989		date = (typeof elsettings.date != 'undefined' && elsettings.date) ? elsettings.date : 'DEF';
6990
6991	var field_disable = (typeof elsettings.field_disable != 'undefined' && !$.isEmptyObject(elsettings.field_disable)) ? elsettings.field_disable : [],
6992		field_list = eltype2 ? [...fields[eltype2]] : [];
6993
6994	if((!like_onoff || !_VALIDTYPE) && field_list.indexOf('like') > -1) field_list.splice(field_list.indexOf('like'), 1);
6995	if((!comment_onoff || $.inArray(eltype2, ['faq','qna']) > -1) && field_list.indexOf('comment') > -1) field_list.splice(field_list.indexOf('comment'), 1);
6996
6997	$.each(fields.all, function(i,v) {
6998		var onoff = ($.inArray(v, field_disable) > -1) ? false : true;
6999		if (onoff && $.inArray(v, field_list) == -1) onoff = false;
7000
7001		if(`${eltype2}.${v}.${isVer}` == 'faq.num.1') return true;
7002
7003		var more_selector = [];
7004		switch(v) {
7005			case 'cont':
7006				if($.inArray(eltype2, ['faq','qna','guestbook']) > -1) elObj.find(`.tpl-forum-list-cont`).addClass('write-css');
7007				break;
7008
7009			case 'category':
7010				more_selector.push(`#scate`);
7011				more_selector.push(`.tpl-forum-category-nav`);
7012				if(elObj.find('#scate').closest('.input-group-btn[data-caret]').length > 0) {
7013					if(onoff) elObj.find('#scate').closest('.input-group-btn[data-caret]').removeClass('hide');
7014					else elObj.find('#scate').closest('.input-group-btn[data-caret]').addClass('hide');
7015				}
7016
7017				if(isVer == '1' && elObj.find('#scate').closest('.input-group-btn.select-arrow').length > 0) {
7018					if(onoff) elObj.find('#scate').closest('.input-group-btn.select-arrow').removeClass('hide');
7019					else elObj.find('#scate').closest('.input-group-btn.select-arrow').addClass('hide');
7020				}
7021				break;
7022
7023			case 'comment':
7024				more_selector.push(`.tpl-forum-list-comment-icon`);
7025				break;
7026
7027			case 'myimg':
7028				more_selector.push(`.myimg-wrap`);
7029				break;
7030
7031			default:
7032				break;
7033		}
7034
7035		// 일괄 적용
7036		if(onoff) {
7037			elObj.find(`.tpl-forum-${v}`).removeClass('hide');
7038			elObj.find(`.tpl-forum-list-${v}`).removeClass('hide');
7039			if(more_selector != '') elObj.find(more_selector.join(',')).removeClass('hide');
7040		} else {
7041			elObj.find(`.tpl-forum-${v}`).addClass('hide');
7042			elObj.find(`.tpl-forum-list-${v}`).addClass('hide');
7043			if(more_selector != '') elObj.find(more_selector.join(',')).addClass('hide');
7044			if(!_CMODE) elObj.find(`.tpl-forum-${v}, .tpl-forum-list-${v}`).empty();
7045		}
7046
7047		// 개별 적용
7048		elObj.find(`.tpl-forum-list-${v}`).each(function(idx, tmp) {
7049			var tmpItem = $(this).closest('.item'),
7050				tmpField = $(this);
7051
7052			if(tmpField.is(':empty')) return true;
7053			
7054			switch(v) {
7055				case 'num':
7056					if(tmpItem.hasClass('n')) {
7057						var notice_tag = $(this).html(),
7058							notice_selector = `.tpl-forum-list-title .tpl-forum-list-notice-icon, .tpl-forum-list-title .tpl-forum-list-notice`;
7059
7060						tmpItem.find(notice_selector).remove();
7061						tmpItem.find('.tpl-forum-list-title').prepend(notice_tag);
7062
7063						if(onoff) tmpItem.find(notice_selector).addSvgClass('hide');
7064						else tmpItem.find(notice_selector).removeSvgClass('hide');
7065					}
7066					break;
7067
7068				case 'state':
7069					if(tmpField.hasClass('active')) tmpItem.removeClass('w');
7070					else tmpItem.addClass('w');
7071					break;
7072
7073				case 'name':
7074					if(onoff && isSample && namemask_onoff) {
7075						var tmp_v = $(this).text().trim(),
7076							tmp_cut = tmp_v.length >= 3 ? 1 : 2;
7077
7078						$(this).text(`${tmp_v.slice(0,tmp_cut)}***`);
7079					}
7080					break;
7081
7082				default:
7083					 break;
7084			}
7085		});
7086		
7087		// fsize 반영
7088		elObj.find(`
7089			.tpl-forum-list-${v}, 
7090			.search-box .form-control, .search-btn,
7091			.tpl-forum-pagination > li > a,
7092			.tpl-forum-write
7093		`).each(function() {
7094			$(this).removeClass(function(index, className) {
7095				return (className.match(/\bfsize\S+/g) || []).join(' ');
7096			});
7097
7098			if(!_CMODE || elObj.is('.el_viewblock')) {
7099				var tmp_fsize = ($(this).css('font-size') || '').match(/\d+(\.\d+)?/);
7100				if(tmp_fsize) $(this).addClass(`fsize${tmp_fsize[0]}`);
7101			}
7102		});
7103	});
7104
7105	elObj.find(`.tpl-forum-ul, .writer-wrap`).each(function() {
7106		if($(this).find('[class*="tpl-forum-list-"]').length > 0) {
7107			var childempty = ($(this).find('[class*="tpl-forum-list-"]:not(.hide)').length > 0) ? false : true;
7108			if(childempty) $(this).addClass('hide');
7109			else $(this).removeClass('hide');
7110		}
7111	});
7112
7113	if(eltype2 == 'guestbook') {
7114		if(getOrDefault(elsettings,'default_message','') != '') elObj.find('.input-content').attr('placeholder', elsettings.default_message);
7115
7116		var secret_display = getOrDefault(elsettings,'secret_display','U'),
7117			secret_checked = (secret_display == 'A') ? true : false;
7118		elObj.find('.secret-check input[type="checkbox"]').prop('checked', secret_checked);
7119		if(secret_display == 'U') elObj.find('.secret-check').removeClass('hide');
7120		else elObj.find('.secret-check').addClass('hide');
7121
7122
7123		var checkNonmem = true;
7124		if(_CMODE) checkNonmem = false;
7125		else {
7126			var mem_data = RENDER.b.UMEMBER;
7127			if(mem_data.id && ((mem_data.check_uadm || mem_data.check_adm) || (!mem_data.check_uadm && !mem_data.check_adm && mem_data.id_type != 'creatorlink'))) {
7128				checkNonmem = false;
7129			}
7130		}
7131		if(!checkNonmem) elObj.find('.input-nonmem, .captcha').addClass('hide');
7132	}
7133
7134	if(isVer == '1') {
7135		elObj.find('.hidden').removeClass('hidden');
7136
7137		if(eltype2 == 'faq') elObj.find(`.tpl-forum-list-num`).removeClass('hide');
7138		else {
7139			if(elObj.find('.tpl-forum-list-num.hide').length > 0) {
7140				elObj.find('.tpl-forum-list-title .tpl-forum-list-notice, .tpl-forum-list-title .tpl-forum-list-notice-icon').removeSvgClass('hide');
7141			} else {
7142				elObj.find('.tpl-forum-list-title .tpl-forum-list-notice, .tpl-forum-list-title .tpl-forum-list-notice-icon').addSvgClass('hide');
7143			}
7144		}
7145
7146		elObj.find('td[colspan]').each(function() {
7147			var tmp_colspan = $(this).closest('tr').prev('tr').find('td:not(:empty):not(.hide)').length;
7148			$(this).attr('colspan',tmp_colspan);
7149		});
7150		
7151	}
7152
7153	var writebtn_onoff = (typeof elsettings.writebtn_display !='undefined' && elsettings.writebtn_display == 'OFF') ? false : true;
7154	
7155	if(!_CMODE && !writebtn_onoff) elObj.find('.tpl-forum-write').remove();
7156	if(!skip_category_sync && typeof window.syncForumCategoryTypeDisplay == 'function') window.syncForumCategoryTypeDisplay(elObj);
7157
7158	if(	$.inArray(eltype2, ['normal','thumb']) > -1 
7159		&& elObj.find('.layout-table').length === 0
7160		&& elObj.is('[data-msny="true"]')
7161		&& typeof elObj.find('.container').data('masonry') != 'object'
7162	) {
7163		reloadBlockMasonry('init',elObj);
7164	}
7165}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.