// source --> /wp-content/plugins/mangboard/assets/js/jcarousel.swipe.js?ver=108 
(function($) {
    $(function() {
		var jcarousel = $('.mb-board .jcarousel');
        jcarousel
            .on('jcarousel:reload jcarousel:create', function () {
                var carousel = $(this),
                    width = carousel.innerWidth();

                carousel.jcarousel('items').css('width', Math.ceil(width) + 'px');
            })
			.swipe({
				swipeLeft: function(event, direction, distance, duration, fingerCount) {   
					$(this).jcarousel('scroll', '+=1');
				},
				swipeRight: function(event, direction, distance, duration, fingerCount) {
					$(this).jcarousel('scroll', '-=1');
				}
			})
            .jcarousel({
                wrap: 'circular'
            });

        $('.jcarousel-control-prev')
            .jcarouselControl({
                target: '-=1'
            });

        $('.jcarousel-control-next')
            .jcarouselControl({
                target: '+=1'
            });

		$('.jcarousel-control-1')
			.on('click', function(e) {
				$('.jcarousel-pagination a').eq(0).trigger('click');
            })
		$('.jcarousel-control-2')
            .on('click', function(e) {
				$('.jcarousel-pagination a').eq(1).trigger('click');
            })
		$('.jcarousel-control-3')
            .on('click', function(e) {
				$('.jcarousel-pagination a').eq(2).trigger('click');
            })
		$('.jcarousel-control-4')
            .on('click', function(e) {
				$('.jcarousel-pagination a').eq(3).trigger('click');
            })
		$('.jcarousel-control-5')
            .on('click', function(e) {
				$('.jcarousel-pagination a').eq(4).trigger('click');
            })
		$('.jcarousel-control-6')
            .on('click', function(e) {
				$('.jcarousel-pagination a').eq(5).trigger('click');
            })
		$('.jcarousel-control-7')
            .on('click', function(e) {
				$('.jcarousel-pagination a').eq(6).trigger('click');
            })
		$('.jcarousel-control-8')
            .on('click', function(e) {
				$('.jcarousel-pagination a').eq(7).trigger('click');
            })
		$('.jcarousel-control-9')
            .on('click', function(e) {
				$('.jcarousel-pagination a').eq(8).trigger('click');
            })
		$('.jcarousel-control-10')
            .on('click', function(e) {
				$('.jcarousel-pagination a').eq(9).trigger('click');
            })

        $('.jcarousel-pagination')
            .on('jcarouselpagination:active', 'a', function() {
                $(this).addClass('active');
            })
            .on('jcarouselpagination:inactive', 'a', function() {
                $(this).removeClass('active');
            })
            .on('click', function(e) {
                e.preventDefault();
            })
            .jcarouselPagination({
                perPage: 1,
                item: function(page) {
                    return '<a href="#' + page + '">' + page + '</a>';
                }
            });
    });
})(jQuery);
// source --> /wp-content/plugins/mangboard/plugins/popup/js/main.js?ver=108 
jQuery( document ).ready(function() {
	//팝업 태그를 body에 추가
	var popup_html	= "";
	popup_html		= popup_html+'<div class="mb-board">';
	popup_html		= popup_html+'<div class="pop-bg" id="mb_pop_bg" onclick="hidePopupAlert()"></div>';
	popup_html		= popup_html+'<div class="pop-main mb-'+mb_options["device_type"]+'" >';
		popup_html		= popup_html+'<div class="pop-html" id="mb_pop_html">';
			popup_html		= popup_html+'<div id="mb_pop_html_head"></div>';
			popup_html		= popup_html+'<div id="mb_pop_html_body"></div>';			
		popup_html		= popup_html+'</div>';
		popup_html		= popup_html+'<div class="mb-pop pop-info" id="mb_pop_info">';
			popup_html		= popup_html+'<div id="mb_pop_info_head"></div>';
			popup_html		= popup_html+'<div id="mb_pop_info_body"></div>';
		popup_html		= popup_html+'</div>';
		popup_html		= popup_html+'<div class="mb-pop pop-confirm" id="mb_pop_confirm">';
			popup_html		= popup_html+'<div class="pop-confirm-head" id="mb_pop_confirm_head"></div>';
			popup_html		= popup_html+'<div class="pop-confirm-body" id="mb_pop_confirm_body"></div>';
		popup_html		= popup_html+'</div>';
		popup_html		= popup_html+'<div class="mb-pop pop-alert" id="mb_pop_alert">';
			popup_html		= popup_html+'<div class="pop-alert-head" id="mb_pop_alert_head"></div>';
			popup_html		= popup_html+'<div class="pop-alert-body" id="mb_pop_alert_body"></div>';			
		popup_html		= popup_html+'</div>';
		
	popup_html		= popup_html+'</div>';
	popup_html		= popup_html+'</div>';

     jQuery("body").append(popup_html);
}); 


var confirmCallbackSend;
var confirmCallbackCancel;
var alertCallbackSend;
var popupCallbackData;
var select_menu		= "";
var eventX				= 0;
var eventY				= 0;
var scrollMode			= true;
var popupMode			= "popup";

function setPopupScrollEvent(){
	jQuery(window).on({
		'mousewheel': function(e){
			if(scrollMode) setPopupPosition("scroll");
		},'scroll': function(e){
			if(scrollMode) setPopupPosition("scroll");
		}
	})
}
function setPopupPosition(mode){
	if(typeof(mode)!=='undefined' && mode=="scroll" && jQuery("#mb_pop_bg").css('display')=='none') return;

	var pHeight			= 120;
	var nWidth			= jQuery(window).width();
	var nHeight			= jQuery(window).height();
	var scrollTop			= jQuery(document).scrollTop();
	
	var popupObj			= jQuery("#mb_pop_confirm");	
	if(mb_options["device_type"]=="mobile") pHeight				= 50;

	popupObj.css('left',(nWidth-popupObj.outerWidth())/2);
	if(popupObj.outerHeight()>400){ pHeight			= 30; }
	popupObj.css('top',(scrollTop-pHeight+((nHeight-popupObj.outerHeight())/2)));

	popupObj		= jQuery("#mb_pop_alert");
	popupObj.css('left',(nWidth-popupObj.outerWidth())/2);
	if(popupObj.outerHeight()>400){ pHeight			= 30; }
	popupObj.css('top',(scrollTop-pHeight+((nHeight-popupObj.outerHeight())/2)));

	popupObj		= jQuery("#mb_pop_info");
	popupObj.css('left',(nWidth-popupObj.outerWidth())/2);
	popupObj.css('top',((scrollTop+((nHeight-popupObj.outerHeight())/2))));

	popupObj		= jQuery("#mb_pop_html");
	if(popupObj.outerHeight()>400){ pHeight			= 30; }
	var nTop			= (scrollTop-pHeight+((nHeight-popupObj.outerHeight())/2));
	if(nTop<scrollTop){
		if((pHeight+nTop)<scrollTop){
			nTop	= scrollTop;
		}else{
			nTop	= parseInt((pHeight+nTop)/2);
		}
	}
	if(nTop<scrollTop){ nTop	= scrollTop; }
	if(popupObj.outerHeight()>=nHeight || popupObj.outerWidth()>=nWidth){
		popupObj.css('position','fixed');
		if(mb_options["device_type"]=="mobile") popupObj.css('width',"100%");
		popupObj.css('height',"100%");
		if(popupObj.outerHeight()>=nHeight){
			popupObj.css('top',0);
		}else{
			popupObj.css('top',nTop);
		}
		popupObj.css('left',(nWidth-popupObj.outerWidth())/2);		
		scrollMode		= false;
		jQuery('body').css('overflow-y','hidden');
	}else{
		popupObj.css('position','absolute');
		popupObj.css('top',nTop);
		popupObj.css('left',(nWidth-popupObj.outerWidth())/2);
	}
}
setPopupScrollEvent();

function showConfirmPopup(message,data,send,cancel){
	popupCallbackData				= data;
	confirmCallbackSend			= send;

	if(typeof(cancel)==='undefined') confirmCallbackCancel = hidePopupBox;
	else confirmCallbackCancel		= cancel;

	//위치 설정
	var pop_head		= '';
	var pop_body		= '';
	var pop_btn_ok		= mb_languages["btn_ok"];
	var pop_btn_cancel	= mb_languages["btn_cancel"];
	if(typeof(data)!=='undefined'){
		if(typeof(data.btn_ok)!=='undefined' && data.btn_ok!=""){
			pop_btn_ok		= data.btn_ok;
		}
		if(typeof(data.btn_cancel)!=='undefined' && data.btn_cancel!=""){
			pop_btn_cancel		= data.btn_cancel;
		}
	}
	if(typeof(data)!=='undefined' && typeof(data.type)!=='undefined' && data.type=="passwd"){
		pop_head		= '<div class="pop-title pop-title-confirm" id="mb_pop_confirm_text">'+message+'</div>';
		pop_body			= pop_body+'<div id="mb_pop_form">';
			pop_body			= pop_body+'<form class="pop-form" action="javascript:sendConfirmCallbackData()" id="mb_confirm_form" method="post" name="mb_confirm_form"><div><input id="mb_confirm_passwd" name="passwd" class="pop-input-passwd" type="password" /></div></form>';

		pop_body			= pop_body+'</div>';		
	}else{
		pop_head		= '<div class="pop-title" id="mb_pop_confirm_text"><p class="pop-title-head">Message</p><p class="pop-title-message">'+message+'</p></div>';
	}
	pop_body			= pop_body+'<div class="btn-box-center">';
	pop_body			= pop_body+'<a href="javascript:;" id="mb_pop_confirm_cancel" onclick="cancelConfirmCallbackData()" class="btn btn-default btn-cancel margin-right-10"><span>'+pop_btn_cancel+'</span></a>';
	pop_body			= pop_body+'<a href="javascript:;" id="mb_pop_confirm_ok" onclick="sendConfirmCallbackData()" class="btn btn-default btn-ok"><span>'+pop_btn_ok+'</span></a>';
	pop_body			= pop_body+'</div>';

	if(typeof(data)!=='undefined'){
		if(typeof(data.head)!=='undefined')  pop_head		= data.head;
		if(typeof(data.body)!=='undefined')  pop_body		= data.body;
	}

	showPopupBox("Confirm",pop_head,pop_body);
}
function showAlertPopup(response,send){
	if(!response || typeof(response)==='undefined') return;

	var code						= "";
	var message				= "";
	var target_name			= "";
	
	if(typeof(send)==='undefined') alertCallbackSend			= null;
	else alertCallbackSend			= send;
	
	if(typeof(response.code)!=='undefined') code				= response.code;
	if(typeof(response.message)!=='undefined') message		= response.message;
	if(typeof(response.target_name)!=='undefined') target_name		= response.target_name;
	if(message=="") return;
	if(code=="1103"){
		showConfirmPopup(message, {}, function(){moveURL(mb_urls["login"]);});
		return;
	}

	var pop_head		= '<div class="pop-title" id="mb_pop_alert_text"><p class="pop-title-head">Message</p><p class="pop-title-message">'+message+'</p></div>';
	var pop_body		= '';
	pop_body			= pop_body+'<div class="btn-box-center">';
	pop_body			= pop_body+'<a href="javascript:;"  id="mb_pop_alert_ok" onclick="showAlertCallback(\''+code+'\',\''+	target_name+'\')" class="btn btn-default btn-ok"><span>'+mb_languages["btn_ok"]+'</span></a>';
	pop_body			= pop_body+'</div>';
	showPopupBox("Alert",pop_head,pop_body);
}
function showPopupBox(type,head,body,data,mode){
	if(typeof(mode)!=='undefined' && mode!=''){
		popupMode			= mode;
	}else{
		popupMode			= "popup";
	}

	scrollMode			= true;
	initLoadingBox();
	var popupID		= "#mb_pop_confirm";	

	if(type=="Alert"){
		popupID		= "#mb_pop_alert";
		if(jQuery("#mb_pop_bg").css('display')=='none') jQuery("#mb_pop_confirm").hide();	

		setTimeout(function(){ jQuery(popupID).addClass("mb-ani-pop-open");	 }, 1);		
	}else if(type=="Info"){
		popupID		= "#mb_pop_info";
		setTimeout(function(){ jQuery(popupID).addClass("mb-ani-pop-fadein"); }, 1);
	}else if(type=="Confirm"){
		popupID		= "#mb_pop_confirm";
		setTimeout(function(){ jQuery(popupID).addClass("mb-ani-pop-open");	 }, 1);		
	}else if(type=="Html"){
		popupID		= "#mb_pop_html";
	}else{
		popupID		= "#mb_pop_alert";
		setTimeout(function(){ jQuery(popupID).addClass("mb-ani-pop-open");	 }, 1);		
	}
	if(typeof(data)==='undefined') data		= {};
	if(typeof(data.position)==='undefined') data.position = "center";
	if(typeof(data.bg)==='undefined') data.bg = true;
	if(typeof(data.eventX)==='undefined') data.eventX = 0;
	if(typeof(data.eventY)==='undefined') data.eventY = 0;
	
	jQuery(popupID+"_head").html(head);
	jQuery(popupID+"_body").html(body);	
	
	var adminbarHeight		= jQuery("#wpadminbar").height();
	if(adminbarHeight==null || typeof(adminbarHeight)==='undefined') adminbarHeight		= 0;

	if(data.position=="click"){
		jQuery(popupID).css("top",parseInt((data.eventY+jQuery(document).scrollTop()-adminbarHeight)/10)*10+20);
		jQuery(popupID).css("left",parseInt(data.eventX/10)*10+30);
	}else{
		setPopupPosition();
	}
	if(data.bg) showPopupBG();
	
	jQuery(popupID).show();	

	if(type=="Alert"){
		jQuery("#mb_pop_alert_ok").focus();
	}else if(type=="Confirm"){
		jQuery("#mb_confirm_passwd").focus();
	}
	
}

function initLoadingBox(){
	jQuery("#mb_pop_html_head").html("");
	jQuery("#mb_pop_html_body").html("");
	jQuery("#mb_pop_html").css({'width':'','height':''});
	jQuery("#mb_pop_html").hide();
}

function showLoadingBox(){
	showPopupBox("Html",'<img src="'+mb_urls["plugin"]+'assets/images/loader.gif" width="50px" height="50px" style="opacity: 0.7;filter: alpha(opacity=0.7);">','<div style="color:#fff;font-size:12px;min-height:19px;">Loading</div>');
}
function hideLoadingBox(){
	initLoadingBox();
	if(jQuery("#mb_pop_alert").css('display')=='none' && jQuery("#mb_pop_confirm").css('display')=='none'){
		jQuery("#mb_pop_bg").hide();
	}
	if(!scrollMode){
		jQuery('body').css('overflow-y','auto');
		scrollMode		= true;
	}
}

function showPopupBG(){
	hideInfoBox();
	jQuery('#mb_pop_bg').height(jQuery(document).height());	
	jQuery("#mb_pop_bg").show();
}

var popup_user_name	= "";
function getUserMenu(uid,pid,name){
	if(typeof(name)!=='undefined' && name!=""){
		popup_user_name		= name;
	}else{
		popup_user_name		= "";
	}
	var menu_options		= "*";	
	if(select_menu==uid+"_"+pid){
		select_menu		= "";
		hideInfoBox();
	}else{		
		sendUserMenu(uid,pid,menu_options,event);
		select_menu		= uid+"_"+pid;
	}
}
function showUserMenu(data){		
	var menu_head		= data["head"];
	var menu_body		= "";
	var menu_foot		= data["foot"];

	var user_name		= "";
	if(typeof(data["user"]["name"])!=='undefined' && data["user"]["name"]!=""){
		user_name		= data["user"]["name"];
	}else if(popup_user_name!=""){
		user_name		= popup_user_name;
	}	
	if(user_name!="") menu_head				= menu_head+'<div class="pop-info-head">'+user_name+'</div>';

	menu_body			= '<ul class="pop-info-body list-unstyled">';	

	if(data["body"].length>0){
		jQuery.each(data["body"], function(key,value){
			menu_body		= menu_body+'<li>'+value+'</li>';
		});
		menu_body		= menu_body+'</ul>';
		showPopupBox("Info","",('<div class="pop-user-menu">'+menu_head+menu_body+menu_foot+"</div>"),{"position":"click","bg":false,"eventX":eventX,"eventY":eventY});
	}
}

function sendUserMenu(uid,board_pid,option,event){
	if(typeof(event)!=='undefined'){
		eventX	= event.clientX;
		eventY		= event.clientY - jQuery('body').offset().top;
	}
	if(option=="*") option	= "search,info,email,homepage,blog";

	var param	= "board_name="+mb_options["board_name"]+"&option="+option+"&list_type="+mb_options["list_type"]+"&page="+mb_options["page"];	
	if(jQuery('#'+mb_options["board_name"]+'_form_board_search')) param		+= "&"+jQuery('#'+mb_options["board_name"]+'_form_board_search').serialize();
	param	+= "&mode=user&board_action=menu"+"&pid="+uid+"&board_pid="+board_pid;

	sendDataRequest2(mb_urls["template_api"], param, sendUserMenuHandler);
}
function sendUserMenuHandler(response, state){		
	if(response.state == "success"){
		showUserMenu(response.data);
	}else{
		showAlertPopup(response);
	}
}



function hideInfoBox() {
	jQuery("#mb_pop_info").hide();
	jQuery("#mb_pop_info").removeClass("mb-ani-pop-fadein");
}

function hidePopupBox() {	
	confirmCallbackSend		= null;
	jQuery(".mb-input-focus").removeClass("mb-input-focus");
	jQuery("#mb_pop_info").hide();
	jQuery("#mb_pop_html").hide();	
	jQuery("#mb_pop_confirm").hide();	
	jQuery("#mb_pop_confirm").removeClass("mb-ani-pop-open");
	jQuery("#mb_pop_alert").removeClass("mb-ani-pop-open");
	jQuery("#mb_pop_info").removeClass("mb-ani-pop-fadein");
	jQuery("#mb_pop_bg").hide();
	if(!scrollMode){
		jQuery('body').css('overflow-y','auto');
		scrollMode		= true;
	}
	popupMode			= "popup";
}

function showAlertCallback(code,target_name) {
	hidePopupAlert(code,target_name);
	sendAlertCallbackData();	
}

function hidePopupAlert(code,target_name) {
	if(popupMode=="modal") return;
	if(typeof(code)!=='undefined' && code!=='undefined' && code!=''){
		if(confirmCallbackSend) jQuery("#mb_pop_confirm").show();		

		if(code.substr(0,2)=="12"){	//입력 관련 에러일 경우 포커스 설정
			if(typeof(target_name)!=='undefined'  && target_name!=='undefined' && target_name!=''){
				var target;
				if(jQuery("#mb_pop_confirm").css('display')!='none'){
					if(jQuery("#mb_confirm_form").find("input[name='"+target_name+"']").length>0){
						target		= jQuery("#mb_confirm_form").find("input[name='"+target_name+"']").first();
					}
				}else{
					if(code=="1299"){
						if(jQuery(target_name).filter(':visible').length>0){
							target		= jQuery(target_name).filter(':visible').first();
						}
					}else{
						if(jQuery("[name='"+target_name+"']").filter(':visible').length>0){
							target		= jQuery("[name='"+target_name+"']").filter(':visible').first();
						}
					}
				}
				jQuery(".mb-input-focus").removeClass("mb-input-focus");

				if(typeof(target)!=='undefined'  && target!=='undefined'){
					jQuery(target).addClass("mb-input-focus");
					jQuery(target).focus();
				}
			}
		}
	}else{
		jQuery(".mb-input-focus").focus();
	}
	
	jQuery("#mb_pop_alert").hide();
	jQuery("#mb_pop_alert").removeClass("mb-ani-pop-open");
	jQuery("#mb_pop_html").hide();
	jQuery("#mb_pop_info").hide();
	if(jQuery("#mb_pop_confirm").css('display')=='none'){
		jQuery("#mb_pop_bg").hide();
		initLoadingBox();
	}
	if(!scrollMode){
		jQuery('body').css('overflow-y','auto');
		scrollMode		= true;
	}
	popupMode			= "popup";
}
function sendAlertCallbackData() {	
	if(alertCallbackSend) alertCallbackSend();
	else alertCallbackSend		= null;
}
function sendConfirmCallbackData() {	
	showLoadingBox();
	jQuery("#mb_pop_confirm").hide();
	if(confirmCallbackSend) confirmCallbackSend(popupCallbackData);
	else confirmCallbackSend		= null;
}
function cancelConfirmCallbackData() {	
	confirmCallbackSend		= null;
	if(confirmCallbackCancel) confirmCallbackCancel();
	else confirmCallbackCancel		= null;
};
// source --> /wp-content/plugins/mangboard/plugins/datepicker/js/datepicker.js?ver=108 
jQuery(function($){
	if($.datepicker && $.datepicker.regional){
		$.datepicker.regional["ko"] = {
			closeText: "닫기",
			prevText: "이전달",
			nextText: "다음달",
			currentText: "오늘",
			monthNames: ["1월(JAN)","2월(FEB)","3월(MAR)","4월(APR)","5월(MAY)","6월(JUN)", "7월(JUL)","8월(AUG)","9월(SEP)","10월(OCT)","11월(NOV)","12월(DEC)"],
			monthNamesShort: ["1월","2월","3월","4월","5월","6월", "7월","8월","9월","10월","11월","12월"],
			dayNames: ["일","월","화","수","목","금","토"],
			dayNamesShort: ["일","월","화","수","목","금","토"],
			dayNamesMin: ["일","월","화","수","목","금","토"],
			weekHeader: "Week",
			dateFormat: "yymmdd",
			firstDay: 0,
			isRTL: false,
			showMonthAfterYear: true,
			yearSuffix: ""
		};
		$.datepicker.setDefaults($.datepicker.regional["ko"]);
	}
});
jQuery(document).ready(function() {
	if(jQuery(".show-datepicker").datepicker) jQuery(".show-datepicker").datepicker({ changeMonth: true, changeYear: true, firstDay:0, dateFormat: "yy-mm-dd", showButtonPanel: true, yearRange: "c-100:c+10"});
});