
	$(function() {
		var form = $('form.board-form'),
			list_type = 'card',
			module_method = (list_type == 'card' || list_type == 'link' ||list_type == 'youtube_card') ? 'masonry' : 'lists';

		new $.module['board.' + module_method](
			form, {
				'callback': function($this) {
              
                    //유튜브 게시판 및 홍보사진쪽 팝업 callback
                    if(list_type == 'history_modal' || list_type == 'history_video')
                    {
                        if($('.modal').length) {
                            modal();
                        }
                    }
                    
					$('.change').ui_swap({
						'Yes': ['공개', '#18A689'],
						'No': ['비공개', "#f26520"]
					});

					if (list_type == 'faq') {
						$('.faq-group .q').on('click', function(e) {
							console.log('a');
							if (e.target == this) {
								var a = $(this).next('.a'),
									group = $(this).parent('.faq-group');

								if (group.hasClass('active') == false) {
									group.addClass('active');
									a.slideDown();
								} else {
									group.removeClass('active');
									a.slideUp();
								}

								return false;
							}
						});
					}
				}
			}
		);

		$('.management', form).on(
				'click',
				function(e) {
					if (e.target.type != 'checkbox') {
						if ($('.ids:checked', form).length < 1) {
							alert('관리하실 게시물을 선택해 주세요');
							return false;
						}
						new $.module['modal'](
							'/cls/information-gallery/pm_management/page/5', {
								'title': '게시물관리 (%s건)'.sprintf($('.ids:checked', form).length),
								'close': false,
								'iframe': true,
								'width': 770,
								'onclose': function() {}
							}
						);
					}
				}
			)
			.find('input').on(
				'change',
				function() {
					$('.ids', form).attr('checked', this.checked);
				}
			);
            $('input[name="search_category_id"]').change(function() {
                $('input[name="search_category_id"]').closest('a').removeClass('active');
                if ($(this).prop('checked')) {
                    $(this).closest('a').addClass('active');
                }
            });
	});
