PageSourceSearch

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

js l2c.co.kr collected 2026-10-07 06:58:09 UTC 324,259 bytes, 7,220 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	var placeTabmenuBeforeForumView = function() {
65		var $forumView = $('.forum-view').first();
66		var $tabmenus = $('.dsgn-body .cl-tabmenu.tabmenu-auto-block');
67		var $tabmenu = $tabmenus.first();
68		$tabmenus.slice(1).each(function() {
69			var $duplicate = $(this);
70			var $wrapper = $duplicate.closest('.elem');
71			if($wrapper.length) $wrapper.remove();
72			else $duplicate.remove();
73		});
74		if($forumView.length && $tabmenu.length) $forumView.before($tabmenu);
75	}
76
77	var forumSearchRegexp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+??>@\#$%&\'\"\\\(\=?쒋€?]/i;
78	var getForumPrevStx = function(id, sfl) {
79		var stx = (typeof $.cookie('forum_'+id+'_prev_stx') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_stx');
80		var search_field = (typeof sfl == 'undefined' || !sfl) ? $.cookie('forum_'+id+'_prev_sfl') : sfl;
81		if(stx && $.inArray(search_field, ['mb_id','nonmem']) < 0 && forumSearchRegexp.test(stx)) {
82			$.removeCookie('forum_'+id+'_stx',{path:'/'});
83			$.removeCookie('forum_'+id+'_prev_stx',{path:'/'});
84			return '';
85		}
86		return stx;
87	}
88
89	var getForumCategoryType = function(elsettings_or_el) {
90		var category_type = 'dropdown';
91		if(typeof elsettings_or_el != 'undefined') {
92			if(elsettings_or_el instanceof jQuery) category_type = elsettings_or_el.attr('data-forum-category-type') || category_type;
93			else if(typeof elsettings_or_el.forum_category_type != 'undefined') category_type = elsettings_or_el.forum_category_type;
94		}
95		return ($.inArray(category_type, ['dropdown','list']) > -1) ? category_type : 'dropdown';
96	}
97
98	var getForumCategoryAllLabel = function(block_lang) {
99		var lang = block_lang || LANG,
100			lang_data = $.lang[lang] || $.lang[LANG] || {};
101		return lang_data['config.label.dropdown.forum.all'] || lang_data['board.scate'] || 'All';
102	}
103
104	var getForumCategoryStyle = function(forum_el) {
105		var $forum_el = $(forum_el),
106			category_style = 'default',
107			style_options = ['default','delimiter1','delimiter2','line1','line2','fill1','fill2','fill3'];
108
109		if($forum_el.length > 0 && $forum_el[0]) {
110			category_style = $.trim(getComputedStyle($forum_el[0]).getPropertyValue('--gcate-style')) || category_style;
111		}
112
113		return ($.inArray(category_style, style_options) > -1) ? category_style : 'default';
114	}
115
116	var getForumCategoryNav = function(forum_el) {
117		var $forum_el = $(forum_el);
118		return $forum_el.find('.tpl-forum-category-nav');
119	}
120
121	var placeForumCategoryNav = function(forum_el, category_nav) {
122		var $forum_el = $(forum_el),
123			$category_nav = $(category_nav);
124
125		if($forum_el.length == 0 || $category_nav.length == 0) return $category_nav;
126
127		$forum_el.find('.tpl-forum-category-nav').not($category_nav).remove();
128
129		var $container = $forum_el.children('.container').first();
130		if($container.length > 0) {
131			$container.prepend($category_nav);
132			return $category_nav;
133		}
134
135		var $hidden_input = $forum_el.children('input[type="hidden"]').last();
136		if($hidden_input.length > 0) $hidden_input.after($category_nav);
137		else $forum_el.prepend($category_nav);
138
139		return $category_nav;
140	}
141
142	var getForumScate = function(forum_el) {
143		var $forum_el = $(forum_el),
144			$active_category = getForumCategoryNav($forum_el).find('.tpl-forum-category-item.active > a').first();
145
146		if($active_category.length > 0) return $active_category.attr('data-cate') || '';
147		return ($forum_el.find('.search-box #scate').length > 0) ? $forum_el.find('.search-box #scate').val() : '';
148	}
149
150	var setForumCategoryActive = function(forum_el, scate) {
151		var $forum_el = $(forum_el),
152			$category_nav = getForumCategoryNav($forum_el),
153			active_scate = (typeof scate != 'undefined' && scate) ? String(scate) : '';
154
155		$category_nav.find('.tpl-forum-category-item').removeClass('active');
156		var $active_item = $category_nav.find('.tpl-forum-category-item').filter(function() {
157			return String($(this).attr('data-cate') || '') == active_scate;
158		}).first();
159		if($active_item.length == 0) {
160			$active_item = $category_nav.find('.tpl-forum-category-item').first();
161			active_scate = $active_item.attr('data-cate') || '';
162		}
163		$forum_el.find('.search-box #scate').val(active_scate);
164		$active_item.addClass('active');
165		if(typeof syncForumCategoryCustomSelect == 'function') syncForumCategoryCustomSelect($forum_el);
166	}
167
168	var scrollToForumBlock = function(forum_el) {
169		var $forum_el = $(forum_el),
170			forum_id = $forum_el.attr('data-id');
171
172		if($forum_el.length == 0 || !forum_id) return false;
173		if(typeof scrollToBlock == 'function') {
174			scrollToBlock('.element[data-id="' + forum_id + '"]', 1000);
175			return true;
176		}
177		if($forum_el.offset()) {
178			$('html, body').animate({ scrollTop: $forum_el.offset().top }, 1000, 'easeInOutQuart');
179			return true;
180		}
181		return false;
182	}
183
184	var getForumSearchboxDisplay = function(elsettings_or_el) {
185		var searchbox_display = 'ON';
186		if(typeof elsettings_or_el != 'undefined') {
187			if(elsettings_or_el instanceof jQuery) searchbox_display = elsettings_or_el.attr('data-searchbox-display') || searchbox_display;
188			else if(typeof elsettings_or_el.searchbox_display != 'undefined') searchbox_display = elsettings_or_el.searchbox_display;
189		}
190		return (searchbox_display == 'OFF') ? false : true;
191	}
192
193	var getForumCategoryCustomMenu = function($custom) {
194		if(!$custom || $custom.length == 0) return $();
195
196		var $menu = $custom.children('.forum-category-custom-menu').first();
197		if($menu.length > 0) return $menu;
198
199		$('.forum-category-custom-menu-layer').each(function() {
200			var $layer = $(this),
201				$owner = $layer.data('forumCategoryOwner');
202
203			if($owner && $owner.length > 0 && $owner[0] == $custom[0]) {
204				$menu = $layer;
205				return false;
206			}
207		});
208		return $menu;
209	}
210
211	var getForumCategoryCustomOwner = function($target) {
212		var $custom = $target.closest('.forum-category-custom-select');
213		if($custom.length > 0) return $custom;
214
215		var $menu = $target.closest('.forum-category-custom-menu-layer');
216		if($menu.length == 0) return $();
217
218		$custom = $menu.data('forumCategoryOwner');
219		return ($custom && $custom.length > 0) ? $custom : $();
220	}
221
222	var copyForumCategoryCustomMenuVars = function($custom, $menu) {
223		if($custom.length == 0 || $menu.length == 0 || !window.getComputedStyle || !$menu[0].style || !$menu[0].style.setProperty) return;
224
225		var custom_style = window.getComputedStyle($custom[0]),
226			vars = [
227				'--searchbox-select-w',
228				'--fcategory-select-menu-w',
229				'--fcategory-select-fname',
230				'--fcategory-select-fsize',
231				'--fcategory-select-fweight',
232				'--fcategory-select-color',
233				'--fcategory-select-bgcolor',
234				'--fcategory-select-line',
235				'--fcategory-select-option-color',
236				'--fcategory-select-option-bgcolor'
237			];
238
239		$.each(vars, function(idx, key) {
240			var value = custom_style.getPropertyValue(key);
241			if(value) $menu[0].style.setProperty(key, value);
242		});
243		$menu.css('text-transform', $custom.css('text-transform'));
244	}
245
246	var positionForumCategoryCustomMenu = function($custom) {
247		var $menu = getForumCategoryCustomMenu($custom);
248		if($custom.length == 0 || $menu.length == 0 || !$custom.offset()) return;
249
250		var offset = $custom.offset(),
251			$win = $(window),
252			left = Math.round(offset.left),
253			top = Math.round(offset.top + $custom.outerHeight()),
254			scroll_left = $win.scrollLeft(),
255			win_width = $win.width(),
256			menu_width;
257
258		$menu.css({
259			'min-width': Math.ceil($custom.outerWidth()) + 'px',
260			'left': left + 'px',
261			'top': top + 'px'
262		});
263
264		menu_width = $menu.outerWidth();
265		if(left + menu_width > scroll_left + win_width) left = Math.max(scroll_left + 8, scroll_left + win_width - menu_width - 8);
266		if(left < scroll_left + 8) left = scroll_left + 8;
267
268		$menu.css({
269			'left': Math.round(left) + 'px',
270			'top': top + 'px'
271		});
272	}
273
274	var syncForumCategoryOptionWidth = function(forum_el) {
275		var $forum_el = $(forum_el),
276			$select = $forum_el.find('.search-box #scate').first();
277
278		if($select.length == 0) return;
279
280		$select.css('width','');
281		if($select.is('.hide, .hidden')) return;
282
283		var toNum = function(value) {
284				value = parseFloat(value);
285				return isNaN(value) ? 0 : value;
286			},
287			$wrap = $select.closest('.forum-category-select-wrap'),
288			$custom = $wrap.find('.forum-category-custom-select').first(),
289			$custom_menu = getForumCategoryCustomMenu($custom),
290			base_width = ($custom.length > 0) ? $custom.outerWidth() : $select.outerWidth(),
291			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,
292			text_width = 0,
293			$measure = $('<span></span>').css({
294				position: 'absolute',
295				visibility: 'hidden',
296				whiteSpace: 'nowrap',
297				top: '-9999px',
298				left: '-9999px',
299				fontFamily: $select.css('font-family'),
300				fontSize: $select.css('font-size'),
301				fontWeight: $select.css('font-weight'),
302				fontStyle: $select.css('font-style'),
303				letterSpacing: $select.css('letter-spacing'),
304				textTransform: $select.css('text-transform')
305			}).appendTo('body');
306
307		if($custom.length > 0 && $custom_menu.find('.forum-category-custom-option').length > 0) {
308			var $custom_option = $custom_menu.find('.forum-category-custom-option').first();
309			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;
310		}
311
312		$select.find('option').each(function() {
313			$measure.text($(this).text());
314			text_width = Math.max(text_width, $measure.outerWidth());
315		});
316		$measure.remove();
317		if($select[0].style && $select[0].style.setProperty) {
318			$select[0].style.setProperty('--fcategory-select-option-w', Math.ceil(Math.max(base_width, text_width + extra_width)) + 'px');
319		}
320		if($wrap.length > 0 && $wrap[0].style && $wrap[0].style.setProperty) {
321			$wrap[0].style.setProperty('--fcategory-select-menu-w', Math.ceil(Math.max(base_width, text_width + extra_width)) + 'px');
322		}
323	}
324
325	var closeForumCategoryCustomSelect = function($custom) {
326		$custom.each(function() {
327			var $this = $(this),
328				$menu = getForumCategoryCustomMenu($this);
329
330			$this.removeClass('open');
331			$this.find('.forum-category-custom-toggle').attr('aria-expanded','false');
332			if($menu.length > 0 && $menu.hasClass('forum-category-custom-menu-layer')) {
333				$menu
334					.removeClass('forum-category-custom-menu-layer')
335					.removeData('forumCategoryOwner')
336					.removeAttr('style')
337					.appendTo($this);
338			}
339		});
340	}
341
342	var openForumCategoryCustomSelect = function($custom) {
343		var $menu = getForumCategoryCustomMenu($custom);
344		if($custom.length == 0 || $menu.length == 0) return;
345
346		copyForumCategoryCustomMenuVars($custom, $menu);
347		$custom.addClass('open');
348		$custom.find('.forum-category-custom-toggle').attr('aria-expanded','true');
349		$menu
350			.addClass('forum-category-custom-menu-layer')
351			.data('forumCategoryOwner', $custom)
352			.appendTo('body');
353		positionForumCategoryCustomMenu($custom);
354	}
355
356	var syncForumCategoryCustomSelect = function(forum_el) {
357		var $forum_el = $(forum_el),
358			$select = $forum_el.find('.search-box #scate').first();
359
360		if($select.length == 0) return;
361
362		var $wrap = $select.closest('.forum-category-select-wrap'),
363			category_on = !$select.is('.hide, .hidden') && getForumCategoryType($forum_el) == 'dropdown';
364
365		if($wrap.length == 0) $wrap = $select.parent().addClass('forum-category-select-wrap');
366
367		if(!category_on) {
368			closeForumCategoryCustomSelect($wrap.find('.forum-category-custom-select'));
369			$wrap.removeClass('forum-category-customized');
370			$wrap.find('.forum-category-custom-select').remove();
371			$select.removeAttr('aria-hidden');
372			return;
373		}
374
375		$wrap.addClass('forum-category-customized');
376		$select.attr('aria-hidden','true');
377
378		var $custom = $wrap.children('.forum-category-custom-select').first();
379		if($custom.length == 0) {
380			$custom = $('<div class="forum-category-custom-select">')
381				.append(
382					$('<button type="button" class="forum-category-custom-toggle" aria-haspopup="listbox" aria-expanded="false">')
383						.append($('<span class="forum-category-custom-label">'))
384				)
385				.append($('<ul class="forum-category-custom-menu" role="listbox">'));
386			$select.after($custom);
387		}
388
389		var selected_value = (typeof $select.val() == 'undefined' || $select.val() == null) ? '' : String($select.val()),
390			selected_text = '',
391			$menu = getForumCategoryCustomMenu($custom).empty();
392
393		if($menu.length == 0) {
394			$menu = $('<ul class="forum-category-custom-menu" role="listbox">').appendTo($custom);
395		}
396
397		$select.find('option').each(function() {
398			var option_value = (typeof $(this).attr('value') == 'undefined') ? '' : String($(this).attr('value')),
399				option_text = $(this).text(),
400				is_selected = option_value == selected_value;
401
402			if(is_selected) selected_text = option_text;
403			$menu.append(
404				$('<li class="forum-category-custom-option" role="option" tabindex="-1">')
405					.attr('data-value', option_value)
406					.attr('aria-selected', is_selected ? 'true' : 'false')
407					.toggleClass('active', is_selected)
408					.text(option_text)
409			);
410		});
411
412		if(!selected_text) selected_text = $select.find('option').first().text() || '';
413		$custom.find('.forum-category-custom-label').text(selected_text);
414		syncForumCategoryOptionWidth($forum_el);
415	}
416
417	var syncForumSearchboxDisplay = function(forum_el, searchbox_on) {
418		var $forum_el = $(forum_el),
419			$search_box = $forum_el.find('.search-box'),
420			$search_controls = $(),
421			$category_select = $forum_el.find('#scate').first(),
422			category_type = getForumCategoryType($forum_el),
423			category_on = $category_select.length > 0 && !$category_select.is('.hide, .hidden'),
424			keep_category_select = category_on && category_type == 'dropdown',
425			list_category_search = category_on && category_type == 'list';
426
427		if(typeof searchbox_on == 'undefined') searchbox_on = getForumSearchboxDisplay($forum_el);
428		else searchbox_on = (searchbox_on == 'OFF' || searchbox_on === false) ? false : true;
429		$forum_el.attr('data-searchbox-display', searchbox_on ? 'ON' : 'OFF');
430		$search_box.find('#scate, #sfl').closest('.input-group-btn').attr('data-caret','arrow1');
431		$search_box.find('#sfl').closest('.input-group-btn').addClass('forum-search-field-select-wrap');
432
433		if($search_box.find('#sfl').length > 0) $search_controls = $search_controls.add($search_box.find('#sfl').closest('.input-group-btn'));
434
435		var $stx = $search_box.find('#stx, input[name="stx"]'),
436			$stx_wrap = $stx.closest('.input-search-box');
437
438		if($stx_wrap.length > 0 && !$stx_wrap.is('.search-box')) {
439			$search_controls = $search_controls.add($stx_wrap);
440		} else {
441			$search_controls = $search_controls.add($stx);
442			if($search_box.find('.search-btn').length > 0) $search_controls = $search_controls.add($search_box.find('.search-btn').closest('.input-group-btn'));
443		}
444
445		$search_box
446			.toggleClass('forum-category-select-only', !searchbox_on && keep_category_select)
447			.toggleClass('forum-category-select-hidden', searchbox_on && !category_on)
448			.toggleClass('forum-category-list-search', searchbox_on && list_category_search)
449			.toggleClass('hide hidden', !searchbox_on && !keep_category_select);
450		$search_controls.toggleClass('hide hidden', !searchbox_on);
451		syncForumCategoryOptionWidth($forum_el);
452		syncForumCategoryCustomSelect($forum_el);
453		}
454		window.syncForumSearchboxDisplay = syncForumSearchboxDisplay;
455
456		var syncForumCategoryDelimiterRows = function(forum_el) {
457			var $forum_el = $(forum_el),
458				$category_nav = getForumCategoryNav($forum_el).first(),
459				category_style = $forum_el.attr('data-gcate-style') || getForumCategoryStyle($forum_el),
460				prev_top = null;
461
462			$category_nav.find('.tpl-forum-category-item').removeClass('forum-category-row-start');
463			if($forum_el.length == 0 || $category_nav.length == 0 || category_style != 'delimiter2' || $category_nav.is('.hide, .hidden')) return;
464
465			$category_nav.find('.tpl-forum-category-item').not('.hide').each(function(idx) {
466				var item_top = Math.round($(this).position().top);
467				if(idx == 0 || prev_top === null || item_top > prev_top + 1) $(this).addClass('forum-category-row-start');
468				prev_top = item_top;
469			});
470		}
471		window.syncForumCategoryDelimiterRows = syncForumCategoryDelimiterRows;
472
473		var syncForumCategorySearchLayout = function(forum_el) {
474			var $forum_el = $(forum_el),
475				$category_nav = getForumCategoryNav($forum_el).first(),
476			$search_box = $forum_el.find('.search-box').first(),
477				$layout_wrap = $forum_el.find('.forum-category-searchbox-top-wrap').first(),
478				$search_origin = $forum_el.find('.forum-category-searchbox-origin').first(),
479				searchbox_top = false,
480				searchbox_top_position = false,
481				searchbox_layout_top = false,
482				category_list_bottom = false;
483
484		$forum_el.removeClass('forum-category-searchbox-top forum-category-searchbox-bottom');
485		$category_nav.removeClass('forum-category-searchbox-top-nav forum-category-searchbox-bottom-nav');
486		$search_box.removeClass('forum-category-searchbox-top-control');
487
488		if($category_nav.length > 0 && $search_box.length > 0) {
489			var $content = $forum_el.find('[data-loop="true"]').first(),
490				searchbox_before_content = false,
491				searchbox_position = $search_box.css('position'),
492				searchbox_top_value = $search_box.css('top'),
493				searchbox_bottom_value = $search_box.css('bottom'),
494				searchbox_css_top = ($.inArray(searchbox_position, ['absolute','fixed']) > -1 && searchbox_top_value != 'auto' && searchbox_bottom_value == 'auto');
495			if($content.length == 0) $content = $forum_el.find('.table-container, .layout-table, .tpl-forum-pagination').first();
496			if($content.length > 0) {
497				if(typeof $search_box[0].compareDocumentPosition == 'function') {
498					searchbox_before_content = !!($search_box[0].compareDocumentPosition($content[0]) & 4);
499				} else {
500					searchbox_before_content = $search_box.index() < $content.index();
501				}
502			}
503
504			searchbox_layout_top = (searchbox_before_content || searchbox_css_top);
505			searchbox_top_position = getForumSearchboxDisplay($forum_el)
506				&& !$search_box.is('.hide, .hidden')
507				&& searchbox_layout_top;
508			searchbox_top = getForumCategoryType($forum_el) == 'list'
509				&& !$category_nav.is('.hide, .hidden')
510				&& !$search_box.hasClass('forum-category-select-only')
511				&& searchbox_layout_top;
512			category_list_bottom = getForumCategoryType($forum_el) == 'list'
513				&& !$category_nav.is('.hide, .hidden')
514				&& !$search_box.hasClass('forum-category-select-only')
515				&& !searchbox_layout_top;
516		}
517
518		if(searchbox_top) {
519			if($layout_wrap.length == 0) {
520				$layout_wrap = $('<div class="forum-category-searchbox-top-wrap">');
521				$category_nav.before($layout_wrap);
522			}
523			if($search_origin.length == 0 && $search_box.parent()[0] !== $layout_wrap[0]) {
524				$search_origin = $('<span class="forum-category-searchbox-origin">').hide();
525				$search_box.before($search_origin);
526			}
527			$layout_wrap.append($category_nav).append($search_box);
528		} else if($layout_wrap.length > 0) {
529			if($search_box.length > 0 && $search_box.parent()[0] === $layout_wrap[0]) {
530				if($search_origin.length > 0) $search_origin.replaceWith($search_box);
531				else $layout_wrap.after($search_box);
532			}
533			if($category_nav.length > 0 && $category_nav.parent()[0] === $layout_wrap[0]) placeForumCategoryNav($forum_el, $category_nav);
534			$layout_wrap.remove();
535		} else if($search_origin.length > 0) {
536			$search_origin.remove();
537		}
538
539		$forum_el.toggleClass('forum-category-searchbox-top', searchbox_top);
540		$forum_el.toggleClass('forum-category-searchbox-bottom', category_list_bottom);
541		$category_nav.toggleClass('forum-category-searchbox-top-nav', searchbox_top);
542		$category_nav.toggleClass('forum-category-searchbox-bottom-nav', category_list_bottom);
543		$search_box.toggleClass('forum-category-searchbox-top-control', searchbox_top_position);
544		$search_box.toggleClass('forum-searchbox-top-position', searchbox_top_position);
545		$search_box.toggleClass('forum-searchbox-layout-top', searchbox_layout_top);
546	}
547
548	var syncForumCategoryTypeDisplay = function(forum_el) {
549		var $forum_el = $(forum_el),
550			category_type = getForumCategoryType($forum_el),
551			$category_select_wrap = $forum_el.find('.forum-category-select-wrap'),
552			$category_nav = getForumCategoryNav($forum_el).first(),
553			category_on = $forum_el.find('#scate').length > 0 && !$forum_el.find('#scate').is('.hide, .hidden'),
554			searchbox_on = getForumSearchboxDisplay($forum_el);
555
556		if($category_select_wrap.length == 0 && $forum_el.find('#scate').length > 0) {
557			$category_select_wrap = $forum_el.find('#scate').parent().addClass('forum-category-select-wrap');
558		}
559		if($category_nav.length > 0 && searchbox_on) $category_nav = placeForumCategoryNav($forum_el, $category_nav);
560
561		$category_select_wrap.toggleClass('hide', !category_on || category_type == 'list');
562		$forum_el.attr('data-gcate-style', getForumCategoryStyle($forum_el));
563			$category_nav
564				.removeAttr('data-sticky')
565				.toggleClass('hide', !category_on || category_type != 'list');
566			syncForumSearchboxDisplay($forum_el);
567			syncForumCategorySearchLayout($forum_el);
568			syncForumCategoryDelimiterRows($forum_el);
569		}
570		window.syncForumCategoryTypeDisplay = syncForumCategoryTypeDisplay;
571
572		var forum_category_row_timer = null;
573		$(window).on('resize', function() {
574			clearTimeout(forum_category_row_timer);
575			forum_category_row_timer = setTimeout(function() {
576				$('[data-type="forum"][data-gcate-style="delimiter2"]').each(function() {
577					syncForumCategoryDelimiterRows($(this));
578				});
579			}, 100);
580		});
581
582
583	function decodeUnicode(str) {
584		return str.replace(/\\u([0-9a-fA-F]{4})/g, function(match, grp) {
585			return String.fromCharCode(parseInt(grp, 16));
586		});
587	}
588
589	function insertHtmlAtCursor(html) {
590	    var sel, range, html;
591	    if (window.getSelection) {
592	        sel = window.getSelection();
593	        if (sel.getRangeAt && sel.rangeCount) {
594	            range = sel.getRangeAt(0);
595	            range.deleteContents();
596			    var htmlNode = document.createElement('p');
597			    htmlNode.innerHTML = html
598	            range.insertNode(htmlNode);
599	            sel.removeAllRanges();
600	            range = range.cloneRange();
601	            range.selectNode(htmlNode);
602	            range.collapse(false);
603	            sel.addRange(range);
604	        }
605	    } else if (document.selection && document.selection.createRange) {
606	        range = document.selection.createRange();
607	        range.pasteHTML(htmlNode);
608	        range.select();
609	    }
610	}
611
612	var setWriteUser = function(data, callback) {
613		resetObject(postUser);
614		postUser.name = data.name;
615		postUser.img = data.myimg;
616		postUser.option = data.option;
617		postUser.secret_display = data.settings.secret_display;
618		postUser.mgr = data.mgr;
619		postUser.replied = data.replied;
620		postUser.writeable = data.writeable;
621			
622		$.post('/fm/guest/login', { user : postUser, guest : user }, function(data2) {
623			if(typeof callback == 'function') {
624				callback();
625			}
626		});
627		return false;
628	}
629
630	var forumWriteform = function(id, pid, reply) {
631		var title 			= (id) ? $('.tpl-forum-title').text() : '',
632			content 		= (id) ? $('.tpl-forum-content .fr-view').html() : '<p><br></p>',
633			name 			= postUser.name,
634			date 			= (id) ? $('.tpl-forum-date').text() : 'now',
635			myimage 		= postUser.img,
636			option 			= postUser.option,
637			secret 			= (option == 'S') ? 'S' : '',
638			notice 			= (option == 'N') ? 'N' : '',
639			secret_display 	= postUser.secret_display,
640			mgr 			= postUser.mgr;
641
642		title = title.replace(/'/g,'&#39;');
643		var square_secret = (secret=='S') ? 'fa-check-square-o' : 'fa-square-o',
644			square_notice = (option=='N') ? 'fa-check-square-o' : 'fa-square-o',
645			secretClass = '',
646			noticeClass = '';
647
648		switch(secret_display) {
649			case 'N' : secretClass = 'hide'; break;
650			case 'A' : 
651				secretClass = 'hide';
652				secret = 'S';
653				break;
654			default : secretClass = 'always'; break;
655		}
656		noticeClass = (mgr==true) ? 'always' : 'hide';
657		if(postUser.replied || reply) noticeClass = 'hide';
658		if(secret=='S' && secret_display!='A') secretClass = '';
659		if(option=='N') noticeClass = '';
660
661		var str = '\
662			<div class="forum-write">\
663				<ul class="forum-user-info clearfix">\
664					<li class="user-image tpl-forum-myimage">\
665						<svg viewbox="0 0 40 40">\
666							<pattern id="forum-write-image" patternUnits="userSpaceOnUse" width="40" height="40">\
667								<image xlink:href="' + myimage + '?_' + new Date().getTime() + '" x="-10" width="60" height="40" />\
668							</pattern>\
669							<polygon points="20 0 37 10 37 30 20 40 3 30 3 10" fill="url(#forum-write-image)" />\
670						</svg>\
671					</li>\
672					<li class="user-info">\
673						<div class="tpl-forum-name">' + name + '</div>\
674						<div class="tpl-forum-date date">' + date + '</div>\
675					</li>\
676					<li class="user-ctrl">\
677						<span id="fm-notice" class="' + noticeClass + '" data-notice="' + notice + '"><i class="fa ' + square_notice + '"></i>' + $.lang[LANG]['board.public'] + '</span>\
678						<span id="fm-secret" class="' + secretClass + '" data-secret="' + secret + '"><i class="fa ' + square_secret + '"></i>' + $.lang[LANG]['board.private'] + '</span>\
679						<span id="fm-reserv" class="' + reservClass + '" data-reserv="' + reserv + '"><i class="fa ' + square_reserv + '"></i>' + $.lang[LANG]['board.reserv'] + '</span>\
680					</li>\
681				</ul>\
682				<input type="hidden" id="fm-id" value="' + id + '">\
683				<input type="hidden" id="fm-pid" value="' + pid + '">\
684				<input type="hidden" id="fm-reply" value="' + reply + '">\
685				<input type="hidden" id="hash" value="' + (($.cookie('hash')) ? $.cookie('hash') : '') + '">\
686				<input class="form-control tpl-forum-title" id="fm-title" value="' + title + '" placeholder="' + $.lang[LANG]['board.enter-title'] + '">\
687				<div class="fm-body fm-content fm-editor" id="fm-editor" data-placeholder="' + $.lang[LANG]['board.enter-content'] + '">' + content + '</div>\
688			</div>\
689			<div class="upload-files"></div>\
690		';
691
692		// $.removeCookie('hash', { path: '/' });
693		return str;
694	}
695
696	$doc.on('keypress','.modal[id*=flat-modal] #mb_id', function(e) {
697		if(e.keyCode == 13) {
698			$('.forum-login').click();
699		}
700	});
701
702	$doc.on('keypress','.modal[id*=flat-modal] #mb_password', function(e) {
703		if(e.keyCode == 13) {
704			$('.forum-login').click();
705		}
706	});
707
708	$doc.on('focus','#fm-title',function(e) {
709		$('.note-toolbar > .btn-group > button').addClass('disabled');
710	}).on('focus','.note-editable',function(e) {
711		$('.note-toolbar > .btn-group > button').removeClass('disabled');
712	});
713
714	$doc.on('click','.note-toolbar > .btn-group > button', function(e) {
715		if($(this).hasClass('disabled')) e.preventDefault();
716	});
717
718	$doc.on('click', '.forum-user-info li.user-ctrl .dropdown-menu', function(e){
719		e.stopPropagation();
720	});
721
722	$doc.on('change', '.tpl-forum-comment_display .comment-onoff', function() {
723		var sid = (typeof SID == 'undefined') ? property.SID : SID;
724		var view = (typeof VIEW == 'undefined') ? property.VIEW : VIEW;
725		var value = $(this).val();
726		if($(this).is('input[type="checkbox"]')) value = ($(this).prop('checked')) ? 'OFF' : 'ON';
727		var settings = {};
728		settings['comment_display'] = value; 
729		$.ajax({
730			url: '/fm/fmSettings/update',
731			data: {sid: sid, settings: JSON.stringify(settings), el: view},
732			method: 'POST',
733			dataType: 'json',
734			async: false,
735			success: function(data) {
736				// console.log(data);
737				checkError(data);
738				var settings = data;
739				if(settings.comment_display != 'OFF') {
740					$('.tpl-forum-comment_display').removeClass('on').addClass('off');
741					$.comment.init();
742				} else {
743					$('.tpl-forum-comment_display').removeClass('off').addClass('on');
744					$('.page-comments').remove();
745				}
746			}
747		});
748	});
749
750
751	var forumView = function(id) {
752		var fv_deferred = $.Deferred();
753
754		setViewPageStyle();
755
756		files = [];
757        $.ajax({
758            url: '/fm/view',
759            dataType: 'json',
760            type: 'POST',
761            data:  { id : id, sid : F_SID },
762            async: false,
763            cache: false,
764            success: function (data) {
765				if(typeof data.error != 'undefined' && data.error) {
766					alert(data.error);
767
768					var error_code = data.code || 0;
769					switch(error_code) {
770						case 404:
771							fv_deferred.reject(data.code);
772							break;
773
774						case 401:
775						case 403:
776							var error_msg = (error_code == 403) ? 'Forbidden' : 'Unauthorized';
777							fv_deferred.reject(`Error ${error_msg}`);
778
779							var umemberActivate = (PAGE_MODE == 'c')? Number(UMEMBER_ACTIVATE) : Number(property.UMEMBER_ACTIVATE);
780							var umember = (PAGE_MODE == 'c')? UMEMBER : property.UMEMBER;
781							var checkLogin = (PAGE_MODE == 'c')? true : umember.check_login;
782							if(umemberActivate == 0 && umember.id_type == 'creatorlink') { //creatorlink login
783								checkLogin = (umember.id !== undefined && umember.id)? true : false;
784							}
785							// $.cookie('gallery','.' + F_PARENT.element, { path: '/' });
786							$('.header.el-menu').hide();
787							$('.el-footer').hide();
788							$.processON('', '#fff');
789
790							if(PAGE_MODE != 'c') {
791								var url = (PAGE_MODE=='s') ? '/' : '/render/';
792								if(checkLogin) {
793									alert(data.error);
794									(F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);		
795								} else {
796									var action = (property.VALIDTYPE == 'SM')  ? '/_login' : '/_cllogin';
797									var url = $(location).attr('pathname');
798									var html = '<form name="write_login_form" id="write-login" method="post" action="' + action + '" style="display:none;">\
799													<input type="hidden" name="status" value="forum_view">\
800													<input type="hidden" name="sid" value="'+property.SID+'">\
801													<input type="hidden" name="page_mode" value="'+data.access+'">\
802													<input type="hidden" name="url" value="'+url+'">\
803												</form>';
804									$('body').append(html);
805									document.write_login_form.submit();
806								}
807							} else {
808								(F_ONE) ? location.replace('/'+CONFIG_URL+'config/page/index#' + F_PARENT.page) : location.replace('/'+CONFIG_URL+'config/page/' + F_PARENT.page);
809							}
810							break;
811
812						default:
813							fv_deferred.reject('Error Undefined');
814							break;
815					}
816
817					return false;
818				}
819
820				if($.inArray(data.fm_type, ['qna','faq']) > -1) {
821					var fm_id = (data.fm_reply!='0' && data.own)? data.fm_reply : data.id;
822					
823					$.cookie('forum-item',F_PARENT.pid, { path: '/' });
824					$.cookie('forum_content_view', F_PARENT.pid + '&' + fm_id, { path: '/', expires: 12 * 60 * 60 * 1000 });
825					$.forum.setForumCookie(F_PARENT.pid, data.page_num, '', '', '');
826
827					if(data.fm_type == 'qna') {
828						var str = '<div class="forum-view" data-forum-type="qna"></div>';
829						if($.clnav.check()) {
830							$('.dsgn-body').prepend(str);
831						} else {
832							$('.header.el-menu').last().after(str);
833						}
834						placeTabmenuBeforeForumView();
835						$('.header.el-menu').hide();
836						$('.el-footer').hide();
837						$.processON('', '#fff');
838					}
839
840					if(PAGE_MODE != 'c') {
841						var url = (PAGE_MODE=='s') ? '/' : '/render/';
842						(F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);
843					} else {
844						(F_ONE) ? location.replace('/'+CONFIG_URL+'config/page/index#' + F_PARENT.page) : location.replace('/'+CONFIG_URL+'config/page/' + F_PARENT.page);
845					}
846					
847					fv_deferred.reject('has error 2');
848					return false;
849				}
850				if(typeof data.fonts != 'undefined' && data.fonts && PAGE_MODE!='c') {
851					$.each(data.fonts, function(i,v) {
852						if(property.ELFONTS.indexOf(i) < 0) {
853							property.ELFONTS.push(i);
854							$('#loadfonts').append(v);
855						}
856					});
857				}
858
859				if(typeof data.webfonts != 'undefined' && data.webfonts && PAGE_MODE!='c') {
860					$.each(data.webfonts, function(i2,v2) {
861						if(property.ELFONTS.indexOf(i2) < 0 && v2) {
862							property.ELFONTS.push(i2);
863							WebFont.load({ google : { families : [ v2 ], display:'swap' }});
864						}
865					})
866				}
867
868				// QnA Block:: notice view page, comment_display: off
869				if(data.fm_type == 'qna' && data.option == 'N') $('.page-comments').hide();
870
871				var settings = (typeof data.fm_settings == 'undefined') ? {} : data.fm_settings,
872					p_settings = (typeof F_PARENT.settings == 'undefined' || F_PARENT.settings == '') ? {} : JSON.parse(F_PARENT.settings),
873					comment_display = (typeof settings.comment_display == 'undefined') ? ((data.check_comment)? 'ON' : 'OFF') : settings.comment_display,
874					wrap = (typeof settings.wrap == 'undefined') ? '' : 'w' + settings.wrap,
875					align = (typeof settings.align == 'undefined') ? 'left' : settings.align,
876					category = (typeof data.category_seq == 'undefined') ? '' : '<div class="tpl-forum-category" data-cate="' + data.category_seq + '">' + data.category_name + '</div>',
877					forum_validplan = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN;
878				// Category Display none case
879				// if(category && typeof p_settings.field_disable != 'undefined') {
880				// 	if($.inArray('category',p_settings.field_disable) > -1)  category = '';
881				// }
882				if(comment_display == 'OFF') $('.page-comments').remove();
883
884				files = data.files;		
885				p_settings.forum_email = ((typeof forum_validplan == 'undefined') || (!forum_validplan)) ? 
886										((typeof p_settings.forum_email == 'undefined') || (!p_settings.forum_email) ? p_settings.forum_email : p_settings.forum_email.split(',')[0]
887										) : p_settings.forum_email;
888
889				var siteSettings = (PAGE_MODE == 'c') ? SETTINGS : property.SETTINGS,
890					f_parallax = (typeof p_settings.parallax == 'undefined') ? false : p_settings.parallax,
891				 	f_type = (typeof p_settings.forum_type == 'undefined') ? '' : 'data-forum-type="' + p_settings.forum_type + '"',
892					forum_email = ((typeof p_settings.forum_email == 'undefined') || (p_settings.email_display == 'OFF')) ? '' : p_settings.forum_email,
893					forum_content = ($('<div>'+data.content+'</div>').find('img[src^="http://"]').length > 0) ? data.content.replace(/src\=\"http\:\/\//gi,'src\=\"\/\/') : data.content;
894				var f_lang = (typeof p_settings.chlang == 'undefined')? LANG : p_settings.chlang;
895				var del_display = (typeof p_settings.del_display == 'undefined' || PAGE_MODE == 'c')? 'ON' : p_settings.del_display,
896					f_b_title = (typeof p_settings.forum_block_title == 'undefined') ? '' : p_settings.forum_block_title;
897				data.f_lang = (f_lang)? f_lang : LANG;
898
899				var format_time = (data.reserved_format == '') ? data.date : data.reserved_format;
900
901				var fm_fonts = (typeof settings.fonts == 'undefined' || settings.fonts === null) ? {} : settings.fonts;
902				// fm_fonts = JSON.parse(fm_fonts);
903				var inline_style = '';
904
905				if(typeof fm_fonts.fontFamily != 'undefined') inline_style += ` font-family:${fm_fonts.fontFamily}; `;
906				if(typeof fm_fonts.fontSize != 'undefined') inline_style += ` font-size:${fm_fonts.fontSize}; `;
907				if(typeof fm_fonts.color != 'undefined') inline_style += ` color:${fm_fonts.color}; `;
908
909				var modoo_str = `
910					<div class="forum-view ${wrap}"  ${f_type} data-parallax="${f_parallax}">
911					<input type="hidden" id="fm-id" value="${data.id}">
912					<input type="hidden" id="fm-pid" value="${data.pid}">
913					<input type="hidden" id="forum-email" value="${forum_email}">
914					<div class="container">
915						<div class="forum-write ${wrap}">
916							<div class="row">
917								<div class="col-md-12 col-sm-12 col-xs-12">
918									<div class="tpl-forum-view-header">
919										<div class="forum-block-title">${f_b_title}</div>
920										<div class="user-ctrl">
921											${((del_display == 'OFF')? '' : postDropMenu(data))}
922										</div>
923									</div>
924									<div class="tpl-forum-view-info">
925										<div class="tpl-forum-title">${data.title}</div>
926										<div class="tpl-forum-info-detail">
927											<div class="tpl-forum-name">${data.name}</div>
928											<div class="tpl-forum-date date">${format_time}</div>
929											<div class="tpl-forum-hit hit">
930												<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>
931												${data.hit}
932											</div>
933										</div>
934									</div>
935									<div class="tpl-forum-content fm-body fm-content fm-editor fr-box ${align}">
936										<div class="fr-wrapper" dir="auto">
937											<div class="fr-element fr-view" dir="auto" style="${inline_style}">${forum_content}</div>
938										</div>
939									</div>
940									<div class="tpl-forum-list-footer">
941										<div class="tpl-forum-control-wrap">
942											<button type="button" class="btn btn-default btn-list tpl-forum-list">${$.lang[f_lang]['board.button.list']}</button>
943											<div class="tpl-forum-modoo-prev-next tpl-forum-pn-row">
944											`;
945											if (typeof data.prev != 'undefined' && Object.keys(data.next).length > 0) {
946											modoo_str += `
947												<a href="${data.next.url}" data-option="${data.next.option}" data-id="${data.next.seq}">
948													<button type="button" class="btn btn-default">이전글</button>
949												</a>
950											`;
951											}
952											if (typeof data.prev != 'undefined' && Object.keys(data.prev).length > 0) {
953											modoo_str += `
954												<a href="${data.prev.url}" data-option="${data.prev.option}" data-id="${data.prev.seq}">
955													<button type="button" class="btn btn-default">다음글</button>
956												</a>
957											`;
958											}
959					modoo_str += `			</div>
960										</div>`;
961					modoo_str += `		<div class="tpl-forum-modoo-reply">
962												${replyPostbutton(data)}
963										</div>
964									</div><!--.tpl-forum-list-footer-->
965				`;
966
967				var str = '\
968				<div class="forum-view ' + wrap + '" ' + f_type + ' data-parallax="'+f_parallax+'">\
969					<input type="hidden" id="fm-id" value="' + data.id + '">\
970					<input type="hidden" id="fm-pid" value="' + data.pid + '">\
971					<input type="hidden" id="forum-email" value="' + forum_email + '">\
972					<div class="container">\
973						<div class="forum-write ' + wrap + '">\
974							<div class="row">\
975								<div class="col-md-12 col-sm-12 col-xs-12">\
976									<ul class="forum-user-info clearfix">\
977										<li class="user-image tpl-forum-myimage forum-image">\
978											<img src="' + data.myimg + '?_' + new Date().getTime() + '" />\
979										</li>\
980										<li class="user-info">\
981											<div class="tpl-forum-name">' + data.name + '</div>\
982											<div class="tpl-forum-date date">' + format_time + '</div>\
983											<div class="tpl-forum-hit hit">\
984												<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>\
985												' + data.hit + '\
986											</div>\
987										</li>\
988										<li class="user-ctrl">\
989											' + ((del_display == 'OFF')? '' : postDropMenu(data)) + '\
990										</li>\
991									</ul>\
992									' + category + '\
993									<div class="tpl-forum-title">' + data.title + '</div>\
994									<div class="tpl-forum-content fm-body fm-content fm-editor fr-box ' + align + '">\
995										<div class="fr-wrapper" dir="auto">\
996											<div class="fr-element fr-view" dir="auto" style="' + inline_style + '">' + forum_content + '</div>\
997										</div>\
998									</div>\
999									<div class="tpl-forum-list-footer">\
1000										<div class="tpl-forum-control-wrap">';
1001									if(data.fm_type == 'qna') {
1002										if(data.answer !== undefined && data.replied == true) {
1003											str += '\
1004											<button type="button" class="btn tpl-forum-list">&nbsp;' + $.lang[LANG]['board.button.list'] + '</button>';
1005										} else {
1006											str += '\
1007											<button type="button" class="btn tpl-forum-list">&nbsp;' + $.lang[LANG]['board.button.list'] + '</button>\
1008											' + replyPostbutton(data);
1009										}	
1010									} else {
1011										str += '\
1012											<button type="button" class="btn tpl-forum-list">&nbsp;' + $.lang[f_lang]['board.button.list'] + '</button>\
1013											' + replyPostbutton(data);
1014									}
1015									str += '\
1016										</div>\
1017									</div><!--.tpl-forum-list-footer-->\
1018									';
1019
1020								if(p_settings.forum_type == 'modoo') str = modoo_str;
1021
1022								if (p_settings.prevnext_display !== undefined && p_settings.prevnext_display == 'ON' && !['qna', 'faq', 'guestbook'].includes(data.fm_type)) {
1023									var hidden = (Object.keys(data.prev).length == 0 && Object.keys(data.next).length == 0) ? ' hidden' : '';
1024									var icon = '';
1025									var title_href = '';
1026									str += `
1027									<div class="tpl-forum-list-prev-next${hidden}">
1028									`;
1029
1030									if (Object.keys(data.next).length > 0) {
1031										if (data.next.option == 'N') icon = '<i class="cl-icon notice01" aria-hidden="true"></i>';
1032										if (data.next.option == 'S') icon = '<i class="cl-icon lock02" aria-hidden="true"></i>';
1033										if (data.next.title == '') {
1034										    title_href = `<a href="javascript:;" class="deleted" data-option="${data.next.option}" data-id="${data.next.seq}">${$.lang[LANG]['board.post.deleted']}</a>`;
1035										} else {
1036										    title_href = `<a href="${data.next.url}" data-option="${data.next.option}" data-id="${data.next.seq}">${data.next.title}</a>`;
1037										}
1038										str += `
1039									    <div class="tpl-forum-pn-row forum-next display-flex space-between align-items-center">
1040									    	<div class="tpl-forum-pn-num">${$.lang[LANG]['board.next']}</div>
1041									    	<div class="tpl-forum-pn-title">${icon}${title_href}</div>
1042									    	<div class="tpl-forum-pn-date">${data.next.date}</div>
1043									    </div>
1044										`;
1045									}
1046
1047									icon = '';
1048									if (Object.keys(data.prev).length > 0) {
1049										if (data.prev.option == 'N') icon = '<i class="cl-icon notice01" aria-hidden="true"></i>';
1050										if (data.prev.option == 'S') icon = '<i class="cl-icon lock02" aria-hidden="true"></i>';
1051										if (data.prev.title == '') {
1052										    title_href = `<a href="javascript:;" class="deleted" data-option="${data.prev.option}" data-id="${data.prev.seq}">${$.lang[LANG]['board.post.deleted']}</a>`;
1053										} else {
1054										    title_href = `<a href="${data.prev.url}" data-option="${data.prev.option}" data-id="${data.prev.seq}">${data.prev.title}</a>`;
1055										}
1056										str += `
1057									    <div class="tpl-forum-pn-row forum-prev display-flex space-between align-items-center">
1058									    	<div class="tpl-forum-pn-num">${$.lang[LANG]['board.prev']}</div>
1059									    	<div class="tpl-forum-pn-title">${icon}${title_href}</div>
1060									    	<div class="tpl-forum-pn-date">${data.prev.date}</div>
1061									    </div>
1062										`;
1063									}
1064
1065									str += `
1066									</div><!--tpl-forum-list-prev-next-->
1067									`;
1068								}
1069								str += '\
1070								</div>\
1071							</div>\
1072						</div>\
1073					</div><!--container-->\
1074				';
1075				if(data.mgr && data.fm_type != 'faq') {
1076					str += '\
1077					<div class="tpl-forum-comment_display container clear ' + wrap + ((comment_display == 'ON')? ' off':' on') + '" data-id="' + data.id + '" data-pid="' + data.pid + '">\
1078						<div class="display-flex align-items-center">\
1079							<div class="newcheckbox hand ">\
1080			                    <label>\
1081			                        <div class="newcheckboxSvg">\
1082			                            <input type="checkbox" class="comment-onoff" '+((comment_display == 'ON')? '':'checked')+'/>\
1083			                            <svg viewBox="0 0 16 16" width="16" height="16">\
1084			                                <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"/>\
1085			                                <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"/>\
1086			                            </svg>\
1087			                            <svg class="active" viewBox="0 0 16 16" width="16" height="16">\
1088			                                <rect x="2" y="2" class="st6" width="12" height="12"/>\
1089			                                <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"/>\
1090			                            </svg>\
1091			                        </div>\
1092			                        <span class="tpl-forum-comment_display-label">'+ $.lang[LANG]['config.comment.title'] +'</span>\
1093			                    </label>\
1094			                </div>\
1095						</div>\
1096					</div>\
1097					';
1098				}
1099				str += '\
1100				</div>\
1101				';
1102
1103				if($.clnav.check()) {
1104					$('.dsgn-body').prepend(str);
1105				} else {
1106					$('.header.el-menu').last().after(str);
1107				}
1108				placeTabmenuBeforeForumView();
1109				changeBrokenImages($('.fr-view'));
1110
1111				if(($('.fr-view').find('img[name^="target_resize_image[]"]').length > 0)) {
1112					$.each($('.fr-view').find('p'),function(){
1113						$(this).find('img[name^="target_resize_image[]"]').removeAttr('width')
1114																		.removeAttr('height');
1115					});
1116				}
1117
1118				// 주소 변경 복원
1119				$.each($('.fr-view').find('iframe'), function(idx,value) {
1120					var src = $(this).attr('src');
1121					if(src.indexOf('http://') > -1 && src.indexOf('youtube.com') > -1) {
1122						src = src.replace('http://','//');
1123						$(this).attr('src',src);
1124					}
1125				});
1126
1127				if(p_settings.field_disable) {
1128					$.each(p_settings.field_disable, function(i,v) {
1129						var tmp_v = (v == 'myimg') ? 'myimage' : v;
1130						$('.forum-write .row > div .tpl-forum-'+tmp_v).addClass('hidden');
1131					});
1132				}
1133
1134				// if($('.user-info > div.hidden').length > 0) $('.user-info > div').removeClass('mt-8').addClass('mt-8');
1135				if($('.tpl-forum-date').next('div').hasClass('hidden')) $('.tpl-forum-date').addClass('afterHide');
1136
1137				initViewPageToolbar(data.option, p_settings, data).then(function(){
1138					if(PAGE_MODE == 'c') setViewPageToolbar();
1139				});
1140				
1141				$.cookie('prev-forum-view',F_PAGE, { path: '/' });
1142				fv_deferred.resolve(data);
1143				// $.removeCookie('hash', { path: '/' });
1144			}
1145		},'json');
1146
1147		return fv_deferred.promise();
1148	}
1149
1150	var replyPostbutton = function(data) {
1151		if(data.is_reserved == 'Y') return '';
1152		var str = '\
1153					<button type="button" class="btn tpl-forum-write" data-pid="' + data.pid + '" data-reply="' + data.id + '">\
1154						&nbsp;' + $.lang[data.f_lang]['board.button.reply'] + '\
1155					</button>\
1156		';
1157
1158		var reply_hidden_case = ['faq'],
1159			reply_hidden =  (reply_hidden_case.indexOf(data.fm_type) > -1) ? true : false;
1160
1161		return (data.reply && data.option != 'N' && !reply_hidden) ? str : '';
1162	}
1163
1164	var postDropMenu = function(data) {
1165		var drop = false;
1166		var str_li = '';
1167		
1168		if((data.own || (data.sign == false && data.fmid == false)) && data.writeable == true || data.mgr_edit) {
1169			drop = true;
1170			str_li += '\
1171				<li><a href="#" class="tpl-forum-write" data-id="' + data.id + '" data-pid="' + data.pid + '">' + $.lang[data.f_lang]['board.button.modify'] + '</a></li>\
1172			';
1173		}
1174		// console.log('data', data);
1175		if(data.own || (data.sign == false && data.fmid == false) || data.mgr) {
1176			drop = true;
1177			str_li += '\
1178				<li><a href="#" class="tpl-forum-delete" data-id="' + data.id + '" data-pid="' + data.pid + '">' + $.lang[data.f_lang]['board.button.delete'] + '</a></li>\
1179			';
1180		}
1181
1182		var str = '\
1183		<ul class="tpl-forum-edit-menu">\
1184			' + str_li + '\
1185		</ul>\
1186		';
1187		return str;
1188	}
1189
1190
1191	var signForm = function(id,pid,access,token) {
1192		var mode = (access=='NM') ? 'nonmem' : 'default',
1193			F_VALIDPLAN = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN,
1194			F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE,
1195			F_SITEUM = (typeof SITEUM == 'undefined') ? property.SITEUM : SITEUM,
1196			F_SERVICE = (typeof SERVICE == 'undefined') ? property.SERVICE : SERVICE,
1197			isGabia = (F_SERVICE.indexOf('gabia') > -1) ? true : false,
1198			host_url = (isGabia) ? 'http://creatorlink-gabia.com' : 'http://creatorlink.net',
1199			classSet = {
1200				'default': ['default-mode','active', '', '', '', ''],
1201				'sitemember': ['sitemember-mode', '', 'active', '', '', 'hidden'],
1202				'nonmem' : ['nonmember-mode', '', '', 'active', '.nonmem', 'hidden'],
1203			},
1204			joinUrl = (LANG != 'ko') ? '//creatorlink.net/en/member/join' : '//creatorlink.net/member/join' ;
1205
1206		var signForm_str_nonmember = '',
1207			signForm_str_defult  = '';
1208
1209		if(F_VALIDTYPE != 'SM' && (F_VALIDTYPE != 'BN' && F_SITEUM > -1)) F_SITEUM = -1;
1210
1211		if((F_VALIDTYPE == 'SM' || (F_VALIDTYPE == 'BN' && F_SITEUM > 0)) && access != 'NM') {
1212			mode = 'sitemember';
1213		}
1214
1215
1216		if(isGabia) {
1217			if(access == 'ADM') {
1218				mode = 'sitemember';
1219			} else if(access == 'NM') {
1220				//
1221			} else {
1222				if((F_VALIDTYPE != 'BN' && F_VALIDTYPE != 'SM') || (F_VALIDTYPE == 'BN' && F_SITEUM < 1)) {
1223					mode = 'nonmem';
1224					access = 'NM';
1225				}
1226			}
1227		}
1228
1229		if (access=='NM') {
1230			signForm_str_nonmember = '' + 
1231			'<ul class="comment-signForm nav ' + classSet[mode][0] + '" role="tablist">';
1232
1233				if(isGabia || (!isGabia && F_SITEUM > 0)) {
1234					signForm_str_nonmember += '' + 
1235					'<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>';
1236					
1237				} else {
1238					signForm_str_nonmember += '' +
1239					'<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>';
1240				}
1241				signForm_str_nonmember += '' + 
1242				'<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>' +
1243			'</ul>';
1244		} else {
1245			signForm_str_defult = '' + 
1246				'<ul class="comment-signForm nav ' + classSet[mode][0] + '" role="tablist">';
1247			if(mode == 'sitemember') {
1248				signForm_str_defult += '' + 
1249				'<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>';
1250			} else {
1251				var tab_str = (isGabia) ? $.lang[LANG]['siteum.login.member'] : $.lang[LANG]['config.creatorlink'];
1252				if((F_VALIDTYPE == 'BN' || F_VALIDTYPE == 'SM') && access == 'ADM' ) {
1253					tab_str = '<br>' + $.lang[LANG]['config.creatorlink.text-adm2'];
1254					classSet[mode][5] = 'hidden';
1255				}
1256				signForm_str_defult += '' + 
1257					'<li class="signType ' + classSet[mode][1] + '" role="presentation"><a href="#creatorlink" aria-controls="creatorlink" role="tab" data-toggle="tab">' + tab_str + '</a></li>';
1258			}
1259			if(access=='A') {
1260				var icon_str = (mode == 'sitemember') ? '' : '<img src="//storage.googleapis.com/i.addblock.net/icon/icon-sign-anonymous.png"><br><br>';
1261				signForm_str_defult += '' + 
1262				'<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>';
1263			}
1264			signForm_str_defult += '' + 
1265			'</ul>';
1266		}
1267
1268
1269
1270
1271		var str = signForm_str_defult +  signForm_str_nonmember +
1272			'<div class="tab-content">' +
1273				'<div role="tabpanel" class="tab-pane ' + classSet[mode][1] + '" id="creatorlink">' +
1274			        '<div class="form-inline comment-addform input-text">' +
1275			        	'<div class="cl-s-form-wrap">' +
1276							'<div class="cl-s-form-group">' +
1277								'<input type="text" class="cl-s-form-control" id="mb_forum_id" name="mb_id" required="required" value="">' +
1278								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.emailaddress'] + '</label>' +
1279							'</div>' +
1280						'</div>' +
1281			        	'<div class="cl-s-form-wrap mt-10">' +
1282							'<div class="cl-s-form-group">' +
1283								'<input type="password" class="cl-s-form-control" id="mb_forum_password" name="mb_password" required="required" value="">' +
1284								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.password'] + '</label>' +
1285							'</div>' +
1286						'</div>' +
1287			        '</div>' +
1288			        '<div class="bottom-box text-right ' + LANG + ' ' + classSet[mode][5] + '">' +
1289						'<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>' +
1290					'</div>' +
1291			        '<div class="btn-wrap comment-addform mt-30">' +
1292			        	'<a href="#" class="btn btn-primary btn-lg btn-block forum-login" data-id="' + id + '" data-pid="' + pid + '">' +  $.lang[LANG]['config.modal.login'] + '</a>' +
1293			        	'<button type="button" class="btn-modal-cancel" data-dismiss="modal">' +  $.lang[LANG]['config.cancel'] + '</button>' +
1294			        '</div>' +
1295				'</div>' +
1296				'<div role="tabpanel" class="tab-pane ' + classSet[mode][2] + '" id="sitemember">' +
1297			        '<div class="form-inline comment-addform input-text">' +
1298			        	'<div class="cl-s-form-wrap">' +
1299							'<div class="cl-s-form-group">' +
1300								'<input type="text" class="cl-s-form-control" id="um_forum_id" name="um_id" required="required" value="">' +
1301								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['siteum.login.id'] + '</label>' +
1302							'</div>' +
1303						'</div>' +
1304			        	'<div class="cl-s-form-wrap mt-10">' +
1305							'<div class="cl-s-form-group">' +
1306								'<input type="password" class="cl-s-form-control" id="um_forum_password" name="um_password" required="required" value="">' +
1307								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['siteum.login.password'] + '</label>' +
1308							'</div>' +
1309						'</div>' +
1310			        '</div>' +
1311			        '<div class="bottom-box text-right ' + LANG + ' ' + classSet[mode][5] + '">' +
1312						'<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>' +
1313					'</div>' +
1314			        '<div class="btn-wrap comment-addform mt-30">' +
1315			        	'<a href="#" class="btn btn-primary btn-lg btn-block forum-login" data-id="' + id + '" data-pid="' + pid + '">' +  $.lang[LANG]['config.modal.login'] + '</a>' +
1316			        	'<button type="button" class="btn-modal-cancel" data-dismiss="modal">' +  $.lang[LANG]['config.cancel'] + '</button>' +
1317			        '</div>' +
1318					'<br>' +
1319				'</div>' +
1320				'<div role="tabpanel" class="tab-pane ' + classSet[mode][3] + '" id="anonymous">' +
1321					'<div class="form-inline comment-addform input-text">' +
1322			        	'<div class="cl-s-form-wrap">' +
1323							'<div class="cl-s-form-group">' +
1324								'<input type="text" class="cl-s-form-control" id="comm-name" required="required" value="">' +
1325								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.name'+classSet[mode][4]] + '</label>' +
1326							'</div>' +
1327						'</div>' +
1328			        	'<div class="cl-s-form-wrap mt-10">' +
1329							'<div class="cl-s-form-group">' +
1330								'<input type="password" class="cl-s-form-control" id="comm-pass" required="required" value="">' +
1331								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.password'+classSet[mode][4]] + '</label>' +
1332							'</div>' +
1333						'</div>' +
1334					'</div>' +
1335					'<div class="kcaptcha-box comment-addform input-text mt-30">' +
1336						'<div class="col-xs-12 col-sm-5 col-md-5 no-padding text-left kcaptcha-img">' +
1337							'<p id="write_option">' +
1338								'<img src="" id="kcaptcha" alt="' +  $.lang[LANG]['config.captcha-alt'] + '"/>' +
1339							'</p>' +
1340						'</div>' +
1341						'<div class="col-xs-12 col-sm-7 col-md-7 no-padding text-left kcaptcha-text">' +
1342							'<input type="text" id="wr_key" name="wr_key" class="col-sm-12 form-control" placeholder="' +  $.lang[LANG]['config.enter-captcha'] + '"/>' +
1343							'<a class="kcaptcha-change hand"><svg viewBox="0 0 24 24" width="24" height="24">
1343<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>' +
1344						'</div>' +
1345					'</div>' +
1346				'</div>' +
1347			'</div>';
1348
1349
1350		return str;
1351	}
1352	var forumWrite = function(id,pid,reply) {
1353		reply = (typeof reply == 'undefined') ? '' : reply;
1354	}
1355
1356
1357	$(document).on('click','.tb-attach-file',function(e) {
1358		// $('#forum-attach').modal('show');
1359      	isReplace = false;
1360		upTYPE = 'image';
1361		$('#file_type').val(upTYPE);
1362	    $('#file_multiple').val(false);
1363		$('#uploadFile').val('').removeAttr('multiple').attr('accept','image/gif,image/jpg,image/jpeg,image/png,image/ico');
1364		$('#uploadFile').trigger('click');
1365		// $('.modal-backdrop').last().removeClass('fade');
1366	});
1367	$(document).on('click','.tb-file-insert', function(e) {
1368		// $('#forum-attach').modal('show');
1369		upTYPE = 'file';
1370		$('#file_type').val(upTYPE);
1371	    $('#file_multiple').val(false);
1372		$('#uploadFile').val('').removeAttr('multiple').removeAttr('accept');
1373		$('#uploadFile').trigger('click');
1374		// $('.modal-backdrop').last().removeClass('fade');
1375	});
1376	$(document).on('click','.tb-video-insert', function(e) {
1377		$('#fm-editor').froalaEditor('selection.save');
1378		var modal = $(this).showModalFlat('INSERT VIDEO',videoForm(),true,true,function() {
1379			$('.error').remove();
1380			var url = $('#video-url').val();
1381			if(!url) {
1382				$('#video-url').after('<label class="error">' +  $.lang[LANG]['config.link-to-go'] + '</label>').focus();
1383				return;
1384			}
1385			var video = insertVideo(url,'src'),
1386				frVideo = '<span class="fr-video fr-dvb fr-draggable" contenteditable="false" draggable="true">' +
1387						'<iframe width="720" height="405" src="' + video + '" frameborder="0" allowfullscreen="true"></iframe>' +
1388						'</span>';
1389
1390			$('#fm-editor').froalaEditor('selection.restore');
1391			$('#fm-editor').froalaEditor('html.insert', frVideo , true);
1392			modal.modal('hide');
1393
1394		},'cancel','','w480 video-modal');
1395		$('.flat-modal').css({
1396			'position' : 'absolute',
1397			'z-index' : '1051'
1398		});
1399		$('.flat-modal').next().css('z-index','1050');
1400	});
1401
1402	$doc.on('click','#insert-forum-attach', function(e) {
1403		var file = $('#uploadFile').val();
1404		if(file=='') {
1405			alert('파일을 입력/선택하세요');
1406			$.processOFF();
1407			return false;
1408		}
1409		$('#forum-attach').modal('hide');
1410	});
1411	
1412	$doc.on('click','#fm-secret', 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-secret','S');
1417
1418			$('#fm-notice').find('.fa').removeClass('fa-check-square-o').addClass('fa-square-o');
1419			$('#fm-notice').attr('data-notice','');
1420		} else {
1421			$target.removeClass('fa-check-square-o').addClass('fa-square-o');
1422			$(this).attr('data-secret','');
1423		}
1424	});
1425
1426	$doc.on('click','#fm-notice', function(e) {
1427		$target = $(this).find('.fa');
1428		if($target.hasClass('fa-square-o')) {
1429			$target.removeClass('fa-square-o').addClass('fa-check-square-o');
1430			$(this).attr('data-notice','N');
1431
1432			$('#fm-secret').find('.fa').removeClass('fa-check-square-o').addClass('fa-square-o');
1433			$('#fm-secret').attr('data-secret','');
1434		} else {
1435			$target.removeClass('fa-check-square-o').addClass('fa-square-o');
1436			$(this).attr('data-notice','');
1437		}
1438	});
1439
1440	$doc.on('click',`
1441		.tpl-forum-list-arrow, .tpl-forum-list-toggle,
1442		[data-ver="1"][data-type2="faq"] .tpl-forum-list-icon
1443	`, function(e) {
1444		$(this).closest('tr').find('.tpl-forum-list-title').click();
1445	});
1446
1447	$doc.on('click','*[class*=tpl-forum-list-] a.deleted', function(e) {
1448		e.preventDefault();
1449		$(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');
1450		return false;
1451	});
1452
1453	$doc.on('click','.tpl-toolbar-question-del, .tpl-toolbar-answer-del', function(e) {
1454		e.preventDefault();
1455		var option = $(this).attr('data-option'),
1456			id = $(this).attr('data-id'),
1457			target_type = $(this).closest('.tpl-qna-toolbar').attr('data-list-option');
1458
1459		var question_del_modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
1460				question_del_modal.modal('hide');
1461				$.forum.delete(id);
1462				if(target_type == 'a') {
1463					location.reload();
1464				}
1465			}, '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');
1466		// if(target_type == 'q') {
1467		// 	var question_del_modal = $(this).showModalFlat('POST DELETE', $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
1468		// 		question_del_modal.modal('hide');
1469		// 		$.forum.delete(id);
1470		// 	}, 'cancel');
1471		// }
1472		// else if(target_type == 'a') {
1473		// 	$.comment.delete(id);
1474		// }
1475	});
1476
1477	$doc.on('click', '.tpl-forum-pn-row a', function(e){
1478		e.preventDefault();
1479		if ($(this).hasClass('deleted')) {
1480		    return false;
1481		}
1482
1483		var fmViewUrl = $(this).attr('href');
1484		var option = $(this).attr('data-option');
1485		var id = $(this).attr('data-id');
1486
1487		var url = forumUrl();
1488		var href = url + fmViewUrl;
1489		
1490		if (option == 'S') {
1491		    $.ajax({
1492		        url: '/fm/access',
1493		        type: 'POST',
1494		        data: {id: id, sid: F_SID},
1495		        dataType: 'json',
1496		        success: function(data) {
1497		            if (data.access == false) {
1498		                if ((data.sign == false && data.fmid == true) || (data.sign == true && data.fmid == true) || (data.sign == true && data.fmid == false)) {
1499		                    $(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');
1500		                } else {
1501		                	$(this).showModalFlat($.lang[LANG]['board.secret-password'],passwdForm(),true,true,function() {
1502								var $pass = $('#comm-pass'),
1503									isSubmit = true,
1504									userInput = $pass.val();
1505								$('label.error').remove();
1506								if($pass.val().length<4) {
1507									$pass.closest('.cl-s-form-wrap').addClass('error');
1508									$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>');
1509									$pass.focus();
1510									isSubmit = false;
1511								}
1512
1513								if(isSubmit) {
1514									$('.comment-addform.password').removeClass('error');
1515									$.ajax({
1516									    type: 'POST',
1517									    url: '/fm/password',
1518									    data: {
1519									        id: id,
1520									        passwd: hex_md5($pass.val())
1521									    },
1522									    dataType: 'json',
1523									    success: function(data) {
1524									        if(typeof data.error != 'undefined' && data.error) {
1525									            $pass.closest('.cl-s-form-wrap').addClass('error');
1526									            $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>');
1527									            return false;
1528									        }
1529
1530									        var date = new Date(),
1531											cookietime = 20 * 60 * 1000;
1532								            date.setTime(date.getTime() + cookietime);
1533								            
1534											$.removeCookie('checkPostHighWriter',{path:'/'});
1535								            $.cookie('checkPostWriter', id, { path: '/' , expires: date});
1536											$.cookie('hash', data.hash, { path: '/' , expires: date});
1537											$('.modal[id*=flat-modal]').modal('hide');
1538											
1539									        if(typeof MODE == 'undefined') {
1540								                RENDER.history.pushState(null, property.TITLE, href);
1541								            } else {
1542								                location.href = href;
1543								            }
1544									    },
1545									    error: function(xhr, textStatus, errorThrown) {
1546									        console.log('Error: ' + errorThrown);
1547									    }
1548									});
1549
1550								}
1551								modalEmptyCheck();
1552							},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', false, '', function() {
1553								$('.board-password .board-secret-info').remove();
1554								$('.comment-addform.password').before('<div class="board-secret-info">' + $.lang[LANG]['board.writer.password.title'] + '</div>');
1555            				});
1556		                }
1557		            } else {
1558		                if (typeof MODE == 'undefined') {
1559		                    RENDER.history.pushState(null, property.TITLE, href);
1560		                } else {
1561		                    location.href = href;
1562		                }
1563		            }
1564		            return false;
1565		        }
1566		    });
1567		} else {
1568		    if (typeof MODE == 'undefined') {
1569		        RENDER.history.pushState(null, property.TITLE, href);
1570		    } else {
1571		        location.href = href;
1572		    }
1573		}
1574		
1575		return false;
1576	});
1577	
1578	$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');
1579	$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) {
1580
1581		var click_this = $(this),
1582			click_tr = ($(this).closest('tr').length > 0) ? $(this).closest('tr') : $(this).closest('.item'),
1583			option = $(this).attr('data-option'),
1584			id = $(this).attr('data-id'),
1585			forum_el = $(this).closest('.element'),
1586			type = $(forum_el).attr('data-forum-type'),
1587			pid = $(forum_el).attr('data-id'),
1588			page_num = $(forum_el).find('.tpl-forum-page.active').attr('data-page-num'),
1589			stx = getForumPrevStx(pid),
1590			sfl = ($(forum_el).find('#sfl').length > 0) ? $(forum_el).find('#sfl').val() : '',
1591			scate = ($(forum_el).find('#scate').length > 0) ? $(forum_el).find('#scate').val() : '';
1592		
1593		var checkOldVerForum = (forum_el.is('[data-ver="1"]')) ? true : false;
1594
1595		if($.inArray(type, ['faq','guestbook']) > -1
1596			|| click_this.find('.tpl-forum-list-title').length > 0
1597			|| (type=='qna' && !click_this.is('.tpl-forum-list-title'))
1598			|| ($(e.target).hasClass('tpl-forum-list-title') && $(e.target).find('a.deleted').length)
1599		) {
1600			if($.inArray(type, ['faq', 'qna']) > -1 && click_this.is('.tpl-forum-list-cont:has(a[rel])')) return true;
1601			else return false;
1602		}
1603
1604		if($(e.target).hasClass('tpl-forum-list-reply-name') ){
1605			var del_chk = $(e.target).next();
1606			if(del_chk.is('a.deleted')) {
1607				$(e.target).next().click();
1608				return false;
1609			}
1610		}
1611
1612		e.preventDefault();
1613
1614		if($(forum_el).find('input[name="user_stx"]').length > 0 && $(forum_el).find('input[name="user_sfl"]').length > 0) {
1615			stx = $(forum_el).find('input[name="user_stx"]').val();
1616			sfl = $(forum_el).find('input[name="user_sfl"]').val();
1617		}
1618		
1619		if($(this).closest('#element-display').length > 0) return false;
1620		if($(this).closest('[data-loop="true"]').hasClass('sample-loop')) return false;
1621		if($(this).closest('tr.active').length > 0 && $(this).closest('.element.page-bottomlist').length > 0) return false;
1622		
1623		F_SID = (typeof SID == 'undefined') ? property.SID : SID;
1624
1625		var checkQnAForum = (type=='qna' && !$(this).hasClass('tpl-qna-toolbar-button')) ? true : false,
1626			click_el = $(this).closest('.item');
1627
1628		if(checkOldVerForum) click_el = (checkQnAForum) ? $(this).closest('.qna-item') : $(this);
1629
1630		if(option=='S') {
1631			e.preventDefault();
1632			var checkhigh_onoff = (typeof click_tr.attr('data-checkhigh') != 'undefined' && click_tr.attr('data-checkhigh')) ? true : false,
1633				checkhigh_mode = (checkhigh_onoff) ? click_tr.attr('data-checkhigh') : '';
1634
1635			$.post('/fm/access',{id:id, sid : F_SID}, function(data) {
1636				if(data.access == false) {
1637					if(((data.sign == false && data.fmid == true) || (data.sign == true && data.fmid == true) || (data.sign == true && data.fmid == false)) && !checkhigh_onoff) {
1638						
1639						if(data.sign == false && data.checkhigh != '') {
1640							var checkhigh_v = (data.checkhigh == 'onlyparent') ? 'parent' : data.checkhigh,
1641								checkhigh_str = '<span class="btn-fm-change-checkhigh" data-checkhigh="'+checkhigh_v+'">' + $.lang[LANG]['board.goto-checkhigh.'+checkhigh_v] + '</span>';
1642							if(data.checkhigh == 'parent') checkhigh_str += '<span class="btn-fm-change-checkhigh" data-checkhigh="reply">' + $.lang[LANG]['board.goto-checkhigh.reply'] + '</span>';
1643
1644							var fmAcc_str = $.lang[LANG]['board.read-not-allowed'] + '<div class="clearfix"></div><div class="wrap-fm-change-checkhigh">' + checkhigh_str + '</div>';
1645							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() {
1646								fmAccModal.find('.btn-fm-change-checkhigh').on('click', function() {
1647									var tmp_v = $(this).attr('data-checkhigh');
1648									click_tr.attr('data-checkhigh',tmp_v);
1649									click_this.click();
1650									fmAccModal.modal('hide');
1651								});
1652							});
1653						} else {
1654							$(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');
1655						}
1656
1657					} else {
1658						var fmAccModal_title = $.lang[LANG]['board.secret-password'];
1659						if(checkhigh_onoff) {
1660							click_tr.removeAttr('data-checkhigh');
1661							fmAccModal_title = $.lang[LANG]['board.goto-checkhigh.'+checkhigh_mode+'.title'];
1662						}
1663						var fmAccModal2 = $(this).showModalFlat(fmAccModal_title,passwdForm(checkhigh_mode),true,true,function() {
1664							var $pass = $('#comm-pass'),
1665								isSubmit = true,
1666								userInput = $pass.val();
1667							$('label.error').remove();
1668							if($pass.val().length<4) {
1669								//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
1670								$pass.closest('.cl-s-form-wrap').addClass('error');
1671								$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">
1671<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>');
1672								$pass.focus();
1673								isSubmit = false;
1674							}
1675
1676							if(isSubmit) {
1677								//$('.comment-addform.password').parent().find('.error').remove();
1678								$('.comment-addform.password').removeClass('error');
1679								$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()), checkhigh: $pass.attr('data-checkhigh')  }, function(pwdata) {
1680									if(typeof pwdata.error != 'undefined' && pwdata.error) {
1681										//$('.comment-addform.password').before('<label class="error">' + pwdata.error + '</label>');
1682										$pass.closest('.cl-s-form-wrap').addClass('error');
1683										$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>');
1684										return false;
1685									}
1686									var date = new Date(),
1687										cookietime = 20 * 60 * 1000;
1688									date.setTime(date.getTime() + cookietime);
1689									
1690									$.removeCookie('checkPostHighWriter',{path:'/'});
1691									$.cookie('checkPostWriter', id, { path: '/' , expires: date});
1692									$.cookie('hash', pwdata.hash, { path: '/' , expires: date});
1693
1694									var tmp_v = $pass.attr('data-checkhigh');
1695									if($pass.is('[data-checkhigh]') && typeof tmp_v != 'undefined' && tmp_v) {
1696										$.cookie('checkPostHighWriter'+id, tmp_v+','+pwdata.checkhigh_val, { path: '/' , expires: date});
1697									} else {
1698										$.removeCookie('checkPostHighWriter',{path:'/'});
1699									}
1700									$('.modal[id*=flat-modal]').modal('hide');
1701
1702									$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
1703									if(checkQnAForum) showQnAForumAnswer(F_SID,id,option,$(click_el),checkOldVerForum);
1704									else {
1705										var url = forumUrl(),
1706											href = url + '/forum/view/' + id;
1707
1708										if(typeof MODE == 'undefined') RENDER.history.pushState(null,property.TITLE,href);											
1709										else location.href = href;
1710									}
1711								},'json');
1712							}
1713							modalEmptyCheck();
1714						},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', false, '', function() {
1715							$('.board-password .board-secret-info').remove();
1716							$('.comment-addform.password').before('<div class="board-secret-info">' + $.lang[LANG]['board.writer.password.title'] + '</div>');
1717
1718							if(!checkhigh_onoff) {
1719								if(data.checkhigh != '') {
1720									var checkhigh_v = (data.checkhigh == 'onlyparent') ? 'parent' : data.checkhigh,
1721										checkhigh_str = '<span class="btn-fm-change-checkhigh" data-checkhigh="'+checkhigh_v+'">' + $.lang[LANG]['board.goto-checkhigh.'+checkhigh_v] + '</span>';
1722									if(data.checkhigh == 'parent') checkhigh_str += '<span class="btn-fm-change-checkhigh" data-checkhigh="reply">' + $.lang[LANG]['board.goto-checkhigh.reply'] + '</span>';
1723									
1724									$('.comment-addform.password').after('<div class="clearfix"></div><div class="wrap-fm-change-checkhigh">' + checkhigh_str + '</div>');
1725								}
1726							}
1727
1728							fmAccModal2.find('.btn-fm-change-checkhigh').on('click', function() {
1729								var tmp_v = $(this).attr('data-checkhigh');
1730								click_tr.attr('data-checkhigh',tmp_v);
1731								click_this.click();
1732								fmAccModal2.modal('hide');
1733							});
1734						});
1735					}
1736				} else {
1737					$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
1738
1739					var cookie_date = new Date();
1740					cookie_date.setTime(cookie_date.getTime() + (60*60*1000));
1741					$.cookie('checkPostWriter',id,{ expires: cookie_date, path:'/'});
1742					$.removeCookie('checkPostHighWriter',{path:'/'});
1743
1744					if(checkQnAForum) showQnAForumAnswer(F_SID,id,option,$(click_el),checkOldVerForum);
1745					else {
1746						var url = forumUrl();
1747						var href = url + '/forum/view/' + id;
1748						if(typeof MODE == 'undefined') RENDER.history.pushState(null,property.TITLE,href);
1749						else location.href = href;
1750					}
1751				}
1752			}, 'json');
1753		} else {
1754			$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
1755			if(checkQnAForum) showQnAForumAnswer(F_SID,id,option,$(click_el),checkOldVerForum);
1756			else {
1757				var url = forumUrl();
1758				var href = url + '/forum/view/' + id;
1759				if(typeof MODE == 'undefined') RENDER.history.pushState(null,property.TITLE,href);
1760				else location.href = href;
1761			}
1762		}
1763
1764	});
1765
1766	var showQnAForumAnswer = function(sid,id,option,qnaitem,isOldVer) {
1767
1768		var checkNotice = $(qnaitem).hasClass('n'),
1769			checkOpen = !$(qnaitem).hasClass('open'),
1770			state = $(qnaitem).find('.tpl-forum-list-state').hasClass('active');
1771
1772		if(isOldVer) {
1773			checkNotice = ($(qnaitem).find('.tpl-forum-list-title').hasClass('n')) ? true : false;
1774			checkOpen = ($(qnaitem).hasClass('qna-item') && $(qnaitem).next('.qna-details').css('display') == 'none') ? true : false;
1775			state = $(qnaitem).find('.tpl-forum-list-state[data-state="true"]').length > 0 ? true : false;
1776		}
1777
1778		if(checkOpen) {
1779
1780			$.ajax({
1781				url: '/fm/view',
1782				dataType: 'json',
1783				type: 'POST',
1784				data: { id : id, sid : sid },
1785				async: false,
1786				cache: false,
1787				success: function(data) {
1788					var umemberActivate = (PAGE_MODE == 'c')? Number(UMEMBER_ACTIVATE) : Number(property.UMEMBER_ACTIVATE);
1789					var umember = (PAGE_MODE == 'c')? UMEMBER : property.UMEMBER;
1790					var checkLogin = (PAGE_MODE == 'c')? true : umember.check_login;
1791					if(umemberActivate == 0 && umember.id_type == 'creatorlink') { //creatorlink login
1792						checkLogin = (umember.id !== undefined && umember.id)? true : false;
1793					}
1794
1795					if(typeof data.error != 'undefined' && data.error) {
1796						var url = (PAGE_MODE=='s') ? '/' : '/render/';
1797						if(checkLogin) {
1798							alert(data.error);
1799							(F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);		
1800						} else {
1801							var action = (property.VALIDTYPE == 'SM')  ? '/_login' : '/_cllogin';
1802							var url = forumUrl() + '/forum/view/'+ id;
1803							var html = '<form name="write_login_form" id="write-login" method="post" action="' + action + '" style="display:none;">\
1804											<input type="hidden" name="status" value="forum_view">\
1805											<input type="hidden" name="sid" value="'+property.SID+'">\
1806											<input type="hidden" name="page_mode" value="'+data.access+'">\
1807											<input type="hidden" name="url" value="'+url+'">\
1808										</form>';
1809							$('body').append(html);
1810							document.write_login_form.submit();
1811						}
1812						// alert(data.error);
1813						// location.reload();
1814						return false;
1815					}
1816				
1817					if(typeof data.fonts != 'undefined' && data.fonts && PAGE_MODE!='c') {
1818						$.each(data.fonts, function(i,v) {
1819							if(property.ELFONTS.indexOf(i) < 0) {
1820								property.ELFONTS.push(i);
1821								$('#loadfonts').append(v);
1822							}
1823						});
1824					}
1825
1826					if(typeof data.webfonts != 'undefined' && data.webfonts && PAGE_MODE!='c') {
1827						$.each(data.webfonts, function(i2,v2) {
1828							if(property.ELFONTS.indexOf(i2) < 0 && v2) {
1829								property.ELFONTS.push(i2);
1830								WebFont.load({ google : { families : [ v2 ], display:'swap' }});
1831							}
1832						})
1833					}
1834
1835					var checkState = data.replied ? true : false;
1836					var answer = {
1837						...data.answer || {},
1838						secret: (checkState && data.answer.fm_option == 'S') ? true : false,
1839						title: checkState ? decodeUnicode(data.answer.fm_title) : '',
1840						cont: checkState ? decodeUnicode(data.answer.fm_content) : '',
1841					};
1842
1843					if(data.own && !checkLogin && data.fmid) data.own = false;
1844
1845					var btns = {
1846						q: {
1847							del: (!checkState && (data.own || (data.sign == false && data.fmid == false) || data.mgr)) ? `
1848									<li class="tpl-qna-toolbar-button tpl-toolbar-question-del" data-id="${id}" data-option="${option}">
1849										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.delete']}</span></button>
1850									</li>
1851								` : '',
1852							edit: (!checkState && ((data.own || (data.sign == false && data.fmid == false)) && data.writeable == true || data.mgr_edit)) ? `
1853									<li class="tpl-qna-toolbar-button tpl-toolbar-question-edit" data-id="${id}" data-option="${option}" data-pid="${data.pid}">
1854										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.modify']}</span></button>
1855									</li>
1856								` : '',
1857							answer: (!checkState && data.mgr && option!= 'N') ? `
1858									<li class="tpl-qna-toolbar-button tpl-toolbar-question-edit" data-id="${id}" data-option="${option}" data-reply="${id}" data-pid="${data.pid}">
1859										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['forum.qna.answer.write.btn']}</span></button>
1860									</li>
1861								` : '',
1862						},
1863						a: {
1864							del: (checkState && (answer.own || data.mgr)) ? `
1865									<li class="tpl-qna-toolbar-button tpl-toolbar-answer-del" data-id="${answer.seq}" data-option="${option}" >
1866										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.delete']}</span></button>
1867									</li>
1868								` : '',
1869							edit: (checkState && answer.own) ? `
1870									<li class="tpl-qna-toolbar-button tpl-toolbar-question-edit" data-id="${answer.seq}" data-option="${option}" data-pid="${data.pid}">
1871										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.modify']}</span></button>
1872									</li>
1873								` : '',
1874						}
1875					};
1876					var question_toolbar = `
1877							<ul class="tpl-qna-toolbar clearfix" data-list-option="q">
1878								${btns.q.answer} ${btns.q.edit} ${btns.q.del}
1879							</ul>
1880						`,
1881						answer_toolbar = `
1882							<ul class="tpl-qna-toolbar clearfix" data-list-option="a">
1883								${btns.a.edit} ${btns.a.del}
1884							</ul>
1885					`;
1886
1887
1888					if(answer.secret) {
1889						var icon_secret = '<i class="tpl-forum-list-secret-icon cl-icon lock02" aria-hidden="true"></i>&nbsp;';
1890						answer.title = icon_secret + ((btns.a.del != '' || checkState) ? answer.title : $.lang[LANG]['forum.qna.content.secret']);
1891						answer.cont = (btns.a.del != '' || checkState) ? answer.cont : '';
1892					}
1893
1894					if($(question_toolbar).html().trim() == '') question_toolbar = '';
1895					if($(answer_toolbar).html().trim() == '') answer_toolbar = '';
1896
1897					if(isOldVer) {
1898						var hasAnswer = $(qnaitem).next().hasClass('qna-details');
1899						if(!hasAnswer) {
1900							var qna_container_default = '\
1901										<div class="tpl-qna-question">\
1902											<div class="tpl-qna-question-content"></div>\
1903										</div>\
1904										<div class="tpl-qna-answer">\
1905											<div class="tpl-qna-answer-title-wrap display-flex space-between">\
1906												<div class="tpl-qna-answer-title"></div>\
1907												<div class="tpl-qna-answer-name"></div>\
1908												<div class="tpl-qna-answer-date"></div>\
1909											</div>\
1910											<div class="tpl-qna-answer-content"></div>\
1911										</div>\
1912								',
1913								detail_html = $(qnaitem).clone(),
1914								detail = document.createElement('div');
1915							$(detail).html(detail_html);
1916							
1917							if($(detail).children().first().is('tr')) {
1918								$(detail).find('.qna-details *[class*=tpl-forum-list-]:not(.tpl-forum-list-content)').html('');
1919								$(detail).find('.qna-details .tpl-forum-list-content').addClass('tpl-qna-container').html(qna_container_default);
1920								$(detail).find('.qna-details').hide();
1921							} else {
1922								$(detail).children().first().addClass('tpl-qna-container').html(qna_container_default);
1923							}
1924
1925							$(qnaitem).after($(detail).html()).hide();
1926							$(detail).remove();
1927						}
1928
1929						$(qnaitem).next('.qna-details').find('.tpl-qna-question-content').html(data.content);
1930						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);
1931						else $(qnaitem).next('.qna-details').find('.tpl-qna-question .tpl-qna-toolbar').replaceWith(question_toolbar);
1932
1933						if(data.replied) {
1934							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-title').html(answer.title);
1935							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-content').html(answer.cont);
1936							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-name').html(answer.fm_name);
1937							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-date').html(answer.fm_re_datetime);
1938							if($(qnaitem).parents().hasClass('newqna')) {
1939								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);
1940								else $(qnaitem).next('.qna-details').find('.tpl-qna-answer .tpl-qna-toolbar').replaceWith(answer_toolbar);
1941							} else {
1942								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);
1943								else $(qnaitem).next('.qna-details').find('.tpl-qna-answer .tpl-qna-toolbar').replaceWith(answer_toolbar);
1944							}
1945						} else {
1946							$(qnaitem).next('.qna-details').find('.tpl-qna-answer').hide();
1947						}
1948
1949						var colspan = $(qnaitem).parents('.table').find('th.tpl-forum-header-row:not(.hide)').length;
1950						if($(qnaitem).next('.qna-details').find('td').length > 1) {
1951							$(qnaitem).next('.qna-details').find('td').each(function() {
1952								if($(this).text().trim() === '') $(this).remove();
1953							});
1954						}
1955						$(qnaitem).next('.qna-details').find('td').attr('colspan', colspan);
1956						$(qnaitem).next('.qna-details').show().siblings('.qna-details').hide();
1957
1958					} else {
1959						var qnaQuestion = $(qnaitem).find(`.tpl-forum-qna-row.question`),
1960							qnaAnswer = $(qnaitem).find(`.tpl-forum-qna-row.answer`);
1961
1962						qnaQuestion.find('.tpl-forum-list-cont').html(data.content);
1963						qnaQuestion.find('.tpl-qna-toolbar').remove();
1964						qnaQuestion.find('.tpl-forum-qna-details').append(question_toolbar);
1965
1966						if(data.replied) {
1967							qnaAnswer.find('.tpl-forum-list-title').html(answer.title);
1968							qnaAnswer.find('.tpl-forum-list-cont').html(answer.cont);
1969							qnaAnswer.find('.tpl-forum-list-name').html(answer.fm_name);
1970							qnaAnswer.find('.tpl-forum-list-date').html(answer.fm_re_datetime);
1971							qnaAnswer.find('.tpl-qna-toolbar').remove();
1972							qnaAnswer.find('.tpl-forum-qna-details').append(`<div class="tpl-forum-qna-row toolbar">${answer_toolbar}</div>`);
1973							$(qnaitem).removeClass('w');
1974						} else {
1975							$(qnaitem).addClass('w');
1976						}
1977
1978						$(qnaitem).addClass('open').siblings().removeClass('open');
1979					}
1980				}
1981			});
1982
1983		} else {
1984			if(isOldVer) $(qnaitem).next('.qna-details').hide();
1985			else $(qnaitem).removeClass('open');
1986		}
1987
1988	}
1989
1990
1991    $(document).on('paste','.note-editable',function(event) {
1992        event.preventDefault();
1993        if(window.clipboardData) {
1994            var text = window.clipboardData.getData('Text');
1995            if (window.getSelection) { // IE11
1996                window.getSelection().getRangeAt(0).insertNode(document.createTextNode(text));
1997            } else if (document.selection && document.selection.createRange) { // old IE
1998                text = text.replace(/\n/g, "<br />");
1999                document.selection.createRange().pasteHTML(text);
2000            }
2001        } else {
2002            var text = (event.originalEvent || event).clipboardData.getData('text/plain') || prompt('Paste something..');
2003            text = text.replace(/\n/g, '<br />');
2004            window.document.execCommand('insertHtml', false, text);
2005        }
2006    });
2007
2008	$(document).on('mousedown mouseup keydown keyup','.fr-view',function(e) {
2009		selRange = saveSelection();
2010	});
2011	
2012	$(document).on('click','button[data-event="showLinkDialog"]', function(e) {
2013		restoreSelection(selRange);
2014	});
2015
2016	$(document).on('click','.set-image', function(e) {
2017		var src = $(this).closest('.result-file').attr('data-file');
2018		$('.fr-view').focus();
2019		if(!$('.fr-view').is(':focus')) {
2020			// placeCaretAtEnd($('.fr-view').get(0));
2021		}
2022
2023		if(upTYPE == 'image') $('#fm-editor').froalaEditor('image.insert', 'http:' + file, true);
2024		else $('#fm-editor').froalaEditor('file.insert', 'http:' + file, orig_name, { 'link' : 'http:' + file, 'target': '_blank' });
2025	});
2026
2027	$(document).on('click','.file-delete', function(e){
2028		var select_file = $(this).parent().attr('data-file-name'),
2029			click_file = $(this).parent().attr('data-file'),
2030			user_file = $('.result-file').map(function() {
2031							return $(this).attr('data-file-name');
2032						}).get().join(',');
2033			$file = $(this).parent();
2034
2035		var modal = $(this).showModalFlat('INFORMATION',$.lang[LANG]['board.ask-delete-attached-file'], true, true, function() {
2036			$.post('/fm/attach_delete',{ select_file : select_file, user_file : user_file, sid : SID }, function(data){
2037				$('.flat-modal').next().remove();
2038				$('.flat-modal').remove();
2039				$file.fadeOut().remove();
2040				$('img[src="' + click_file + '"]').fadeOut('fast',function() { $(this).remove(); });
2041			}, 'json');
2042		}, 'cancel');
2043	});
2044
2045	$(document).on('focus','#fm-editor',function(e) {
2046		$(this).removeClass('content-empty');
2047		// placeCaretAtEnd($('.fr-view').get(0));
2048	}).on('focusout','#fm-editor', function(e) {
2049		setPlaceholder($(this));
2050	});
2051
2052	var setPlaceholder = function($editor) {
2053		var empty = ($editor.find('.fr-view').html()=="<p><br></p>") ? true : false;
2054		(empty) ? $editor.addClass('content-empty') : $editor.removeClass('content-empty');
2055	}
2056
2057	var updateForumPost = function(id,pid) {
2058
2059		var idstr = (id) ? '/m/u/id/' + id : '';
2060		$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
2061			if(typeof data.error != 'undefined' && data.error) {
2062				$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2063				return false;
2064			}
2065			var post_data = data;
2066			if(data.fmid && data.sign == false) {
2067				userLogin();
2068				return false;
2069			}
2070
2071			if(data.sign == false) {
2072				$(this).showModalFlat($.lang[LANG]['board.button.modify.password'],passwdForm(),true,true,function() {
2073					var $pass = $('#comm-pass'),
2074						isSubmit = true,
2075						userInput = $pass.val();
2076					$('label.error').remove();
2077					if($pass.val().length<4) {
2078						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2079						$pass.closest('.cl-s-form-wrap').addClass('error');
2080						$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>');
2081						$pass.focus();
2082						isSubmit = false;
2083					}
2084
2085					if(isSubmit) {
2086						//$('.comment-addform.password').parent().find('.error').remove();
2087						$.post('/fm/password',{ id: id, passwd : hex_md5($pass.val()) }, function(data) {
2088							if(typeof data.error != 'undefined' && data.error) {
2089								//$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2090								//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
2091								$pass.closest('.cl-s-form-wrap').addClass('error');
2092								$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>');
2093								return false;
2094							}
2095							var date = new Date(),
2096								cookietime = 20 * 60 * 1000;
2097				            date.setTime(date.getTime() + cookietime);
2098
2099							$.cookie('hash', data.hash, { path: '/' , expires: date});
2100							$('.modal[id*=flat-modal]').modal('hide');
2101							setWriteUser(post_data, function() {
2102								location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid;
2103								// forumWrite(id,pid);
2104							});
2105						},'json');
2106					}
2107					modalEmptyCheck();
2108				},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password');
2109			} else if(data.own == true || data.mgr_edit == true) {
2110				setWriteUser(data, function() {
2111					location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid;
2112					// forumWrite(id,pid);
2113				});
2114			} else alert($.lang[LANG]['board.not-own-no-edit']);
2115
2116		}, 'json');
2117	}
2118
2119	var userLogin = function() {
2120		var id = $('#fm-id').val(),
2121			pid = $('#fm-pid').val(),
2122			info = $.lang[LANG]['re-login.info'];
2123
2124		$.post('/fm/checkUser', { pid : pid }, function(data) {
2125			if(!data.user || typeof data.user == 'undefined') {
2126				if(typeof data.error != 'undefined' && data.error) {
2127					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2128					return false;
2129				}
2130				var modal = $(this).showModalFlat($.lang[LANG]['config.postforum'], info + signForm(id,pid,data.access,data.stoken),true,true,function() {
2131					var isSubmit = true;
2132					$('.error').remove();
2133
2134					var $name = $('#comm-name'),
2135						$pass = $('#comm-pass'),
2136						$key = $('#wr_key'),
2137						nameLength = getBytes( $name.val() );
2138
2139					if( nameLength==0) {
2140						$name.after('<label class="error">' +  $.lang[LANG]['config.enter-name'] + '</label>').focus();
2141						isSubmit = false;
2142					}
2143					else if ( nameLength > 20 ) {
2144						$name.after('<label class="error">' +  $.lang[LANG]['config.guest-id-max-length'] + '</label>').focus();
2145						isSubmit = false;
2146					}
2147					if($pass.val().length<4) {
2148						$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2149						isSubmit = false;
2150					}
2151
2152					if($key.val().length==0) {
2153						$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
2154						isSubmit = false;
2155					}
2156
2157					if($key.val() && (Base64.encode($key.val().trim()) != md5_norobot_key)) {
2158						$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2159						isSubmit = false;
2160					}
2161
2162					// var key = '';
2163					// if(isSubmit == true) {
2164					// 	key = checkCaptcha();
2165					// 	if(!key.success) {
2166					// 		$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2167					// 		isSubmit = false;
2168					// 	}
2169					// }
2170
2171					resetObject(user);
2172					if(isSubmit==true) {
2173						modal.modal('hide');
2174						user.name = data.name = $name.val();
2175						user.nameLength = nameLength;
2176						user.pass = hex_md5( $pass.val() );
2177						user.key = $key.val().trim();
2178						setWriteUser(data);
2179					}
2180				},'cancel','','w450',true,'',function() {
2181					// loadCaptcha();
2182					load_kcaptcha();
2183				});
2184				$('.flat-modal .modal-body').addClass('comment');
2185				$('.flat-modal .modal-footer').hide();
2186				$('.modal[id*=flat-modal]').css('z-index','1040');
2187				$('.flat-modal').next('.modal-backdrop').css('z-index','1039');
2188				if(!user.pass) $('.flat-modal .signType').last().hide();
2189				// $('#kcaptcha').click();
2190			} else {
2191				// resetObject(user);
2192				setWriteUser(data);
2193			}
2194		},'json');
2195	}
2196
2197	var passwdForm = function(checkhigh) {
2198		if(typeof checkhigh == 'undefined') checkhigh = '';
2199		return '' +
2200			'<div class="cl-s-form-wrap comment-addform password">' +
2201				'<div class="cl-s-form-group">' +
2202					'<input type="password" class="cl-s-form-control" id="comm-pass" name="comm-pass" required="required" value="" data-checkhigh="' + checkhigh + '">' +
2203					'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.password'] + '</label>' +
2204				'</div>' +
2205			'</div>';
2206	}
2207	var videoForm = function() {
2208		return '' +
2209			'<div class="form-inline comment-addform video">' + 
2210			  	'<div class="form-group">' +
2211			  		'<p><b>Video URL?</b> (YouTube, Vimeo, SoundCloud, Metacafe or DailyMotion)</p>' + 
2212			    	'<label class="sr-only" for="label-video">' +  $.lang[LANG]['config.modal.password'] + '</label>' +
2213			    	'<input type="text" class="form-control" id="video-url" placeholder="http(s)://">' +
2214			  	'</div>' +
2215			'</div>';
2216	}
2217
2218
2219	var modalEmptyCheck = function() {
2220		$('.cl-s-form-control').off().on({
2221			keyup: function(e) {
2222				if(e.keyCode === 13) {
2223					if($(this).closest('.cl-s-form-wrap').next('.cl-s-form-wrap').length > 0) {
2224						$(this).closest('.cl-s-form-wrap').next('.cl-s-form-wrap').find('.cl-s-form-control').focus();
2225					} else if($(this).closest('.cl-s-form-wrap').next('#captcha:not(:empty)').length > 0) {
2226						$('#wr_key').focus();
2227					}
2228				}
2229			},
2230			focus: function(e) {
2231				$(this).closest('.cl-s-form-wrap').addClass('active');
2232			},
2233			blur: function(e) {
2234				var inputEL = $(this),
2235					type = $(this).attr('id'),
2236					val = $(this).val().trim(),
2237					error_str = '';
2238
2239				inputEL.closest('.cl-s-form-wrap').removeClass('active');
2240				if(val.length == 0) {
2241					inputEL.closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
2242					inputEL.closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
2243					return false;
2244				} else {
2245					inputEL.closest('.cl-s-form-wrap').removeClass('empty');
2246					var error_str = '';
2247					if(type == 'comm-pass') {
2248						if(val.length<4) {
2249							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>
2249' + $.lang[LANG]['config.pass-min-length'];
2250						}
2251					}
2252					if(error_str.length > 0) {
2253						inputEL.closest('.cl-s-form-wrap').addClass('error');
2254						if(inputEL.parent().parent().find('.cl-s-control-label.error').length > 0) {
2255							inputEL.parent().parent().find('.cl-s-control-label.error').html(error_str);
2256						} else {
2257							inputEL.parent().parent().next('.cl-s-control-label.error').remove();
2258							inputEL.parent().parent().after('<label for="input" class="cl-s-control-label error">'+error_str+'</label>');
2259						}
2260						return false;
2261					}
2262				}
2263				inputEL.closest('.cl-s-form-wrap').removeClass('error').removeClass('empty');
2264				inputEL.parent().parent().next('.cl-s-control-label.error').remove();
2265				if($('.error_login').length > 0) $('.error_login').remove();
2266			}
2267		});
2268		$('#wr_key').off().on({
2269			keyup: function(e) {
2270				$(this).closest('.kcaptcha-box').removeClass('empty').removeClass('error');
2271			},
2272			focus: function(e) {
2273				$(this).closest('.kcaptcha-box').addClass('active');
2274			},
2275			blur: function(e) {
2276				if($(this).val().trim().length == 0) {
2277					$(this).closest('.kcaptcha-box').removeClass('active');
2278				} else {
2279					$(this).closest('.kcaptcha-box').removeClass('empty').removeClass('error').removeClass('active');
2280				}
2281				$(this).closest('.kcaptcha-box').parent().find('.kcaptcha-error').remove();
2282			}
2283		});
2284	}
2285
2286	$(document).on('click', '.tpl-guestbook-write', function(e) {
2287		if(PAGE_MODE == 'r') return false;
2288		var id = '';
2289		var element = $(this).parents('.element');
2290		var sid = (typeof property == 'undefined') ? SID : property.SID,
2291			pid = element.attr('data-id');
2292		
2293		var content = '', passwd = '', captcha = '', secret = 'N', writer = '';
2294
2295			
2296		var validation_flag = true;
2297		element.find('.error-box').remove();
2298		if($(this).attr('data-id')) {//if는 수정창 등록 버튼
2299			id = $(this).attr('data-id');
2300			var edit_box = element.find('.guestbook-edit');
2301			content = edit_box.find('.input-content').val();
2302			secret = edit_box.find('.secret-check input[type="checkbox"]').prop('checked') ? 'S' : 'N';
2303			if($.trim(content) == '' || $.trim(content).length < 2) {
2304				edit_box.find('.input-content').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.content'] + '</div>');
2305				validation_flag = false;
2306			}
2307		} else {
2308			
2309			//element.find('.list-area').find('.editing,.hide').removeClass('editing hide');			
2310			element.find('.guestbook-edit').parents('.list-item').find('.editing.hide').removeClass('editing hide');			
2311			$('.guestbook-edit').remove();
2312			
2313			
2314			
2315			writer = element.find('.input-name').val();
2316			content = element.find('.input-content').val();
2317			passwd = element.find('.input-pw').val();
2318			captcha = element.find('input[name="wr_key"]').val();
2319			secret = element.find('.secret-check input[type="checkbox"]').prop('checked') ? 'S' : 'N';
2320			
2321			if(PAGE_MODE != 'c' ) {
2322				if((!RENDER.b.UMEMBER.id || (RENDER.b.UMEMBER.id_type == 'creatorlink' && !RENDER.b.UMEMBER.check_adm && !RENDER.b.UMEMBER.check_adm)) && $.trim(writer) == '') {
2323					element.find('.input-name').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.name'] + '</div>');
2324					validation_flag = false;
2325				}
2326				if((!RENDER.b.UMEMBER.id || (RENDER.b.UMEMBER.id_type == 'creatorlink' && !RENDER.b.UMEMBER.check_adm && !RENDER.b.UMEMBER.check_adm)) && $.trim(passwd) == '') {
2327					element.find('.input-pw').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.passwd'] + '</div>');
2328					validation_flag = false;
2329				} 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) {
2330					element.find('.input-pw').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.passwd.length'] + '</div>');
2331					validation_flag = false;
2332				}
2333				if(element.find('.kcaptcha-key-wrap:visible').length > 0 && $.trim(captcha) == '') {
2334					element.find('.captcha').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.captcha'] + '</div>');
2335					validation_flag = false;
2336				}
2337			}
2338			if($.trim(content) == '' || $.trim(content).length < 2) {
2339				//방명록 블럭 디자인 5,6번
2340				if (element.find('.guestbook-design5-bgcolor').is('.guestbook-design5-bgcolor') || element.hasClass('guestbook-fr-35')) {				
2341					element.find('.input-content').parent().after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.content'] + '</div>');
2342					validation_flag = false;
2343				}
2344				else{
2345					element.find('.input-content').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.content'] + '</div>');
2346					validation_flag = false;
2347				}
2348			}
2349		}
2350
2351
2352		if(!validation_flag) return false;
2353
2354		$.ajax({
2355			url:'/fm/guestbook',
2356			type:'post',
2357			dataType:'json',
2358			data:{
2359				'id' : id,
2360				'sid' : sid,
2361				'pid' : pid,
2362				'writer' : writer,
2363				'content' : content,
2364				'passwd' : hex_md5(passwd),
2365				'captcha' : captcha,
2366				'secret' : secret,
2367				'mode' : PAGE_MODE,
2368			},
2369			success:function(data) {		
2370				if(data.error) {
2371					alert(data.error);
2372				} else {	
2373					page = 1,
2374					page_num = 1,
2375					view = element.find('[data-view]').attr('data-view'),
2376					sfl = "",
2377					stx = "",
2378					scate = "";
2379
2380					$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
2381					cookie_page_num = $.cookie('forum_'+pid);
2382					$.forum.init(pid,page,view,cookie_page_num,sfl,stx,scate);
2383				}
2384			}
2385		});
2386	});
2387
2388	$(document).on('click', '.tpl-guestbook-more-menu', function(e) {
2389		if($(this).next('.tpl-guestbook-more-menu-area').length) {
2390			$('.tpl-guestbook-more-menu-area').remove();
2391			return false;
2392		}
2393		$('.tpl-guestbook-more-menu-area').remove();
2394		var html = '';
2395		html += '\
2396		<div class="tpl-guestbook-more-menu-area">\
2397		';
2398		var fm_mb_id = $(this).parents('.list-item').find('.tpl-forum-list-cont').attr('data-fm_mb_id');
2399		if((PAGE_MODE != 'c' && (RENDER.b.UMEMBER.check_adm != true && RENDER.b.UMEMBER.check_uadm != true)) || 
2400				(PAGE_MODE != 'c' && (RENDER.b.UMEMBER.check_adm == true || RENDER.b.UMEMBER.check_uadm == true) && fm_mb_id == RENDER.b.UMEMBER.id)
2401			|| (PAGE_MODE == 'c' && fm_mb_id == MB_ID)) {
2402			html += '<div data-oper="U">' + $.lang[LANG]['forum.guestbook.btn.modify'] + '</div>';
2403		}
2404		html += '\
2405			<div data-oper="D">' + $.lang[LANG]['forum.guestbook.btn.delete'] + '</div>\
2406		</div>\
2407		';
2408		var $box = $(html);
2409		$(this).after($box);
2410		var top = $(this).position().top + $(this).outerHeight();
2411		var left = $(this).position().left + $(this).outerWidth() / 2;
2412		left -= $box.outerWidth() / 2;
2413		$box.css('top', top);
2414		$box.css('left', left);
2415	});
2416
2417	$(document).on('click', '.tpl-guestbook-cancel', function(e) {
2418		$(this).parents('.list-item').find('.tpl-forum-list-cont').removeClass('editing hide');
2419		$(this).parents('.list-item').find('.tpl-guestbook-more-menu').removeClass('editing hide');
2420		$(this).parents('.list-item').find('.tpl-guestbook-more-menu-area-el2').removeClass('editing hide');
2421		$(this).parents('.list-item').find('.guestbook-edit').remove();
2422		$('.tpl-guestbook-more-menu-area-el2').css('display','');		
2423	});
2424
2425
2426	//guest book2
2427	$(document).on('click', '.tpl-guestbook-more-menu-area-el2 div', function(e) {
2428	
2429		var $cont_box = $(this).parents('.list-item').find('.tpl-forum-list-cont');		
2430		var check_text = $(this).parents('.btn-area2').parents('.list-item').find('.content').text();	
2431		var $btn = $(this);
2432		var element = $(this).parents('.element');
2433		var oper = $btn.attr('data-oper');
2434		var fm_id = $cont_box.attr('data-fm_mb_id');
2435		var id = $cont_box.attr('data-id');
2436		var element = $(this).closest('.element');
2437		var pid = element.attr('data-id');
2438		var $list_item = $btn.parents('.list-item');
2439
2440		if (element.find('.fr34').hasClass('fr34')) {
2441		var chk_delete_first = check_text.substr(1);		
2442		var chk_delete_last = chk_delete_first.slice(0, -1);
2443		}
2444
2445		var makeUpdateForm = function() {
2446			$('.guestbook-edit').remove();
2447			$('.editing.hide').removeClass('editing hide');
2448
2449			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
2450				if(typeof data.error != 'undefined' && data.error) {
2451					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2452					return false;
2453				} else {
2454					if(data.own) {
2455						$list_item.find('.tpl-guestbook-more-menu-area-el2').addClass('editing hide');
2456						var text = $.trim($cont_box.text());
2457						var button_area = element.find('.button-area').clone();						
2458						button_area.find('.tpl-guestbook-write').before('<button type="button" class="btn tpl-guestbook-cancel">' + element.find('.tpl-guestbook-cancel:first').text() + '</button>');
2459						
2460					var hasTextClass = button_area[0].classList.contains('fr34-input-height');
2461					var fr35_hasTextClass = button_area[0].classList.contains('guestfr35');
2462					if(hasTextClass === false){
2463						if(fr35_hasTextClass === true){ //forum35							
2464						var html = '\
2465							<div class="guestbook-edit">\
2466							<div class="textarea-wrap-error" style="position:relative;">\
2467								<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>\
2468								</div>\
2469								' + button_area.outerHTML() + '\
2470							</div>\
2471						';	
2472						}else{//forum29,32,33
2473							
2474						var html = '\
2475							<div class="guestbook-edit">\
2476								<textarea class="input-content form-control input-bg-opacity"></textarea>\
2477								' + button_area.outerHTML() + '\
2478							</div>\
2479						';}
2480					}else if(fr35_hasTextClass === false ){//forum34
2481
2482						var html = '\
2483							<div class="guestbook-edit">\
2484								<div class="textarea-wrap-error " style="position:relative;">\
2485								<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>\
2486								</div>\
2487								' + button_area.outerHTML() + '\
2488							</div>\
2489						';						
2490						text = text.replace(/^"*/,"").replace(/"*$/,"");
2491					} 
2492					var $html = $(html);
2493						$cont_box.before($html);
2494						$html.find('.input-content').val(text);
2495						if(data.option == 'S') $cont_box.prev('.guestbook-edit').find('.secret-check input[type="checkbox"]').prop('checked', true);
2496						$cont_box.prev('.guestbook-edit').find('.tpl-guestbook-write').attr('data-id', id);
2497						$cont_box.addClass('editing hide');
2498					}
2499					var header_check = $("header").attr("data-fh-type");										
2500					 var editor_height = ( $(".editor-navbar").hasClass("editor-navbar")) ? $(".editor-navbar").outerHeight(true) : 0 ;
2501					
2502					
2503
2504					if (header_check != "sidebar") { 
2505						var header_height = $("header").outerHeight(true); 
2506					}else{
2507						var header_height = 0;
2508					}
2509					
2510					
2511					if ( PAGE_MODE == ('c')) {						
2512						$('.dsgn-body').scrollTop($('.dsgn-body').scrollTop() + $cont_box.closest('.list-item').offset().top  - editor_height - header_height );
2513								
2514					} else if (PAGE_MODE == ('s')) {							
2515						//$(document).scrollTop($(document).scrollTop() + $cont_box.closest('.list-item').offset().top  -  header_height );
2516						$(document).scrollTop ($cont_box.closest('.list-item').offset().top - header_height - 200 )
2517						
2518					}	
2519							
2520				}
2521			}, 'json');
2522		};
2523
2524		if(oper == 'D') { // 삭제
2525			if(PAGE_MODE == 'c' || RENDER.b.UMEMBER.check_adm == true || RENDER.b.UMEMBER.check_uadm == true) {
2526				var modal = $(this).showModalFlat('', $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
2527					modal.modal('hide');
2528					deleteGuestbook(pid, id);
2529				}, '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');
2530			} else {
2531				$.forum.deleteGuestbook(pid, id);
2532			}
2533		} else if(oper == 'U') { // 수정
2534			if(PAGE_MODE == 'c' || (PAGE_MODE != 'c' && fm_id != '' && fm_id == RENDER.b.UMEMBER.id)) {
2535				makeUpdateForm();
2536			} else {
2537
2538				var modal = $(this).showModalFlat($.lang[LANG]['forum.guestbook.title.edit'], passwdForm(), true, true, function() {
2539					var $pass = $('#comm-pass'),
2540						isSubmit = true;
2541					$('label.error').remove();
2542					if($pass.val().length<4) {
2543						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2544						$pass.closest('.cl-s-form-wrap').addClass('error');
2545						$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">
2545<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>');
2546						$pass.focus();
2547						isSubmit = false;
2548					}
2549
2550					if(isSubmit) {
2551						//$('.comment-addform.password').parent().find('.error').remove();
2552						$('.comment-addform.password').removeClass('error');
2553						$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()) }, function(data) {
2554							if(typeof data.error != 'undefined' && data.error) {
2555								//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
2556								$pass.closest('.cl-s-form-wrap').addClass('error');
2557								$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>');
2558								return false;
2559							}
2560							var date = new Date(),
2561								cookietime = 20 * 60 * 1000;
2562							date.setTime(date.getTime() + cookietime);
2563							
2564							$.removeCookie('checkPostHighWriter',{path:'/'});
2565							$.cookie('checkPostWriter', id, { path: '/' , expires: date});
2566							$.cookie('hash', data.hash, { path: '/' , expires: date});
2567							$('.modal[id*=flat-modal]').modal('hide');
2568
2569							
2570							makeUpdateForm();
2571						},'json');
2572					}
2573					modalEmptyCheck();
2574					
2575				}, 'cancel', 'ok','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
2576					modal.find('#comm-pass').addClass('guestbook-pass');
2577				});
2578				
2579			}
2580		}
2581		// $(this).parents('.tpl-guestbook-more-menu-area-el2').css('display','none');
2582	});
2583
2584
2585
2586
2587	$(document).on('click', '.tpl-guestbook-more-menu-area div', function(e) {
2588		var $cont_box = $(this).parents('.list-item').find('.tpl-forum-list-cont');
2589		var $btn = $(this);
2590		var element = $(this).parents('.element');
2591		var oper = $btn.attr('data-oper');
2592		var fm_id = $cont_box.attr('data-fm_mb_id');
2593		var id = $cont_box.attr('data-id');
2594		var element = $(this).closest('.element');
2595		var pid = element.attr('data-id');
2596		var $list_item = $btn.parents('.list-item');
2597		var makeUpdateForm = function() {
2598			$('.guestbook-edit').remove();
2599			$('.editing.hide').removeClass('editing hide');
2600
2601			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
2602				if(typeof data.error != 'undefined' && data.error) {
2603					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2604					return false;
2605				} else {
2606					if(data.own) {
2607						$list_item.find('.tpl-guestbook-more-menu').addClass('editing hide');
2608						var text = $.trim($cont_box.text());
2609						var button_area = element.find('.button-area').clone();
2610						
2611						button_area.find('.tpl-guestbook-write').before('<button type="button" class="btn tpl-guestbook-cancel">' + element.find('.tpl-guestbook-cancel:first').text() + '</button>');
2612
2613						$cont_box.before(`
2614							<div class="guestbook-edit">
2615								<textarea class="input-content form-control ${(element.hasClass('versioncheck')) ? 'input-bg-opacity' : ''}">${text}</textarea>
2616								${button_area.outerHTML()}
2617							</div>
2618						`);
2619						if(data.option == 'S') $cont_box.prev('.guestbook-edit').find('.secret-check input[type="checkbox"]').prop('checked', true);
2620						$cont_box.prev('.guestbook-edit').find('.tpl-guestbook-write').attr('data-id', id);
2621						$cont_box.addClass('editing hide');
2622					}
2623				}
2624			}, 'json');
2625		};
2626
2627		if(oper == 'D') { // 삭제
2628			if(PAGE_MODE == 'c' || RENDER.b.UMEMBER.check_adm == true || RENDER.b.UMEMBER.check_uadm == true) {
2629				var modal = $(this).showModalFlat('', $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
2630					modal.modal('hide');
2631					deleteGuestbook(pid, id);
2632				}, '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');
2633			} else {
2634				$.forum.deleteGuestbook(pid, id);
2635			}
2636		} else if(oper == 'U') { // 수정
2637			if(PAGE_MODE == 'c' || (PAGE_MODE != 'c' && fm_id != '' && fm_id == RENDER.b.UMEMBER.id)) {
2638				makeUpdateForm();
2639			} else {
2640
2641				var modal = $(this).showModalFlat($.lang[LANG]['forum.guestbook.title.edit'], passwdForm(), true, true, function() {
2642					var $pass = $('#comm-pass'),
2643						isSubmit = true;
2644					$('label.error').remove();
2645					if($pass.val().length<4) {
2646						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2647						$pass.closest('.cl-s-form-wrap').addClass('error');
2648						$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">
2648<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>');
2649						$pass.focus();
2650						isSubmit = false;
2651					}
2652
2653					if(isSubmit) {
2654						//$('.comment-addform.password').parent().find('.error').remove();
2655						$('.comment-addform.password').removeClass('error');
2656						$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()) }, function(data) {
2657							if(typeof data.error != 'undefined' && data.error) {
2658								//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
2659								$pass.closest('.cl-s-form-wrap').addClass('error');
2660								$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>');
2661								return false;
2662							}
2663							var date = new Date(),
2664								cookietime = 20 * 60 * 1000;
2665							date.setTime(date.getTime() + cookietime);
2666
2667							$.removeCookie('checkPostHighWriter',{path:'/'});
2668							$.cookie('checkPostWriter', id, { path: '/' , expires: date});
2669							$.cookie('hash', data.hash, { path: '/' , expires: date});
2670							$('.modal[id*=flat-modal]').modal('hide');
2671
2672							
2673							makeUpdateForm();
2674						},'json');
2675					}
2676					modalEmptyCheck();
2677					
2678				}, 'cancel', 'ok','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
2679					modal.find('#comm-pass').addClass('guestbook-pass');
2680				});
2681			}
2682		}
2683		$(this).parents('.tpl-guestbook-more-menu-area').remove();
2684	});
2685
2686	$(document).on('click', '[data-type="forum"] .list-item.blind', function(e) {
2687		e.preventDefault();
2688		e.stopPropagation();
2689		var $list_item = $(this);
2690		var $cont_box = $(this).find('.tpl-forum-list-cont');
2691		var element = $(this).parents('.element');
2692		var fm_id = $cont_box.attr('data-fm_mb_id');
2693		var id = $cont_box.attr('data-id');
2694		var element = $(this).closest('.element');
2695		var pid = element.attr('data-id');
2696
2697		var modal = $(this).showModalFlat($.lang[LANG]['forum.guestbook.title.secret'], passwdForm(), true, true, function() {
2698			var $pass = $('#comm-pass'),
2699				isSubmit = true;
2700			$('label.error').remove();
2701			if($pass.val().length<4) {
2702				//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2703				$pass.closest('.cl-s-form-wrap').addClass('error');
2704				$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>');
2705				$pass.focus();
2706				isSubmit = false;
2707			}
2708
2709			if(isSubmit) {
2710				//$('.comment-addform.password').parent().find('.error').remove();
2711				$('.comment-addform.password').removeClass('error');
2712				$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()) }, function(data) {
2713					if(typeof data.error != 'undefined' && data.error) {
2714						//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
2715						$pass.closest('.cl-s-form-wrap').addClass('error');
2716						$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>
2716'+data.error+'</label>');
2717						return false;
2718					}
2719					var date = new Date(),
2720						cookietime = 20 * 60 * 1000;
2721					date.setTime(date.getTime() + cookietime);
2722					
2723					$.removeCookie('checkPostHighWriter',{path:'/'});
2724					$.cookie('checkPostWriter', id, { path: '/' , expires: date});
2725					$.cookie('hash', data.hash, { path: '/' , expires: date});
2726
2727					$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
2728						if(typeof data.error != 'undefined' && data.error) {
2729							$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2730							return false;
2731						} else {
2732							$cont_box.html(nl2br(data.content));
2733							$list_item.removeClass('blind');
2734							$list_item.find('.tpl-guestbook-more-menu').removeClass('hide');
2735							$list_item.find('.tpl-guestbook-more-menu-area-el2').removeClass('hide');
2736						}
2737					}, 'json');
2738
2739
2740					$('.modal[id*=flat-modal]').modal('hide');
2741
2742				},'json');
2743			}
2744			modalEmptyCheck();
2745			
2746		}, 'cancel', 'ok','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
2747			modal.find('#comm-pass').addClass('guestbook-pass');
2748		});
2749	});
2750
2751	$(document).on('click', function(e) {
2752		var container = $('.tpl-guestbook-more-menu-area');
2753		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')) {
2754			container.hide();
2755			//버그수정
2756			container.remove();
2757
2758		}
2759
2760		if($('.search-forum-user-posts').length > 0 && !$(e.target).is('.tpl-forum-list-name')) {
2761			$('.tpl-forum-list-name').removeClass('search-on');
2762			$('.search-forum-user-posts').remove();
2763		}
2764	});
2765	$(document).on('keyup keydown','.keyup-check',function(e) {	
2766	if (e.keyCode == 13) {e.preventDefault();} 
2767		var content = $(this).val();
2768          $($(this).next('.textcount, .textarea-height')).text(""+ content.length + "/300");
2769        if (content.length >= 300) {
2770        	$(this).val($(this).val().substring(0, 300)); 
2771         	$($(this).next('.textcount,.textarea-height')).text(""+ "300" + "/300");   
2772         } 
2773	});
2774	$(document).on('click','.tpl-forum-write',function(e) {
2775		var sid = (typeof property == 'undefined') ? SID : property.SID;
2776		var pid = $(this).attr('data-pid');
2777		var id = (typeof $(this).attr('data-id') != 'undefined') ? $(this).attr('data-id') : '';
2778		var reply = (typeof $(this).attr('data-reply') != 'undefined') ? $(this).attr('data-reply') : '';
2779		var one = (typeof ONE == 'undefined') ? property.ONE : ONE;
2780		var page = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
2781
2782		try {
2783			var validType = property['VALIDTYPE'];
2784		} catch (err) {
2785			var validType = '';
2786		}
2787
2788		var idstr = (id) ? '/m/u/id/' + id : '';
2789		var replystr = (reply) ? '/reply/' + reply : '';
2790
2791		if(id) {
2792			updateForumPost(id,pid);
2793			return false;
2794		}
2795
2796		var url = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
2797		var is_new = (id != '') ? 'false' : 'true';
2798		$.post('/fm/checkUser', { pid : pid, reply : reply, id : id, isnew : is_new }, function(data) {
2799			if(!data.user || typeof data.user == 'undefined') {
2800				if(typeof data.error != 'undefined' && data.error) {
2801					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2802					return false;
2803				}
2804				
2805				var base_url = (PAGE_MODE=='s') ? '/' : '/render/';
2806				if(PAGE_MODE == 'c') {
2807					base_url = '/'+CONFIG_URL+'config/page/'
2808				}
2809
2810				var page_url = (one) ? base_url + 'index#' + page : base_url + page;
2811				var action = (validType == 'SM') ? '/_login' : '/_cllogin',
2812					html = '\
2813						<form name="write_login_form" id="write_login_form" method="post" action="' + action + '" style="display:none;">\
2814							<input type="hidden" name="status" value="write">\
2815							<input type="hidden" name="sid" value="'+sid+'">\
2816							<input type="hidden" name="type" value="F">\
2817							<input type="hidden" name="pid" value="'+pid+'">\
2818							<input type="hidden" name="page_url" value="'+page_url+'">\
2819							<input type="hidden" name="page_mode" value="'+data.access+'">\
2820							<input type="hidden" name="url" value="'+url+'">\
2821							<input type="hidden" name="reply" value="'+reply+'">\
2822							<input type="hidden" name="id" value="'+id+'">\
2823						</form>\
2824					';
2825
2826				$('body').append(html);
2827				document.write_login_form.submit();
2828
2829				/*
2830				if (validType == 'SM') {
2831					var html = '<form name="write_login_form" id="write_login_form" method="post" action="/_login" style="display:none;">\
2832									<input type="hidden" name="status" value="write">\
2833									<input type="hidden" name="url" value="'+url+'">\
2834									<input type="hidden" name="pid" value="'+pid+'">\
2835									<input type="hidden" name="pid_type" value="forum">\
2836									<input type="hidden" name="reply" value="'+reply+'">\
2837									<input type="hidden" name="id" value="'+id+'">\
2838									<input type="hidden" name="page_mode" value="'+data.access+'">\
2839								</form>';
2840
2841					$('body').append(html);
2842					document.write_login_form.submit();
2843				} else {
2844					// FREE or BN login
2845					var html = '<form name="write_cllogin_form" id="write_cllogin_form" method="post" action="/_cllogin" style="display:none;">\
2846									<input type="hidden" name="status" value="write">\
2847									<input type="hidden" name="sid" value="'+F_SID+'">\
2848									<input type="hidden" name="url" value="'+url+'">\
2849									<input type="hidden" name="pid" value="'+pid+'">\
2850									<input type="hidden" name="pid_type" value="forum">\
2851									<input type="hidden" name="reply" value="'+reply+'">\
2852									<input type="hidden" name="id" value="'+id+'">\
2853									<input type="hidden" name="page_mode" value="'+data.access+'">\
2854								</form>';
2855
2856					$('body').append(html);
2857					document.write_cllogin_form.submit();
2858				}
2859				*/
2860
2861			} else { //login user
2862				if(data.writeable == false) {
2863					var access = data.access;
2864					var message = 'error';
2865					
2866					switch (access) {
2867						// case 'NM':
2868						// 	message = $.lang[LANG]['board.nonmembers-can-write'];
2869						// 	break;
2870						case 'G':
2871							message = $.lang[LANG]['board.group-can-write'];
2872							break;
2873						case 'ADM':
2874							message = $.lang[LANG]['board.admin-can-write'];
2875							break;
2876						default:
2877							break;
2878					}
2879
2880					$(this).showModalFlat('INFORMATION', message, true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
2881					return false;
2882				}
2883				setWriteUser(data, function() {
2884					location.href = url;
2885				});
2886			}
2887		},'json');
2888//asdf
2889
2890
2891	
2892				// return false;
2893
2894
2895				// var modal_str = signForm(id,pid,data.access,data.stoken);
2896				// if(typeof modal_str != 'string') return false;
2897				// var modal = $(this).showModalFlat($.lang[LANG]['config.postforum'],modal_str,true,true,function() {
2898
2899				// 	var isSubmit = true;
2900				// 	//$('.error').remove();
2901				// 	var $name = $('#comm-name'),
2902				// 		$pass = $('#comm-pass'),
2903				// 		$key = $('#wr_key'),
2904				// 		nameLength = getBytes( $name.val() );
2905
2906				// 	$('.kcaptcha-error').remove();
2907				// 	$('label.error').remove();
2908
2909				// 	if( nameLength==0) {
2910				// 		//$name.after('<label class="error">' +  $.lang[LANG]['config.enter-name'] + '</label>').focus();
2911				// 		$name.closest('.cl-s-form-wrap').addClass('empty');
2912				// 		$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>');
2913				// 		isSubmit = false;
2914				// 	}
2915				// 	else if ( nameLength > 20 ) {
2916				// 		//$name.after('<label class="error">' +  $.lang[LANG]['config.guest-id-max-length'] + '</label>').focus();
2917				// 		$name.closest('.cl-s-form-wrap').addClass('empty');
2918				// 		$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>');
2919				// 		isSubmit = false;
2920				// 	}
2921				// 	if($pass.val().length<4) {
2922				// 		//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2923				// 		$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>');
2924				// 		$pass.closest('.cl-s-form-wrap').addClass('empty');
2925				// 		isSubmit = false;
2926				// 	}
2927				// 	// if($('#recaptcha').attr('data-res')=='') {
2928				// 	// 	$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
2929				// 	// 	isSubmit = false;
2930				// 	// }
2931
2932				// 	if($key.val().length==0) {
2933				// 		//$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
2934				// 		$key.closest('.kcaptcha-box').addClass('empty');
2935				// 		$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();
2936				// 		isSubmit = false;
2937				// 	}
2938
2939				// 	if($key.val() && (Base64.encode($key.val().trim()) != md5_norobot_key)) {
2940				// 		//$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2941				// 		$key.closest('.kcaptcha-box').addClass('error');
2942				// 		$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();
2943				// 		// console.log('input value :' + $key.val());
2944				// 		// console.log('hex_md5 : ' + Base64.encode($key.val().trim()));
2945				// 		// console.log('key : ' + md5_norobot_key);
2946				// 		isSubmit = false;
2947				// 	}
2948
2949				// 	// var key = '';
2950				// 	// if(isSubmit == true) {
2951				// 	// 	key = checkCaptcha();
2952				// 	// 	if(!key.success) {
2953				// 	// 		$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2954				// 	// 		isSubmit = false;
2955				// 	// 	}
2956				// 	// }
2957
2958				// 	modalEmptyCheck();
2959
2960				// 	if($('.tab-pane.active .empty, .tab-pane.active .error').length > 0) {
2961				// 		$('.tab-pane.active .empty').find('input').eq(0).focus();
2962				// 		isSubmit = false;
2963				// 		return false;
2964				// 	}
2965
2966
2967				// 	resetObject(user);
2968				// 	if(isSubmit==true) {
2969				// 		$('.modal[id*=flat-modal]').modal('hide');
2970				// 		user.name = data.name = $name.val();
2971				// 		user.nameLength = nameLength;
2972				// 		user.pass = hex_md5( $pass.val() );
2973				// 		user.key = $key.val().trim();
2974				// 		setWriteUser(data,function() {
2975				// 			location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
2976				// 			// forumWrite(id,pid,reply);
2977				// 		});
2978				// 	}
2979				// },'cancel','','cl-modal cl-cmmodal cl-p130 cl-s-btn cl-close-btn w560 block-write','','',function() {
2980				// 	// loadCaptcha();
2981				// 	load_kcaptcha();
2982				// });
2983				// $('.flat-modal .modal-body').addClass('comment');
2984				// $('body').addClass('no-fixed');
2985				// if($('.flat-modal .modal-body .comment-signForm').hasClass('default-mode') || $('.flat-modal .modal-body .comment-signForm').hasClass('sitemember-mode')) 
2986				// 	$('.flat-modal .modal-footer').hide();
2987				// // $('#kcaptcha').click();
2988
2989	});
2990
2991	// $(document).on('click','.tpl-forum-write, .tpl-toolbar-question-edit',function(e) {
2992	$(document).off('click', '.tpl-toolbar-question-edit').on('click','.tpl-toolbar-question-edit',function(e) {
2993		var id = $(this).attr('data-id'),
2994			pid = $(this).attr('data-pid'),
2995			reply = $(this).attr('data-reply');
2996		try {
2997			var validType = property['VALIDTYPE'];
2998		} catch (err) {
2999			var validType = '';
3000		}
3001		
3002		id = (typeof id == 'undefined') ? '' : id;
3003		reply = (typeof reply == 'undefined') ? '' :reply;
3004
3005		var idstr = (id) ? '/m/u/id/' + id : '',
3006			replystr = (reply) ? '/reply/' + reply : '';
3007
3008		if(reply) {
3009			idstr = '';
3010			// location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
3011			// return false;
3012		}
3013		// location.href = '/post/t/' + F_MODE + idstr + '/pid/' + pid + replystr;
3014
3015		if(id && !reply) {
3016			updateForumPost(id,pid);
3017			return false;
3018		}
3019
3020		$.post('/fm/checkUser', { pid : pid, reply : reply, id : id }, function(data) {
3021			if(!data.user || typeof data.user == 'undefined') {
3022				if(typeof data.error != 'undefined' && data.error) {
3023					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
3024					return false;
3025				}
3026
3027				if (validType == 'SM') {
3028					var url = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
3029					var status = 'write';
3030
3031					var html = '<form name="write_login_form" id="write_login_form" method="post" action="/_login" style="display:none;">\
3032									<input type="hidden" name="status" value="'+status+'">\
3033									<input type="hidden" name="url" value="'+url+'">\
3034									<input type="hidden" name="pid" value="'+pid+'">\
3035									<input type="hidden" name="page_mode" value="'+data.access+'">\
3036									<input type="hidden" name="reply" value="'+reply+'">\
3037									<input type="hidden" name="id" value="'+id+'">\
3038								</form>';
3039
3040					$('body').append(html);
3041					document.write_login_form.submit();
3042					return false;
3043				}
3044
3045				var modal_str = signForm(id,pid,data.access,data.stoken);
3046				if(typeof modal_str != 'string') return false;
3047				var modal = $(this).showModalFlat($.lang[LANG]['config.postforum'],modal_str,true,true,function() {
3048
3049					var isSubmit = true;
3050					//$('.error').remove();
3051					var $name = $('#comm-name'),
3052						$pass = $('#comm-pass'),
3053						$key = $('#wr_key'),
3054						nameLength = getBytes( $name.val() );
3055
3056					$('.kcaptcha-error').remove();
3057					$('label.error').remove();
3058
3059					if( nameLength==0) {
3060						//$name.after('<label class="error">' +  $.lang[LANG]['config.enter-name'] + '</label>').focus();
3061						$name.closest('.cl-s-form-wrap').addClass('empty');
3062						$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>');
3063						isSubmit = false;
3064					}
3065					else if ( nameLength > 20 ) {
3066						//$name.after('<label class="error">' +  $.lang[LANG]['config.guest-id-max-length'] + '</label>').focus();
3067						$name.closest('.cl-s-form-wrap').addClass('empty');
3068						$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>');
3069						isSubmit = false;
3070					}
3071					if($pass.val().length<4) {
3072						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
3073						$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>');
3074						$pass.closest('.cl-s-form-wrap').addClass('empty');
3075						isSubmit = false;
3076					}
3077					// if($('#recaptcha').attr('data-res')=='') {
3078					// 	$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
3079					// 	isSubmit = false;
3080					// }
3081
3082					if($key.val().length==0) {
3083						//$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
3084						$key.closest('.kcaptcha-box').addClass('empty');
3085						$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();
3086						isSubmit = false;
3087					}
3088
3089					if($key.val() && (Base64.encode($key.val().trim()) != md5_norobot_key)) {
3090						//$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
3091						$key.closest('.kcaptcha-box').addClass('error');
3092						$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();
3093						// console.log('input value :' + $key.val());
3094						// console.log('hex_md5 : ' + Base64.encode($key.val().trim()));
3095						// console.log('key : ' + md5_norobot_key);
3096						isSubmit = false;
3097					}
3098
3099					// var key = '';
3100					// if(isSubmit == true) {
3101					// 	key = checkCaptcha();
3102					// 	if(!key.success) {
3103					// 		$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
3104					// 		isSubmit = false;
3105					// 	}
3106					// }
3107
3108					modalEmptyCheck();
3109
3110					if($('.tab-pane.active .empty, .tab-pane.active .error').length > 0) {
3111						$('.tab-pane.active .empty').find('input').eq(0).focus();
3112						isSubmit = false;
3113						return false;
3114					}
3115
3116
3117					resetObject(user);
3118					if(isSubmit==true) {
3119						$('.modal[id*=flat-modal]').modal('hide');
3120						user.name = data.name = $name.val();
3121						user.nameLength = nameLength;
3122						user.pass = hex_md5( $pass.val() );
3123						user.key = $key.val().trim();
3124						setWriteUser(data,function() {
3125							location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
3126							// forumWrite(id,pid,reply);
3127						});
3128					}
3129				},'cancel','','cl-modal cl-cmmodal cl-p130 cl-s-btn cl-close-btn w560 block-write','','',function() {
3130					// loadCaptcha();
3131					load_kcaptcha();
3132				});
3133				$('.flat-modal .modal-body').addClass('comment');
3134				$('body').addClass('no-fixed');
3135				if($('.flat-modal .modal-body .comment-signForm').hasClass('default-mode') || $('.flat-modal .modal-body .comment-signForm').hasClass('sitemember-mode')) 
3136					$('.flat-modal .modal-footer').hide();
3137				// $('#kcaptcha').click();
3138			} else {
3139				// resetObject(user);
3140
3141				setWriteUser(data, function() {
3142					location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
3143					// forumWrite(id,pid,reply);
3144				});
3145			}
3146		},'json');
3147	});
3148
3149	$(document).off('click', '.tpl-forum-list').on('click','.tpl-forum-list',function(e) {
3150		// $.cookie('gallery','.' + F_PARENT.element, { path: '/' });
3151		$.cookie('forum-item',F_PARENT.pid, { path: '/' });
3152		
3153		if(PAGE_MODE != 'c') {
3154			var url = (PAGE_MODE=='s') ? '/' : '/render/',
3155				uri = (F_ONE) ? url + 'index#' + F_PARENT.page : url + F_PARENT.page;
3156
3157			var hash = uri.split('#');
3158			if(hash.length>1) {
3159				RENDER.history.pushState(null,property.TITLE,hash[0]);
3160				history.pushState('', '', hash[0] + '#' + hash[1]);
3161			} else {
3162				RENDER.history.pushState(null,property.TITLE,uri);
3163			}
3164			// (F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);	
3165			// (F_ONE) ? location.replace('/' + url + '/index#') + F_PARENT.page : location.replace('/' + url + '/' + F_PARENT.page);	
3166		} else {
3167			(F_ONE) ? location.replace('/'+CONFIG_URL+'config/page/index#') + F_PARENT.page : location.replace('/'+CONFIG_URL+'config/page/' + F_PARENT.page);
3168		}
3169	});
3170
3171	$(document).off('click', '.tpl-forum-delete').on('click','.tpl-forum-delete',function(e) {
3172		var id = $(this).attr('data-id');
3173		// if($('.cm-row ').length >= 1) {
3174			$.forum.delete(id);			
3175		// } else {
3176			// var modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
3177			// modal.modal('hide');
3178			// $.forum.delete(id);			
3179			// }, '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');
3180		// }
3181	});
3182
3183	$(document).off('click', '.tpl-forum-page').on('click','.tpl-forum-page', function(e) {
3184		e.preventDefault();
3185		if($(this).closest('.element').find('[data-loop="true"]').hasClass('sample-loop')) return false;
3186		var id = $(this).attr('data-id'),
3187			page = $(this).attr('data-page'),
3188			page_num = $(this).attr('data-page-num'),
3189			view = $(this).attr('data-view'),
3190			forum_el = $(this).closest('.element'),
3191			sfl = $.cookie('forum_' + id + '_prev_sfl') ? $.cookie('forum_' + id + '_prev_sfl') : "",
3192			stx = getForumPrevStx(id),
3193			scate = getForumScate(forum_el);
3194		
3195		var regexp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+┼<>@\#$%&\'\"\\\(\=“‘,]/gi;
3196		if(regexp.test(stx) || regexp.test(scate)) {
3197			$(this).showModalFlat('ERROR', '특수문자를 입력할 수 없습니다.', true , false, '', 'close');
3198			return false;
3199		}
3200
3201		if($(forum_el).find('input[name="user_stx"]').length > 0 && $(forum_el).find('input[name="user_sfl"]').length > 0) {
3202			stx = $(forum_el).find('input[name="user_stx"]').val();
3203			sfl = $(forum_el).find('input[name="user_sfl"]').val();
3204		}
3205		
3206		$.forum.setForumCookie(id,page_num,stx,sfl,scate);
3207		cookie_page_num = $.cookie('forum_'+id);
3208		
3209		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
3210		activeEL('userEL'+id);
3211	});
3212
3213	$(document).on('click','.forum-login',function(e) {
3214
3215		var forumLoginModal = $(this).closest('.modal'),
3216			id = $(this).attr('data-id'),
3217			pid = $(this).attr('data-pid'),
3218			F_SERVICE = (typeof SERVICE == 'undefined') ? property.SERVICE : SERVICE,
3219			F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE,
3220			F_SITEUM = (typeof SITEUM == 'undefined') ? property.SITEUM : SITEUM,
3221			isGabia = (F_SERVICE.indexOf('gabia') > -1) ? true : false,
3222			login_type = (isGabia || F_VALIDTYPE=='SM' || (F_VALIDTYPE=='BN' && F_SITEUM > 0)) ? 'um' : 'mb';
3223
3224		$('.comment .error').remove();
3225
3226		var $input_id = $('#'+login_type+'_forum_id'),
3227			$input_password = $('#'+login_type+'_forum_password'),
3228			isSubmit = true,
3229			idErrorTxt = (isGabia || F_VALIDTYPE=='SM' || (F_VALIDTYPE=='BN' && F_SITEUM > 0)) ? $.lang[LANG]['config.enter-id'] : $.lang[LANG]['config.enter-email'];
3230
3231		if($input_id.val().length==0) {
3232			//$input_id.after('<label class="error">! ' +  $.lang[LANG]['config.enter-id'] + '</label>').focus();
3233			//$input_id.closest('.cl-s-form-wrap').addClass('empty');
3234			$input_id.closest('.cl-s-form-wrap').addClass('empty');
3235			$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>');
3236			isSubmit = false;
3237		}
3238
3239		if($input_password.val().length==0) {
3240			//$input_password.after('<label class="error">! ' +  $.lang[LANG]['config.enter-password'] + '</label>').focus();
3241			//$input_password.closest('.cl-s-form-wrap').addClass('empty');
3242			$input_password.closest('.cl-s-form-wrap').addClass('empty');
3243			$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>');
3244			isSubmit = false;
3245		}
3246
3247		modalEmptyCheck();
3248
3249		if($('.tab-pane.active .empty, .tab-pane.active .error').length > 0) {
3250			$('.tab-pane.active .empty').find('input').eq(0).focus();
3251			isSubmit = false;
3252			return false;
3253		}
3254
3255		if(isSubmit) {
3256			var sid = (typeof MODE == 'undefined') ? '' : SID; //config outlogin limit
3257			var login_success_fnc = function() {
3258				$('button.close').click();
3259				if(RELOAD) {
3260					// $.cookie('gallery','.' + F_PARENT.element, { path: '/' });
3261					location.reload();
3262				}
3263				if(typeof MODE == 'undefined') RENDER.setLoginout(property.LOGINOUT, property.SID, 1, property.PROFILEIMG);
3264				//forumWrite(id,pid);
3265			}
3266
3267			if(login_type == 'mb') {
3268				$.post('/member/login/outlogin', { mb_id : $input_id.val(), mb_password : $input_password.val(), sid : sid}, function(data) {
3269					if(typeof data.error != 'undefined' && data.error) {
3270						$('.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">
3270<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>');
3271						$('.cl-s-form-group input').val('');
3272						$('.tab-pane.active').find('.cl-s-form-wrap').addClass('empty');
3273						return false;
3274					}
3275					login_success_fnc();
3276				}, 'json');
3277
3278			} else {
3279
3280				var input_data = {
3281					'id' : $input_id.val().toLowerCase(),
3282					'password' : hex_md5($input_password.val()),
3283				};
3284
3285				$.post('/umember/login/in', { sid : sid, data : JSON.stringify(input_data) }, function(data) {
3286
3287					if (typeof data.result != 'undefined' && data.result == 'fail') {
3288						alert(data.message);
3289						return false;
3290					} else {
3291						$.umember.init();
3292						login_success_fnc();
3293
3294						if(typeof data.result != 'undefined' && data.result == 'success') {
3295							if(typeof data.ss_url != 'undefined' && data.ss_url) {
3296								$.each(data.ss_url, function(i,url) {
3297									$('.dsgn-body').after('<img class="auth-img" src="' + ss_url + '">');
3298								});
3299							}
3300
3301							if(typeof data.ga_uid != 'undefined' && data.ga_uid) {
3302								localStorage.setItem('googleAnalyticsUID'+sid, data.ga_uid);
3303							}
3304						}
3305					}
3306					/*
3307					if(typeof data.error != 'undefined' && data.error) {
3308						$.each(data.error, function(key,str) {
3309							if(forumLoginModal.find('#um_forum_'+key).length > 0 ) {
3310								forumLoginModal.find('#um_forum_'+key).after('<span class="error">' + str + '</span>');
3311							} else { 
3312								$('.comment-signForm').after("<label class='error text-center'>" + str + "</label>"); 
3313							}
3314						});
3315						if(forumLoginModal.find('.error').length > 0) return false;
3316					}
3317
3318					$.umember.init();
3319					login_success_fnc();
3320
3321					if(data.member.check_login) {
3322						if(typeof data.ss_url != 'undefined' && data.ss_url) {
3323							$.each(data.ss_url, function(i,url) {
3324								$('.dsgn-body').after('<img class="auth-img" src="' + ss_url + '">');
3325							});
3326						}
3327					}
3328					*/					
3329
3330				},'json');
3331
3332			}
3333		}
3334	});	
3335
3336	$doc.off('click', '[data-loop]:not(.sample-loop) .tpl-forum-list-name:not(.namemask)')
3337		.on('click', '[data-loop]:not(.sample-loop) .tpl-forum-list-name:not(.namemask)', function(e){
3338		e.stopPropagation();
3339		
3340		var parentEl = $(this).parents('.element');
3341		if(parentEl.attr('data-type') != 'forum' || parentEl.attr('data-type2') == 'guestbook') return false;
3342
3343		var userid = ($(this).attr('data-userid') !== undefined)? $(this).attr('data-userid') : '';
3344		var username = $(this).contents().filter(function() {
3345					return this.nodeType === 3; // 텍스트 노드만 선택
3346				}).text().trim();
3347		var langClass = (LANG == 'ko')? 'ko':'en';
3348		// console.log(userid);
3349		if($(this).hasClass('search-on')) {
3350			$('.tpl-forum-list-name').removeClass('search-on');
3351			$('.search-forum-user-posts').remove();
3352		} else {
3353			$('.tpl-forum-list-name').removeClass('search-on');
3354			$('.search-forum-user-posts').remove();
3355			$(this).addClass('search-on');
3356			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>';
3357
3358			var text = $(this).text().trim();
3359			var fontSize = parseFloat($(this).css("font-size"));
3360			
3361			var span = $('<span>').css({
3362				'display': 'inline-block',
3363				'font-family': $(this).css('font-family'),
3364				'font-size': fontSize + 'px',
3365				'font-weight': $(this).css('font-weight'),
3366				'visibility': 'hidden'
3367			}).text(text);
3368
3369			// 가상 요소를 body에 추가한 후, 너비를 가져오기
3370			$('body').append(span);
3371			var textWidth = parseFloat(span.width());
3372			// 가상 요소 삭제하기
3373			span.remove();
3374
3375			var textHeight = parseFloat($(this).css("line-height"));
3376			var height = $(this)[0].getBoundingClientRect().height;
3377			var width = $(this)[0].getBoundingClientRect().width;
3378			var translateX = (langClass == 'en')? 61 : 46;
3379
3380			var offset = $(this).offset();
3381			var parentOffset = parentEl.offset();
3382			var paddingTop = (height - $(this).height()) * 0.5;
3383			var paddingLeft = ($(this).is('td') || $(this).css('text-align') == 'center')? (width - textWidth) * 0.5 : (width - $(this).width()) * 0.5;
3384			if($(this).css('text-align') == 'right') paddingLeft = width - textWidth;
3385			if(paddingTop < 0) paddingTop = 0;
3386			if(paddingLeft < 0) paddingLeft = 0;
3387			
3388			var top = offset.top - parentOffset.top + paddingTop + textHeight + 5;
3389			var left = ($('.dsgn-body').hasClass('sidebar'))? offset.left + paddingLeft + textWidth*0.5 - parentOffset.left - translateX : offset.left + paddingLeft + textWidth*0.5 - translateX;
3390			// console.log(offset, parentOffset);
3391			parentEl.append(searchBox);
3392			$('.search-forum-user-posts').css({'top': top, 'left': left});
3393
3394			var $searchBtn = $('.search-forum-user-posts');
3395			if($('.dsgn-body').hasClass('sidebar')) {
3396				if($searchBtn.offset().left < parentOffset.left) {
3397					left = 0;
3398					$searchBtn.css({'top': top, 'left': left});
3399				}
3400			} else {
3401				if($searchBtn.offset().left < 0) {
3402					left -= $searchBtn.offset().left;
3403					$searchBtn.css({'top': top, 'left': left});
3404				}
3405			}
3406			if($('header .navbar-toggle').css('display') == 'block' && ($searchBtn.offset().left + $searchBtn.width() > $('.dsgn-body').width())) {
3407				left = $('.dsgn-body').width() - $searchBtn.width();
3408				$searchBtn.css({'top': top, 'left': left});
3409			}
3410		}
3411	});
3412
3413	$(document).on('click','.forum-type-btn',function(e) {
3414		if($(this).parents('.element').attr('data-type') != 'forum') return false;
3415		e.preventDefault();
3416
3417		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
3418		var typeCheck = $(this).attr('data-type'),
3419			$elementCheck = $(this).parents('.element');
3420
3421		if($elementCheck.attr('data-list-type') == typeCheck) return false;
3422		
3423		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
3424		var data_sfl = $(this).parents('.search-box').find('#sfl').val(),
3425			data_stx = '',
3426			data_scate = getForumScate($elementCheck),
3427			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
3428			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
3429			data_page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
3430			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
3431		
3432		var F_PARENT = (typeof PARENT == 'undefined') ? property.PARENT : PARENT;
3433			F_ONE = (typeof ONE == 'undefined') ? property.ONE : ONE;
3434			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
3435			F_PAGE = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
3436
3437		var page_num = (typeof data_page_num != 'undefined' && data_page_num) ? data_page_num : -1,
3438			sfl = (typeof data_sfl == 'undefined') ? 'all' : data_sfl, 
3439			stx = (typeof data_stx == 'undefined') ? '' : data_stx,
3440			scate = (typeof data_scate == 'undefined') ? '' : data_scate;
3441
3442			if(page_num < 0) {
3443				page_num = (typeof $.cookie('forum_'+id) != 'undefined' && $.cookie('forum_'+id)) ? $.cookie('forum_'+id) : 1;
3444				$.removeCookie('forum_'+id,{path:'/'});
3445			}
3446			if(!stx) stx = getForumPrevStx(id);
3447			if(sfl=='all' && typeof $.cookie('forum_'+id+'_sfl') != 'undefined') sfl = $.cookie('forum_'+id+'_sfl');
3448			if(!scate && typeof $.cookie('forum_'+id+'_scate') != 'undefined') scate = $.cookie('forum_'+id+'_scate');
3449			$.forum.setForumCookie(id,page_num,stx,sfl,scate);
3450			cookie_page_num = $.cookie('forum_'+id);
3451			$.cookie('forum_'+id+'_type', typeCheck);
3452
3453			$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
3454			activeEL('userEL'+id);
3455
3456			// fmID = id;
3457   //          $.ajax({
3458   //              url: '/fm/lists/pid/' + id + '/sid/' + F_SID + '/page/' + F_PAGE + '/view/' + view + '/page_num/' + page_num,
3459   //              dataType: 'json',
3460   //              type: 'POST',
3461   //              data: { sfl: sfl, stx: stx, scate: scate},
3462   //              async: false,
3463   //              cache: false,
3464   //              success: function (data) {
3465   //              	if(typeof data.error != 'undefined' && data.error) {
3466   //              		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
3467   //              		return false;
3468   //              	}
3469			// 		displayTypeForum(data,$elementCheck,typeCheck,view,page_num,id);
3470   //      		}
3471
3472   //          });
3473	});
3474
3475	$('.tpl-forum-my').live('click', function(e) {
3476		if($(this).parents('.element').attr('data-type') != 'forum') return false;
3477		e.preventDefault();
3478		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
3479		
3480		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
3481		var umember = (PAGE_MODE == 'c') ? UMEMBER : property.UMEMBER,
3482			sfl ='mb_id',
3483			stx = umember.id,
3484			scate = getForumScate($(this).parents('.element')),
3485			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
3486			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
3487			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
3488			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
3489
3490		$.forum.setForumCookie(id,page_num,stx,sfl,scate);
3491		cookie_page_num = $.cookie('forum_'+id);
3492		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
3493		activeEL('userEL'+id);
3494	});
3495
3496	$.forum = {
3497		modoo_loop_card : `
3498			<div class="table" data-loop="true">
3499				<div class="col-xs-12 col-sm-6 col-md-4 item">
3500	                <div class="item-inner op_itemline10">
3501	                    <div class="thumb-wrap">
3502	                        <div class="tpl-forum-list-thumb">
3503	                            <img src="//storage.googleapis.com/i.addblock.net/sample/forum_thumb_4_1.jpg" class="img-responsive">
3504	                        </div>
3505	                        <div class="tpl-forum-list-num"><i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i></div>
3506	                    </div>
3507	                    <div class="cont-wrap">
3508	                        <div class="tpl-forum-list-content">
3509	                            <span class="tpl-forum-list-title" data-selector=".tpl-forum-list-title" data-font="true" data-title="title font">작업의 페이지 및 모든 프로세스에 대해 궁금한 점, 질문 드립니다.</span>
3510	                        </div>
3511	                        <div class="tpl-forum-list-cont" data-selector=".tpl-forum-list-cont" data-font="true" data-title="content font">항상 배우는 마음으로 보고 있습니다. 이번 프로젝트도 꼭 따라해보고 싶어요. 프로젝트를 보면서 디자인에 궁금한 점이 있습니다. 프로젝트 작업하실 때 주로 어디서 영감을 얻으시나요?</div>
3512	                        <ul>
3513	                            <div>
3514	                            <li class="tpl-forum-list-name tpl-forum-list-etc">데이비드 제임스</li>
3515	                            <li class="tpl-forum-list-date tpl-forum-list-etc">방금 전</li>
3516	                            </div>
3517	                            <div>
3518	                            <li class="tpl-forum-list-comment tpl-forum-list-etc">25</li>
3519	                            </div>
3520	                        </ul>
3521	                        <ul>
3522	                            <li class="tpl-forum-list-category tpl-forum-list-etc">카테고리</li>
3523	                            <li class="tpl-forum-list-hit tpl-forum-list-etc">1486</li>
3524	                            <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>
3525	                        </ul>
3526	                    </div>
3527	                </div>
3528	            </div>
3529            </div>
3530		`,
3531		modoo_loop_list : `
3532			<table class="table">
3533				<thead>
3534					<tr class="thead-bottom-line tpl-forum-header-row" data-selector=".tpl-forum-header-row" data-font="true" data-title="header row font">
3535						<th class="ntpl-forum-num tpl-forum-num tpl-forum-header-row">no</th>
3536						<th class="ntpl-forum-category tpl-forum-category tpl-forum-header-row">카테고리</th>
3537						<th class="ntpl-forum-content tpl-forum-content tpl-forum-header-row">제목</th>
3538						<th class="ntpl-forum-name tpl-forum-name tpl-forum-header-row">작성자</th>
3539						<th class="ntpl-forum-date tpl-forum-date tpl-forum-header-row">작성일</th>
3540						<th class="ntpl-forum-hit tpl-forum-hit tpl-forum-header-row">조회수</th>
3541						<th class="ntpl-forum-like tpl-forum-like tpl-forum-header-row">좋아요</th>
3542					</tr>
3543				</thead>
3544				<tbody data-loop="true">
3545					<tr class="op_itemline10">
3546						<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>
3547						<td class="tpl-forum-list-category tpl-forum-list-etc config-font-etc">카테고리</td>
3548						<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>
3549						<td class="tpl-forum-list-name tpl-forum-list-etc config-font-etc">작성자</td>
3550						<td class="tpl-forum-list-date tpl-forum-list-etc config-font-etc">방금 전</td>
3551						<td class="tpl-forum-list-hit tpl-forum-list-etc config-font-etc">50</td>
3552						<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>
3553					</tr>
3554				</tbody>
3555			</table>
3556		`,
3557		init : function(id, page, view, page_num, sfl, stx, scate) {
3558			F_PARENT = (typeof PARENT == 'undefined') ? property.PARENT : PARENT;
3559			F_ONE = (typeof ONE == 'undefined') ? property.ONE : ONE;
3560			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
3561			F_PAGE = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
3562
3563			// var page_num = (typeof page_num == 'undefined' || page_num == 'NaN') ? 1 : page_num,
3564			var page_num = (typeof page_num != 'undefined' && page_num) ? page_num : -1,
3565				sfl = (typeof sfl == 'undefined') ? 'all' : sfl, 
3566				stx = (typeof stx == 'undefined') ? '' : stx,
3567				scate = (typeof scate == 'undefined') ? '' : scate;
3568
3569			if(page_num < 0) {
3570				page_num = (typeof $.cookie('forum_'+id) != 'undefined' && $.cookie('forum_'+id)) ? $.cookie('forum_'+id) : 1;
3571				$.removeCookie('forum_'+id,{path:'/'});
3572				$.removeCookie('forum_'+id+'_type');
3573			}
3574
3575			if(!stx) stx = getForumPrevStx(id);
3576			if(sfl=='all' && typeof $.cookie('forum_'+id+'_sfl') != 'undefined') sfl = $.cookie('forum_'+id+'_sfl');
3577			if(!scate && typeof $.cookie('forum_'+id+'_scate') != 'undefined') scate = $.cookie('forum_'+id+'_scate');
3578			$.forum.setForumCookie(id,page_num,stx,sfl,scate);
3579			
3580			fmID = id;
3581            $.ajax({
3582                url: '/fm/lists/pid/' + id + '/sid/' + F_SID + '/page/' + F_PAGE + '/view/' + view + '/page_num/' + page_num,
3583                dataType: 'json',
3584                type: 'POST',
3585                data: { sfl: sfl, stx: stx, scate: scate},
3586                async: false,
3587                cache: false,
3588                success: function (data) {
3589                	if(typeof data.error != 'undefined' && data.error) {
3590                		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
3591                		return false;
3592                	}
3593
3594					$.forum.set(id,page_num,view,F_PAGE,sfl,stx,scate,data);
3595                }
3596            });
3597		},
3598		update_ver1 : function(id,page_num,view,page,sfl,stx,scate,data) {
3599			var modoo_login_check;
3600        	var source = (typeof data.source == 'undefined') ? '' : data.source;
3601        	var $source = $(htmlspecialchars_decode(source)),
3602        		type = (typeof $source.attr('data-forum-type') == 'undefined' || !$source.attr('data-forum-type')) ? '' : $source.attr('data-forum-type'),
3603	        	elsetting = (typeof data.elsettings != 'undefined' && data.elsettings) ? $.parseJSON(data.elsettings) : {};
3604
3605        	if(elsetting.forum_type == 'modoo') {
3606        		//모두 게시판 source 교체
3607				var $loopElement,
3608					data_view = $source.find('[data-loop="true"]').attr('data-view');
3609				if(typeof $.cookie('forum_'+id+'_type') != 'undefined' && $.cookie('forum_'+id+'_type') == 'card' ||
3610					typeof $.cookie('forum_'+id+'_type') == 'undefined' && $source.attr('data-list-type') == 'card') {
3611					$loopElement = $source.clone();
3612					$loopElement.find('.table-container').empty().append($.forum.modoo_loop_card);
3613					$loopElement.find('[data-loop="true"]').attr('data-view',data_view);
3614					$source = $loopElement;
3615					type = 'thumb';
3616				} else {
3617					if(typeof $.cookie('forum_'+id+'_type') != 'undefined' && $.cookie('forum_'+id+'_type') == 'list' && $source.find('table.table').length < 1) {
3618						$loopElement = $source.clone();
3619						$loopElement.find('.table-container').empty().append($.forum.modoo_loop_list);
3620						$loopElement.find('[data-loop="true"]').attr('data-view',data_view);
3621						$source = $loopElement;
3622					}
3623				}
3624				$source.find('.forum-title').empty().text(elsetting.forum_block_title);
3625				modoo_login_check = (PAGE_MODE != 'c') ? property.UMEMBER.check_login : true;
3626
3627				if(!modoo_login_check) $source.find('.tpl-forum-my').css('visibility','hidden');
3628			}
3629
3630        	var $first = (type == 'qna') ? $source.find('[data-loop="true"]').children('.qna-item').eq(0).clone() : $source.find('[data-loop="true"]').children().eq(0).clone(),
3631        		F_SID = (typeof SID == 'undefined') ? property.SID : SID,
3632	        	F_VALIDPLAN = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN,
3633	        	F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE;
3634        	var field_lang = (typeof elsetting.field_lang != 'undefined') ? elsetting.field_lang : (typeof elsetting.blocklang != 'undefined' && elsetting.blocklang ? elsetting.blocklang : LANG);
3635        	var is_templates = checkTemplateSite(F_SID);
3636        	if($.inArray(type, ['qna', 'faq', 'guestbook']) == -1 && F_VALIDPLAN && $first.find('.tpl-forum-list-like').length == 0) {
3637				if((elsetting.like_display != undefined && elsetting.like_display == 'ON') || (elsetting.likeComment_display != undefined && elsetting.likeComment_display == 'ON')) {
3638					if($source.find('table').length > 0) { //table
3639						if($source.find('thead').length > 0) { //thead
3640							$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>');
3641		        			$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>');
3642		        			if(data.total == 0) {
3643		        				$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>');
3644		        			}
3645		        		} else {
3646		        			$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>');
3647		        			if(data.total == 0) {
3648		        				$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>');
3649		        			}
3650		        		}
3651					} else {
3652						if(data.total == 0) {
3653							$source.find('.item ul').each(function(idx, v){
3654								if($(v).find('.tpl-forum-list-like').length > 0) return true;
3655								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>');
3656								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>');
3657							});
3658
3659							$source.find('.b_txt ul').each(function(idx, v){
3660								if($(v).find('.tpl-forum-list-like').length > 0) return true;
3661								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>');
3662								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>');
3663							});
3664						}
3665					}
3666				}
3667			}
3668
3669        	var first_html = $first.prop('outerHTML'),
3670        		$bbs = $('.element[data-id="' + id + '"]');
3671
3672        	var d = document.createElement('div');
3673        	$(d).html(first_html);
3674
3675			$source.find('thead tr th').each(function() {
3676				var field_text = (typeof $(this).attr('class') != 'undefined') ? $(this).attr('class') : 'tpl-forum-title';
3677				if(field_text.indexOf('ntpl') > -1) field_text = field_text.split(' ')[1];  //게시판 폰트설정 -  기존, 새 코드 블럭 구분
3678
3679				if(field_text.indexOf('title') > -1 || field_text.indexOf('content') > -1) $(this).text($.lang[field_lang.toLowerCase()]['forum.field.tpl-forum-title']);
3680				else $(this).text($.lang[field_lang.toLowerCase()]['forum.field.' + field_text]);
3681				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']);
3682			});
3683
3684			if($source.find('tr.tpl-forum-header-row').length > 0) {
3685				var checkHeaderOnlyTitle = ($source.find('tr.tpl-forum-header-row th:not(.hide)').length === 1) ? true : false;
3686				if(checkHeaderOnlyTitle) $source.find('tr.tpl-forum-header-row').addClass('hide');
3687				else $source.find('tr.tpl-forum-header-row').removeClass('hide');
3688			}
3689			var answer	= (type == 'qna') ? $source.find('[data-loop="true"]').children('.qna-details').eq(0).clone().prop('outerHTML') : '';
3690
3691			var loop = $(d).html() + '\
3692    				'+ answer;
3693    		$(d).remove();
3694        	$bbs.html($source.html());
3695
3696        	var	$row = $bbs.find('[data-loop="true"]'),
3697        		$pagination = $bbs.find('.tpl-forum-pagination'),
3698        		$write = $bbs.find('.tpl-forum-write').attr('data-pid',id),
3699        		css_id = $bbs.attr('data-el'),
3700        		block_lang = ($bbs.attr('data-blocklang')) ? $bbs.attr('data-blocklang') : LANG;
3701
3702        	var data_el = $bbs.attr('data-el');
3703
3704        	if(data.total > 0) {
3705				$bbs.find('[data-loop="true"]').removeClass('sample-loop');
3706           		$row.html('');
3707
3708				if(typeof elsetting.forum_type !== "undefined" && elsetting.forum_type == "modoo") {
3709					var typeCookieCheck;
3710					if(typeof $.cookie('forum_'+id+'_type') == 'undefined') typeCookieCheck = $source.attr('data-list-type');
3711						else typeCookieCheck = $.cookie('forum_'+id+'_type');
3712						
3713		    		if(typeCookieCheck == 'list') {
3714		    			$bbs.attr('data-list-type','list');
3715		    			$bbs.attr('data-msny', false);
3716		    		} else if(typeCookieCheck == 'card') {
3717		    			$bbs.attr('data-list-type','card');
3718		    			$bbs.attr('data-msny', true);
3719		    		}
3720				}
3721
3722                // if(typeof elsetting.forum_type !== "undefined" && elsetting.forum_type == "modoo") {
3723                //     if($source.attr('data-list-type') == 'card') {
3724                //         displayTypeForum(data,$source,'card',view,page_num,id);
3725                //         return false;
3726                //     }
3727                // }
3728
3729				if(data.total<=((view*page_num)-view)) {
3730					page_num = page_num-1;
3731					if(page_num==0) page_num=1;
3732				}
3733
3734        		$.each(data.list, function(i,v) {
3735        			var num = data.total - (view * (page_num-1)) - i;
3736					$row.append(forumRow(v, num, page_num, id, loop, data.config, type, $source));
3737        		});
3738
3739			}
3740
3741        	var field_disable = getOrDefault(elsetting,'field_disable',[]),
3742				check_faq = (type == 'faq' && $(d).find('.tpl-forum-list-content .inner-box').length > 0) ? true : false;
3743        	if(check_faq) {
3744        		if($.inArray('name',field_disable) > -1 && $.inArray('date',field_disable) > -1) {
3745					$bbs.find('[data-loop="true"] .tpl-forum-list-name').removeClass('removeBar');
3746				} else if($.inArray('date',field_disable) > -1) {
3747					$bbs.find('[data-loop="true"] .tpl-forum-list-name').addClass('removeBar');
3748				}
3749			}
3750
3751		},
3752		view : function(id) {
3753		    var deferred = $.Deferred();
3754			F_PARENT = (typeof PARENT == 'undefined') ? property.PARENT : PARENT;
3755			F_ONE = (typeof ONE == 'undefined') ? property.ONE : ONE;
3756			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
3757			F_PAGE = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
3758			F_VIEW = id;
3759
3760			var ps_forumview = forumView(id);
3761			ps_forumview.done(function(data) {
3762				setForumWrap();
3763				if(typeof MODE != 'undefined' && (MODE=='config' || MODE=='demo')) displayComment(data);
3764
3765				deferred.resolve(data);
3766			}).fail(function(error_msg) {
3767				deferred.reject(error_msg);
3768
3769				if(error_msg == 404) show404();
3770			});
3771
3772		    return deferred.promise();
3773		},
3774		delete : function(id) {
3775			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
3776				if(typeof data.error != 'undefined' && data.error) {
3777					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
3778					return false;
3779				}
3780				if(data.fmid && data.sign == false) {
3781					userLogin();
3782					return false;
3783				}
3784				if(data.comment_count > 0) {
3785					$(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');
3786					return false;
3787				}
3788
3789
3790				if(data.sign == false) {
3791					var passwordModal = $(this).showModalFlat($.lang[LANG]['board.button.delete.password'],passwdForm(),true,true,function() {
3792						var $pass = $('#comm-pass'),
3793							isSubmit = true,
3794							userInput = $pass.val();
3795						$('label.error').remove();
3796						if($pass.val().length<4) {
3797							//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
3798							$pass.closest('.cl-s-form-wrap').addClass('error');
3799							$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>');
3800							$pass.focus();
3801							isSubmit = false;
3802						}
3803
3804						if(isSubmit) {
3805							//$('.comment-addform.password').parent().find('.error').remove();
3806							$.post('/fm/password',{ id: id, passwd : hex_md5($pass.val()) }, function(data) {
3807								if(typeof data.error != 'undefined' && data.error) {
3808									//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
3809									$pass.closest('.cl-s-form-wrap').addClass('error');
3810									$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>');
3811									return false;
3812								}
3813								var date = new Date(),
3814									cookietime = 20 * 60 * 1000;
3815					            date.setTime(date.getTime() + cookietime);
3816
3817								$.cookie('hash', data.hash, { path: '/' , expires: date});
3818								$('.modal[id*=flat-modal]').modal('hide');
3819								resetObject(user);
3820								user.pass = hex_md5($pass.val());
3821								if(data.fm_type && data.fm_type == 'qna' ) {
3822									deleteForumPost(id);
3823								} else {
3824									var modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {			
3825									deleteForumPost(id);
3826									modal.modal('hide');												
3827									}, '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');												
3828								}
3829
3830								passwordModal.modal('hide');
3831							},'json');
3832						}
3833						modalEmptyCheck();
3834					},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password');
3835				} else if(data.own == true || data.mgr == true) {
3836					if(data.fm_type && $.inArray(data.fm_type, ['qna','faq']) > -1) {
3837						deleteForumPost(id);
3838					} else {
3839						var modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {			
3840						deleteForumPost(id);
3841						modal.modal('hide');												
3842						}, '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');												
3843					}
3844				} else {
3845					 alert( $.lang[LANG]['board.not-own-no-delete'] );
3846				}
3847			}, 'json');
3848		},
3849		deleteGuestbook : function(pid, id) {
3850			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
3851				if(typeof data.error != 'undefined' && data.error) {
3852					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
3853					return false;
3854				}
3855				if(data.fmid && data.sign == false) {
3856					userLogin();
3857					return false;
3858				}
3859
3860				if(data.sign == false) {
3861					var passwordModal = $(this).showModalFlat($.lang[LANG]['guestbook.button.delete.password'],passwdForm(),true,true,function() {
3862						var $pass = $('#comm-pass'),
3863							isSubmit = true,
3864							userInput = $pass.val();
3865						$('label.error').remove();
3866						if($pass.val().length<4) {
3867							//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
3868							$pass.closest('.cl-s-form-wrap').addClass('error');
3869							$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>');
3870							$pass.focus();
3871							isSubmit = false;
3872						}
3873
3874						if(isSubmit) {
3875							//$('.comment-addform.password').parent().find('.error').remove();
3876							$.post('/fm/password',{ id: id, passwd : hex_md5($pass.val()) }, function(data) {
3877								if(typeof data.error != 'undefined' && data.error) {
3878									//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
3879									$pass.closest('.cl-s-form-wrap').addClass('error');
3880									$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>');
3881									return false;
3882								}
3883								var date = new Date(),
3884									cookietime = 20 * 60 * 1000;
3885					            date.setTime(date.getTime() + cookietime);
3886
3887								$.cookie('hash', data.hash, { path: '/' , expires: date});
3888								$('.modal[id*=flat-modal]').modal('hide');
3889								resetObject(user);
3890								user.pass = hex_md5($pass.val());
3891								deleteGuestbook(pid, id);
3892								passwordModal.modal('hide');
3893							},'json');
3894						}
3895						modalEmptyCheck();
3896					},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
3897						passwordModal.find('#comm-pass').addClass('guestbook-pass');
3898					});
3899				} else if(data.own == true || data.mgr == true) {
3900					deleteGuestbook(pid, id);
3901				} else {
3902					 alert( $.lang[LANG]['board.not-own-no-delete'] );
3903				}
3904			}, 'json');
3905		},
3906		setForumCookie : function(id,page_num,stx,sfl,scate) {
3907			// Recent  forum only
3908			// var cookies = $.cookie();
3909			// for(var cookie in cookies) {
3910			// 	if( cookie.indexOf($.cookie('forum')) == -1 && cookie.indexOf('forum') > -1) {
3911			// 		$.removeCookie(cookie);
3912			// 	}
3913			// }
3914			// console.log('setForumCookie', id,page_num,stx,sfl,scate);
3915			var prev_sfl = (typeof $.cookie('forum_'+id+'_prev_sfl') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_sfl'),
3916				prev_stx = (typeof $.cookie('forum_'+id+'_prev_stx') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_stx'),
3917				prev_scate = (typeof $.cookie('forum_'+id+'_prev_scate') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_scate'),
3918				change_stx = (prev_stx != stx) ? true : false,
3919				change_sfl = (prev_sfl != sfl && stx.length > 0) ? true : false,
3920				change_scate = (prev_scate != scate) ? true : false;
3921			if(change_stx || (!change_stx && (change_sfl || change_scate))) page_num = 1;
3922			// console.log(prev_sfl, prev_stx, prev_scate);
3923			// console.log(change_stx, change_sfl, change_scate, page_num);
3924			$.cookie('forum',id,{path:'/'});
3925			$.cookie('forum_'+id, page_num,{path:'/'});
3926			if(typeof stx != 'undefined' && stx) {
3927				$.cookie('forum_'+id+'_sfl',sfl,{path:'/'});
3928				$.cookie('forum_'+id+'_stx',stx,{path:'/'});
3929			} else {
3930				$.removeCookie('forum_'+id+'_stx',{path:'/'});
3931			}
3932
3933			if(typeof scate != 'undefined' && scate) {
3934				$.cookie('forum_'+id+'_scate',scate,{path:'/'});
3935			} else {
3936				$.removeCookie('forum_'+id+'_scate',{path:'/'});
3937			}
3938
3939			// console.log($.cookie('forum_'+id+'_sfl'), $.cookie('forum_'+id+'_stx'), $.cookie('forum_'+id));
3940			if(stx || sfl) {
3941				$.cookie('forum_'+id+'_prev_sfl', sfl, {path:'/'});
3942				if(stx) {
3943					$.cookie('forum_'+id+'_prev_stx', stx, {path:'/'});
3944				} else {
3945					$.removeCookie('forum_'+id+'_prev_stx', {path:'/'});
3946				}
3947				$.cookie('forum_'+id+'_prev_scate', scate, {path:'/'});
3948			} else {
3949				$.removeCookie('forum_'+id+'_prev_sfl', {path:'/'});
3950				$.removeCookie('forum_'+id+'_prev_stx', {path:'/'});
3951				$.removeCookie('forum_'+id+'_prev_scate', {path:'/'});
3952			}
3953		},
3954		setDefaultConfig : function(config) {
3955			var defaultConfig = {
3956				group 			: '',
3957				write_level 	: (PLAN || SERVICE.indexOf('gabia') > -1) ? 'NM' : 'M',
3958				reply_level		: (PLAN || SERVICE.indexOf('gabia') > -1) ? 'NM' : 'A',
3959				view_level		: 'A',
3960				list_level		: 'A',
3961				modify			: 0,
3962				delete 			: 0,
3963				page_row		: 10,
3964				secret_display	: 'U',
3965				comment_display : 'OFF',
3966				secretComment_display: 'U',
3967				sns_share_display	: 'OFF',
3968				bottomlist_display	: 'OFF',
3969				forum_count		: 0,
3970				comment_count	: 0,
3971				field_lang		: 'en',
3972				field_disable	: [],
3973				searchbox_display : 'ON',
3974				writebtn_display : 'ON',
3975				forum_category_type : 'dropdown',
3976			}
3977			if(config==null) config = defaultConfig;
3978			$.each(defaultConfig, function(k,v) {
3979				if(typeof config[k] == 'undefined') config[k] = v;
3980			});
3981			return config;
3982		},
3983		groupconfig : function(id) {
3984			$('.config-modal').remove();
3985
3986			if(typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == id) {
3987				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'); 
3988			} else {
3989				$.post('/fm/config', { id : id }, function(data) {
3990					if(typeof data.error != 'undefined' && data.error) {
3991						$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
3992						return false;
3993					}
3994					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'); 
3995				},'json');
3996			}
3997		},
3998		getgroupdata : function(id) {
3999			if(typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == id) {
4000				str = '', groups = bc_fr.group;
4001				for(var i=0; i<groups.length; i++) {
4002					str = str + getGroupList(groups[i].id, groups[i].name, groups[i].member_count);
4003				}
4004				$('#group-accordion').html(str);
4005			} else {
4006				$.post('/fm/config', { id : id }, function(data) {
4007					if(typeof data.error != 'undefined' && data.error) {
4008						return false;
4009					}
4010					str = '', groups = data.group;
4011					for(var i=0; i<groups.length; i++) {
4012						str = str + getGroupList(groups[i].id, groups[i].name, groups[i].member_count);
4013					}
4014					$('#group-accordion').html(str);
4015				},'json');
4016			}
4017		},
4018		getGroupNameList : function(fid) {
4019			var str = '';
4020			if(typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == fid) {
4021				groups = bc_fr.group;
4022				for(var i=0; i<groups.length; i++) {
4023					str = str + '<option value="' + groups[i].name + '" data-id="' + groups[i].id + '" data-member-count="' + groups[i].member_count + '">' + groups[i].name + '</option>';
4024				}
4025				return str;
4026			} else {
4027				$.post('/fm/config', { id : fid }, function(data) {
4028					if(typeof data.error != 'undefined' && data.error) {
4029						return false;
4030					}				
4031					groups = data.group;
4032					for(var i=0; i<groups.length; i++) {
4033						str = str + '<option value="' + groups[i].name + '" data-id="' + groups[i].id + '" data-member-count="' + groups[i].member_count + '">' + groups[i].name + '</option>';
4034					}
4035					return str;
4036				}, 'json');
4037			}
4038		},
4039		setfile : function (file,file_name,orig_name) {
4040			var $file = $('<div class="result-file" data-file="' + file + '" data-file-name="' + file_name + '">'),
4041				$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>');
4042				$del = $('<span class="file-delete hand"><i class="fa fa-times"></i></span>');
4043
4044			$file.append($result).append($del);
4045			$file.appendTo('.upload-files');
4046			
4047			$('#fm-editor').froalaEditor('selection.restore');
4048
4049			if(upTYPE == 'image') {
4050				if(isReplace == true) editorImageReplace('http:' + file, orig_name);
4051				else $('#fm-editor').froalaEditor('image.insert', 'http:' + file, true);
4052			} else $('#fm-editor').froalaEditor('file.insert', 'http:' + file, orig_name, { 'link' : 'http:' + file, 'target': '_blank' });
4053		},
4054		drawSelboxCategory : function(sel_replace,pid) {
4055			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
4056
4057			var str = '',
4058				block_lang = ($(sel_replace).attr('data-blocklang')) ? $(sel_replace).attr('data-blocklang') : LANG,
4059				block_content = (typeof SID == 'undefined') ? property.CONTENTS['el'+pid] : {};
4060
4061			if(block_content === undefined || block_content.category === undefined) {
4062				$.ajax({
4063	                url: '/fm/category/list',
4064	                dataType: 'json',
4065	                type: 'POST',
4066	                data: { pid: pid, sid: F_SID },
4067	                async: true,
4068	                cache: false,
4069	                success: function (list_data) {
4070						if(typeof list_data.error != 'undefined' && list_data.error) {
4071							$(this).showModalFlat('ERROR',list_data.error,true,false,'','ok');
4072							return false;
4073						}
4074						displayCategoryHtml(pid,list_data,sel_replace,block_lang);
4075					}
4076				});
4077			} else displayCategoryHtml(pid,block_content.category,sel_replace,block_lang);
4078		},
4079		callOpenForumCategoryConfig : function(pid) {
4080			openForumCategoryConfig(pid);
4081		},
4082		set : function(id,page_num,view,page,sfl,stx,scate,data) {
4083			var F_SID = (typeof SID == 'undefined') ? property.SID : SID,
4084				F_VALIDPLAN = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN,
4085				F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE;
4086
4087			var _fu = {
4088				pid: id,
4089				sid: F_SID,
4090				validplan: F_VALIDPLAN,
4091				validtype: F_VALIDTYPE,				
4092				elname: data.elname,
4093				eltag: (typeof data.source == 'undefined') ? '' : data.source,
4094				elcss: (typeof data.css != 'undefined') ? CSSJSON.toJSON(htmlspecialchars_decode(data.css)) : CSSJSON.toJSON(),
4095				elsettings: (typeof data.elsettings != 'undefined' && data.elsettings) ? $.parseJSON(data.elsettings) : {},
4096				config: (typeof data.config != 'undefined' && data.config) ? data.config : {},
4097				check: {
4098					templateview: (window.location != window.parent.location) ? true : false,
4099					demo: data.demo,
4100					notsupported: false,
4101				},
4102			};
4103
4104			_fu.elstyle =  style.get(_fu.elcss,`.${_fu.elname}`);
4105			_fu.sampleEL =  $(htmlspecialchars_decode(_fu.eltag));
4106			_fu.blockEL = $(`.element[data-id="${id}"]`);
4107
4108			_fu.el = _fu.blockEL.attr('data-el');
4109			_fu.elname = _fu.blockEL.attr('data-name');
4110			_fu.eltype = _fu.blockEL.attr('data-type');
4111			_fu.eltype2 = _fu.blockEL.attr('data-type2');
4112			_fu.elmsny = _fu.blockEL.is('[data-msny="true"]');
4113			_fu.field_lang = (_fu.elsettings.field_lang || _fu.elsettings.blocklang || LANG).toLowerCase();
4114			_fu.block_lang = (_fu.elsettings.blocklang || LANG).toLowerCase();
4115
4116        	if(!checkTemplateSite(F_SID) 
4117				&& (!F_VALIDPLAN || F_VALIDTYPE == 'PK') 
4118				&& $.inArray(_fu.eltype2, ['qna', 'faq']) > -1
4119			) {
4120				_fu.check.notsupported = true;
4121				if(PAGE_MODE != 'c') {
4122					_fu.blockEL.empty().addClass('hide');
4123					return false;
4124				}
4125			}
4126
4127			if(_fu.elcss === CSSJSON.toJSON()) {
4128				if(typeof data.msg == 'undefined') _fu.blockEL.empty().addClass('hide');
4129			} else {
4130				_fu.blockEL.removeClass('hide');
4131				$(`#${_fu.el}css`).text(data.css);
4132			}
4133
4134			var $current_category_nav = getForumCategoryNav(_fu.blockEL).first().clone();
4135
4136			initForumField(_fu.sampleEL);
4137			_fu.sampleEL.find('.tpl-forum-category-nav').remove();
4138			_fu.sampleEL.find('#scate option:not(:first)').remove();
4139			_fu.sampleEL.find('#scate').val('');
4140			_fu.blockEL.html(_fu.sampleEL.html()).attr('data-init',true);
4141			_fu.blockEL.attr('data-forum-category-type', getForumCategoryType(_fu.elsettings));
4142			_fu.blockEL.removeAttr('data-forum-category-sticky');
4143			_fu.blockEL.attr('data-gcate-style', getForumCategoryStyle(_fu.blockEL));
4144			if(getForumCategoryType(_fu.elsettings) == 'list' && $current_category_nav.length > 0) {
4145				placeForumCategoryNav(_fu.blockEL, $current_category_nav);
4146				if(typeof scate != 'undefined') setForumCategoryActive(_fu.blockEL, scate);
4147				syncForumCategoryTypeDisplay(_fu.blockEL);
4148			}
4149			_fu.blockLoop = _fu.blockEL.find('[data-loop="true"]');
4150
4151			if(_fu.check.notsupported) $.notSupported.set(F_SID, id, _fu.eltype2, true);
4152
4153			if(_fu.eltype2) _fu.blockEL.attr('data-forum-type',_fu.eltype2);
4154			else _fu.blockEL.removeAttr('data-forum-type');
4155
4156			// [data-ver="1"] add default init root css 
4157			if(_fu.blockEL.length > 0) {
4158				if(getOrDefault(_fu.elstyle,'__forum_color','') == '') {
4159					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');
4160					if($.inArray(forum_color, ['black','white']) > -1) forum_color = (forum_color == 'black') ? '#191919' : '#ffffff';
4161					_fu.blockEL.attr('data-fcolor',forum_color);
4162
4163					if(document.querySelector(`.${_fu.elname}`)) {
4164						document.querySelector(`.${_fu.elname}`).style.setProperty('--forum-color', forum_color, null);
4165						document.querySelector(`.${_fu.elname}`).style.setProperty('--forum-color-rgb', Coloris.getChangeColorVal(forum_color,'rgb_str'), null);
4166						document.querySelector(`.${_fu.elname}`).style.setProperty('--searchbox-option-color', forum_color, null);
4167						document.querySelector(`.${_fu.elname}`).style.setProperty('--searchbox-option-bgcolor', _fu.blockEL.css('background-color'), null);
4168					}
4169				}
4170				if(_fu.blockEL.is('[data-fcolor]')) _fu.blockEL.attr('data-ver','1');
4171			}
4172
4173			if(data.total == 0) {
4174        		if(data.msg) {
4175        			RELOAD = true;
4176        			if(data.sign == false) _fu.blockEL.find('.tpl-forum-write').text($.lang[_fu.field_lang]['config.comment.login-modal']);
4177        		}
4178
4179				if(!_fu.check.templateview 
4180					&& !_fu.check.demo
4181					&& (typeof MODE == 'undefined' || typeof $.cookie(`forum_${id}_stx`) != 'undefined' || typeof $.cookie(`forum_${id}_scate`) != 'undefined')
4182				) {
4183					if(data.msg) _fu.blockEL.find('.search-box').addClass('hide');
4184					_fu.blockEL.find('.table thead').addClass('hide');
4185
4186					var msg = data.msg;
4187					if (msg && /<br\s*\/?>/i.test(msg)) {
4188						msg = msg.replace(/<br\s*\/?>/gi, '\n');   // 개행 처리
4189						_fu.blockLoop.addClass('has-multiline-desc');
4190					}					
4191
4192					_fu.blockLoop.empty().attr('data-description',msg ? msg : $.lang[_fu.block_lang]['board.no-posts']
4193					);
4194
4195					// Fix : html content="" 값으로 <br> 태그 들어가는 경우 개행 처리가 되지 않아 위와 같이<br> 예외 처리 수정
4196					//_fu.blockLoop.empty().attr('data-description',(data.msg) ? data.msg : $.lang[_fu.block_lang]['board.no-posts']);
4197					_fu.blockEL.find('.tpl-forum-pagination').empty().attr({'data-page':page, 'data-view':view});
4198				} else {
4199					// view sample block
4200					_fu.blockLoop.addClass('sample-loop');
4201					_fu.blockLoop.find(`
4202								.tpl-guestbook-more-menu, 
4203								.tpl-guestbook-more-menu-area-el2
4204					`).remove();
4205				}
4206			} else {
4207				
4208				if(	_fu.eltype2 == 'guestbook'
4209					|| _fu.blockEL.is('[data-ver="1"]')
4210				) {
4211					$.forum.update_ver1(id,page_num,view,page,sfl,stx,scate,data);
4212				} else {
4213					_fu.blockLoop.empty();
4214
4215					if(data.total<=((view*page_num)-view)) {
4216						page_num = page_num-1;
4217						if(page_num==0) page_num=1;
4218					}
4219	
4220					$.each(data.list, function(post_i,post) {
4221						var num = data.total - (view * (page_num-1)) - post_i;
4222						var item_tag = getForumListItem(num,post,_fu);
4223						_fu.blockLoop.append(item_tag);
4224	
4225					});
4226					if(_fu.sampleEL.find('.layout-table .tpl-forum-header-row').length > 0) {
4227						_fu.blockLoop.prepend(_fu.sampleEL.find('.layout-table .tpl-forum-header-row').prop('outerHTML'));
4228					}
4229				}
4230			}
4231
4232			showHideForumField(_fu.blockEL, _fu.elsettings, true);
4233
4234			// 검색창
4235			var searchbox_onoff = (typeof _fu.elsettings.searchbox_display != 'undefined' && _fu.elsettings.searchbox_display == 'OFF') ? false : true;
4236			if(!searchbox_onoff) {
4237				syncForumSearchboxDisplay(_fu.blockEL, false);
4238				if(!_fu.blockEL.find('#scate').hasClass('hide')) $.forum.drawSelboxCategory(_fu.blockEL,id);
4239				syncForumCategoryTypeDisplay(_fu.blockEL);
4240			} else {
4241				syncForumSearchboxDisplay(_fu.blockEL, true);
4242				if(!_fu.blockEL.find('#scate').hasClass('hide')) $.forum.drawSelboxCategory(_fu.blockEL,id);
4243	
4244				if(typeof scate != 'undefined' && scate) scate = data.scate;
4245				if(typeof stx != 'undefined' && stx) stx = data.stx;
4246				$.forum.setForumCookie(id,page_num,stx,sfl,scate);
4247	
4248				if($.inArray(sfl, ['mb_id','nonmem']) > -1) {
4249					_fu.blockEL.remove('input[name="user_sfl"], input[name="user_stx"]');
4250					_fu.blockEL.append(`<input type="hidden" name="user_sfl" value="${sfl}"><input type="hidden" name="user_stx" value="${stx}">`);
4251				} else {
4252					var prev_stx = getForumPrevStx(id);
4253					_fu.blockEL.find('.search-box #sfl').val(sfl);
4254					_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);
4255					_fu.blockEL.find('.search-box #sfl option').map( function() {
4256						var sfl = $(this).attr('value');
4257						$(this).text($.lang[_fu.block_lang][`board.sfl.${sfl}`]);
4258					});
4259
4260					if($.inArray(sfl, ['mb_id','nonmem']) < 0
4261						&& stx.length > 0 
4262						&& _fu.blockLoop.find(`.tpl-forum-list-title a:contains("${stx}")`).length > 0
4263					) {
4264						_fu.blockLoop.find(`.tpl-forum-list-title a:contains("${stx}")`).each(function() {
4265							var title_txt = $(this).text(),
4266								regex = new RegExp(stx,'gi'),
4267								new_title_txt = title_txt.replace(regex, `<strong class="search-txt">${stx}</strong>`);
4268							$(this).html(new_title_txt);
4269						});
4270					}
4271				}
4272	
4273				if(!sfl) _fu.blockEL.find('.search-box select').children().first().attr('selected','selected');
4274				if(!stx || stx.length==0) _fu.blockEL.find('.search-box #sfl').val($('.search-box #sfl').children().first().attr('value'));
4275	
4276				_fu.blockEL.find('.search-box #scate').val(scate);
4277				if(!scate || scate.length==0) _fu.blockEL.find('.search-box #scate').val('');
4278				setForumCategoryActive(_fu.blockEL, scate);
4279				syncForumCategoryTypeDisplay(_fu.blockEL);
4280			}
4281
4282			// 항목 > 언어
4283			_fu.blockEL.find('.tpl-forum-header-row').children('[class*="tpl-forum-"]').each(function(idx, v) {
4284				var tmp_cls = $(this).attr('class'),
4285				tmp_matches = [...tmp_cls.matchAll(/tpl-forum-(\w+)/g)].map(match => match[1])[0];
4286				if(tmp_matches == 'content') tmp_matches = 'title';
4287				else if(tmp_matches == 'num' && $(this).hasClass('num-ko')) tmp_matches += '.ko';
4288				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}`]);
4289			});
4290
4291            // 버튼 > 텍스트 
4292            var btn_arr = (_fu.eltype2 == 'guestbook') ? ['write','cancel'] : ['write'];
4293            $.each(btn_arr, function(i,k) {
4294                var tmp_k = (_fu.eltype2 == 'guestbook') ? _fu.eltype2 : 'forum',
4295                    tmp_selector = `.tpl-${tmp_k}-${k}`,
4296                    tmp_custom = `btn${i > 0 ? k.charAt(0).toUpperCase() + k.slice(1) : ''}Text`,
4297                    tmp_text = _fu.elsettings[tmp_custom] ?? $.lang[_fu.block_lang][`forum.field${tmp_selector}`] ?? _fu.blockEL.find(tmp_selector).text().trim();
4298
4299				_fu.blockEL.find(tmp_selector).text(tmp_text).attr('data-pid',id);
4300            });
4301
4302			// 페이지네이션
4303			if(!_fu.blockEL.find('[data-loop="true"]').is('.sample-loop')) {
4304				setForumPagination(_fu.blockEL.find('.tpl-forum-pagination'),data.total,view,page_num,id,page);
4305				if(Number(data.total) <= Number(view)) _fu.blockEL.find('.tpl-forum-pagination').addClass('hide');
4306				else _fu.blockEL.find('.tpl-forum-pagination').removeClass('hide');
4307			}
4308
4309			switch(_fu.eltype2) {
4310				case 'faq':
4311					if(typeof MODE == 'undefined') _fu.blockEL.find('.tpl-forum-write').remove();
4312					break;
4313				
4314				default:
4315					 break;
4316			}
4317
4318			// 방명록 캡챠
4319			if(_fu.eltype2 == 'guestbook') {
4320				var captcha_onoff = (getOrDefault(_fu.elsettings,'captcha_display','OF
4320F') == 'ON') ? true : false;
4321				if(captcha_onoff) {
4322					_fu.blockEL.find('.kcaptcha-box img').attr('src', '//storage.googleapis.com/i.addblock.net/js/load_kcaptcha.gif');
4323					$.post(rt_path + '/check/kcaptcha/session/' + id + '?_' + new Date().getTime(), function(data) {
4324						// md5_norobot_key = data;
4325						var tmpImg = new Image();
4326						tmpImg.src = rt_path + '/check/kcaptcha/image/' + id;
4327						tmpImg.onload = function() {
4328							_fu.blockEL.find('.kcaptcha-box img').attr('src', rt_path + '/check/kcaptcha/image/' + id + '?_' + new Date().getTime());
4329						};          
4330					});
4331		
4332					_fu.blockEL.find('.kcaptcha.small').off('click').on('click', function() {
4333						_fu.blockEL.find('.kcaptcha-box img').attr('src', '//storage.googleapis.com/i.addblock.net/js/load_kcaptcha.gif');
4334						$.post(rt_path + '/check/kcaptcha/session/' + id + '?_' + new Date().getTime(), function(data) {
4335							// md5_norobot_key = data;
4336							var tmpImg = new Image();
4337							tmpImg.src = rt_path + '/check/kcaptcha/image/' + id;
4338							tmpImg.onload = function() {
4339								_fu.blockEL.find('.kcaptcha-box img').attr('src', rt_path + '/check/kcaptcha/image/' + id + '?_' + new Date().getTime());
4340							};          
4341						});
4342					});
4343				} else {
4344					_fu.blockEL.find('.captcha').hide();
4345				}
4346		
4347				_fu.blockEL.find('.default_top, .default_bottom').removeClass('flex-value-order1 flex-value-order2');
4348				var guestbook_input_updown = getOrDefault(_fu.elsettings,'input_updown','U');
4349				if(guestbook_input_updown == 'U') {
4350					_fu.blockEL.find('.default_top').addClass('flex-value-order1');
4351					_fu.blockEL.find('.default_bottom').addClass('flex-value-order2');
4352				} else {
4353					_fu.blockEL.find('.default_top').addClass('flex-value-order2');
4354					_fu.blockEL.find('.default_bottom').addClass('flex-value-order1');
4355				}
4356			}
4357
4358			var writebtn_onoff = (typeof _fu.elsettings.writebtn_display !='undefined' && _fu.elsettings.writebtn_display == 'OFF') ? false : true;
4359			if(typeof MODE == 'undefined' && !writebtn_onoff) {
4360				_fu.blockEL.find('.tpl-forum-write[data-disabled="true"]').remove();
4361			}
4362			
4363			_fu.blockEL.removeClass('preloading');
4364		},
4365	};
4366
4367	$.forumChangeList = {
4368		init : function(id){
4369
4370		},
4371		makeList : function(F_SID,id){
4372			var listStr = '';
4373
4374			$.ajax({
4375                url: '/fm/ChangeList/type/get',
4376                dataType: 'json',
4377                type: 'POST',
4378                data: { sid: F_SID, pid : id},
4379                async: false,
4380                cache: false,
4381                success: function (data) {
4382
4383                	if(typeof data.error != 'undefined' && data.error) {
4384                		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
4385                		return false;
4386                	}
4387
4388                	var notice_list = [],
4389                		general_list = [];
4390
4391            		$.each(data,function(f,g){
4392            			if(g.fm_option=='N') notice_list.push(g);
4393            			else general_list.push(g);
4394            		});
4395                	
4396
4397                	listStr += '\
4398                		<div class="change-list-box">\
4399                		';
4400                	
4401                	if(notice_list.length>0) {		
4402                	listStr +='\
4403                			<h3>'+$.lang[LANG]['editor.forum.faqChangeList.config.notice']+'</h3>\
4404                			';
4405            		}
4406
4407            		listStr +='\
4408            				<ul class="ui-sortable change-list" data-listtype="notice">\
4409	            				';
4410        					$.each(notice_list,function(i,v){
4411					listStr += '\
4412								<li data-num="'+v.fm_num+'" data-seq="'+v.seq+'">\
4413									<div class="change-list-move hand cl-sort-handle change-list-handle-notice">\
4414									' + clSVG('move_handle', 20, 20) + '\
4415									</div>\
4416									<div class="change-list-text">\
4417										' + initSVGIcon('item_forum_notice','bc-svg-notice') + '\
4418										<span class="change-fmtitle">'+v.fm_title+'</span>\
4419									</div>\
4420								</li>\
4421								';
4422							});
4423            		listStr += '\
4424            				</ul>\
4425                		';
4426
4427            		if(general_list.length>0) {		
4428            		listStr += '\
4429            				<h3>'+$.lang[LANG]['editor.forum.faqChangeList.config.normal']+'</h3>\
4430            				';
4431    				}
4432            		
4433            		listStr += '\
4434		            		<ul class="ui-sortable change-list" data-listtype="general">\
4435            				';
4436        					$.each(general_list,function(s,d){
4437					listStr += '\
4438								<li data-num="'+d.fm_num+'" data-seq="'+d.seq+'">\
4439									<div class="change-list-move hand cl-sort-handle change-list-handle-normal">\
4440									' + clSVG('move_handle', 20, 20) + '\
4441									</div>\
4442									<div class="change-list-text">\
4443										' + (d.fm_option=='S' ? initSVGIcon('item_forum_secret','bc-svg-secret') : '') + '\
4444										<span class="change-fmtitle">'+d.fm_title+'</span>\
4445									</div>\
4446								</li>\
4447								';
4448							});
4449            		listStr += '\
4450            				</ul>\
4451            			</div>\
4452            		';
4453
4454                }
4455            });		
4456
4457			return listStr;
4458
4459		},
4460		open : function(id){
4461			//$.forumChangeList.init(id);			
4462			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
4463			
4464			var listStr = $.forumChangeList.makeList(F_SID,id),
4465				modal = $(this).showModalFlat($.lang[LANG]['editor.forum.faqChangeList.config'],listStr,true,true,function(){
4466
4467				$.progressON($.lang[LANG]['editor.forum.faqChangeList.config.changing'],'','',true);
4468				
4469				var updateList = {},
4470					updateList_notice = {},
4471					updateList_general = {};
4472
4473				$.each($('.change-list'),function(z,x){
4474					var listType = $(this).attr('data-listtype');
4475
4476					if(listType=='notice') {
4477					 	updateList_notice = $(this).find('li').map(function(i,v) {
4478							var dataNum = $(this).attr('data-num'),
4479								dataSeq = $(this).attr('data-seq');
4480
4481							return {
4482								dataNum : dataNum,
4483								dataSeq : dataSeq
4484							}
4485						}).get();
4486					} else {
4487						updateList_general = $(this).find('li').map(function(i,v) {
4488							var dataNum = $(this).attr('data-num'),
4489								dataSeq = $(this).attr('data-seq');
4490
4491							return {
4492								dataNum : dataNum,
4493								dataSeq : dataSeq
4494							}
4495						}).get();
4496					}
4497
4498					updateList = updateList_notice.concat(updateList_general);
4499					$('.progress-bar').css('width','40%');
4500				});
4501
4502				$.ajax({
4503	                url: '/fm/ChangeList/type/update',
4504	                dataType: 'json',
4505	                type: 'POST',
4506	                data: { sid: F_SID, pid : id, updateList : updateList },
4507	                async: false,
4508	                cache: false,
4509	                success: function (data) {
4510	                	if(typeof data.error != 'undefined' && data.error) {
4511	                		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
4512	                		return false;
4513	                	}
4514	                	$('.progress-bar').css('width','100%');
4515	                	setTimeout(function() {		                		
4516                			modal.modal('hide');
4517		                  	$.progressOFF();
4518		                  	showPageCallback(showPage);	
4519		                },'650');
4520	                }
4521                });	
4522
4523                var type = getElementType();
4524                setLogs(type,'forum.faq.sort','block-sort', type);
4525				
4526			},'config.close','config.save', 'cl-cmmodal cl-cmwide cl-s-btn w700 cl-p70 cl-p0 cl-forum-changeList',true,'',function(){			
4527				var num_array = [];
4528				$('.change-list').each(function(){
4529					$(this).sortable({
4530						placeholder:'chage-list-move-placeholder',
4531						connectWith: $(this),
4532		                handle : '.change-list-move',
4533		                revert :50,
4534		                tolerance: 'pointer',
4535						helper : 'clone',
4536		                update : function(e,ui){
4537		                	$(this).find('li').removeClass('chage-list-move-placeholder');
4538		                	num_array = $(this).sortable( "toArray", { attribute : 'data-num' });
4539		                	num_array.sort(function(q,w){
4540		                		return q - w;
4541		                	});
4542
4543		                	var listType = $(this).attr('data-listtype');
4544
4545		                	$.each(num_array,function(a,b){
4546								$.each($('.change-list[data-listtype="'+listType+'"] li'),function(n,m){
4547									if(a==n) $(this).attr('data-num',b);
4548								});
4549							});
4550		                }
4551		            }).disableSelection();
4552				});
4553			});
4554		},
4555	};
4556
4557	var getConfigChecked = function (value,select,valstr) {
4558		valstr = (typeof valstr == 'undefined') ? 'selected' : valstr;
4559		var check = [];
4560
4561		$.each(select, function(i,v) {
4562			check.push((value.toUpperCase()==v) ? valstr : '');
4563		});
4564		return check;
4565	}
4566
4567	var groupConfigForum = function(config,id,group) {
4568		config = $.forum.setDefaultConfig(config);
4569
4570		var tpUser = ['ADM','A','M','N','G'],
4571			tpOnoff = ['ON','OFF'],
4572			tpSecret = ['N','U','A'],
4573			tpSecretComment = ['N','U','A'],
4574			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
4575			group_member = 0,
4576			groups = group,
4577			select_group = config.group,
4578			select_group_str = '';
4579
4580		var preference = { group : '', write : [], view : [], reply : [], list : [], modify : config.modify, delete : config.delete, row : config.page_row, secret : [], sns : [], comment : []}
4581		preference.write 	= getConfigChecked(config.write_level,tpUser);
4582		preference.view 	= getConfigChecked(config.view_level,tpUser);
4583		preference.reply 	= getConfigChecked(config.reply_level,tpUser);
4584		preference.list 	= getConfigChecked(config.list_level,tpUser);
4585		preference.secret 	= getConfigChecked(config.secret_display,tpSecret,'checked');
4586		preference.secretComment = getConfigChecked(config.secretComment_display,tpSecretComment,'checked');
4587		preference.comment 	= getConfigChecked(config.comment_display,tpOnoff,'checked');
4588
4589		var namelist_str = $.forum.getGroupNameList(id);
4590
4591		var str = '\
4592		<div class="clearwrap">\
4593			<div class="forum-member-search">\
4594				<div class="select-wrap">\
4595					<select class="hand" id="g-sfl" name="g-sfl" placeholder="' + $.lang[LANG]['board.g-sfl.all'] + '">\
4596						<option value="all" data-id="all" selected>' + $.lang[LANG]['board.g-sfl.all'] + '</option>\
4597						' + namelist_str + '\
4598					</select>\
4599				</div>\
4600				<div class="cl-common-form-wrap nonplace-holder">\
4601                    <div class="cl-common-form-group">\
4602    					<input id="g-stx" name="g-stx" class="config-input member-search" placeholder="' + $.lang[LANG]['board.search.userid.'+mtype] + '">\
4603                        <label class="lock-input-error"></label>\
4604                    </div>\
4605                    <span class="btn btn-xs btn-forum-config btn-forum-group-search" data-toggle="tooltip" data-placement="top" data-id="' + SID + '">\
4606	                	<svg viewBox="0 0 13 13" width="13" height="13">\
4607	                		<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"/>\
4608	                	</svg>\
4609	                </span>\
4610                </div>\
4611			</div>\
4612		</div>\
4613		<div class="config-wrap">';
4614		if(groups.length == 0) {
4615			str = str + '<div class="forum-settings group empty"><p>그룹이 없습니다.</p></div>';
4616		} else {
4617			str = str + '\
4618			<div class="panel-group forum-settings group" id="group-accordion">\
4619			';
4620			for(var i=0; i<groups.length; i++) {
4621				if(select_group == groups[i].id) {
4622					selected = 'selected';
4623					group_member = groups[i].member_count;
4624					select_group_str = ' - ' + groups[i].name;
4625				} else {
4626					selected = '';
4627				}
4628				
4629				str = str + getGroupList(groups[i].id, groups[i].name, groups[i].member_count);
4630			}
4631
4632			str = str + '\
4633			</div>\
4634		';
4635		}
4636		str = str + '\
4637		</div>\
4638		<div class="froum-group-add">\
4639			<span class="btn btn-group-add">\
4640				<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>\
4641			' + $.lang[LANG]['board.add-group'] + '</span>\
4642		</div>\
4643		';
4644		return str;
4645	}
4646
4647
4648	var getGroupList = function (gid, gname, gmcount) {
4649		var str =  '\
4650				<div class="panel">\
4651					<div class="panel-heading">\
4652						<div class="panel-title">\
4653							<a class="accordion-toggle group-item hand" data-id="' + gid + '" data-member-count="' + gmcount + '">\
4654								<label class="group-name hand">' + gname + '</label>\
4655								<span class="group-member-count">' + gmcount + '</span>\
4656								<svg viewBox="0 0 8 4" width="8" height="4"><polygon points="0 0 4 4 8 0 "/></svg>\
4657							</a>\
4658							<div class="content">\
4659								<span>\
4660									<svg viewBox="0 0 13 13" width="13" height="13" class="group-user-add hand">\
4661										<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 "/>\
4662										<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"/>\
4663									</svg>\
4664								</span>\
4665								<span>\
4666									<svg viewBox="0 0 13 13" width="13" height="13" class="group-name-edit hand">\
4667										<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"/>\
4668										<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"/>\
4669									</svg>\
4670								</span>\
4671								<span>\
4672									<svg viewBox="0 0 12 13" width="12" height="13" class="group-delete hand">\
4673										<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"/>\
4674										<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
4675									</svg>\
4676								</span>\
4677							</div>\
4678						</div>\
4679					</div>\
4680					<div id="group-list-' + gid + '" class="panel-collapse" style="display:none;" data-load="'+((gmcount > 0) ? 'true' : 'false')+'">\
4681						<div class="panel-body">\
4682						</div>\
4683					</div>\
4684				</div>\
4685		';
4686		return str;
4687	}
4688
4689	var getGroupMemberList = function (id,userid) {
4690
4691		var userid = (typeof userid == 'undefined' || !userid) ? '' : userid, 
4692			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
4693			str = '';
4694
4695		$.post('/fm/group/member', { id : id, page : 1, userid : userid, mtype:mtype }, function(data) {
4696			if(typeof data.error != 'undefined' && data.error) {
4697				return false;
4698			}
4699
4700			if(data.total>0) {
4701				str = '		<ul class="group-member-list">';
4702				$.each(data.list, function(i,v) {
4703					str = str + '\
4704								<li class="gm-item">\
4705									<div>\
4706										<div class="gmi-img">\
4707											<span class="hexagon">\
4708												<img src="'+v.img+'" alt="" class="img-responsive">\
4709											</span>\
4710										</div>\
4711										<div class="gmi-info">\
4712					';
4713					if(v.name != v.id && v.name) {
4714						str = str + '\
4715											<span class="gmi-name">' + v.name + '</span>\
4716						';
4717					}
4718						str = str + '\
4719											<span class="gmi-id">' + v.id + '</span>\
4720										</div>\
4721										<div class="gmi-btn">\
4722											<svg viewBox="0 0 12 13" width="12" height="13" class="gmi-del hand" data-userid="' + v.id + '" data-id="' + v.fg_id + '" data-mtype="' + mtype + '">\
4723												<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"/>\
4724												<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
4725											</svg>\
4726										</div>\
4727									</div>\
4728								</li>';
4729				});
4730				str = str + '</ul>';
4731			} else {
4732				str = '		<div class="empty">' + $.lang[LANG]['board.group-no-members'] + '</div>';
4733			}
4734
4735		}, 'json');
4736		return str;
4737	}
4738
4739	var settingEditMode = function(mode) {
4740		if(mode) {
4741			$('.forum-member-search, .froum-group-add').css('pointer-events','none');
4742			$('#group-accordion').find('.forum-group-update').css('pointer-events','auto').find('input').focus();
4743			$('#group-accordion').find('.forum-group-user-add').css('pointer-events','auto').find('input').focus();
4744		} else {
4745			$('.forum-member-search, .froum-group-add').css('pointer-events','auto');
4746			$('#group-accordion').find('.config-error').remove();
4747		}
4748	}
4749
4750	var addForumGroupUpdateInput = function(gid, gname) {
4751		var gid = (typeof gid=='undefined' || !gid) ? '' : gid,
4752			gname = (typeof gname=='undefined' || !gname) ? '' : gname,
4753			str = '\
4754			<div class="forum-group-update">\
4755				<div class="input-group">\
4756					<input type="text" class="forum-group-name hand forum-control" placeholder="' + $.lang[LANG]['board.enter-group-name'] + '" value="' + gname + '"/>\
4757					<div class="input-group-btn hand ga-save" data-id="' + gid + '">\
4758						<svg viewBox="0 0 15 10" width="15" height="10" class="">\
4759							<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"/>\
4760						</svg>\
4761					</div>\
4762					<div class="ga-cancel">\
4763						<svg viewBox="0 0 12 12" width="12" height="12">\
4764							<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 "/>\
4765						</svg>\
4766					</div>\
4767				</div>\
4768			</div>\
4769		';
4770		return str;
4771	}
4772
4773
4774	$doc.on('hidden.bs.modal','.flat-gc-modal .modal', function (e) {
4775		var ctrlChmodSelectGroup = $('#el-blockConfig .ctrl-chmod-select[data-mode="group"]'),
4776			gid = ctrlChmodSelectGroup.find('option:selected').attr('data-id'),
4777			str = $.forum.getGroupNameList(selectID);
4778		settingEditMode(false);
4779
4780		ctrlChmodSelectGroup.html(str);
4781		var selectGroup = (ctrlChmodSelectGroup.find('option[data-id="' + gid + '"]').length > 0) ? ctrlChmodSelectGroup.find('option[data-id="' + gid + '"]') : ctrlChmodSelectGroup.find('option:first-child');
4782		selectGroup.attr('selected',true);
4783
4784		$('#el-blockConfig .ctrl-chmod-select option[value="G"]').each(function() {
4785			$(this).text($.lang[LANG]['board.access-group-label'] + ' - ' + selectGroup.val());
4786		});
4787		$('.flat-gc-modal').remove();
4788		setTimeout(function() {
4789			if($('.modal.modal-default:visible').length == 0) {
4790				$('.modal-backdrop').remove();
4791				$('body').removeClass('modal-open');
4792			}
4793		},50);
4794	});
4795
4796	var restoreForumGroupModalLayer = function() {
4797		setTimeout(function() {
4798			var $group_modal = $('.flat-gc-modal .modal.modal-default');
4799			if($group_modal.length == 0 || !$group_modal.is(':visible')) return false;
4800
4801			$group_modal.css('zIndex','');
4802			var group_zindex = parseInt($group_modal.css('zIndex'),10);
4803			if(!group_zindex) group_zindex = 1050;
4804
4805			$('.modal-backdrop').each(function() {
4806				var backdrop_zindex = parseInt($(this).css('zIndex'),10);
4807				if(backdrop_zindex >= group_zindex) $(this).remove();
4808			});
4809
4810			var $group_backdrops = $('.modal-backdrop').filter(function() {
4811				var backdrop_zindex = parseInt($(this).css('zIndex'),10);
4812				return (!backdrop_zindex || backdrop_zindex < group_zindex);
4813			});
4814			$group_backdrops.not(':first').remove();
4815			if($group_backdrops.length == 0) {
4816				$group_modal.closest('.flat-modal').after($('<div class="modal-backdrop fade in"></div>').css('z-index',group_zindex-10));
4817			}
4818			$('body').addClass('modal-open');
4819		},30);
4820	};
4821
4822	var updateForumGroupMemberCount = function(id,count) {
4823		var $select_group = $('.flat-gc-modal .group-item[data-id="'+id+'"]');
4824		$select_group.attr('data-member-count',count);
4825		$select_group.find('.group-member-count').text(count);
4826		$('.flat-gc-modal #g-sfl option[data-id="'+id+'"]').attr('data-member-count',count);
4827		groups = getForumGroupObject();
4828		if($('#el-blockConfig.open').length > 0 && (typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == selectID)) {
4829			bc_fr.group = groups;
4830		}
4831	};
4832
4833	$doc.on('hidden.bs.modal','.modal.modal-default', function (e) {
4834		if($(this).closest('.flat-gc-modal').length == 0 && $('.flat-gc-modal .modal.modal-default').length > 0) {
4835			restoreForumGroupModalLayer();
4836		}
4837	});
4838
4839
4840	$doc.on('click','.btn-group-add', function (e) {
4841		if($('#group-accordion').find('.forum-group-update').length > 0) return false;
4842
4843		$('#g-stx').val('');
4844		$('#g-sfl option:first-child').attr('selected',true);
4845		$.forum.getgroupdata($('.flat-gc-modal .modal').attr('data-fid'));
4846
4847		var input_text = addForumGroupUpdateInput();
4848		$(input_text).appendTo($('#group-accordion'));
4849		settingEditMode(true);
4850	});
4851
4852	$doc.on('click','.ga-cancel',function (e) {
4853		settingEditMode(false);
4854		$('#group-accordion').find('.forum-group-update').remove();
4855	});	
4856
4857
4858	$doc.on('click','.ga-save', function (e) {
4859		if($(this).hasClass('clicked')) return false;
4860		else $(this).addClass('clicked');
4861
4862		var group_name = $('.forum-group-name').val();
4863		var id = $(this).attr('data-id');
4864		var categoryRegexp =  /[\[\]|,'"<>{}\/\\:;%&@$!*?\^]/;
4865		var special_pattern = /[~!?@\#$%<>^&*\(){}\-\[\]\\:;=+_\’'"]/gi;
4866		var editgroupname = (id) ? 'g-edit' : '';
4867		$position = (id) ? $('.group-item[data-id="'+id+'"]').parents('.panel-title') : $('#group-accordion');
4868
4869		$('.config-error').remove();
4870		var show_error_ga_save = function(error_message) {
4871			$position.find('.forum-group-update').removeClass('error-forum').addClass('error-forum');
4872			$position.append('\
4873				<div class="config-error '+editgroupname+'">\
4874					' + clSVG('info',13,13) +'\
4875					<span>' + error_message + '</span>\
4876				</div>\
4877		    ');
4878		    $('.ga-save').removeClass('clicked');
4879		}
4880
4881		if($('.group-item[data-id="'+id+'"] .group-name').text() == group_name) {
4882			settingEditMode(false);
4883			$('#group-accordion').find('.forum-group-update').remove();
4884			$('.ga-save').removeClass('clicked');
4885			return false;
4886		}
4887
4888		if(!group_name.trim()) {
4889			show_error_ga_save($.lang[LANG]['board.allowed-chars.none']);
4890			return false;
4891		}
4892		if(checkEmojis(group_name.trim())) {
4893			show_error_ga_save($.lang[LANG]['config.unable.emoji']);
4894			return false;
4895		}
4896		if((special_pattern.test(group_name.trim()) == true)) {
4897			show_error_ga_save($.lang[LANG]['board.allowed-chars']);
4898            return false;
4899        }
4900		if(group_name.length<1) {
4901			show_error_ga_save($.lang[LANG]['board.enter-group-name']);
4902			return false;
4903		}
4904		if(group_name.length>60) {
4905			show_error_ga_save($.lang[LANG]['board.enter-max-chars.60']);
4906			return false;
4907		}
4908
4909		$.post('/fm/group/update', { sid : F_SID, id : id, name : encodeURIComponent(group_name) }, function(data) {
4910			if(typeof data.error != 'undefined' && data.error) {
4911				show_error_ga_save(data.error);
4912				return false;
4913			}
4914
4915			$('#group-accordion').find('.forum-group-update').remove();
4916			settingEditMode(false);
4917			if(id) {
4918				var str = '\
4919					<label class="group-name">' + data.name + '</label>\
4920					<span class="group-member-count">' + $('#group-accordion .group-item[data-id="' + data.id + '"]').attr('data-member-count') + '</span>\
4921					<svg viewBox="0 0 8 4" width="8" height="4"><polygon points="0 0 4 4 8 0 "/></svg>\
4922				';
4923				$('#group-accordion .group-item[data-id="' + data.id + '"]').html(str);
4924				$('.flat-gc-modal #g-sfl option[data-id="' + data.id + '"]').attr('value',data.name).text(data.name);
4925			} else {
4926				var newgroup = getGroupList(data.id, data.name, 0);
4927				$('#group-accordion').append(newgroup);
4928				$('#group-accordion .group-item[data-id="' + data.id + '"]').click();
4929				$('.flat-gc-modal #g-sfl').append('<option value="'+data.name+'" data-id="'+data.id+'" data-member-count="'+data.member_count+'">'+data.name+'</option>');
4930			}
4931
4932			groups = getForumGroupObject();
4933			if($('#el-blockConfig.open').length > 0 && (typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == selectID)) {
4934				bc_fr.group = groups;
4935			}
4936			$('.ga-save').removeClass('clicked');
4937
4938		}, 'json');
4939	});
4940
4941	$doc.on('click','.group-user-add, .group-item', function (e) {
4942		if($('#group-accordion').find('.forum-group-user-add').length > 0) return false;
4943		$select_group = $(this).parents('.content').prev('.group-item');
4944
4945		var gid = ($(this).hasClass('group-item')) ? $(this).attr('data-id') : $select_group.attr('data-id'),
4946			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
4947			group_member_list_check = $(this).parents('.panel').find('.group-member-list').length,
4948			display_check = $('#group-list-'+gid).css('display');
4949
4950		var input_text = '\
4951			<li class="gm-item forum-group-user-add-li">\
4952				<div class="forum-group-user-add">\
4953					<div class="input-group">\
4954						<input type="text" class="gua-userid forum-control" placeholder="' + $.lang[LANG]['board.enter-member-email.'+mtype] + '"/>\
4955						<span class="input-group-btn hand gua-save" data-id="' + gid + '" data-mtype="' + mtype + '">\
4956							<svg viewBox="0 0 15 10" width="15" height="10" >\
4957								<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"/>\
4958							</svg>\
4959						</span>\
4960						<div class="gua-cancel">\
4961							<svg viewBox="0 0 12 12" width="12" height="12">\
4962								<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 "/>\
4963							</svg>\
4964						</div>\
4965					</div>\
4966				</div>\
4967			</li>\
4968		',
4969		member_list = '\
4970			<ul class="group-member-list">\
4971			' + input_text + '\
4972			</ul>\
4973			';
4974
4975		if(display_check=='none') {
4976			if($(this).hasClass('group-item')=== false) {
4977		 		groupAddClass(group_member_list_check,$(this),input_text,member_list);
4978			} else {
4979
4980				if($('#group-list-'+gid).is('[data-load="true"]')) {
4981					var glist_html = getGroupMemberList(gid);
4982					$('#group-list-'+gid+' .panel-body').html(glist_html);
4983					$('#group-list-'+gid).removeAttr('data-load');
4984				}
4985			}
4986
4987			$('#group-list-'+gid).slideDown();
4988			$(this).addClass('glOpen');
4989
4990		} else {			
4991			if($(this).hasClass('group-item')===false) {
4992				groupAddClass(group_member_list_check,$(this),input_text,member_list);
4993			} else {
4994				$(this).removeClass('glOpen');
4995				$('#group-list-'+gid).slideUp();
4996			}
4997		}
4998	});
4999	
5000
5001	$doc.on('click','.gua-cancel',function (e) {
5002		var empty_check = $(this).parents('.panel-body').find('.empty').css('display');
5003		if(empty_check == 'none') {
5004			$(this).parent('.panel').find('.group-member-list').remove();
5005			$(this).parents('.panel').find('.empty').show();  
5006		}	
5007		settingEditMode(false);
5008		$('#group-accordion').find('.forum-group-user-add-li').remove();
5009	});
5010
5011	$doc.on('click','.gua-save',function (e) {
5012		if($(this).hasClass('clicked')) return false;
5013		else $(this).addClass('clicked');
5014
5015		var $select_group = $(this).parents('.panel').find('.group-item'),
5016			$add_error = $(this).parents('.gm-item'),
5017			$userid = $('.gua-userid'),
5018			id = $(this).attr('data-id'),
5019			mtype = $(this).attr('data-mtype');
5020
5021		$('.config-error').remove();
5022		var show_error_gua_save = function(error_message) {
5023			$add_error.append('\
5024				<div class="config-error">\
5025					' + clSVG('info',13,13) +'\
5026					<span>' + error_message + '</span>\
5027				</div>\
5028		    ');
5029		    $('.gua-save').removeClass('clicked');
5030		}
5031
5032		if(!$userid.val().trim()) {
5033			show_error_gua_save($.lang[LANG]['board.enter-member-email.um']);
5034			return false;
5035		}
5036		if(checkEmojis($userid.val().trim())) {
5037			show_error_gua_save($.lang[LANG]['config.unable.emoji']);
5038			return false;
5039		}
5040		if(typeof id == 'undefined' || id==null || !id) {
5041			show_error_gua_save('Invalid variable');
5042			return false;
5043		}
5044		$.post('/fm/group/useradd', { id:id, userid:$userid.val().trim().toLowerCase(), mtype:mtype }, function(data) {
5045			if(typeof data.error != 'undefined' || data.error) {
5046				show_error_gua_save(data.error);
5047				return false;
5048			}
5049
5050			if($('.member-search').val()) {
5051				$('#g-stx').val('');
5052				$('#g-sfl option:first-child').attr('selected',true);
5053				$.forum.getgroupdata($('.flat-gc-modal .modal').attr('data-fid'));
5054			}
5055			$select_group.attr('data-member-count',data.count);
5056			$select_group.find('.group-member-count').text(data.count);
5057
5058			settingEditMode(false);
5059
5060			$('#group-accordion').find('.forum-group-user-add-li').remove();
5061			groups = getForumGroupObject();
5062			if($('#el-blockConfig.open').length > 0 && (typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == selectID)) {
5063				bc_fr.group = groups;
5064			}
5065
5066			getGroupMembers(id);
5067			$('.gua-save').removeClass('clicked');
5068
5069		},'json');
5070	});
5071
5072	$doc.on('click','.group-name-edit',function (e) {
5073		$select_group = $(this).parents('.content').prev('.group-item');
5074		var gid = $select_group.attr('data-id'),
5075			gname = $select_group.find('.group-name').text();
5076		if($('#group-accordion').find('.forum-group-update').length > 0) return false;
5077
5078		var input_text = addForumGroupUpdateInput(gid, gname);
5079		$(input_text).appendTo($select_group.closest('.panel-title'));
5080		settingEditMode(true);
5081	});
5082
5083	$doc.on('click','.group-delete',function (e) {
5084		$select_group = $(this).parents('.content').prev('.group-item');
5085		var gid =  $select_group.attr('data-id'),
5086			gname = $select_group.find('.group-name').text();
5087
5088		if($('#group-accordion .group-item').length==1) {
5089			if($('#group-accordion .group-item').find('.config-error').length==0)
5090				$select_group.parents('.panel-title').append('<div class="config-error managegroups-error">\
5091						<svg viewBox="0 0 13 13" width="13" height="13">\
5092		                    <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"/>\
5093		                    <rect x="6" y="3" width="1" height="5"/>\
5094		                    <rect x="6" y="9" width="1" height="1"/>\
5095		                </svg>\
5096	                <span>' + $.lang[LANG]['board.min-num-groups'] + '</span></div>');
5097			return false;
5098		}
5099		var str = $.lang[LANG]['board.ask-delete-group-2'] + "\
5100		";
5101
5102		var gd_modal = $(this).showModalFlat($.lang[LANG]['board.ask-delete-group.title'], str, true, true, function() {
5103			$.post('/fm/group/delete', { id : gid }, function(data) {
5104				if(typeof data.error != 'undefined' || data.error) {
5105					$('.forum-group-delete .content').append('<div class="config-error">' + data.error + '</div>');
5106					return false;
5107				}
5108				$('#group-accordion .group-item[data-id="' + data.id + '"]').parents('.panel').remove();
5109				$('.flat-gc-modal #g-sfl option[data-id="' + data.id + '"]').remove();
5110				groups = getForumGroupObject();
5111				if($('#el-blockConfig.open').length > 0 && (typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == selectID)) {
5112					bc_fr.group = groups;
5113				}
5114				gd_modal.modal('hide');
5115			},'json');
5116
5117		}, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 zindex1060','','','',restoreForumGroupModalLayer);
5118		$('#delete-group-name').text(gname);
5119	});
5120
5121	$doc.on('click','.gmi-del', function (e) {
5122		var userid = $(this).attr('data-userid'),
5123			id = $(this).attr('data-id'),
5124			mtype = $(this).attr('data-mtype') || ((SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink'),
5125			$select_group = $('.group-item[data-id="'+id+'"]'),
5126			str = userid + $.lang[LANG]['board.ask-delete-member-from-group'];
5127
5128		var gmid_modal = $(this).showModalFlat($.lang[LANG]['config.information'], str, true, true, function() {
5129			$.post('/fm/group/userdel', { id : id, userid : userid, mtype : mtype }, function(data) {
5130				if(typeof data.error != 'undefined' && data.error) {
5131					$select_group.append('<div class="config-error">' + data.error + '</div>');
5132					return false;
5133				}
5134
5135				updateForumGroupMemberCount(id,data.count);
5136
5137				getGroupMembers(id);
5138				gmid_modal.modal('hide');
5139			},'json');
5140		},'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 zindex1060','','','',restoreForumGroupModalLayer);
5141	});
5142
5143
5144	$doc.on('click','#ctrl-forum-group', function(e) {
5145		var id = $(this).attr('data-id');
5146		$.forum.groupconfig(id);
5147	});
5148
5149	$doc.on('click','#bc-default-forum-chlistmod', function(e) {
5150		var id = $('.forum-change-list').attr('data-id'),
5151			hasNoList = $('.forum-change-list').hasClass('noList') ? true : false,
5152			hasDisabled = $('.forum-change-list').hasClass('disabled') ? true : false,
5153			check_count_txt = (hasNoList) ? $.lang[LANG]['editor.forum.faqChangeList.config.noList'] : $.lang[LANG]['editor.forum.faqChangeList.config.disabled'];
5154
5155		if(hasNoList || hasDisabled) {
5156			$(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');
5157		} else $.forumChangeList.open(id);
5158	});
5159
5160	$doc.on('change','.property-form-wrap select, #prop-forum-etcmod .switch-input', function(e) {
5161		var id =  $(this).attr('data-id'),
5162			mode = $(this).attr('data-mode'),
5163			value = (mode == 'group') ? $(this).find('option:selected').attr('data-id') : $(this).val();
5164
5165		if(typeof id == 'undefined' || id==null || id=='') {
5166			$(this).showModalFlat('ERROR', $.lang[LANG]['board.error-setting-value'], true, false, '', 'ok');
5167			return false;
5168		}
5169
5170		if(value != 'undefined' && value == 'NULL') {
5171			e.preventDefault();
5172
5173            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'];
5174			$(this).showModalFlat('INFORMATION', upgrade_text, true, false, '', 'close');
5175            $(this).val( $(this).data('choice') );
5176			return false;
5177		}
5178
5179		if(mode == 'comment') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
5180		if(mode == 'sns') 	  value = ($(this).prop('checked')) ? 'ON' : 'OFF';
5181		if(mode == 'bottomlist') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
5182		if(mode == 'searchbox') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
5183		if(mode == 'captcha') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
5184
5185		var modetype = {
5186			'group' : 'group',
5187			'write'	: 'write_level',
5188			'view'	: 'view_level',
5189			'reply'	: 'reply_level',
5190			'list'	: 'list_level',
5191			'secret' : 'secret_display',
5192			'comment': 'comment_display',
5193			'like': 'like_display',
5194			'sns'	: 'sns_share_display',
5195			'bottomlist': 'bottomlist_display',
5196			'fieldlang' : 'field_lang',
5197			'searchbox': 'searchbox_display',
5198			'date' : 'date',
5199			'captcha' : 'captcha_display',
5200		}, settings = {};
5201
5202		settings[modetype[mode]] = value;
5203
5204
5205		$.post('/template/settings', { sid : F_SID, settings : JSON.stringify(settings), el : id }, function(data) {
5206			if(typeof data.error != 'undefined' && data.error) {
5207				$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
5208				return false;
5209			}
5210			var block_lang = ($('.element[data-id="' + id + '"]').attr('data-blocklang')) ? $('.element[data-id="' + id + '"]').attr('data-blocklang') : LANG;
5211
5212			if(mode == 'fieldlang') {
5213				$('.element[data-id="' + id + '"]').attr('data-fieldlang',value.toLowerCase());
5214				$('.element[data-id="' + id + '"] thead tr th').each(function() {
5215					var field_text = (typeof $(this).attr('class') != 'undefined') ? $(this).attr('class') : 'tpl-forum-title';
5216					if(field_text.indexOf('title') > -1 || field_text.indexOf('content') > -1) $(this).text($.lang[value.toLowerCase()]['forum.field.tpl-forum-title']);
5217					else $(this).text($.lang[value.toLowerCase()]['forum.field.' + field_text]);
5218				});
5219
5220				if($('.element[data-id="' + id + '"]').attr('data-type') == 'forum' && $('.element[data-id="' + id + '"]').attr('data-type2') == 'qna') {
5221					$('.element[data-id="' + id + '"] .qna-item .tpl-forum-list-state').each(function(i) {
5222                        if($(this).closest('.qna-item').find('.tpl-forum-list-num').hasClass('n')) $(this).text('');
5223                        else if(typeof $(this).attr('data-state') != 'undefined' && $(this).attr('data-state') == 'true') $(this).text($.lang[block_lang]['forum.qna.state.replied']);
5224						else $(this).text($.lang[block_lang]['forum.qna.state.waiting']);
5225					});
5226				}
5227	
5228				$('.element[data-id="' + id + '"]').find('.tpl-forum-write').text($.lang[value.toLowerCase()]['forum.field.tpl-forum-write']);
5229			}
5230			if(mode == 'searchbox') {
5231				var $forum_el = $('.element[data-id="' + id + '"]');
5232				syncForumSearchboxDisplay($forum_el, value == 'ON');
5233				syncForumCategoryTypeDisplay($forum_el);
5234			}
5235			if(mode == 'date') {
5236				var page = F_PAGE,
5237					page_num = 1,
5238					view = $('.element.active').find('.tpl-forum-pagination li').first().attr('data-view'),
5239					sfl = '',
5240					stx = '',
5241					scate = '';
5242
5243				$.forum.setForumCookie(id,page_num,stx,sfl,scate);
5244				cookie_page_num = $.cookie('forum_'+id);
5245				$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
5246				activeEL('userEL'+id);
5247			}
5248
5249		}, 'json');
5250	});
5251	
5252	var getForumGroupObject = function() {
5253		var $select = $('#group-accordion .group-item');
5254		groups = [];
5255		$.each($select,function(i,v) {
5256			groups[i] = {
5257				'id' : $(this).attr('data-id'),
5258				'name' : $(this).find('.group-name').text(),
5259				'member_count' : $(this).attr('data-member-count')
5260			}
5261		});
5262		return groups;
5263	}
5264
5265	var deleteForumPost = function(id) {
5266
5267			$.post('/fm/delete', { id : id, user : user }, function(data) {
5268				if(typeof data.error != 'undefined' && data.error) {
5269					$('.flat-modal .modal').modal('hide');
5270					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');
5271					return false;
5272				}
5273
5274				//this case:: forum QnA / FAQ block, answer delete =>> page refresh
5275				var checkPageReload = (	$('.element[data-type="forum"][data-type2="qna"] .qna-details .tpl-toolbar-question-del[data-id="' + id + '"]').length > 0 
5276										|| $('.fctrl-item[data-cmd="del"]').attr('data-seq') == id
5277										|| $(`.element[data-type="forum"][data-type2="faq"] .tpl-forum-faq-ctrl [data-id="${id}"]`).length > 0
5278									) ? true : false;
5279
5280				if( $('.page-bottomlist').length > 0 && $('.page-bottomlist').attr('data-pid') === id ) {
5281					checkPageReload = false;				
5282				}
5283				
5284				if(checkPageReload) location.reload();
5285				else $('.tpl-forum-list').click();
5286
5287				// modal.modal('hide');
5288			},'json');
5289
5290	}
5291
5292	var deleteGuestbook = function(pid, id) {
5293		$.post('/fm/delete', { id : id, user : user }, function(data) {
5294			if(typeof data.error != 'undefined' && data.error) {
5295				$('.flat-modal .modal').modal('hide');
5296				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');
5297				return false;
5298			} else {
5299				var view = $('.element[data-id="' + pid + '"]').find('[data-view]').attr('data-view');
5300				$.forum.init(pid, 1, view);
5301			}
5302		},'json');
5303	}
5304
5305	var setForumPagination = function($obj, total, view, page_num, id, page) {
5306		var page_view = 5,
5307		    start = Math.floor((page_num-1) / page_view) * page_view,
5308		    pages = Math.ceil(total/view),
5309		    end = (Math.floor((page_num-1) / page_view) + 1) * page_view,
5310		    end = (end>pages) ? pages : end,
5311		    prev = (start > 0) ? start : 1,
5312		    next = ((end+1) > pages) ? pages : end+1;
5313		$obj.find('li').addClass('tpl-forum-page');
5314
5315		var arrow_selector = `.userEL${$obj.parents('.element').data('id')}`,
5316			arrow_str = (document.querySelector(arrow_selector) != null) ? getComputedStyle(document.querySelector(arrow_selector)).getPropertyValue('--pagination-arrow') : '',
5317			arrow_arr = arrow_str.trim().split(','),
5318			arrow_obj = {
5319				check: arrow_arr[0] ? true : false,
5320				type: arrow_arr[0] || '1',
5321				w: arrow_arr[1] || '12',
5322				h: arrow_arr[2] || '12',
5323			};
5324
5325		if(!arrow_obj.check && $obj.children().first().find('svg').length == 0) {
5326			arrow_obj.arrow = [`<i class="fa fa-angle-double-left"></i>`,`<i class="fa fa-angle-double-right"></i>`];
5327		} else {
5328			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)];
5329		}
5330
5331		var $prev = $obj.children().first().clone(),
5332			$next = $obj.children().last().clone();
5333		$prev.attr({'data-page': page, 'data-id': id, 'data-view': view, 'data-page-num':prev});
5334		$next.attr({'data-page': page, 'data-id': id, 'data-view': view, 'data-page-num':next});
5335
5336		var $first = $prev.clone(),
5337			$last = $next.clone();
5338		$first.attr({'data-page-num':'1'}).find('a').empty().append(arrow_obj.arrow[0]);
5339		$last.attr({'data-page-num':pages}).find('a').empty().append(arrow_obj.arrow[1]);
5340
5341		$obj.empty().append($prev).append($next);
5342
5343		for(i=start;i<end;i++) {
5344			var active = ((i+1) == page_num) ? 'active' : '';
5345			$obj.children().last().before($(`
5346					<li class="tpl-forum-page ${active}" data-id="${id}" data-page="${page}" data-view="${view}" data-page-num="${i+1}" data-pid="${id}">
5347						<a href="#">${i+1}</a>
5348					</li>
5349				`));
5350		}
5351
5352		if(pages>1 && pages>=page_num && pages>page_view) $obj.prepend($first).append($last);
5353	}
5354
5355
5356	var getGroupMembers = function(id, userid) {
5357		userid = (typeof userid == 'undefined' || !userid) ? '' : userid;
5358		var $grouplist = $('#group-list-'+id+' .panel-body');
5359		$grouplist.find('.empty').remove();
5360		$grouplist.find('.group-member-list').remove();
5361
5362		$grouplist.append(getGroupMemberList(id,userid));
5363	}
5364
5365	var setMemberPagination = function($obj,total,page_num,id) {
5366		var page_view = 10, view = 10,
5367		    start = Math.floor((page_num-1) / page_view) * page_view,
5368		    pages = Math.ceil(total/view),
5369		    end = (Math.floor((page_num-1) / page_view) + 1) * page_view,
5370		    end = (end>pages) ? pages : end,
5371		    prev = (start > 0) ? start : 1,
5372		    next = ((end+1) > pages) ? pages : end+1;
5373
5374		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>'),
5375			$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>');
5376			
5377		$obj.empty();
5378		$obj.append($prev);
5379		for(i=start;i<end;i++) {
5380			var active = ((i+1) == page_num) ? 'active' : '';
5381			$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>'));
5382		}
5383		if(end==0) { 
5384			$obj.append($('<li class="forum-group-member-pagination" data-id="' + id + '" data-view="' + page_view + '" data-page-num="0"><a href="#">1</a></li>'));
5385		}
5386		$obj.append($next);
5387	}
5388
5389	$doc.on('click','.forum-group-member-pagination', function(e) {
5390		var id = $(this).attr('data-id'),
5391			page = $(this).attr('data-page-num');
5392		if(page==0) return false;
5393	});
5394
5395	var tplmemberSearch = function(id) {
5396		var str = '\
5397			<div class="forum-member-search">\
5398				<input type="text" class="config-input member-search" placeholder="' + $.lang[LANG]['board.enter-member-id'] + '">\
5399				<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>\
5400			</div>\
5401		';
5402		return str;
5403	}
5404
5405	$doc.on('change','#g-sfl',function(e) {
5406		$('.btn-forum-group-search').click();
5407	});
5408
5409	$doc.on('click','.btn-forum-group-search',function(e) {
5410		if($(this).hasClass('clicked')) return false;
5411		else $(this).addClass('clicked');
5412
5413		var id = $(this).attr('data-id'),
5414			gsfl = $('#g-sfl option:selected').attr('data-id'),
5415			gstx = $('#g-stx').val().toLowerCase().trim(),
5416			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
5417			str = '';
5418
5419		if(checkEmojis(gstx)) {
5420			e.preventDefault();
5421			$('.btn-forum-group-search').removeClass('clicked');
5422			errorEmojisModal();
5423			return false;
5424		}
5425
5426		$.post('/fm/group/membersearch', { id : id, gsfl : gsfl, gstx : gstx, mtype:mtype }, function(data) {
5427			if(typeof data.error != 'undefined' && data.error) {
5428				$('#group-accordion').html('<div class="empty">' + data.error + '</div>');
5429				$('.btn-forum-group-search').removeClass('clicked');
5430				return false;
5431			}
5432			if(!$.isNumeric(gsfl) && !gstx) {
5433				$('#g-stx').val('');
5434				$('#g-sfl option:first-child').attr('selected',true);
5435				$.forum.getgroupdata($('.flat-gc-modal .modal').attr('data-fid'));
5436				$('.btn-forum-group-search').removeClass('clicked');
5437				return false;
5438			}
5439
5440			if(data.total>0) {
5441				var group = '',
5442					mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink';
5443
5444				$.each(data.list, function(i,v) {
5445					if(group != v.fg_id) {
5446						group = v.fg_id;
5447						str = (group=='') ? '' : str + '\
5448									</ul>\
5449								</div>\
5450							</div>\
5451						</div>\
5452						';
5453						str = str + '\
5454						<div class="panel">\
5455							<div class="panel-heading">\
5456								<div class="panel-title">\
5457									<a class="accordion-toggle collapsed group-item" data-id="' + group + '" data-member-count="' + v.fg_member_count + '">\
5458										<label class="group-name hand">' + v.fg_name + '</label>\
5459										<span class="group-member-count">' + v.fg_member_count + '</span>\
5460										<svg viewBox="0 0 8 4" width="8" height="4"><polygon points="0 0 4 4 8 0 "/></svg>\
5461									</a>\
5462									<div class="content">\
5463										<span>\
5464											<svg viewBox="0 0 13 13" width="13" height="13" class="group-user-add hand">\
5465												<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 "/>\
5466												<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"/>\
5467											</svg>\
5468										</span>\
5469										<span>\
5470											<svg viewBox="0 0 13 13" width="13" height="13" class="group-name-edit hand">\
5471												<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"/>\
5472												<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"/>\
5473											</svg>\
5474										</span>\
5475										<span>\
5476											<svg viewBox="0 0 12 13" width="12" height="13" class="group-delete hand">\
5477												<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"/>\
5478												<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
5479											</svg>\
5480										</span>\
5481									</div>\
5482								</div>\
5483							</div>\
5484							<div id="group-list-' + group + '" class="panel-collapse" style="display:none;">\
5485								<div class="panel-body">\
5486									<ul class="group-member-list">\
5487						';
5488					}
5489					if(v.fg_member_count!=0) {
5490						str += '\
5491										<li class="gm-item">\
5492											<div>\
5493												<div class="gmi-img">\
5494													<span class="hexagon">\
5495														<img src="'+v.img+'" alt="" class="img-responsive">\
5496													</span>\
5497												</div>\
5498					                			<div class="gmi-info">\
5499					    ';
5500					    if(v.name != v.id && v.name) {
5501						    str += '\
5502						                			<span class="gmi-name">' + v.name + '</span>\
5503							';
5504						}
5505						str += '\
5506						                			<span class="gmi-id">' + v.id + '</span>\
5507					                			</div>\
5508					                			<div class="gmi-btn">\
5509													<svg viewBox="0 0 12 13" width="12" height="13" class="gmi-del hand" data-userid="' + v.id + '" data-id="' + v.fg_id + '" data-mtype="' + mtype + '">\
5510														<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"/>\
5511														<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
5512													</svg>\
5513												</div>\
5514											</div>\
5515										</li>\
5516						';
5517					} else {
5518						str = str + '<div class="empty">' + $.lang[LANG]['board.group-no-members'] + '</div>';
5519					}
5520				});
5521				str = str + '\
5522									</ul>\
5523								</div>\
5524							</div>\
5525						</div>\
5526				';
5527			}
5528			//  else {
5529			// 	str = '<div class="empty">' + $.lang[LANG]['board.empty-member-in-group'] + '</div>';
5530			// }
5531			$('#group-accordion').html(str);
5532			$('.btn-forum-group-search').removeClass('clicked');
5533
5534		}, 'json');
5535	});
5536
5537	var displayMember = function(mb) {
5538		var str = '\
5539			<li>\
5540				<span class="userimg"><img src="' + mb.img + '"></span>\
5541				<span class="user-info"><div class="user-name">' + mb.name + '</div><div class="user-id">' + mb.id + '</div></span>\
5542				<div class="userdel" data-userid="' + mb.id + '" data-id="' + mb.fg_id + '"><i class="fa fa-trash-o"></i></div>\
5543			</li>\
5544		';
5545		return str;
5546	}
5547
5548	$doc.on('click','.member .userdel', function(e) {
5549		var userid = $(this).attr('data-userid'),
5550			id = $(this).attr('data-id'),
5551			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink';
5552
5553		initControlForm();
5554		$('.delete-member-userid').text(userid);
5555		$('.btn-forum-group-delete-member-ok').attr('data-userid',userid).attr('data-id',id).attr('data-mtype',mtype);
5556		$('.forum-group-delete-member-confirm').show();
5557	});
5558
5559	$doc.on('click','.btn-forum-group-delete-member-ok',function(e) {
5560		var userid = $(this).attr('data-userid'),
5561			id = $(this).attr('data-id'),
5562			mtype = $(this).attr('data-mtype');
5563
5564		$.post('/fm/group/userdel', { id : id, userid : userid, mtype : mtype }, function(data) {
5565			if(typeof data.error != 'undefined' && data.error) {
5566				$('.forum-group-delete-member-confirm .content').append('<div class="config-error">' + data.error + '</div>')
5567				return false;
5568			}
5569		},'json');
5570	});
5571
5572
5573	$doc.on('click','.forum-category-custom-toggle', function(e) {
5574		e.preventDefault();
5575		e.stopPropagation();
5576
5577		var $custom = $(this).closest('.forum-category-custom-select'),
5578			is_open = $custom.hasClass('open');
5579
5580		closeForumCategoryCustomSelect($('.forum-category-custom-select.open').not($custom));
5581		if(is_open) closeForumCategoryCustomSelect($custom);
5582		else openForumCategoryCustomSelect($custom);
5583	});
5584
5585	$doc.on('click','.forum-category-custom-option', function(e) {
5586		e.preventDefault();
5587		e.stopPropagation();
5588
5589		var $option = $(this),
5590			$custom = getForumCategoryCustomOwner($option),
5591			$select = $custom.siblings('#scate').first(),
5592			value = (typeof $option.attr('data-value') == 'undefined') ? '' : $option.attr('data-value');
5593
5594		closeForumCategoryCustomSelect($custom);
5595		if($select.length == 0 || String($select.val()) == String(value)) return false;
5596
5597		$select.val(value).trigger('change');
5598	});
5599
5600	$doc.on('keydown','.forum-category-custom-toggle', function(e) {
5601		if(e.which == 13 || e.which == 32 || e.which == 40) {
5602			e.preventDefault();
5603			$(this).trigger('click');
5604			getForumCategoryCustomMenu($(this).closest('.forum-category-custom-select')).find('.forum-category-custom-option.active').focus();
5605		}
5606	});
5607
5608	$doc.on('keydown','.forum-category-custom-option', function(e) {
5609		var $option = $(this),
5610			$custom = getForumCategoryCustomOwner($option);
5611
5612		if(e.which == 13 || e.which == 32) {
5613			e.preventDefault();
5614			$option.trigger('click');
5615		} else if(e.which == 27) {
5616			e.preventDefault();
5617			closeForumCategoryCustomSelect($custom);
5618			$custom.find('.forum-category-custom-toggle').focus();
5619		} else if(e.which == 38 || e.which == 40) {
5620			e.preventDefault();
5621			var $options = getForumCategoryCustomMenu($custom).find('.forum-category-custom-option'),
5622				idx = $options.index($option),
5623				next_idx = (e.which == 38) ? idx - 1 : idx + 1;
5624
5625			if(next_idx < 0) next_idx = $options.length - 1;
5626			if(next_idx >= $options.length) next_idx = 0;
5627			$options.eq(next_idx).focus();
5628		}
5629	});
5630
5631	$doc.on('click', function(e) {
5632		if($(e.target).closest('.forum-category-custom-select, .forum-category-custom-menu-layer').length == 0) {
5633			closeForumCategoryCustomSelect($('.forum-category-custom-select.open'));
5634		}
5635	});
5636
5637	$(window).on('scroll.forumCategoryCustomSelect resize.forumCategoryCustomSelect', function() {
5638		closeForumCategoryCustomSelect($('.forum-category-custom-select.open'));
5639	});
5640	$('.dsgn-body').on('scroll.forumCategoryCustomSelect', function() {
5641		closeForumCategoryCustomSelect($('.forum-category-custom-select.open'));
5642	});
5643
5644	$doc.on('change','#scate', function(e) {
5645		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
5646		
5647		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
5648		var sfl = $(this).parents('.search-box').find('#sfl').val(),
5649			stx = '',
5650			scate = $(this).find('option:selected').val(),
5651			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
5652			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
5653			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
5654			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
5655
5656		stx = getForumPrevStx(id);
5657		setForumCategoryActive($(this).parents('.element'), scate);
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		scrollToForumBlock($(this).parents('.element'));
5663	});
5664
5665	$doc.on('click','.tpl-forum-category-nav .tpl-forum-category-item', function(e) {
5666		e.preventDefault();
5667		if($(this).closest('.element').attr('data-type') != 'forum') return false;
5668
5669		var $forum_el = $(this).closest('.element'),
5670			scate = $(this).attr('data-cate') || $(this).find('> a').attr('data-cate') || '';
5671
5672		if($(this).hasClass('active')) return false;
5673
5674		var dataCheck = ($forum_el.find('.tpl-forum-pagination').children().length > 0) ? true : false;
5675		$this_pagination = $forum_el.find('.tpl-forum-pagination li.active');
5676
5677		var sfl = $forum_el.find('.search-box #sfl').val(),
5678			stx = '',
5679			id = (dataCheck) ? $this_pagination.attr('data-id') : $forum_el.attr('data-id'),
5680			page = (dataCheck) ? $this_pagination.attr('data-page') : $forum_el.find('.tpl-forum-pagination').attr('data-page'),
5681			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
5682			view = (dataCheck) ? $this_pagination.attr('data-view') : $forum_el.find('.tpl-forum-pagination').attr('data-view');
5683
5684		stx = getForumPrevStx(id);
5685		setForumCategoryActive($forum_el, scate);
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		scrollToForumBlock($forum_el);
5691	});
5692
5693	$('.search-btn').live('click', function(e) {
5694		if($(this).parents('.element').attr('data-type') != 'forum') return false;
5695		e.preventDefault();
5696		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
5697		
5698		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
5699		var sfl = $(this).parents('.search-box').find('#sfl').val(),
5700			stx = $(this).parents('.search-box').find('#stx').val(),
5701			scate = getForumScate($(this).parents('.element')),
5702			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
5703			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
5704			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
5705			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
5706
5707		var regexp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+┼<>@\#$%&\'\"\\\(\=“‘,]/gi;
5708		if(regexp.test(stx) || regexp.test(scate)) {
5709			$(this).showModalFlat('ERROR', '특수문자를 입력할 수 없습니다.', true , false, '', 'close');
5710			return false;
5711		}
5712
5713    	$.forum.setForumCookie(id,page_num,stx,sfl,scate);
5714		cookie_page_num = $.cookie('forum_'+id);
5715		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
5716		activeEL('userEL'+id);
5717	});
5718
5719	$doc.on('keypress','input#stx', function (e) {
5720		if(e.which == 13 && $(this).val().length>0) $(this).closest('.search-box').find('.search-btn').click();
5721	});
5722
5723	$('.element[data-type="forum"]:not([data-type2="guestbook"]) .search-forum-user-posts').die('click');
5724	$('.element[data-type="forum"]:not([data-type2="guestbook"]) .search-forum-user-posts').live('click', function(e) {
5725		e.stopPropagation();
5726		var parentEl = $(this).parents('.element');
5727		var dataCheck =  (parentEl.find('.tpl-forum-pagination').children().length > 0) ? true :  false;
5728		
5729		$this_pagination = parentEl.find('.tpl-forum-pagination li.active');
5730		var stx = $(this).attr('data-userid'),
5731			sfl = (stx)? 'mb_id' : 'nonmem',
5732			scate = '',
5733			id = (dataCheck) ? $this_pagination.attr('data-id') : parentEl.attr('data-id'),
5734			page = (dataCheck) ? $this_pagination.attr('data-page') : parentEl.find('.tpl-forum-pagination').attr('data-page'),
5735			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
5736			view = (dataCheck) ? $this_pagination.attr('data-view') : parentEl.find('.tpl-forum-pagination').attr('data-view');
5737		if(!stx) {
5738			stx = $(this).attr('data-username');
5739		}
5740
5741    	$.forum.setForumCookie(id,page_num,stx,sfl,scate);
5742		cookie_page_num = $.cookie('forum_'+id);
5743		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
5744		activeEL('userEL'+id);
5745	});
5746
5747	$(document).on('mousedown','.fr-file',function(e) {
5748		if(PAGE_MODE!='c') {
5749			var url = new getLocation($(this).closest('[data-href]').attr('data-href')),
5750				file_name = encodeURIComponent($(this).find('.fr-file-nm').text().trim() + $(this).find('.fr-file-ext').text().trim());
5751			file_name = file_name == '' ? $(this).text().trim() : file_name;
5752			var go = '/down?n=' + file_name + '&s=' + (url.pathname).replace('/cr-resource/forum/','').replace('/','&f=');
5753			window.open(go,'_blank');
5754		}
5755	});
5756
5757
5758	function groupAddClass(group_member_list_check, $select, input_text, member_list) {
5759
5760		$select.parents('.panel').find('.empty').hide();
5761		if(group_member_list_check > 0) $select.parents('.panel').find('.group-member-list').prepend(input_text);		
5762		else $select.parents('.panel').find('.panel-body').append(member_list);
5763		settingEditMode(true);
5764	}
5765
5766
5767
5768
5769		var bindForumCategorySortable = function() {
5770			$('.forum-category-content:not(.empty)').sortable({
5771				items: '.forum-category-item',
5772				cancel: '.forum-category-update-cancel, button, .forum-category-update-name',
5773				handle: '.forum-category-info > .icons.cl-sort-handle svg',
5774				update: function (event, ui) {
5775					var pid = $(this).closest('.flat-forum-category-modal').find('.modal[id*=flat-modal]').attr('data-pid');
5776					if(!pid && typeof selectEL != 'undefined') pid = $('.'+selectEL).attr('data-id');
5777
5778					$(this).children().each(function(i,o) {
5779						var cate = $(this).attr('data-cate');
5780						$(this).attr('id','forumCateSort'+i).attr('data-idx',i);
5781						$(this).find('[data-idx]').each(function() { $(this).attr('data-idx',i); });
5782						if(!cate) return true;
5783
5784						$.post('/fm/category/replace', { sid : F_SID, pid : pid, cate : cate, code : i+1 }, function(data) {
5785							if(typeof data.error != 'undefined' && data.error) {
5786								$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
5787								return false;
5788							}
5789						},'json');
5790					});
5791				}
5792			}).disableSelection();
5793		}
5794
5795		$doc.on('hidden.bs.modal', '.flat-forum-category-modal', function() {
5796			var fcategory_str = '';
5797			$(this).find('.forum-category-name').each(function(idx) {
5798				fcategory_str += (idx == 0) ? $(this).text() : ', '+$(this).text();
5799			});
5800
5801			var pid = $(this).find('.modal[id*=flat-modal]').attr('data-pid'),
5802				$forum_el = $('.element[data-id="' + pid + '"]');
5803			if($forum_el.find('#scate').length > 0 && !$forum_el.find('#scate').hasClass('hide')) {
5804				$.forum.drawSelboxCategory($forum_el,pid);
5805			}
5806
5807		if(!fcategory_str) fcategory_str = $.lang[LANG]['editor.category.empty'];
5808		if($('#el-blockConfig').length > 0) $('#ctrl-card-list-category .selected-category').text(fcategory_str);
5809		$(this).remove();
5810	});
5811
5812	var openForumCategoryConfig = function(id) {
5813		var str = '';
5814		if(typeof id == 'undefined' && typeof selectID != 'undefined') id = selectID;
5815
5816		$.post('/fm/category/list', { pid: id, sid: F_SID }, function(data) {
5817			if(typeof data.error != 'undefined' && data.error) {
5818				$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
5819				return false;
5820				}
5821				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');
5822				bindForumCategorySortable();
5823			}, 'json');
5824		};
5825
5826	$doc.on('click','#el-blockConfig .forum-category-config',function(e) {
5827		openForumCategoryConfig(selectID);
5828	});
5829
5830        
5831
5832	//forum category Config (Add.Edit.Remove)
5833	var categoryConfigForum = function (data,id) {
5834		var empty = (data.length > 0) ? '' : 'empty',
5835			forum_category_list = '',
5836			str = '';
5837
5838		$.each(data, function(i,v) {
5839			if(v) forum_category_list = forum_category_list + forumCategoryItem(v.fca_name.trim(), i,v.seq);
5840		});
5841
5842		forum_category_list = (empty) ? '<p>' + $.lang[LANG]['editor.category.empty'] + '</p>' : forum_category_list;
5843
5844		str = '\
5845        <div class="forum-category-header">\
5846            <p>' + $.lang[LANG]['editor.category.description'] + '</p>\
5847        </div>\
5848        <div class="forum-category-content ' + empty + '">\
5849            ' + forum_category_list + '\
5850        </div>\
5851        <div class="btn-wrap">\
5852        	<span class="btn forum-category-add">\
5853				<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>\
5854				' + $.lang[LANG]['config.gallery.add'] + '\
5855			</span>\
5856        </div>\
5857        ';
5858		return str;
5859	}
5860
5861	var forumCategoryItem = function(name,idx,seq) {
5862		var categoryAdd = (!name) ? 'additem' : '',
5863			cate_seq = (!seq) ? '' : seq;
5864
5865		var str = '\
5866			<div class="forum-category-item ' + categoryAdd + '" id="forumCateSort' + idx + '" data-idx="' + idx + '" data-cate="' + cate_seq + '">\
5867				<div class="forum-category-info">\
5868					<span class="icons cl-sort-handle">\
5869						' + clSVG('move_handle', 20, 20) + '\
5870					</span>\
5871					<span class="forum-category-name">' + name + '</span>\
5872				</div>\
5873				<div class="forum-config-icons">\
5874					<div class="icons hand">\
5875						<svg viewBox="0 0 13 13" width="13" height="13" class="forum-category-edit" data-idx="' + idx + '">\
5876							<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"/>\
5877						</svg>\
5878					</div>\
5879					<div class="icons hand">\
5880						<svg viewBox="0 0 12 13" width="12" height="13" class="forum-category-delete hand" data-idx="' + idx + '">\
5881							<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"/>\
5882						</svg>\
5883					</div>\
5884				</div>\
5885			</div>\
5886		';
5887		return str;
5888	}
5889
5890	var forumCategoryItemEmptyCheck = function() {
5891		if($('.forum-category-content').find('.forum-category-item').length == 0) {
5892			$('.forum-category-content').addClass('empty').html('<p>' + $.lang[LANG]['editor.category.empty'] + '</p>');
5893			} else {
5894				$('.forum-category-content').removeClass('empty').find('p').remove();
5895				bindForumCategorySortable();
5896			}
5897		}
5898
5899	var addForumCategoryInput = function(cateidx, catename, cateseq) {
5900		var cateidx = (typeof cateidx == 'undefined' || !cateidx) ? $('.forum-category-content .forum-category-item').length : cateidx;
5901		var cateseq = (typeof cateseq == 'undefined' || !cateseq) ? '' : cateseq;
5902		var catename = (typeof catename == 'undefined' || !catename) ? '' : catename;
5903		// var catecode = (typeof catecode == 'undefined' || !catecode) ? Number($('.forum-category-content .forum-category-item').last().attr('data-code')) + 1 : catecode;
5904
5905		return `
5906				<div class="forum-category-update">
5907					<div class="input-group">
5908						<input type="text" class="forum-category-update-name forum-control" placeholder="${$.lang[LANG]['editor.gallery.category.enter-name']}" value="${catename}"/>
5909						<span class="input-group-btn">
5910							<button class="forum-category-update-save btn btn-active" data-id="${selectID}" data-idx="${cateidx}" data-cate="${cateseq}">
5911								<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>
5912							</button>
5913						</span>
5914						<div class="forum-category-update-cancel">
5915							<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>
5916						</div>
5917					</div>
5918				</div>
5919		`;
5920	}
5921
5922	$doc.on('click', '.forum-category-delete', function(e) {
5923		// var checkLast = ($(this).closest('.forum-category-content').find('.forum-category-item').length <= 1) ? true : false;
5924		// if(checkLast) {
5925		// 	$(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');
5926		// 	return false;
5927		// }
5928		
5929        var idx = $(this).attr('data-idx');
5930        var cate = $('.forum-category-content #forumCateSort'+idx).attr('data-cate');
5931        var category_del_modal = $(this).showModalFlat($.lang[LANG]['editor.gallery.category.delete.title'], $.lang[LANG]['editor.gallery.category.delete'], true, true, function() {
5932
5933			$.post('/fm/category/delete', {  sid : F_SID, pid : selectID, cate: cate}, function(data) {
5934				if(typeof data.error != 'undefined' && data.error) {
5935					return false;
5936				}
5937					$('.forum-category-content #forumCateSort'+idx).remove();
5938					$('.'+selectEL).find('#scate option[value="' + data.seq + '"]').remove();
5939					$('.'+selectEL).find('.tpl-forum-category-item[data-cate="' + data.seq + '"]').remove();
5940					if($('.'+selectEL).find('.tpl-forum-category-item.active').length == 0) setForumCategoryActive($('.'+selectEL), '');
5941					$('.'+selectEL).find('.tpl-forum-list-category[data-cate="' + cate + '"]').text('');
5942					syncForumCategoryOptionWidth($('.'+selectEL));
5943					syncForumCategoryCustomSelect($('.'+selectEL));
5944					syncForumCategoryDelimiterRows($('.'+selectEL));
5945
5946				$('.forum-category-content .forum-category-item').each(function(i) {
5947					$(this).attr('id','forumCateSort'+i).attr('data-idx',i);
5948					$(this).find('[data-idx]').each(function() { $(this).attr('data-idx',i); });
5949				});
5950
5951				forumCategoryItemEmptyCheck();
5952				category_del_modal.modal('hide');
5953			},'json');
5954
5955        },'cancel','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 zindex1046');
5956
5957	});
5958
5959	$doc.on('click', '.forum-category-add', function(e) {
5960		if($('.forum-category-content').find('.forum-category-update').length > 0 ) {
5961			$('.forum-category-content').find('.forum-category-update-name').focus();
5962			return false;
5963		}
5964		
5965        var idx = $('.forum-category-content .forum-category-item').length;
5966        var str = forumCategoryItem('',idx,'');
5967		// var code = (idx > 0) ? Number($('.forum-category-content .forum-category-item').last().attr('data-code')) + 1 : 1,
5968
5969        $('.forum-category-content').append(str);
5970
5971        forumCategoryItemEmptyCheck();
5972        $('.forum-category-edit[data-idx=' +idx +']').click();
5973	});
5974
5975	$doc.on('click', '.forum-category-edit', function(e) {
5976        if($('.forum-category-content').find('.forum-category-update').length>0) return false;
5977
5978        var cate_idx = $(this).attr('data-idx');
5979        var $category_item = $('.forum-category-content').find('#forumCateSort'+cate_idx);
5980		var cate_seq = $category_item.attr('data-cate');
5981		var cate_name = $category_item.find('.forum-category-name').text();
5982
5983        var input_text = addForumCategoryInput(cate_idx,cate_name,cate_seq);
5984
5985        $(input_text).appendTo($category_item.find('.forum-category-info'));
5986
5987        $('.forum-category-content').find('.forum-category-item').removeClass('editing').css('pointer-events','none');
5988        $category_item.addClass('editing').css('pointer-events','auto');
5989        $('.forum-category-content').find('.forum-category-update-cancel, .forum-category-update-save, .forum-category-update-name').css('pointer-events','auto');
5990        $('.forum-category-update .forum-category-update-name').focus();
5991	});
5992
5993	$doc.on('click', '.forum-category-update-cancel', function(e) {
5994		if(!$(this).closest('.forum-category-info').find('.forum-category-name').text()) {
5995			$(this).closest('.forum-category-item').remove();
5996			forumCategoryItemEmptyCheck();
5997		}
5998		$('.forum-category-content').find('.config-error').remove();
5999		$('.forum-category-content').find('.forum-category-item').removeClass('editing').removeAttr('style');
6000		$('.forum-category-content').find('.forum-category-update').remove();
6001	});
6002
6003	$doc.on('click', '.forum-category-update-save', function(e) {
6004		if($(this).hasClass('clicked')) return false;
6005		else $(this).addClass('clicked');
6006
6007        var pid = $(this).attr('data-id');
6008        var idx = $(this).attr('data-idx');
6009        var cate_seq = $('.forum-category-content').find('#forumCateSort'+idx).attr('data-cate');
6010        var position = $('.forum-category-content');
6011        var category_name = $('.forum-category-update-name').val().trim();
6012        var category_prev = position.find(`#forumCateSort${idx} .forum-category-name`).text().trim();
6013		var categoryRegexp =  /[\[\]|,'"<>{}\/\\:;%&@$!*?\^]/;
6014
6015        $position = (position.find('.forum-category-item').length > idx) ? position.find(`#forumCateSort${idx}`) : position;
6016
6017        $('.config-error').remove();
6018		var show_error_fc_save = function(error_message) {
6019			$position.append('\
6020				<div class="config-error">\
6021					' + clSVG('info',13,13) +'\
6022					<span>' + error_message + '</span>\
6023				</div>\
6024		    ');
6025		    $('.forum-category-update-save').removeClass('clicked');
6026		}
6027
6028        if(category_prev == category_name) {
6029            if($('.forum-category-content #forumCateSort'+idx).hasClass('additem')) {
6030            	show_error_fc_save($.lang[LANG]['editor.gallery.category.enter-name']);
6031            } else {
6032	                $('.forum-category-content').find('.forum-category-item').removeClass('editing').removeAttr('style');
6033	                $('.forum-category-content').find('.forum-category-update').remove();
6034                $('.forum-category-update-save').removeClass('clicked');
6035            }
6036            return false;
6037        }
6038        if(categoryRegexp.test(category_name)) {
6039        	show_error_fc_save($.lang[LANG]['board.allowed-chars']);
6040            return false;
6041        }
6042        if(category_name.length<1) {
6043        	show_error_fc_save($.lang[LANG]['board.enter-group-name']);
6044            return false;
6045        }
6046        if(category_name.length>30) {
6047        	show_error_fc_save($.lang[LANG]['board.enter-max-chars.30']);
6048            return false;
6049        }
6050        var list =  position.find('.forum-category-item .forum-category-name').map(function() { return $(this).text().trim(); }).get();
6051        if($.inArray(category_name,list) > -1 ) {
6052        	show_error_fc_save($.lang[LANG]["editor.gallery.category.inuse-name"]);
6053        	return false;
6054        }
6055
6056
6057		$.post('/fm/category/update', {  sid : F_SID, pid : pid, cate: cate_seq, name : encodeURIComponent(category_name) }, function(data) {
6058			if(typeof data.error != 'undefined' && data.error) {
6059				show_error_fc_save(data.error);
6060				return false;
6061			}
6062
6063			if($('#forumCateSort'+idx).hasClass('additem')) $('#forumCateSort'+idx).removeClass('additem');
6064			$('#forumCateSort'+idx).attr('data-cate',data.seq);
6065			$('#forumCateSort'+idx).find('.forum-category-name').text(category_name);
6066
6067				position.find('.forum-category-item').removeClass('editing').removeAttr('style');
6068				position.find('.forum-category-update').remove();
6069
6070				if($('.'+selectEL).find('#scate option[value="' + data.seq + '"]').length > 0 ) $('.'+selectEL).find('#scate option[value="' + data.seq + '"]').text(category_name);
6071				else $('.'+selectEL).find('#scate').append($('<option>').attr('value', data.seq).text(category_name));
6072
6073				if($('.'+selectEL).find('.tpl-forum-category-item[data-cate="' + data.seq + '"]').length > 0 ) {
6074					$('.'+selectEL).find('.tpl-forum-category-item[data-cate="' + data.seq + '"] > a').text(category_name);
6075				} else {
6076					$('.'+selectEL).find('.tpl-forum-category-list').append(
6077						$('<li class="tpl-forum-category-item">').attr('data-cate',data.seq).append(
6078							$('<a href="javascript:;">').attr('data-cate',data.seq).text(category_name)
6079						)
6080					);
6081				}
6082
6083				$('.'+selectEL).find('.tpl-forum-list-category[data-cate='+data.seq+']').text(category_name);
6084				syncForumCategoryOptionWidth($('.'+selectEL));
6085				syncForumCategoryCustomSelect($('.'+selectEL));
6086				syncForumCategoryDelimiterRows($('.'+selectEL));
6087			
6088			$('.forum-category-update-save').removeClass('clicked');
6089		},'json');
6090	});
6091
6092		var displayCategoryHtml = function(id,list_data,sel_replace,block_lang) {
6093			var $forum_el = $(sel_replace),
6094				category_hidden = $forum_el.find('#scate').hasClass('hide'),
6095				scate = '',
6096			$select = $('<select id="scate" class="form-control" name="scate">').attr('placeholder', $.lang[block_lang]['board.scate']),
6097			$category_nav = $('<div class="tpl-forum-category-nav">'),
6098			$category_list = $('<ul class="tpl-forum-category-list">'),
6099			all_label = getForumCategoryAllLabel(block_lang);
6100
6101		if(typeof $.cookie('forum_'+id+'_scate') != 'undefined' && $.cookie('forum_'+id+'_scate')) scate = $.cookie('forum_'+id+'_scate');
6102
6103		$select.append($('<option>').attr('value','').text($.lang[block_lang]['board.scate']));
6104		$category_list.append(
6105			$('<li class="tpl-forum-category-item">').attr('data-cate','').append(
6106				$('<a href="javascript:;">').attr('data-cate','').text(all_label)
6107			)
6108		);
6109
6110		$.each(list_data, function(i,v) {
6111			var cate_seq = (typeof v['seq'] != 'undefined') ? String(v['seq']) : '',
6112				cate_name = (typeof v['fca_name'] != 'undefined') ? v['fca_name'] : '';
6113
6114			$select.append($('<option>').attr('value',cate_seq).prop('selected', scate == cate_seq).text(cate_name));
6115			$category_list.append(
6116				$('<li class="tpl-forum-category-item">').attr('data-cate',cate_seq).append(
6117					$('<a href="javascript:;">').attr('data-cate',cate_seq).text(cate_name)
6118				)
6119			);
6120		});
6121
6122		$category_nav.append($category_list);
6123		$forum_el.find('#scate').replaceWith($select);
6124		$forum_el.find('#scate').parent().removeClass('hidden').addClass('forum-category-select-wrap');
6125		if(category_hidden) $forum_el.find('#scate').addClass('hide');
6126
6127		placeForumCategoryNav($forum_el, $category_nav);
6128
6129		setForumCategoryActive($forum_el, scate);
6130		syncForumCategoryTypeDisplay($forum_el);
6131	}
6132
6133	var displayTypeForum = function(data,$el,typeCheck,view,page_num,id) {
6134		var isMasonry = (typeCheck == 'card') ? true : false,
6135			forum_item = '';
6136
6137		$el.attr('data-list-type',typeCheck);
6138		if(isMasonry) $el.attr('data-msny', true);
6139		else $el.attr('data-msny', false);
6140
6141		$el.find('.table-container').empty();
6142		if(typeCheck == 'card') {
6143			$el.find('.table-container').append('<div class="table" data-loop="true"></div>');
6144		} else {
6145			$el.find('.table-container').append($(data.source).find('table'));
6146			$el.find('.table [data-loop="true"]').empty();
6147		}
6148
6149		var $row = $el.find('[data-loop="true"]'),
6150			loop = $(data.source).find('[data-loop="true"]').children().eq(0).clone();
6151
6152		$.each(data.list, function(i,v) {
6153			var num = data.total - (view * (page_num-1)) - i;
6154			if(isMasonry) {
6155				forum_item = forum_item + forumRow(v, num, page_num, id, $.forum.modoo_card, data.config, 'thumb', $(data.source));
6156			} else {
6157				$row.append(forumRow(v, num, page_num, id, loop, data.config, '', $(data.source)));
6158			}
6159		});
6160
6161		if(isMasonry) {
6162			$el.find('.table').attr('data-view',view);
6163
6164			var $forum_items = ($(forum_item).find('.item').length) ? $(forum_item) : $('<div>'+forum_item+'</div>');
6165			$forum_items.hide();
6166
6167			$row.before("<div class='forum-loading-status'><div class='loading-dots'></div></div>");
6168			var f_items = data.list.length;
6169			var f_process_index = 0;
6170
6171			$forum_items.children().imagesLoaded().progress(function(imgload, image) {
6172				f_process_index++;
6173				var $item = $(image.img).parents('.item');
6174				$item.show();
6175
6176				if(f_items == f_process_index) {
6177					var reload_forum_items = $forum_items.html();
6178					forumReloadMasonry($row,$(reload_forum_items));
6179				}
6180			});
6181		}
6182	}
6183
6184
6185	
6186	$doc.on('click', `
6187			[data-ver="1"][data-type="forum"][data-type2="faq"] tr .tpl-forum-list-title
6188		`, function(e) {
6189
6190		var isElview = ($('.elviewcss').length > 0) ? true : false;
6191		if(!isElview) {
6192			$(this).closest('tr').addClass('this');
6193			$(this).closest('[data-loop="true"]').find('tr').each(function() {
6194				var checkClick = $(this).hasClass('this'),
6195					checkClose = (!checkClick && $(this).find('.toggle').hasClass('open')) ? true : false;
6196
6197				if(checkClick || checkClose) {
6198					$(this).find('.toggle').toggleClass('open');
6199					$(this).toggleClass('open');
6200					$(this).next().toggle();
6201				}
6202			});
6203
6204			$(this).closest('[data-loop="true"]').find('tr.this').removeClass('this');
6205		}
6206	});
6207
6208	$doc.on('click', `
6209			[data-type="forum"][data-type2="faq"] .item .question .tpl-forum-list-title,
6210			[data-type="forum"][data-type2="faq"] .item .question .tpl-forum-list-faq-toggle
6211		`, function(e) {
6212
6213		var isElview = ($('.elviewcss').length > 0) ? true : false;
6214		if(!isElview) $(this).closest('.item').toggleClass('open').siblings().removeClass('open');
6215	});
6216
6217	$doc.on('click', `
6218			[data-type="forum"][data-type2="faq"] .tpl-forum-faq-edit,
6219			[data-type="forum"][data-type2="faq"] .tpl-forum-faq-del
6220		`, function(e) {
6221		var ctrlBtn = $(this),
6222			ctrlUL = ctrlBtn.closest('ul[data-id]');
6223
6224		if(ctrlBtn.hasClass('clicked')) return;
6225		ctrlBtn.addClass('clicked');
6226
6227		var pid = ctrlUL.attr('data-pid'),
6228			id = ctrlUL.attr('data-id'),
6229			mode = (ctrlBtn.is('.tpl-forum-faq-del')) ? 'del' : 'edit';
6230
6231		switch(mode) {
6232			case 'edit':
6233				ctrlBtn.removeClass('clicked');
6234				updateForumPost(id,pid);
6235				break;
6236
6237			case 'del':
6238				var faqdelModal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
6239					faqdelModal.modal('hide');
6240					$.forum.delete(id);
6241				}, '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() {
6242					ctrlBtn.removeClass('clicked');
6243				});
6244				break;
6245
6246			default:
6247				ctrlBtn.removeClass('clicked');
6248				break;
6249		}
6250
6251	// 	var view = $(this).parent('ul[data-id]').attr('data-id');
6252	// 	location.replace(forumUrl() + '/forum/view/' + view);
6253	});
6254
6255
6256}(jQuery));
6257
6258
6259var forumRow = function(row,num,page_num,pid,loop_item,config,type,$source) {
6260	var forum_row = document.createElement('div');
6261	$(forum_row).html(loop_item);
6262	$(forum_row).children().removeClass('active');
6263
6264	var checkNotice	= (row.option == 'N') ? true : false,
6265		checkSecret	= (row.option == 'S') ? true : false,
6266		checkNew	= (row.new) ? true : false,
6267		checkEmpty	= (row.title == '' && row.content == '') ? true : false,
6268		checkNamemask = (row.namemask) ? true : false;
6269
6270	var row_settings = getOrDefault(row,'settings',{})
6271		field_lang	= getOrDefault(config,'field_lang','EN'),
6272		max_title	= getOrDefault(config,'max_title',150),
6273		max_cont	= getOrDefault(config,'max_cont',300);
6274
6275	var url	= forumUrl(),
6276		href = $.inArray(type, ['faq','qna','guestbook']) > -1 ? 'javascript:void(0);' : url + '/forum/view/' + row.id,
6277		icon_notice	= (checkNotice) ? '<i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i>' : '',
6278		icon_secret	= (checkSecret) ? '<i class="tpl-forum-list-secret-icon cl-icon lock02" aria-hidden="true"></i>&nbsp;' : '',
6279		icon_new	= (checkNew) ? '<img src="//storage.googleapis.com/i.addblock.net/icon/icon_new_forum.png" title="new" alt="new">' : '';
6280
6281	var title_str	= (row.title) ? ((type == 'faq') ? row.title : htmlEntities(cutStrInBytes(htmlspecialchars_decode(row.title),max_title))) : '',
6282		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,
6283		is_Masonry = ($('.element[data-id="' + pid + '"]').attr('data-msny') == 'true') ? true : false,
6284		block_lang = ($('.element[data-id="' + pid + '"]').attr('data-blocklang')) ? $('.element[data-id="' + pid + '"]').attr('data-blocklang') : LANG;
6285
6286	if($.cookie('forum_'+pid+'_type') == 'card' ||
6287		typeof $.cookie('forum_'+pid+'_type') == 'undefined' && $source.attr('data-list-type') == 'card') is_Masonry = true;
6288
6289	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') : '';
6290	
6291	$(forum_row).find('.tpl-forum-list-num').text(num).attr('data-fm-num', num);
6292	if($(forum_row).find('.tpl-forum-list-num.two-digit-number').length){
6293		if($(forum_row).find('.tpl-forum-list-num').text() <= 9) {
6294			var two_count = $(forum_row).find('.tpl-forum-list-num').text()
6295			$(forum_row).find('.tpl-forum-list-num').text('0'+two_count)
6296		}
6297	}
6298	$(forum_row).find('.tpl-forum-list-hit').text(row.hit);
6299	$(forum_row).find('.tpl-forum-list-date').text(row.datetime);
6300	$(forum_row).find('.tpl-forum-list-name').attr('data-userid', row.fm_mb_id).text(row.name);
6301	$(forum_row).find('.tpl-forum-list-title').html(icon_secret + title_href).attr('data-option',row.option).attr('data-id',row.id
6301);
6302	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');
6303	$(forum_row).find('.sample-notice').remove();
6304
6305	if(row.fm_mb_id) $(forum_row).find('.tpl-forum-list-name').addClass('is-user');
6306	
6307	if(row.depth > 0 && !checkNotice) {
6308		if($(forum_row).find('.tpl-forum-list-name').hasClass('tpl-sync-reply')) $(forum_row).find('.tpl-forum-list-name').addClass('reply');
6309
6310		$(forum_row).find('.tpl-forum-list-title').addClass('reply');
6311		$(forum_row).find('.tpl-forum-list-title').prepend('<span class="tpl-forum-list-reply-name">' + row.reply_name + '</span>');
6312	}
6313	
6314	if(checkNamemask) {
6315		$(forum_row).find('.tpl-forum-list-name').addClass('namemask');
6316	}
6317
6318	if($(forum_row).find('.tpl-forum-list-cont').length > 0) {
6319		var row_content = row.content.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim,' ');
6320
6321		var cont_txt = (row.content.length > 0) ? row_content.replace(/(<([^>]+)>)/ig,' ') : '',
6322			cont_str = (cont_txt.length > 0) ? cutStrInBytes(cont_txt,max_cont) : '',
6323			cont_str = (type == 'guestbook' ? cont_txt : cont_str),
6324			cont_href = (title_str == '') ? '<a href="javascript:;" class="deleted"></a>' : '<a href="' + href + '">' + cont_str + '</a>';
6325		
6326		if(type == 'guestbook') {
6327			if($('.element[data-id="' + pid + '"]').find('.fr34-input-height').length) cont_str = '\"' + cont_str + '\"';
6328			cont_href = icon_secret + nl2br(cont_str);
6329		}
6330
6331		if($(forum_row).find('.tpl-forum-list-cont').find('.tpl-forum-list-more').length > 0) {
6332			var contmore_str = $(forum_row).find('.tpl-forum-list-cont').find('.tpl-forum-list-more').html();
6333			cont_href += '<div class="tpl-forum-list-more forum-contmore"><a href="' + href + '">' + contmore_str + '</a></div>';
6334			$(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);
6335		} 
6336		
6337		$(forum_row).find('.tpl-forum-list-cont').html(cont_href).attr('data-option',row.option).attr('data-id',row.id);
6338	}
6339	if($(forum_row).find('.tpl-forum-list-myimg').length > 0) {
6340		if($(forum_row).find('.tpl-forum-list-myimg').hasClass('hexagon')) {
6341			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>';
6342			$(forum_row).find('.tpl-forum-list-myimg').html(hexagon);
6343		} else {
6344			$(forum_row).find('.tpl-forum-list-myimg').html('<img src="' + row.myimg + '?_' + new Date().getTime() + '">');
6345		}
6346	}
6347
6348	if($(forum_row).find('.tpl-forum-list-category').length > 0 && $(forum_row).find('.tpl-forum-list-category').hasClass('.forum-contmore')==false) {
6349		var cate_name	= (row.category_name) ? row.category_name : '';
6350		$(forum_row).find('.tpl-forum-list-category').removeAttr('data-cate').empty();
6351		if(row.category_seq) $(forum_row).find('.tpl-forum-list-category').text(cate_name).attr('data-cate',row.category_seq);
6352	}
6353
6354	if($(forum_row).find('.tpl-forum-list-more').length > 0) {
6355		var more_str = $(forum_row).find('.tpl-forum-list-more').html();
6356		$(forum_row).find('.tpl-forum-list-more').html('<a href="' + href + '">' + more_str + '</a>' ).attr('data-option',row.option).attr('data-id',row.id);
6357	}
6358
6359	var comment_str = (row.comment > 0) ? row.comment : '';
6360	$(forum_row).find('.tpl-forum-list-comment').html(comment_str);
6361	if(!comment_str) {
6362		 $(forum_row).find('.tpl-forum-list-comment-icon').remove();
6363		 $(forum_row).find('.tpl-forum-list-comment').addClass('empty');
6364	} else {
6365		if($(forum_row).find('.tpl-forum-list-comment').length < 1) {
6366			var comment_icon = $source.find('.tpl-forum-list-comment-icon').clone();
6367			$(forum_row).find('.tpl-forum-list-comment').prev(comment_icon);
6368		}
6369		$(forum_row).find('.tpl-forum-list-comment').removeClass('empty');
6370	}
6371
6372	if(checkNotice) {
6373		var isMobileWidth = (isMobile() || (PAGE_MODE == 'r' && window.innerWidth <= 767))? true : false;
6374
6375		$(forum_row).find('.tpl-forum-list-num').addClass('n');
6376		if($(forum_row).find('[data-notice-type="text"]').length > 0) {
6377			icon_notice = '<span class="tpl-forum-list-notice">'+$.lang[block_lang]['forum.forum.notice.text']+'</span>';
6378			$(forum_row).find('.tpl-forum-list-title').addClass('tpl-forum-list-notice');
6379		}
6380		if($(forum_row).find('.tpl-forum-list-num').hasClass('notice-svg')) { //notice icon svg
6381			icon_notice = $source.find('.tpl-forum-list-num').find('.tpl-forum-list-notice-icon').outerHTML();
6382		}
6383
6384		$(forum_row).find('.tpl-forum-list-num').html(icon_notice);
6385		$(forum_row).find('.tpl-forum-list-title .tpl-forum-list-notice-icon, .tpl-forum-list-title .tpl-forum-list-notice').remove();
6386		$(forum_row).find('.tpl-forum-list-title').prepend(icon_notice);
6387	}
6388
6389	if($(forum_row).find('.tpl-forum-list-like').length > 0) {
6390
6391		var like_cnt = (row.like !== undefined && row.like.cnt !== undefined)? row.like.cnt : 0;
6392		$(forum_row).find('.tpl-forum-list-like').attr('data-id', row.id);
6393		if($(forum_row).find('.tpl-forum-list-like').is('td') && $(forum_row).find('.tpl-forum-list-like .forum-like-cnt').length == 0) {
6394			$(forum_row).find('.tpl-forum-list-like').text(like_cnt);
6395		} else {
6396			$(forum_row).find('.tpl-forum-list-like .forum-like-cnt').text(like_cnt);
6397		}
6398
6399		if(row.like !== undefined  && row.like.cnt !== undefined && row.like.own) $(forum_row).find('.tpl-forum-list-like').addClass('active');
6400		else $(forum_row).find('.tpl-forum-list-like').removeClass('active');
6401	}
6402
6403	switch(type) {
6404		case 'thumb':
6405			if($(forum_row).find('.tpl-forum-list-thumb').length > 0) {
6406				var f_color = ($('.element[data-id="' + pid + '"]').attr('data-fcolor')) ? $('.element[data-id="' + pid + '"]').attr('data-fcolor') : '#000000',
6407					ffolder = $('.element[data-id="' + pid + '"]').attr('data-width'),
6408					thumb_empty = (row.thumb == '' || row.title == '') ? true : false,
6409					content_noimage_img = (thumb_empty && row.content_noimage_img) ? setResizeImageFolder(ffolder,row.content_noimage_img) : row.content_noimage_img,
6410					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 + '\/'),
6411					thumb_href = (title_str == '') ? '<a href="javascript:;" class="deleted"></a>' : '<a href="' + href + '"></a>';
6412
6413				$(forum_row).find('.tpl-forum-list-thumb img').attr('src',thumb_src).wrap(thumb_href).attr('alt',row.title.replace(/\s/g,'-'));
6414
6415				if(thumb_empty) {
6416					if(!is_Masonry && !row.content_noimage_img) {
6417						var text = '<p class="noimage_text">no image</p>';
6418						$(forum_row).find('.tpl-forum-list-thumb').append(text);
6419						$(forum_row).find('.tpl-forum-list-thumb').css('background-color',Coloris.getChangeColorVal(f_color,'a',0.1));
6420						$(forum_row).find('.noimage_text').css('color',Coloris.getChangeColorVal(f_color,'a',0.15));
6421					}	
6422
6423					$(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').addClass('empty');
6424					$(forum_row).find('.tpl-forum-list-thumb').attr('data-option',row.option).attr('data-id',row.id);
6425				} else {
6426					$(forum_row).find('.noimage_text').remove();
6427					$(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').removeClass('empty');
6428					$(forum_row).find('.tpl-forum-list-thumb').attr('data-option',row.option).attr('data-id',row.id);
6429				}
6430
6431				if(content_noimage_img) $(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').addClass('empty_con_img');
6432				else $(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').removeClass('empty_con_img');
6433
6434				//$(forum_row).find('.tpl-forum-list-thumb.empty.empty_con_img img').css('display','block');
6435				if(is_Masonry && $(forum_row).find('.tpl-forum-list-thumb').not('.empty_con_img').hasClass('empty')) $(forum_row).find('.item-inner').addClass('msny_10');
6436			}
6437			break;
6438
6439		case 'faq': 
6440			var colspan = $(forum_row).find('th').length,
6441				settings = (typeof row.settings == 'undefined') ? {} : row.settings,
6442				wrap = (typeof settings.wrap != 'undefined') ? 'w' + settings.wrap : '',
6443				align = (typeof settings.align != 'undefined') ? settings.align : '',
6444				align_class = (align != '') ? 'text-'+align : '',
6445				list_no = $(forum_row).find('.tpl-forum-list-num').hasClass('fl-num'),
6446				icon_wrap = $(forum_row).find('.tpl-forum-list-num').data('icon-wrap'),
6447				unit_icon = $(forum_row).find('.tpl-forum-list-etc').data('uniticon') ? clSVG($(forum_row).find('.tpl-forum-list-etc').data('uniticon'),16,16) : '',
6448				unit = ($(forum_row).find('.tpl-forum-list-num').hasClass('unit-empty')) ? { 'question':unit_icon, 'answer':'' } : { 'question':'Q', 'answer':'A' };
6449
6450			colspan = colspan + $(forum_row).find('td').length;
6451
6452			var answer_len = $source.find('.answer').length,
6453				an_class = (typeof $source.find('.answer').attr('class') != 'undefined') ? $source.find('.answer').attr('class') : '',
6454				an_th_class = 'tpl-forum-list-num tpl-forum-list-etc';
6455
6456			var $answer = $('<tr class="'+an_class+'">');
6457			if(answer_len > 0) {
6458				var an_html = $source.find('.answer:eq(0)').outerHTML();
6459				var $an_html2 = $(htmlspecialchars_decode(an_html));
6460				an_th_class = (typeof $an_html2.find('th').attr('class') != 'undefined') ? $an_html2.find('th').attr('class') : '';
6461				$an_html2.empty();
6462				$answer = $an_html2.attr('style','');
6463			}
6464
6465			var answerClass = ($source) ? (($source.find('.tpl-forum-list-cont').length > 0) ? $source.find('.tpl-forum-list-cont').attr('class').replace(/fsize\d+/gi,'') : '') : '',
6466				toggleOpenContent = ($source.find('.answer').length>0) ? '' : 'toggleOpenContent',
6467				answer_col = $source.find('.tpl-forum-list-cont').data('answer-col'),
6468				answer_colspan = (answer_col) ? colspan : colspan-1;
6469
6470			$answer.append('<th scope="row" class="'+an_th_class+'">' + unit['answer'] + '</th>');
6471			$answer.append('<td class="'+answerClass+' '+toggleOpenContent+'" colspan="' + answer_
6471colspan + '">' + ((typeof config.faq_view_msg != 'undefined' && config.faq_view_msg) ? config.faq_view_msg : row.content) + '</td>');
6472			$answer.hide();
6473
6474			if(checkNotice) {
6475				$answer.find('.tpl-forum-list-num').text('');
6476				$(forum_row).find('.question').addClass('notice');
6477			} else {
6478				var f_num = $(forum_row).find('.tpl-forum-list-num').data('fm-num');
6479				$(forum_row).find('.tpl-forum-list-num').removeClass('n').html(unit['question']);
6480				if(list_no) $(forum_row).find('.tpl-forum-list-num').append(f_num);
6481			}
6482
6483			if(icon_wrap) {
6484				$(forum_row).find('.tpl-forum-list-num').wrapInner('<span class="'+icon_span_class+'"></span>');
6485				$answer.find('.tpl-forum-list-num').wrapInner('<span class="'+icon_span_class+'"></span>');
6486			}
6487
6488			if(row_settings.fonts) {
6489				if(row_settings.fonts.color) $(forum_row).find('.tpl-forum-list-cont').css('color', row_settings.fonts.color);
6490				if(row_settings.fonts.fontFamily) $(forum_row).find('.tpl-forum-list-cont').css('font-family', row_settings.fonts.fontFamily);
6491				if(row_settings.fonts.fontSize) $(forum_row).find('.tpl-forum-list-cont').css('font-size', row_settings.fonts.fontSize);
6492			}
6493
6494			$answer.find('.tpl-forum-faq-ctrl').remove();
6495			if(row.check_ctrl) {
6496				$answer.find('.tpl-forum-list-cont').append(`
6497					<div class="tpl-forum-faq-ctrl auto">
6498						<ul data-pid="${pid}" data-id="${row.id}">
6499							<li class="tpl-forum-faq-edit">${$.lang[block_lang]['board.button.modify']}</li>
6500							<li class="tpl-forum-faq-del">${$.lang[block_lang]['board.button.delete']}</li>
6501						</ul>
6502					</div>
6503				`);
6504			}
6505			break;
6506
6507		case 'qna':
6508			$(forum_row).find('.tpl-forum-list-state').text('');
6509			if((row.reply_name == null || !row.reply_name) && $(forum_row).find('.tpl-forum-list-num.n').length == 0) {
6510				if($('.element[data-id="' + pid + '"]').hasClass('newqna')) {
6511					var state_false_fsize = ($source.find('.tpl-forum-list-state span').attr('class')) ? $source.find('.tpl-forum-list-state span').attr('class') : '',
6512						state_true_fsize = ($source.find('.tpl-forum-list-state.true span').attr('class')) ? $source.find('.tpl-forum-list-state.true span').attr('class') : '',
6513						state_fsize = (row.replied == true) ? state_true_fsize : state_false_fsize;
6514
6515					$(forum_row).find('.tpl-forum-list-state').append('<span></span>');
6516
6517					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);
6518					else $(forum_row).find('.tpl-forum-list-state').removeAttr('data-state').find('span').text($.lang[block_lang]['forum.qna.state.waiting']).addClass(state_fsize);
6519				} else {
6520					if(row.replied == true) $(forum_row).find('.tpl-forum-list-state').attr('data-state',true).text($.lang[block_lang]['forum.qna.state.replied']);
6521					else $(forum_row).find('.tpl-forum-list-state').removeAttr('data-state').text($.lang[block_lang]['forum.qna.state.waiting']);
6522				}
6523			}
6524			
6525			$(forum_row).find('.qna-details *[class*=tpl-forum-list-]').not('.tpl-forum-list-content, .tpl-forum-list-like').html('');
6526			$(forum_row).find('.qna-details *[class*=tpl-qna-answer-]').html('');
6527			
6528			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>';
6529			var forum_img = $(forum_row).find('.qna-details img');
6530			forum_img.each(function(idx, v){
6531				var src = $(v).attr('src');
6532				$(v).wrap('<a href="'+src+'" target="_blank"></a>')
6533			});
6534
6535			
6536			if(row_settings.fonts) {
6537				if(row_settings.fonts.color) $(forum_row).find('.tpl-qna-question-content').css('color', row_settings.fonts.color);
6538				if(row_settings.fonts.fontFamily) $(forum_row).find('.tpl-qna-question-content').css('font-family', row_settings.fonts.fontFamily);
6539				if(row_settings.fonts.fontSize) $(forum_row).find('.tpl-qna-question-content').css('font-size', row_settings.fonts.fontSize);
6540			}
6541
6542			$(forum_row).find('.qna-details').hide();
6543			break;
6544		case 'guestbook':
6545			// 관리자
6546			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) {
6547				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))
6548					) || (PAGE_MODE == 'c' && row.id_type != 'A')) {
6549					$(forum_row).find('[data-oper="U"]').hide();
6550					$(forum_row).find('[data-oper="U"]').next().hide();
6551				}
6552			} else {
6553				$(forum_row).find('.tpl-guestbook-more-menu').addClass('hide');
6554				//guest book2 fm29 렌더에서 기능 동작 x
6555				$(forum_row).find('.tpl-guestbook-more-menu-area-el2').addClass('hide');
6556			}
6557			if(row.fm_mb_id == '' && row.option == 'S' && PAGE_MODE != 'c' && RENDER.b.UMEMBER.id == '') {
6558				$(forum_row).find('.list-item').addClass('blind');
6559				$(forum_row).find('.tpl-guestbook-more-menu').addClass('hide');
6560				//guest book2 fm29 렌더에서 기능 동작 x
6561				$(forum_row).find('.tpl-guestbook-more-menu-area-el2').addClass('hide');
6562			}
6563			$(forum_row).find('.tpl-forum-list-cont').attr('data-fm_mb_id', row.fm_mb_id
6563);
6564			break;
6565		default: //normal
6566			break;
6567	}
6568
6569	var forum_row_html = $(forum_row).html();
6570	$(forum_row).remove();
6571
6572	return (type == 'faq') ? forum_row_html + $answer.outerHTML() : forum_row_html;
6573}
6574
6575var forumUrl = function() {
6576	if(PAGE_MODE != 'c') {
6577		var url = (PAGE_MODE=='s') ? '' : '/render';
6578	} else {
6579		var url = '/'+CONFIG_URL+'config/page';
6580	}
6581	return url;		
6582}
6583
6584// NEW
6585var getForumListItem = function(num,data,_fu) {
6586	// console.log('getForumListItem','num',num,`data`,data,`_fu`,_fu);
6587
6588	var fields = {
6589		normal: ['title','num','category','name','date','hit','comment','like','myimg'],
6590		thumb: ['title','cont','thumb','num','category','name','date','hit','comment','like'],
6591		faq: ['title','cont','faq-icon','faq-toggle'],
6592		qna: ['title','num','category','name','date','state','cont'],
6593		guestbook: ['cont','name','date'],
6594	};
6595	fields.all = [...new Set([...fields.normal, ...fields.thumb, ...fields.qna, ...fields.faq, ...fields.guestbook])];
6596
6597	var item = {
6598		pid: _fu.pid,
6599		id: data.id,
6600		link: {
6601			active: (data.title == '') ? false : true,
6602			val: ($.inArray(_fu.eltype2, ['faq','qna','guestbook']) > -1) ? 'javascript:void(0);' : `${forumUrl()}/forum/view/${data.id}`,
6603			cls: ``,
6604			attr: {},
6605		},
6606		new: data.new ? true : false,
6607		option: {
6608			val: data.option,
6609			notice: data.option == 'N' ? true : false,
6610			secret: data.option == 'S' ? true : false,
6611		},
6612		reply: {
6613			active: data.depth > 0 && data.option != 'N' ? true : false,
6614			name: data.reply_name || '',
6615		},
6616
6617		selector: '.item',
6618
6619		// field
6620		title: {
6621			val: data.title || '',
6622			max: _fu.elsettings.max_title || 150,
6623		},
6624		cont: {
6625			val: (_fu.eltype2 == 'faq' && _fu.config.faq_view_msg) ? _fu.config.faq_view_msg : data.content,
6626			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') : '',
6627			max: _fu.elsettings.max_cont || 300,
6628		},
6629		thumb: {
6630			val: data.thumb || '',
6631			ffolder: _fu.blockEL.attr('data-width'),
6632			alt: data.title.replace(/\s/g,'-'),
6633			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()}`,
6634		},
6635		num: {
6636			val: num,
6637			isThumb: _fu.sampleEL.find('.tpl-forum-list-thumb .tpl-forum-list-num').length > 0 ? true : false,
6638		},
6639		cateogry: {
6640			seq: data.category_seq, 
6641			name: data.category_name
6642		},
6643		name: {
6644			val: data.name || '',
6645			mask: (_fu.elsettings.namemask_display == 'ON') ? true : false,
6646		},
6647		date: data.datetime,
6648		hit: data.hit,
6649		comment: {
6650			val: Number(data.comment) || 0,
6651		},
6652		like: {
6653			val: Number(data.like.cnt) || 0,
6654			active: data.like.own || false,
6655		},
6656		myimg: {
6657			val: data.myimg,
6658		},
6659		state: data.replied || false,
6660	};
6661	// console.log('data',data,'item',item);
6662
6663	var icon = {
6664		new: `<img src="//storage.googleapis.com/i.addblock.net/icon/icon_new_forum.png" title="new" alt="new">`,
6665		notice: `<i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i>`,
6666		secret: `<i class="tpl-forum-list-secret-icon cl-icon lock02" aria-hidden="true"></i>&nbsp;`,
6667	};
6668
6669	var tag = _fu.sampleEL.find(item.selector).eq(0).clone();
6670	tag.removeClass('active n s w');
6671	if(item.option.notice) tag.addClass('n');
6672	if(item.option.secret) tag.addClass('s');
6673	// w - qna block (state waiting)
6674
6675	$.each(fields.all, function(i,field_k) {
6676		var field_selector = `.tpl-forum-list-${field_k}`,
6677			unused = ($.inArray(field_k, fields[_fu.eltype2]) > -1) ? false : true,
6678			htmlField = '';
6679
6680		if(unused) {
6681			tag.find(field_selector).remove();
6682			return true;
6683		}
6684
6685		switch(field_k) {
6686			// .tpl-forum-list-title
6687			case 'title': 
6688				item.title.txt = item.title.val;
6689				if(item.title.txt) {
6690					if(_fu.eltype2 != 'faq') item.title.txt = htmlEntities(cutStrInBytes(htmlspecialchars_decode(item.title.txt), item.title.max));
6691					htmlField = `<a>${item.title.txt}</a> ${item.new ? icon.new : ''}`;
6692				} else {
6693					htmlField = `<a>${$.lang[LANG]['board.post.deleted']}</a>`;
6694				}
6695				if(item.option.secret) htmlField = `${icon.secret} ${htmlField}
6695`;
6696				var titleField = tag.find(field_selector);
6697				titleField.removeClass('reply').html(htmlField);
6698				if($.inArray(_fu.eltype2, ['normal','thumb']) > -1 && item.reply.active) {
6699					titleField.addClass('reply').prepend(`<span class="tpl-forum-list-reply-name">${item.reply.name}</span>`);
6700				}
6701				break;
6702
6703			// .tpl-forum-list-cont
6704			case 'cont':
6705				if(item.cont.val) {
6706					if(_fu.eltype2 == 'qna' && item.option.secret) {
6707						htmlField = `${icon.secret} ${$.lang[LANG]['forum.qna.content.secret']}`;
6708					} else {
6709						if($.inArray(_fu.eltype2, ['faq','guestbook']) > -1) {
6710							item.cont.txt = item.cont.val.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim,' ');
6711						} else {
6712							// item.cont.txt = item.cont.val.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim,' ');
6713							// item.cont.txt = item.cont.txt.replace(/(<([^>]+)>)/ig,' ');
6714							// item.cont.txt = cutStrInBytes(item.cont.txt,item.cont.max);
6715							
6716							// 다른 폰트 적용 시 공백 생기는 문제로 인해 아래 코드로 교체
6717							item.cont.txt = item.cont.val.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim, ' ');
6718							item.cont.txt = item.cont.txt.replace(/<[^>]+>/g, '');
6719							item.cont.txt = cutStrInBytes(item.cont.txt, item.cont.max);							
6720						}
6721						if(item.cont.more) {
6722							htmlField = `
6723								<div class="forum-cont-val"><a>${item.cont.txt}</a></div>
6724								${$(item.cont.more).find('a').length == 0 ? $(item.cont.more).wrapInner('<a></a>').prop('outerHTML') : item.cont.more}
6725							`;
6726						} else {
6727							htmlField = item.cont.txt;
6728						}
6729					}
6730				}
6731				tag.find(field_selector).html(htmlField);
6732
6733				if($.inArray(_fu.eltype2, ['faq','qna']) > -1) {
6734					var tmp_style = data.settings.fonts || { fontFamily: 'Noto Sans KR', fontSize: '13px', fontWeight: '300', color: '#000000'};
6735					tag.find(field_selector).css({
6736						'font-family': tmp_style.fontFamily,
6737						'font-size': tmp_style.fontSize,
6738						'font-weight': tmp_style.fontWeight,
6739						'color': tmp_style.color,
6740					});
6741				}
6742
6743				if(_fu.eltype2 == 'faq') {
6744					if(data.check_ctrl) {
6745						var faqCtrlAuto = (tag.find('.answer .tpl-forum-faq-ctrl').length > 0) ? false : true;
6746						if(faqCtrlAuto) {
6747							tag.find('.answer').append(`
6748								<div class="tpl-forum-faq-ctrl auto">
6749									<ul data-pid="" data-id="">
6750										<li class="tpl-forum-faq-edit"></li>
6751										<li class="tpl-forum-faq-del"></li>
6752									</ul>
6753								</div>
6754							`);
6755						}
6756
6757						tag.find('.answer .tpl-forum-faq-ctrl [data-id]').attr('data-id',item.id);
6758						tag.find('.answer .tpl-forum-faq-ctrl [data-pid]').attr('data-pid',item.pid);
6759						tag.find('.answer .tpl-forum-faq-ctrl .tpl-forum-faq-edit').html($.lang[_fu.block_lang]['board.button.modify']);
6760						tag.find('.answer .tpl-forum-faq-ctrl .tpl-forum-faq-del').html($.lang[_fu.block_lang]['board.button.delete']);
6761					} else {
6762						tag.find('.answer .tpl-forum-faq-ctrl').remove();
6763					}
6764				}
6765				break;
6766
6767			// .tpl-forum-list-thumb
6768			case 'thumb':
6769				if(item.thumb.val == '' && item.cont.val) {
6770					item.thumb.val = (item.thumb.noimg.includes('noimage')) ? '' : item.thumb.noimg;
6771				}
6772
6773				if(item.thumb.val) {
6774					item.src = item.thumb.val.replace('\/60\/','\/' + item.thumb.ffolder + '\/');
6775					tag.find(`${field_selector} img`).attr({'src':item.src, 'alt':item.thumb.alt});
6776					tag.find(field_selector).wrapInner('<a></a>');
6777				} else {
6778					tag.find(field_selector).empty();
6779				}
6780				break;
6781	
6782			// .tpl-forum-list-num
6783			case 'num': 
6784				item.num.isSingle = (tag.find('.tpl-forum-list-num').length > 1) ? false : true;
6785				if(item.option.notice) {
6786					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;
6787				} else {
6788					var tmp_num = item.num.val,
6789						tmp_digitlen = tag.find(field_selector).attr('data-digitlen') || 1;
6790
6791					htmlField = String(tmp_num).padStart(Number(tmp_digitlen), '0');
6792				}
6793				tag.find(field_selector).html(htmlField);
6794				break;
6795			
6796			// .tpl-forum-list-faq-state
6797			case 'state':
6798				// "forum.qna.state.replied":                  "답변완료",
6799				// "forum.qna.state.waiting":                  "답변대기",
6800				var tmp_state = (item.state) ? $.lang[_fu.block_lang]['forum.qna.state.replied'] : $.lang[_fu.block_lang]['forum.qna.state.waiting'];
6801				tag.find(field_selector).html(`<span>${tmp_state}</span>`);
6802
6803				if(item.state) tag.find(field_selector).addClass('active');
6804				else tag.find(field_selector).removeClass('active');
6805				
6806				if(item.option.notice) tag.find(field_selector).empty().removeClass('active');
6807				break;
6808
6809			// .tpl-forum-list-faq-icon
6810			case 'faq-icon':
6811				if(_fu.sampleEL.find(`${field_selector}.notice`).length > 0) icon.notice = _fu.sampleEL.find(`${field_selector}.notice`).html();
6812				icon.question = (_fu.sampleEL.find(`${field_selector}.question`).length > 0) ? _fu.sampleEL.find(`${field_selector}.question`).html() : false;
6813				icon.answer = (_fu.sampleEL.find(`${field_selector}.answer`).length > 0) ? _fu.sampleEL.find(`${field_selector}.answer`).html() : false;
6814
6815				tag.find(field_selector).removeClass('notice question answer');
6816				if(item.option.notice) {
6817					tag.find(`.question ${field_selector}`).addClass('notice').html(icon.notice);
6818				} else {
6819					if(icon.question === false) {
6820						tag.find(`.question ${field_selector}`).remove();
6821					} else if(icon.question) {
6822						var tmp_q = icon.question;
6823						if(_fu.sampleEL.find(`${field_selector}.question`).is('[data-num="true"]')) tmp_q = tmp_q.replace(/\d+/gi,'') + num;
6824						tag.find(`.question ${field_selector}`).addClass('question').html(tmp_q);
6825					} else {
6826						tag.find(`.question ${field_selector}`).empty();
6827					}
6828				}
6829				
6830				if(icon.answer === false) tag.find(`.answer ${field_selector}`).remove();
6831				else if(icon.answer) tag.find(`.answer ${field_selector}`).addClass('answer').html(icon.answer);
6832				else tag.find(`.answer ${field_selector}`).empty();
6833				break;
6834
6835			// .tpl-forum-list-faq-toggle
6836			case 'faq-toggle':
6837				var tmp_faqtoggle_selector = `.item${item.option.notice ? '.n' : ''} ${field_selector}`;
6838				icon.toggle = (_fu.sampleEL.find(tmp_faqtoggle_selector).length > 0) ? _fu.sampleEL.find(tmp_faqtoggle_selector).eq(0).outerHTML() : '';
6839				if(icon.toggle && tag.find(field_selector).length == 0) {
6840					if(_fu.sampleEL.find(field_selector).eq(0).next('.tpl-forum-list-content').length > 0) tag.find(`.tpl-forum-list-content`).before(icon.toggle);
6841				}
6842				break;
6843			
6844			// .tpl-forum-list-category
6845			case 'category': 
6846				if(item.cateogry.seq) {
6847					tag.find(field_selector).text(item.cateogry.name).attr('data-cate',item.cateogry.seq);
6848				} else {
6849					tag.find(field_selector).removeAttr('data-cate').empty();
6850				}
6851				break;
6852
6853			case 'name':
6854				// tpl-forum-list-name
6855				var nameField = tag.find(field_selector);
6856				nameField.removeClass('reply').text(item.name.val);
6857				if($.inArray(_fu.eltype2, ['normal','thumb']) > -1 && item.reply.active && nameField.hasClass('tpl-sync-reply')) nameField.addClass('reply');
6858				break;
6859				
6860			case 'date':
6861				// tpl-forum-list-date
6862				tag.find(field_selector).text(item.date);
6863				break;
6864				
6865			case 'hit':
6866				// tpl-forum-list-hit
6867				if(tag.find(`${field_selector} .forum-hit-cnt`).length > 0) tag.find(`${field_selector} .forum-hit-cnt`).text(item.hit);
6868				else tag.find(field_selector).text(item.hit);
6869				break;
6870				
6871			case 'comment':
6872				// tpl-forum-list-comment
6873				if(_fu.eltype2 == 'qna') tag.find(`${field_selector}, ${field_selector}-icon`).remove();
6874				else if(item.comment.val > 0) tag.find(`${field_selector} .forum-comment-cnt`).text(item.comment.val);
6875				else tag.find(field_selector).empty();
6876
6877				break;
6878				
6879			case 'like':
6880				// tpl-forum-list-like
6881				if(tag.find(`${field_selector} .forum-like-cnt`).length > 0) tag.find(`${field_selector} .forum-like-cnt`).text(item.like.val);
6882				else tag.find(field_selector).text(item.like.val);
6883
6884				if(item.like.active) tag.find(field_selector).addClass('active');
6885				else tag.find(field_selector).removeClass('active');
6886				break;
6887				
6888			case 'myimg':
6889				// tpl-forum-list-myimg
6890				if(item.myimg.val) {
6891					item.src = item.myimg.val.replace('\/60\/','\/' + item.myimg.ffolder + '\/');
6892
6893					// tag.find(`${field_selector} img`).attr({'src':item.src}); forum3은 프로필 적용 되는데 forum2만 적용 안 되어서 아래와 같이 수정
6894
6895					if (tag.find(`${field_selector} img`).length > 0) {
6896						tag.find(`${field_selector} img`).attr({'src':item.src});
6897					} else {
6898						if (tag.find(field_selector).hasClass('hexagon')) {
6899							const $hex = tag.find(field_selector);
6900							if ($hex.hasClass('hexagon')) {
6901								const $img = $hex.find('image');
6902								if ($img.length > 0) {
6903									$img.attr('xlink:href', item.src);
6904								}
6905							}
6906						} 
6907					}
6908				}
6909				break;
6910
6911			default:
6912				break;
6913		}
6914	});
6915
6916	switch(_fu.eltype2) {
6917		case 'qna':
6918			tag.find(`.tpl-forum-qna-row > *:not(.tpl-forum-qna-details):not(.tpl-forum-list-content)`).empty();
6919			tag.find(`.tpl-forum-qna-row.answer .tpl-forum-list-cont`).removeAttr('style');
6920			break;
6921		case 'faq':
6922			if(_fu.config.faq_view_msg) {
6923				if(tag.find('.answer .tpl-forum-list-cont').length > 0) {
6924					tag.find('.answer .tpl-forum-list-cont').html(_fu.config.faq_view_msg);
6925				} else if(tag.find('.answer .inner-box').length > 0) {
6926					tag.find('.answer .inner-box').html(_fu.config.faq_view_msg);
6927				} else {
6928					tag.find('.answer .tpl-forum-list-content').html(_fu.config.faq_view_msg);
6929				}
6930			}
6931			break;
6932		default:
6933			break;
6934	}
6935
6936	if(item.link.active) tag.find('a:not([rel])').attr({href:item.link.val, class:item.link.cls, ...item.link.attr});
6937	else tag.find('a:not([rel])').attr({href:'javascript:void(0);', class:'deleted'});
6938	tag.find(`.tpl-forum-list-title,.tpl-forum-list-cont,.tpl-forum-list-thumb`).attr({'data-id':item.id,'data-option':item.option.val});
6939
6940	return tag.prop('outerHTML');
6941}
6942var initForumField = function(tmpEL) {
6943    if(tmpEL.is('[data-init="true"]')) return true;
6944    tmpEL.attr('data-init','true');
6945
6946	tmpEL.find('[data-loop="true"]').removeClass('sample-loop');
6947	if(tmpEL.is('[data-list-type]')) {
6948		tmpEL.attr('data-type2', tmpEL.is('[data-list-type="card"]') ? 'thumb' : 'normal');
6949	}
6950
6951	var eltype2 = 'normal';
6952	if(tmpEL.is('[data-type2]')) eltype2 = tmpEL.attr('data-type2');
6953	else if(tmpEL.is('[data-forum-type]').length > 0) eltype2 = tmpEL.attr('data-forum-type');
6954	else if(tmpEL.find('.tpl-forum-guestbook-area').length > 0) eltype2 = 'guestbook';
6955	else if(tmpEL.find('.tpl-forum-qna').length > 0) eltype2 = 'qna';
6956	else if(tmpEL.find('.question').length > 0) eltype2 = 'faq';
6957	else if(tmpEL.find('.thumb-wrap').length > 0) eltype2 = 'thumb';
6958
6959    var verOlder = (tmpEL.is('[data-fcolor]') || tmpEL.is('[data-ver="1"]')) ? true : false;
6960    if(verOlder) {
6961    } else {
6962
6963		var fields = {
6964			normal: ['hit','comment','like'],
6965			thumb: ['hit','comment','like'],
6966			faq: ['faq-toggle'],
6967			qna: ['cont'],
6968			guestbook: [],
6969		};
6970		fields.all = [...new Set([...fields.normal, ...fields.thumb, ...fields.qna, ...fields.faq, ...fields.guestbook])];
6971
6972		var fitem_selector = '.item';
6973		if(tmpEL.find(fitem_selector).length == 0 && tmpEL.find('tbody[data-loop="true"]').length > 0) tmpEL.find('tbody > tr').addClass('item');
6974		if(tmpEL.find(fitem_selector).length == 0) return false;
6975
6976		var fitem = tmpEL.find(fitem_selector).eq(0);
6977		if(fitem.length === 0 || fitem.find('[class*="tpl-forum-list-"]').length === 0) return false;
6978        var target = fitem.find('[class*="tpl-forum-list-"]').last().attr('class').trim().replace(/ /gi,'.');
6979
6980        $.each(fields[eltype2], function(i,k) {
6981			var tmpField = (fitem.find(`.tpl-forum-list-${k}`).length > 0) ? fitem.find(`.tpl-forum-list-${k}`) : tmpEL.find(`.tpl-forum-list-${k}`);
6982            var tmp_check = (tmpField.length > 0) ? true : false;
6983			if(tmp_check) {
6984				var tmp_iconstyle = tmpField.attr('data-style'),
6985					tmp_svg = '';
6986				if(typeof tmp_iconstyle != 'undefined' && tmp_iconstyle) {
6987					tmp_svg = clSVG(`field_${k.replace(/-/gi,'_')}_${tmp_iconstyle}`,16,16);
6988				}
6989
6990				if(tmp_svg != '') {
6991					tmpEL.find(`.tpl-forum-list-${k} > svg, .tpl-forum-list-${k} > .forum-${k}-icon`).remove();
6992					tmpEL.find(`.tpl-forum-list-${k}`).attr('data-style',tmp_iconstyle).prepend(`<span class="forum-${k}-icon">${tmp_svg}</span>`);
6993				}
6994
6995				if(k == 'cont' && eltype2 == 'qna') {
6996					var $tmp_qna_view = tmpEL.find(`.tpl-forum-qna.view`).eq(0).clone();
6997					tmpEL.find(`.tpl-forum-qna.view`).remove();
6998					tmpEL.find(`.tpl-forum-qna.list`).after($tmp_qna_view);
6999				}
7000			}
7001        });
7002    }
7003}
7004var showHideForumField = function(elObj, elsettings, skip_category_sync) {
7005	// console.log('showHideForumField', elObj.attr('data-name'), elObj.attr('data-ver'));
7006    /*
7007        - 설정에서 항목 OFF → .hidden 추가
7008		- 설정에서 항목 ON + empty or 0  → :empty 처리
7009
7010        - 폰트 반응형 설정 (fsize class 추가)
7011    */
7012
7013	initForumField(elObj);
7014
7015	if (typeof elsettings == 'undefined' ||
7016		$.isEmptyObject(elsettings)
7017	) {
7018		return false;
7019	}
7020
7021	var fields = {
7022		normal: ['title','num','category','name','myimg','date','hit','comment','like'],
7023		thumb: ['title','cont','thumb','num','category','name','date','hit','comment','like'],
7024		faq: ['title','cont'],
7025		qna: ['title','num','state','category','name','date','cont'],
7026		guestbook: ['cont','name','date'],
7027	};
7028	fields.all = [...new Set([...fields.normal, ...fields.thumb, ...fields.qna, ...fields.faq, ...fields.guestbook])];
7029
7030	if(elObj.is('[data-list-type]')) {
7031		elObj.attr('data-type2', elObj.is('[data-list-type="card"]') ? 'thumb' : 'normal');
7032	}
7033
7034    var _CMODE = (PAGE_MODE == 'c') ? true : false,
7035		_VALIDTYPE = (_CMODE) ? VALIDTYPE : property.VALIDTYPE,
7036		// el_seq = elObj.attr('data-id'),
7037		elid = elObj.attr('data-id') || '',
7038		eltype2 = elObj.attr('data-type2') || 'normal',
7039		isSample = elObj.find('.sample-loop').length > 0 ? true : false,
7040		isVer = elObj.attr('data-ver') || '',
7041		like_onoff = (typeof elsettings.like_display != 'undefined' && elsettings.like_display != 'N') ? true : false,
7042		comment_onoff = (typeof elsettings.comment_display != 'undefined' && elsettings.comment_display == 'OFF') ? false : true,
7043		namemask_onoff = (typeof elsettings.namemask_display != 'undefined' && elsettings.namemask_display == 'ON') ? true : false,
7044		date = (typeof elsettings.date != 'undefined' && elsettings.date) ? elsettings.date : 'DEF';
7045
7046	var field_disable = (typeof elsettings.field_disable != 'undefined' && !$.isEmptyObject(elsettings.field_disable)) ? elsettings.field_disable : [],
7047		field_list = eltype2 ? [...fields[eltype2]] : [];
7048
7049	if((!like_onoff || !_VALIDTYPE) && field_list.indexOf('like') > -1) field_list.splice(field_list.indexOf('like'), 1);
7050	if((!comment_onoff || $.inArray(eltype2, ['faq','qna']) > -1) && field_list.indexOf('comment') > -1) field_list.splice(field_list.indexOf('comment'), 1);
7051
7052	$.each(fields.all, function(i,v) {
7053		var onoff = ($.inArray(v, field_disable) > -1) ? false : true;
7054		if (onoff && $.inArray(v, field_list) == -1) onoff = false;
7055
7056		if(`${eltype2}.${v}.${isVer}` == 'faq.num.1') return true;
7057
7058		var more_selector = [];
7059		switch(v) {
7060			case 'cont':
7061				if($.inArray(eltype2, ['faq','qna','guestbook']) > -1) elObj.find(`.tpl-forum-list-cont`).addClass('write-css');
7062				break;
7063
7064			case 'category':
7065				more_selector.push(`#scate`);
7066				more_selector.push(`.tpl-forum-category-nav`);
7067				if(elObj.find('#scate').closest('.input-group-btn[data-caret]').length > 0) {
7068					if(onoff) elObj.find('#scate').closest('.input-group-btn[data-caret]').removeClass('hide');
7069					else elObj.find('#scate').closest('.input-group-btn[data-caret]').addClass('hide');
7070				}
7071
7072				if(isVer == '1' && elObj.find('#scate').closest('.input-group-btn.select-arrow').length > 0) {
7073					if(onoff) elObj.find('#scate').closest('.input-group-btn.select-arrow').removeClass('hide');
7074					else elObj.find('#scate').closest('.input-group-btn.select-arrow').addClass('hide');
7075				}
7076				break;
7077
7078			case 'comment':
7079				more_selector.push(`.tpl-forum-list-comment-icon`);
7080				break;
7081
7082			case 'myimg':
7083				more_selector.push(`.myimg-wrap`);
7084				break;
7085
7086			default:
7087				break;
7088		}
7089
7090		// 일괄 적용
7091		if(onoff) {
7092			elObj.find(`.tpl-forum-${v}`).removeClass('hide');
7093			elObj.find(`.tpl-forum-list-${v}`).removeClass('hide');
7094			if(more_selector != '') elObj.find(more_selector.join(',')).removeClass('hide');
7095		} else {
7096			elObj.find(`.tpl-forum-${v}`).addClass('hide');
7097			elObj.find(`.tpl-forum-list-${v}`).addClass('hide');
7098			if(more_selector != '') elObj.find(more_selector.join(',')).addClass('hide');
7099			if(!_CMODE) elObj.find(`.tpl-forum-${v}, .tpl-forum-list-${v}`).empty();
7100		}
7101
7102		// 개별 적용
7103		elObj.find(`.tpl-forum-list-${v}`).each(function(idx, tmp) {
7104			var tmpItem = $(this).closest('.item'),
7105				tmpField = $(this);
7106
7107			if(tmpField.is(':empty')) return true;
7108			
7109			switch(v) {
7110				case 'num':
7111					if(tmpItem.hasClass('n')) {
7112						var notice_tag = $(this).html(),
7113							notice_selector = `.tpl-forum-list-title .tpl-forum-list-notice-icon, .tpl-forum-list-title .tpl-forum-list-notice`;
7114
7115						tmpItem.find(notice_selector).remove();
7116						tmpItem.find('.tpl-forum-list-title').prepend(notice_tag);
7117
7118						if(onoff) tmpItem.find(notice_selector).addSvgClass('hide');
7119						else tmpItem.find(notice_selector).removeSvgClass('hide');
7120					}
7121					break;
7122
7123				case 'state':
7124					if(tmpField.hasClass('active')) tmpItem.removeClass('w');
7125					else tmpItem.addClass('w');
7126					break;
7127
7128				case 'name':
7129					if(onoff && isSample && namemask_onoff) {
7130						var tmp_v = $(this).text().trim(),
7131							tmp_cut = tmp_v.length >= 3 ? 1 : 2;
7132
7133						$(this).text(`${tmp_v.slice(0,tmp_cut)}***`);
7134					}
7135					break;
7136
7137				default:
7138					 break;
7139			}
7140		});
7141		
7142		// fsize 반영
7143		elObj.find(`
7144			.tpl-forum-list-${v}, 
7145			.search-box .form-control, .search-btn,
7146			.tpl-forum-pagination > li > a,
7147			.tpl-forum-write
7148		`).each(function() {
7149			$(this).removeClass(function(index, className) {
7150				return (className.match(/\bfsize\S+/g) || []).join(' ');
7151			});
7152
7153			if(!_CMODE || elObj.is('.el_viewblock')) {
7154				var tmp_fsize = ($(this).css('font-size') || '').match(/\d+(\.\d+)?/);
7155				if(tmp_fsize) $(this).addClass(`fsize${tmp_fsize[0]}`);
7156			}
7157		});
7158	});
7159
7160	elObj.find(`.tpl-forum-ul, .writer-wrap`).each(function() {
7161		if($(this).find('[class*="tpl-forum-list-"]').length > 0) {
7162			var childempty = ($(this).find('[class*="tpl-forum-list-"]:not(.hide)').length > 0) ? false : true;
7163			if(childempty) $(this).addClass('hide');
7164			else $(this).removeClass('hide');
7165		}
7166	});
7167
7168	if(eltype2 == 'guestbook') {
7169		if(getOrDefault(elsettings,'default_message','') != '') elObj.find('.input-content').attr('placeholder', elsettings.default_message);
7170
7171		var secret_display = getOrDefault(elsettings,'secret_display','U'),
7172			secret_checked = (secret_display == 'A') ? true : false;
7173		elObj.find('.secret-check input[type="checkbox"]').prop('checked', secret_checked);
7174		if(secret_display == 'U') elObj.find('.secret-check').removeClass('hide');
7175		else elObj.find('.secret-check').addClass('hide');
7176
7177
7178		var checkNonmem = true;
7179		if(_CMODE) checkNonmem = false;
7180		else {
7181			var mem_data = RENDER.b.UMEMBER;
7182			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'))) {
7183				checkNonmem = false;
7184			}
7185		}
7186		if(!checkNonmem) elObj.find('.input-nonmem, .captcha').addClass('hide');
7187	}
7188
7189	if(isVer == '1') {
7190		elObj.find('.hidden').removeClass('hidden');
7191
7192		if(eltype2 == 'faq') elObj.find(`.tpl-forum-list-num`).removeClass('hide');
7193		else {
7194			if(elObj.find('.tpl-forum-list-num.hide').length > 0) {
7195				elObj.find('.tpl-forum-list-title .tpl-forum-list-notice, .tpl-forum-list-title .tpl-forum-list-notice-icon').removeSvgClass('hide');
7196			} else {
7197				elObj.find('.tpl-forum-list-title .tpl-forum-list-notice, .tpl-forum-list-title .tpl-forum-list-notice-icon').addSvgClass('hide');
7198			}
7199		}
7200
7201		elObj.find('td[colspan]').each(function() {
7202			var tmp_colspan = $(this).closest('tr').prev('tr').find('td:not(:empty):not(.hide)').length;
7203			$(this).attr('colspan',tmp_colspan);
7204		});
7205		
7206	}
7207
7208	var writebtn_onoff = (typeof elsettings.writebtn_display !='undefined' && elsettings.writebtn_display == 'OFF') ? false : true;
7209	
7210	if(!_CMODE && !writebtn_onoff) elObj.find('.tpl-forum-write').remove();
7211	if(!skip_category_sync && typeof window.syncForumCategoryTypeDisplay == 'function') window.syncForumCategoryTypeDisplay(elObj);
7212
7213	if(	$.inArray(eltype2, ['normal','thumb']) > -1 
7214		&& elObj.find('.layout-table').length === 0
7215		&& elObj.is('[data-msny="true"]')
7216		&& typeof elObj.find('.container').data('masonry') != 'object'
7217	) {
7218		reloadBlockMasonry('init',elObj);
7219	}
7220}

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.