// source --> https://lee-lab.net/wp-content/plugins/mangboard/assets/js/common.js?ver=195 
function sendFormDataRequest(form, action, successCallback, errorCallback, type, dataType){
	if(typeof(action)==='undefined' || action=='') action = 'mb_board';
	if(typeof(type)==='undefined') type = "POST";
	if(typeof(dataType)==='undefined') dataType = "json";
	if(typeof(successCallback)==='undefined') successCallback	= function s(a,b){};
	if(typeof(errorCallback)==='undefined') errorCallback	= function e(a){};

	if(String(action).indexOf('http')!==0){
		action	= mb_ajax_object.ajax_url+"?action="+action+"&admin_page="+mb_ajax_object.admin_page+"&hybrid_app="+mb_hybrid_app;
	}
	form.attr("action", action);
	form.ajaxForm({
		type: type,
		async: true,
		crossDomain: true,
		dataType : dataType,
		xhrFields:{withCredentials:true},
		success:function(data, state){
			hideLoadingBox();
			successCallback(data, state);
		},error:function(e){
			//console.log(JSON.stringify(e));
			hideLoadingBox();
			if(e.responseJSON && e.responseJSON.state=="success"){
				successCallback(e.responseJSON, e.responseJSON.state);
			}else{
				errorCallback(e);
			}
		}
	});
	form.submit();
	showLoadingBox();
}

function sendDataRequest(action, param, successCallback, errorCallback, type, dataType){
	if(typeof(action)==='undefined' || action=='') action = 'mb_template';
	if(typeof(type)==='undefined') type = "POST";
	if(typeof(dataType)==='undefined') dataType = "json";
	if(typeof(successCallback)==='undefined') successCallback	= function s(a,b){};
	if(typeof(errorCallback)==='undefined') errorCallback	= function e(a){};

	if(param.indexOf('mb_nonce_value=')==-1){
		if(param=="") param	= mb_options["nonce2"];
		else param	= param+"&"+mb_options["nonce2"];
	}

	if(String(action).indexOf('http')!==0){
		param	= param+"&action="+action+"&admin_page="+mb_ajax_object.admin_page+"&hybrid_app="+mb_hybrid_app;
		action	= mb_ajax_object.ajax_url;
	}
	if(param.indexOf('board_action=board_hit')==-1) showLoadingBox();

	jQuery.ajax({
		url: action,
		type: type,
		data: param,
		success:function(data,state){
			hideLoadingBox();
			successCallback(data, state);
		},error:function(e){			
			//console.log(JSON.stringify(e));
			hideLoadingBox();			
			if(e.responseJSON && e.responseJSON.state=="success"){
				successCallback(e.responseJSON, e.responseJSON.state);
			}else{
				errorCallback(e);
			}
		},timeout: 15000,
		cache: false,
		dataType: dataType
	});
}

function sendDataRequest2(action, param, successCallback, errorCallback, type, dataType){
	if(typeof(action)==='undefined' || action=='') action = 'mb_template';
	if(typeof(type)==='undefined') type = "POST";
	if(typeof(dataType)==='undefined') dataType = "json";
	if(typeof(successCallback)==='undefined') successCallback	= function s(a,b){};
	if(typeof(errorCallback)==='undefined') errorCallback	= function e(a){};

	if(param.indexOf('mb_nonce_value=')==-1){
		if(param=="") param	= mb_options["nonce2"];
		else param	= param+"&"+mb_options["nonce2"];
	}

	if(String(action).indexOf('http')!==0){
		param	= param+"&action="+action+"&admin_page="+mb_ajax_object.admin_page+"&hybrid_app="+mb_hybrid_app;
		action	= mb_ajax_object.ajax_url;
	}
	jQuery.ajax({
		url: action,
		type: type,
		data: param,
		success:function(data,state){
			successCallback(data, state);
		},error:function(e){			
			//console.log(JSON.stringify(e));
			hideLoadingBox();			
			errorCallback(e);
		},timeout: 15000,
		cache: false,
		dataType: dataType
	});
}

function mb_insertHtml(name,message){
	jQuery(name).html(message);	
}
function mb_appendHtml(name,message){
	jQuery(name).append(message);	
}

function checkCSSDisplay(name,time){
	if(typeof(time)==='undefined') time = 0;
	var objTarget		= jQuery(name);
	if(objTarget.css("display")=="none"){
		if(time==0) objTarget.show();
		else objTarget.slideDown( time );
	}else{		
		if(time==0) objTarget.hide();
		else objTarget.slideUp( time );
	}
}

function checkCSSDisplayID(id,time){
	if(typeof(time)==='undefined') time = 0;
	var objTarget		= jQuery("#"+id);
	if(objTarget.css("display")=="none"){
		if(time==0) objTarget.show();
		else objTarget.slideDown( time );
	}else{		
		if(time==0) objTarget.hide();
		else objTarget.slideUp( time );
	}
}

function checkBoxDisplayID(obj, id){
	if(jQuery(obj).prop('checked')){		
		jQuery("#"+id).show();
	}else{		
		jQuery("#"+id+" input").val("");
		jQuery("#"+id).hide();
	}
}
function replaceCategoryText(value){
  	return value.replace(/&#038;/g, "&").replace(/&/g, "&amp;").replace(/[=<>`'"]/g, '');
}
function set_category_data(data, id,value){
	if(typeof(data)!=='undefined'){
		jQuery("#"+id+" option").remove();
		var index		= id.substr(-1);
		if(typeof(mb_languages["selectbox"+index])!='undefined' && mb_languages["selectbox"+index]!=""){
			jQuery("#"+id).append('<option value="">'+mb_languages["selectbox"+index]+'</option>');
		}
		if(typeof(data)==='object'){
			var add_html			= "";
			var category_text	= "";
			jQuery.each(data, function(key, entry){
				category_text	= replaceCategoryText(key);
				if(value!="" && (key==value || category_text==value)){
					add_html	+= '<option value="'+category_text+'" selected>'+category_text+'</option>';
				}else{
					add_html	+= '<option value="'+category_text+'">'+category_text+'</option>';
				}
			});
			if(add_html!=""){
				jQuery("#"+id).append(add_html);
			}
			jQuery("#"+id).css("display","inline-block");
		}else{
			jQuery("#"+id).html('<option value=""></option>');
			jQuery("#"+id).hide();
		}
	}else{
		jQuery("#"+id).html('<option value=""></option>');
		jQuery("#"+id).hide();
	}
}


function category_select(index){
	var value1			= "";
	var value2			= "";
	var theme_type		= "type1";

	if(typeof(category_text)!=='undefined' && category_text!="" && category_text.indexOf('&#038;')!=-1){
		theme_type	= "type2";
	}
	if(index==0){
		set_category_data(category_data,mb_options["board_name"]+"_category1",mb_categorys["value1"]);
		value1		= jQuery("#"+mb_options["board_name"]+"_category1 option").filter(":selected").val();
		if(theme_type=="type2" && value1.indexOf('&')!=-1){
			value1		= value1.replace(/&/g, "&#038;");
		}		
		if(mb_categorys["value1"]!=undefined && mb_categorys["value1"]!="" && value1!=''){
			set_category_data(category_data[value1],mb_options["board_name"]+"_category2",mb_categorys["value2"]);
		}else{
			jQuery("#"+mb_options["board_name"]+"_category2").hide();
		}

		value2		= jQuery("#"+mb_options["board_name"]+"_category2 option").filter(":selected").val();
		if(theme_type=="type2" && value2!="" && value2.indexOf('&')!=-1){
			value2		= value2.replace(/&/g, "&#038;");
		}
		if(mb_categorys["value2"]!=undefined && mb_categorys["value2"]!="" && value2!=''){
			set_category_data(category_data[value1][value2],mb_options["board_name"]+"_category3",mb_categorys["value3"]);
		}else{
			jQuery("#"+mb_options["board_name"]+"_category3").hide();
		}
	}else{
		value1		= jQuery("#"+mb_options["board_name"]+"_category1 option").filter(":selected").val();
		value2		= jQuery("#"+mb_options["board_name"]+"_category2 option").filter(":selected").val();
		if(theme_type=="type2"){
			if(value1!="" && value1.indexOf('&')!=-1){
				value1		= value1.replace(/&/g, "&#038;");
			}
			if(value2!="" && value2.indexOf('&')!=-1){
				value2		= value2.replace(/&/g, "&#038;");
			}
		}
		if(index==1){
			if(value1!=""){
				set_category_data(category_data[value1],mb_options["board_name"]+"_category2","");
			}else{
				set_category_data("",mb_options["board_name"]+"_category2","");
			}
			set_category_data("",mb_options["board_name"]+"_category3","");
		}else if(index==2){
			if(value1!=""){				
				if(value2!=""){					
					set_category_data(category_data[value1][value2],mb_options["board_name"]+"_category3","");
				}else{
					set_category_data("",mb_options["board_name"]+"_category3","");
				}
			}else{
				set_category_data("",mb_options["board_name"]+"_category3","");
			}
		}
	}
}

function movePage(url, param){	
	moveURL(url, param)
}
function moveViewPage(pid,board_name,page){
	var param		= "vid="+pid;
	if(typeof(board_name)!=='undefined'&& board_name!="") param		= param+"&board_name="+board_name;
	if(typeof(page)!=='undefined' && page!="") param			= param+"&page="+page;
	moveURL("", param)
}
function moveURL(url, param, loading){
	var isLoading		= false;
	if(typeof(loading)!=='undefined') isLoading = loading;
	if(isLoading) showLoadingBox();

	if(typeof(param)!=='undefined' && param!=""){
		if(url.indexOf('?')==-1){
			url		= url+'?';
		}else{
			url		= url+'&';
		}
		url		= url+param;
	}
	if(url.indexOf('category1=')!=-1){
		if(url.indexOf('category1=&')!=-1){
			url		= url.replace('category2=&','');
			url		= url.replace('category3=&','');
		}else{
			url		= url.replace(/(category)(\d{1})=&/g,'');
		}
	}
	if(url.indexOf('&#038;')!=-1){
		url		= url.replace(/&#038;/g,'&');
	}
	var match_count = (url.match(/page_id=/g) || []).length;
	if(match_count>0) {
		url		= url.replace(/page_id=&/g,'');
		if(match_count>1) {
			var index1		= url.lastIndexOf('page_id=');
			var index2		= url.indexOf('&',index1);
			if(index2==-1){
				url					= url.slice(0,index1-1);
			}else{
				url					= url.slice(0,index1-1)+url.slice(index2);
			}
		}
	}
	if(url=="reload"){
		window.location.reload();
	}else if(url=="back"){
		window.history.back();
	}else if(url=="forward"){
		window.history.forward();
	}else if(url=="referer" || url=="referrer"){
		url		= document.referrer;
		if(url.indexOf('%26')==-1){
			url		= decodeURIComponent(url);
		}else{
			url		= url.replace(/%26/g,"##26##");
			url		= decodeURIComponent(url);
			url		= url.replace(/##26##/g,"%26");
		}
		window.location.href		= url;
	}else{
		if(url.indexOf('%26')==-1){
			url		= decodeURIComponent(url);
		}else{
			url		= url.replace(/%26/g,"##26##");
			url		= decodeURIComponent(url);
			url		= url.replace(/##26##/g,"%26");
		}
		window.location.href		= url;
	}
}
function openWindow(url,name,option){
	var objPopup;
	if(url.indexOf('&#038;')!=-1){
		url		= url.replace(/&#038;/g,'&');
	}
	if(typeof(mb_hybrid_app)==='undefined' || mb_hybrid_app==""){
		if(typeof(option)==='undefined') option	= "width=600,height=640,toolbar=no,location=no,status=no,menubar=no,top=200,left=300,scrollbars=no,resizable=no";
		if(typeof(mb_options)!=='undefined' && typeof(mb_options["device_type"])!=='undefined' && mb_options["device_type"]=="mobile"){
			objPopup		= window.open(url,name);
		}else{
			objPopup		= window.open(url,name,option);
		}
	}else{
		 objPopup		= openMobileWindow(url,name,option);
	}
	return objPopup;
}

var mb_selectFileName		= "";
function sendBoardFileData(file_pid,file_name){
	var data				= "mode=file&board_action=file_download&board_name="+mb_options["board_name"]+"&file_pid="+file_pid+"&file_name="+encodeURIComponent(file_name);
	mb_selectFileName		= file_name;
	sendDataRequest2(mb_urls["board_api"], data, sendBoardFileDataHandler);
}
function sendBoardFileDataHandler(response, state)
{
	if(response.state == "success"){
		if(typeof(response.data)!=='undefined' && typeof(response.data.file_path)!=='undefined'){
			if(mb_hybrid_app=="ios" && typeof(response.data.file_path2)!=='undefined'){
				var file_url	= mb_urls["base"];
				file_url			= file_url.replace('/wp-content/plugins','/wp-content/uploads');
				homeSendMessage({"mode":"FILE_DOWNLOAD","value": file_url+response.data.file_path2,"name": mb_selectFileName});
			}else{
				downloadFile(mb_urls["file"],"path="+encodeURIComponent(response.data.file_path));
			}			
		}
	}else{
		showAlertPopup(response);
	}
}
function downloadFile(url, param){
	if(typeof(param)!=='undefined' && param!=""){
		if(url.indexOf('?')==-1){
			url		= url+'?';
		}else{
			url		= url+'&';
		}
		url		= url+param;
	}
	if(typeof(mb_hybrid_app)==='undefined' || mb_hybrid_app==""){
		window.location.href		= decodeURIComponent(url+"&file_name="+mb_selectFileName+"&type=download");
	}else{
		window.location.href		= decodeURIComponent(url+"&type=download&file_name="+mb_selectFileName);
	}
}

var listTemplateMode		= "";
var listTemplateBoard		= "";
var listTemplateCheck		= true;
var listTemplateAction		= "";


function sendTabReload(data,idx){
	if(typeof(idx)==='undefined') idx	= "1";
	if(jQuery("input[name=category"+idx+"]")) jQuery("input[name=category"+idx+"]").val(data);
	if(idx==1 && data==''){
		if(jQuery("input[name=category2]")) jQuery("input[name=category2]").val(data);
		if(jQuery("input[name=category3]")) jQuery("input[name=category3]").val(data);
	}else if(idx==2 && data==''){
		if(jQuery("input[name=category3]")) jQuery("input[name=category3]").val(data);
	}
	if(jQuery('.mb-board.mb-commerce').length>0){
		sendSearchData();
	}else{
		sendSearchData("#mb_top");
	}
}

function setEditorType(type){
	if(document.getElementById("editor_type")){
		document.getElementById("editor_type").value	= type;
	}
}
function sendListTemplateData(data){
	listTemplateCheck	= true;
	if(typeof(data)==='undefined') data = {};
	if(typeof(data.board_name)==='undefined' || data.board_name==='undefined' || data.board_name==='') board_name = mb_options["board_name"];	
	else board_name = data.board_name;	
	if(typeof(data.mode)==='undefined' || data.mode==='undefined') mode = "";
	else mode = data.mode;
	if(typeof(data.page)==='undefined' || data.page==='undefined' || data.page==='') page = 1;
	else page = data.page;	
	
	listTemplateBoard					= board_name;
	listTemplateMode					= mode;	
	var params		= jQuery('#'+listTemplateBoard+'_form_board_search').serialize();
	if(jQuery('#'+listTemplateBoard+'_form_board_search2').length>0) params		= params+"&"+jQuery('#'+listTemplateBoard+'_form_board_search2').serialize();
	params		= params+"&"+jQuery('#'+listTemplateBoard+'_form_board_list').serialize()+"&board_action=load";

	if(typeof(data.category)!=='undefined'){
		if(typeof(data.idx)==='undefined' || data.idx==='undefined' || data.idx==='') idx = "1";
		else idx = data.idx;
		params					= params+"&category"+idx+"="+encodeURIComponent(data.category);
	}else if(typeof(data.page_type)!=='undefined' && data.page_type=="ajax"){
		if(typeof(mb_categorys["value1"])!=='undefined' && mb_categorys["value1"]!=""){		
			params					= params+"&category1="+encodeURIComponent(mb_categorys["value1"]);
			if(typeof(mb_categorys["value2"])!=='undefined' && mb_categorys["value2"]!=""){		
				params					= params+"&category2="+encodeURIComponent(mb_categorys["value2"]);
				if(typeof(mb_categorys["value3"])!=='undefined' && mb_categorys["value3"]!=""){		
					params					= params+"&category3="+encodeURIComponent(mb_categorys["value3"]);
				}
			}
		}
	}

	if(typeof(data.page_type)!=='undefined'){
		params					= params+"&page_type="+encodeURIComponent(data.page_type);
	}		
	params					= params+"&board_page="+page;	
	sendDataRequest(mb_urls["template_api"], params, sendListTemplateDataHandler);			
}

function sendListTemplateDataHandler(response, state){		
	if(listTemplateCheck){
		if(response.state == "success"){
			if(listTemplateMode!="append"){
				jQuery("#"+listTemplateBoard+"_board_body>tr").remove();
				jQuery("#"+listTemplateBoard+"_board_body>div").remove();
			}

			if(response.data["body"]){
				jQuery("#"+listTemplateBoard+"_board_body").append(response.data["body"]);
			}
			if(response.data["pagination"]!=""){
				jQuery('#'+listTemplateBoard+'_pagination_box').html(response.data["pagination"]);
			}else{
				jQuery('#'+listTemplateBoard+'_pagination_box').html("");
			}
			if(listTemplateMode!="append" && typeof(scrollToBoardTop)==='function'){
				scrollToBoardTop();
			}
		}else{
			showAlertPopup(response);
		}
		listTemplateCheck		= false;
	}
}

function scrollToBoardTop(mode, id, offset){
	if(typeof(mode)==='undefined' || mode=='') mode = "list";
	if(typeof(id)==='undefined' || id=='') id	= "mb_top";
	if(typeof(offset)==='undefined' || offset=='') offset = 130;
	if(jQuery('div[id="'+id+'"]').length==1 && mb_options["mode"]==mode){
		var nTop	= jQuery('#'+id).offset().top - offset;
		if(nTop<0) nTop		= 0;
		if(Math.abs(jQuery(window).scrollTop()-nTop)>offset){
			jQuery("html, body").animate({scrollTop: nTop}, 300);
		}
	}
}

function getPostcode(type,id) {
	if(typeof(mb_hybrid_app)==='undefined' || mb_hybrid_app==""){
		new kakao.Postcode({
			oncomplete: function(data) {
				var fullAddr = ""; 
				var extraAddr = "";

				if(data.userSelectedType === "R"){
					fullAddr = data.roadAddress;
				}else{
					fullAddr = data.jibunAddress;
				}

				if(data.userSelectedType === "R"){
					if(data.bname !== ""){extraAddr += data.bname;}
					if(data.buildingName !== ""){extraAddr += (extraAddr !== "" ? ", " + data.buildingName : data.buildingName);}
					fullAddr += (extraAddr !== "" ? " ("+ extraAddr +")" : "");
				}

				//document.getElementById(type+"_postcode").value = data.postcode1+"-"+data.postcode2;
				document.getElementById(type+"_postcode").value = data.zonecode;
				document.getElementById(type+"_address1").value = fullAddr;
				jQuery("#"+type+"_address2").focus();
			}
		}).open();
	}else{
		openWindow(mb_urls["home"]+"/?mb_app=postcode&type="+type);
	}
}
function getPostcodeIframe(type,id) {
	if(typeof(id)==='undefined' || id=='') id = 'mb_kakao_postcode1';
	var element_wrap	= document.getElementById(id);
	var currentScroll		= Math.max(document.body.scrollTop, document.documentElement.scrollTop);
	new kakao.Postcode({
		oncomplete: function(data) {
			var fullAddr = ""; 
			var extraAddr = "";

			if(data.userSelectedType === "R"){
				fullAddr = data.roadAddress;
			}else{
				fullAddr = data.jibunAddress;
			}
			if(data.userSelectedType === "R"){
				if(data.bname !== ""){extraAddr += data.bname;}
				if(data.buildingName !== ""){extraAddr += (extraAddr !== "" ? ", " + data.buildingName : data.buildingName);}
				fullAddr += (extraAddr !== "" ? " ("+ extraAddr +")" : "");
			}
			//document.getElementById(type+"_postcode").value = data.postcode1+"-"+data.postcode2;
			document.getElementById(type+"_postcode").value = data.zonecode;
			document.getElementById(type+"_address1").value = fullAddr;
			
			element_wrap.style.display = 'none';
			jQuery("html, body").scrollTop( currentScroll );
			jQuery("#"+type+"_address2").focus();
		},
		onresize : function(size) {
			element_wrap.style.height = (size.height+30)+'px';
		},
		width : '100%',
		height : '100%'
	}).embed(element_wrap);
	element_wrap.style.display = 'block';
}
function template_match_handler(type,obj,name,match_type,match_value){
	var value		= "";
	if(type=="checkbox"){
		value		= jQuery(obj).prop('checked') ? "1":"0";
	}else if(type=="radio" || type=="select"){
		value		= jQuery(obj).val();
	}else{
		if(jQuery(obj).val()!=""){
			value		= jQuery(obj).val();
		}else{
			value		= jQuery(obj).find('input').first().val();
		}		
	}
	match_value	= ","+match_value+",";
	value				= ","+value+",";
	var target		= jQuery(".mb-combo-"+name);
	if(match_type=="show"){
		if(match_value.indexOf(value)!=-1) target.css("display","inline-block");
		else{
			target.hide();
		}
	}else if(match_type=="hide"){
		if(match_value.indexOf(value)!=-1){
			target.hide();
		}else target.css("display","inline-block");
	}
}
var template_combo_hide	= {};
function template_combo_handler(type,obj,name){
	var value		= "";
	if(type=="checkbox"){
		value		= jQuery(obj).prop('checked') ? "1":"0";
	}else{
		value		= jQuery(obj).val();
	}
	var combo_wrapper		= jQuery(obj).closest('.mb-combo-wrapper').find('.mb-combo-items');
	combo_wrapper.children().hide();
	combo_wrapper.find(":input").prop("disabled", true);
	combo_wrapper.find('.mb-combo-'+name+'-'+value).show();
	combo_wrapper.find('.mb-combo-'+name+'-'+value).find(":input").prop("disabled", false);

	if(typeof(template_combo_hide[name])!=='undefined' && template_combo_hide[name]!=''){
		template_combo_display_check('show',name,template_combo_hide[name]);
	}	
	if(combo_wrapper.find('.mb-combo-'+name+'-'+value+' .mb-combo-box-hide-element').length>0){
		var combo_hide		= combo_wrapper.find('.mb-combo-'+name+'-'+value+' .mb-combo-box-hide-element').val();
		if(combo_hide!=''){
			template_combo_display_check('hide',name,combo_hide);
		}
	}
}
function template_combo_display_check(type,name,value){
	if(typeof(mb_options["board_name"])!=='undefined' && value!=''){
		var items			= value.split(",");
		var item_name	= mb_options["board_name"];
		for(var i=0; i < items.length; i++) {
			if(type=='hide'){
				jQuery('tr#mb_'+item_name+'_tr_'+items[i]).find(":input").prop("disabled", true);
				jQuery('tr#mb_'+item_name+'_tr_'+items[i]).hide();
			}else{
				jQuery('tr#mb_'+item_name+'_tr_'+items[i]).find(":input").prop("disabled", false);
				jQuery('tr#mb_'+item_name+'_tr_'+items[i]).show();
			}
		}
		if(type=='hide'){
			template_combo_hide[name] = value;
		}else{
			template_combo_hide[name] = "";
		}
	}
}
function checkEnterKey(callback,param){
	if(event.keyCode == 13){

		if(typeof(param)==='undefined')
			callback();
		else
			callback(param);
	}
}
var openTarget;
var openPid				= "";
var openColspan		= 0;
var openColspanIndex	= 0;
function openContents(obj, name, index, action){		
	if(typeof(index)!=='undefined') openColspanIndex	= index;
	if(typeof(action)!=='undefined') open_action	= action;
	else open_action	= "content";

	openTarget		= jQuery(obj).closest("tr");	
	if(openTarget.next().hasClass("mb-open-box")){
		if(openTarget.next().css("display")=="none"){
			//openTarget.next().fadeIn('slow');
			openTarget.next().show();
			openTarget.next().find(".mb-open-slide").slideDown(300);
			openTarget.find(".mb-icon-box").addClass('mb-icon-close');
		}else{			
			//openTarget.next().fadeOut('slow');
			openTarget.next().find(".mb-open-slide").slideUp(300,function(){openTarget.next().hide();});
			openTarget.find(".mb-icon-box").removeClass('mb-icon-close');
		}
	}else{
		//콘텐츠 데이타 불러오기		
		if(typeof(name)==='undefined' || name=="") name	= mb_options["board_name"];
		var board_pid = jQuery(obj).attr("class").split("_").pop(); 		
		var data		= "board_name="+name+"&mode=list&board_action="+open_action+"&board_pid="+board_pid;
		sendDataRequest2(mb_urls["template_api"], data, sendContentDataHandler);		
	}
}

function isJsonType(data){
	if(data.indexOf("{")!==-1) return true;
	else return false;
}
function sendContentDataHandler(response, state){		
	if(response.state == "success"){
		var content_html		= '<tr class="mb-open-box">';
		var colspan				= openTarget.find("td").length;
		if(openColspanIndex>0){
			colspan		= colspan - openColspanIndex;
			for(i=0;i<openColspanIndex;i++){
				content_html		= content_html+'<td></td>';
			}
		}
		content_html		= content_html+'<td colspan="'+colspan+'"><div class="mb-open-slide" style="display:none"><div class="mb-open-content">'+response.data+'</div></div></td></tr>';
		openTarget.after(content_html);		
		//openTarget.next().hide();
		//openTarget.next().fadeIn('slow');
		openTarget.next().show();
		openTarget.next().find(".mb-open-slide").slideDown(300);
		openTarget.find(".mb-icon-box").addClass('mb-icon-close');
	}else{
		showAlertPopup(response);
	}
}
function mb_reloadImage_class(name){
	if(typeof(name)==='undefined' || name=='') name = "mb_kcaptcha";

	var img_url			= jQuery("."+name).attr("src");
	var timestamp		= new Date().getTime();

	if(img_url.indexOf('?')==-1){
		img_url		= img_url+'?time=';
	}else{
		img_url		= img_url+'&time=';
	}
	img_url		= img_url+timestamp;

	jQuery("."+name).attr("src",img_url)
}
function mb_reloadImage(id){
	if(typeof(id)==='undefined') id = "mb_kcaptcha";

	var img_url			= jQuery("#"+id).attr("src");
	var timestamp		= new Date().getTime();

	if(img_url.indexOf('?')==-1){
		img_url		= img_url+'?time=';
	}else{
		img_url		= img_url+'&time=';
	}
	img_url		= img_url+timestamp;

	jQuery("#"+id).attr("src",img_url)
}

function checkMaxNumber(obj,max){
	if(typeof(max)!=='undefined'){
		if(max<parseInt(jQuery(obj).val())){
			jQuery(obj).val(max);		
		}		
	}	
}
Number.prototype.to2 = function(){return this<10?'0'+this:this;}
function setSearchDate(type){
	var date				= new Date();
	end_date			= date.getFullYear()+"-"+(date.getMonth()+1).to2()+"-"+(date.getDate()).to2();

	if(type=="month"){
		var date2			= new Date(date.getFullYear(),date.getMonth(),0);
		start_date			= date2.getFullYear()+"-"+(date2.getMonth()+1).to2()+"-"+(date.getDate()).to2();
	}else if(type=="total" || type=="empty"){
		start_date			= ""; end_date			= "";
	}else{
		if(type=="today"){
			start_date			= end_date;
		}else if(type=="yesterday"){
			date.setTime(date.getTime() - (24 * 60 * 60 * 1000));
			end_date			= date.getFullYear()+"-"+(date.getMonth()+1).to2()+"-"+(date.getDate()).to2();
		}else if(type=="tomorrow"){
			date.setTime(date.getTime() + (24 * 60 * 60 * 1000));
			end_date			= date.getFullYear()+"-"+(date.getMonth()+1).to2()+"-"+(date.getDate()).to2();
		}else if(type=="week"){
			date.setTime(date.getTime() - (24 * 60 * 60 * 1000 * 7));
		}else if(type=="last_year"){
			date					= new Date(date.getFullYear()-1,12,0);
			end_date				= date.getFullYear()+"-"+(date.getMonth()+1).to2()+"-"+(date.getDate()).to2();
			date					= new Date(date.getFullYear(),0,1);
		}else if(type=="last_month"){
			date					= new Date(date.getFullYear(),date.getMonth(),0);
			end_date			= date.getFullYear()+"-"+(date.getMonth()+1).to2()+"-"+(date.getDate()).to2();
			date					= new Date(date.getFullYear(),date.getMonth(),1);
		}else if(type=="this_month"){
			date					= new Date(date.getFullYear(),date.getMonth(),1);
		}else if(type=="next_month"){
			date					= new Date(date.getFullYear(),(date.getMonth()+2),0);
			end_date			= date.getFullYear()+"-"+(date.getMonth()+1).to2()+"-"+(date.getDate()).to2();
			date					= new Date(date.getFullYear(),date.getMonth(),1);
		}
		start_date			= date.getFullYear()+"-"+(date.getMonth()+1).to2()+"-"+(date.getDate()).to2();
	}
	jQuery("input[name='start_date']").val(start_date);
	jQuery("input[name='end_date']").val(end_date);
}

function inputOnlyNumber(event){
	var code = event.which ? event.which : event.keyCode;
	if(code == 0 || code == 9 || code == 8 || code == 46 || code == 110 || code == 188 || code == 37 || code == 39 || code == 190 || (96<=code && code <= 105)){
		return;
	}
	if( (code < 48) || (code > 57) ){
		return false;
	}	
}

function moveBodyScrollPosition(name,top,time){
	if(typeof(top)==='undefined') top = 40;
	if(typeof(time)==='undefined') time = 0;
	jQuery("html, body").animate({scrollTop: jQuery(name).offset().top-top}, time);
}

function imgResize(objImage,nWidth,nHeight){
	if(typeof(nWidth)==='undefined') nWidth = 50;
	if(typeof(nHeight)==='undefined') nHeight = nWidth;

	nWidth		= parseInt(nWidth);
	nHeight		= parseInt(nHeight);

	var imgFile			= new Image();
	imgFile.src			= objImage.src;

	var imgWidth		= imgFile.width;
	var imgHeight		= imgFile.height;
	
	if(imgWidth>imgHeight)
	{
		imgHeight = imgHeight * nWidth/imgWidth;
		imgWidth  = nWidth;
		
		if(imgHeight>nHeight)
		{
			imgWidth  = imgWidth * nHeight/imgHeight;
			imgHeight = nHeight;			
		}
		
	} else if(imgWidth<=imgHeight)
	{
		imgWidth  = imgWidth * nHeight/imgHeight;
		imgHeight = nHeight;
		
		if(imgWidth>nWidth)
		{
			imgHeight = imgHeight * nWidth/imgWidth;
			imgWidth  = nWidth;
		}
	} else
	{
		imgWidth  = nWidth;
		imgHeight = nHeight;
	}
	objImage.width		= imgWidth;
	objImage.height		= imgHeight;
}
function checkSendApiURL(){
	if(typeof(mb_urls['board_api'])==='undefined' && typeof(mb_urls['template_api'])==='undefined') {
		mb_urls['board_api']			= "mb_board";
		mb_urls['comment_api']	= "mb_comment";
		mb_urls['user_api']			= "mb_user";
		mb_urls['heditor_api']		= "mb_heditor";
		mb_urls['template_api']		= "mb_template";
		mb_urls['custom_api']		= "mb_custom";
		mb_urls['commerce_api']	= "mb_commerce";
	}
}

jQuery(document).ready(function() {
	if(jQuery.isFunction(jQuery(".tooltip").tipTip)){
		jQuery(".tooltip").tipTip();
	}
	//숫자만 입력받기
	jQuery(".mbi-only-int").keyup (function () {
		jQuery(this).val(jQuery(this).val().replace(/[^0-9]/g,""));
    });
	jQuery(".mbi-only-num").keyup (function () {
		jQuery(this).val(jQuery(this).val().replace(/[^0-9,.]/g,""));
    });
	//숫자만 입력받고 최대 자릿수가 되면 다음 포커스로 이동
	jQuery(".mbi-next-focus-num").keyup (function () {
		var maxLength = jQuery(this).attr("maxlength");
		jQuery(this).val(jQuery(this).val().replace(/[^0-9]/g,""));
        if (this.value.length >= maxLength) {
			if(jQuery(this).next('.mbi-next-focus-num').length>0){
				jQuery(this).next('.mbi-next-focus-num').focus();
			}else if(jQuery(this).next().next('.mbi-next-focus-num').length>0){
				jQuery(this).next().next('.mbi-next-focus-num').focus();
			}
            return false;
        }
    });
	//텍스트를 입력받고 최대 자릿수가 되면 다음 포커스로 이동
	jQuery(".mbi-next-focus").keyup (function () {
		var maxLength = jQuery(this).attr("maxlength");
        if (this.value.length >= maxLength) {
			if(jQuery(this).next('.mbi-next-focus').length>0){
				jQuery(this).next('.mbi-next-focus').focus();
			}else if(jQuery(this).next().next('.mbi-next-focus').length>0){
				jQuery(this).next().next('.mbi-next-focus').focus();
			}            
            return false;
        }
    });
	jQuery(".mb-user-phone").keyup (function () {
		var key = event.charCode || event.keyCode || 0;
		var value	= jQuery(this).val();		
		value		= value.replace(/[^0-9\-\(\)\+\s]/g,"");
		if(value.length>2){
			if(value.indexOf('010')==0){
				if(key!=8 && (value.length==3 || value.length==8)) value += '-';
				if(value.indexOf('-')==-1){
					if(value.length>10){
						value		= value.substr(0, 3)+'-'+value.substr(3, 4)+'-'+value.substr(7,4);
					}
				}else{
					value	= value.replace("--", "-");
				}
			}
		}
		jQuery(this).val(value);
    });
	checkSendApiURL();
});
// source --> https://lee-lab.net/wp-content/plugins/mangboard/assets/js/jquery.number.min.js?ver=195 
﻿/**
 * jQuery number plug-in 2.1.5
 * Copyright 2012, Digital Fusion
 * Licensed under the MIT license.
 * http://opensource.teamdf.com/license/
 *
 * A jQuery plugin which implements a permutation of phpjs.org's number_format to provide
 * simple number formatting, insertion, and as-you-type masking of a number.
 *
 * @author	Sam Sehnert
 * @docs	http://www.teamdf.com/web/jquery-number-format-redux/196/
 */
!function(e){"use strict";function t(e,t){if(this.createTextRange){var a=this.createTextRange();a.collapse(!0),a.moveStart("character",e),a.moveEnd("character",t-e),a.select()}else this.setSelectionRange&&(this.focus(),this.setSelectionRange(e,t))}function a(e){var t=this.value.length;if(e="start"==e.toLowerCase()?"Start":"End",document.selection){var a,i,n,l=document.selection.createRange();return a=l.duplicate(),a.expand("textedit"),a.setEndPoint("EndToEnd",l),i=a.text.length-l.text.length,n=i+l.text.length,"Start"==e?i:n}return"undefined"!=typeof this["selection"+e]&&(t=this["selection"+e]),t}var i={codes:{46:127,188:44,109:45,190:46,191:47,192:96,220:92,222:39,221:93,219:91,173:45,187:61,186:59,189:45,110:46},shifts:{96:"~",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",48:")",45:"_",61:"+",91:"{",93:"}",92:"|",59:":",39:'"',44:"<",46:">",47:"?"}};e.fn.number=function(n,l,s,r){r="undefined"==typeof r?",":r,s="undefined"==typeof s?".":s,l="undefined"==typeof l?0:l;var u="\\u"+("0000"+s.charCodeAt(0).toString(16)).slice(-4),h=new RegExp("[^"+u+"0-9]","g"),o=new RegExp(u,"g");return n===!0?this.is("input:text")?this.on({"keydown.format":function(n){var u=e(this),h=u.data("numFormat"),o=n.keyCode?n.keyCode:n.which,c="",v=a.apply(this,["start"]),d=a.apply(this,["end"]),p="",f=!1;if(i.codes.hasOwnProperty(o)&&(o=i.codes[o]),!n.shiftKey&&o>=65&&90>=o?o+=32:!n.shiftKey&&o>=69&&105>=o?o-=48:n.shiftKey&&i.shifts.hasOwnProperty(o)&&(c=i.shifts[o]),""==c&&(c=String.fromCharCode(o)),8!=o&&45!=o&&127!=o&&c!=s&&!c.match(/[0-9]/)){var g=n.keyCode?n.keyCode:n.which;if(46==g||8==g||127==g||9==g||27==g||13==g||(65==g||82==g||80==g||83==g||70==g||72==g||66==g||74==g||84==g||90==g||61==g||173==g||48==g)&&(n.ctrlKey||n.metaKey)===!0||(86==g||67==g||88==g)&&(n.ctrlKey||n.metaKey)===!0||g>=35&&39>=g||g>=112&&123>=g)return;return n.preventDefault(),!1}if(0==v&&d==this.value.length?8==o?(v=d=1,this.value="",h.init=l>0?-1:0,h.c=l>0?-(l+1):0,t.apply(this,[0,0])):c==s?(v=d=1,this.value="0"+s+new Array(l+1).join("0"),h.init=l>0?1:0,h.c=l>0?-(l+1):0):45==o?(v=d=2,this.value="-0"+s+new Array(l+1).join("0"),h.init=l>0?1:0,h.c=l>0?-(l+1):0,t.apply(this,[2,2])):(h.init=l>0?-1:0,h.c=l>0?-l:0):h.c=d-this.value.length,h.isPartialSelection=v==d?!1:!0,l>0&&c==s&&v==this.value.length-l-1)h.c++,h.init=Math.max(0,h.init),n.preventDefault(),f=this.value.length+h.c;else if(45!=o||0==v&&0!=this.value.indexOf("-"))if(c==s)h.init=Math.max(0,h.init),n.preventDefault();else if(l>0&&127==o&&v==this.value.length-l-1)n.preventDefault();else if(l>0&&8==o&&v==this.value.length-l)n.preventDefault(),h.c--,f=this.value.length+h.c;else if(l>0&&127==o&&v>this.value.length-l-1){if(""===this.value)return;"0"!=this.value.slice(v,v+1)&&(p=this.value.slice(0,v)+"0"+this.value.slice(v+1),u.val(p)),n.preventDefault(),f=this.value.length+h.c}else if(l>0&&8==o&&v>this.value.length-l){if(""===this.value)return;"0"!=this.value.slice(v-1,v)&&(p=this.value.slice(0,v-1)+"0"+this.value.slice(v),u.val(p)),n.preventDefault(),h.c--,f=this.value.length+h.c}else 127==o&&this.value.slice(v,v+1)==r?n.preventDefault():8==o&&this.value.slice(v-1,v)==r?(n.preventDefault(),h.c--,f=this.value.length+h.c):l>0&&v==d&&this.value.length>l+1&&v>this.value.length-l-1&&isFinite(+c)&&!n.metaKey&&!n.ctrlKey&&!n.altKey&&1===c.length&&(p=d===this.value.length?this.value.slice(0,v-1):this.value.slice(0,v)+this.value.slice(v+1),this.value=p,f=v);else n.preventDefault();f!==!1&&t.apply(this,[f,f]),u.data("numFormat",h)},"keyup.format":function(i){var n,s=e(this),r=s.data("numFormat"),u=i.keyCode?i.keyCode:i.which,h=a.apply(this,["start"]),o=a.apply(this,["end"]);0!==h||0!==o||189!==u&&109!==u||(s.val("-"+s.val()),h=1,r.c=1-this.value.length,r.init=1,s.data("numFormat",r),n=this.value.length+r.c,t.apply(this,[n,n])),""===this.value||(48>u||u>57)&&(96>u||u>105)&&8!==u&&46!==u&&110!==u||(s.val(s.val()),l>0&&(r.init<1?(h=this.value.length-l-(r.init<0?1:0),r.c=h-this.value.length,r.init=1,s.data("numFormat",r)):h>this.value.length-l&&8!=u&&(r.c++,s.data("numFormat",r))),46!=u||r.isPartialSelection||(r.c++,s.data("numFormat",r)),n=this.value.length+r.c,t.apply(this,[n,n]))},"paste.format":function(t){var a=e(this),i=t.originalEvent,n=null;return window.clipboardData&&window.clipboardData.getData?n=window.clipboardData.getData("Text"):i.clipboardData&&i.clipboardData.getData&&(n=i.clipboardData.getData("text/plain")),a.val(n),t.preventDefault(),!1}}).each(function(){var t=e(this).data("numFormat",{c:-(l+1),decimals:l,thousands_sep:r,dec_point:s,regex_dec_num:h,regex_dec:o,init:this.value.indexOf(".")?!0:!1});""!==this.value&&t.val(t.val())}):this.each(function(){var t=e(this),a=+t.text().replace(h,"").replace(o,".");t.number(isFinite(a)?+a:0,l,s,r)}):this.text(e.number.apply(window,arguments))};var n=null,l=null;e.isPlainObject(e.valHooks.text)?(e.isFunction(e.valHooks.text.get)&&(n=e.valHooks.text.get),e.isFunction(e.valHooks.text.set)&&(l=e.valHooks.text.set)):e.valHooks.text={},e.valHooks.text.get=function(t){var a,i=e(t),l=i.data("numFormat");return l?""===t.value?"":(a=+t.value.replace(l.regex_dec_num,"").replace(l.regex_dec,"."),(0===t.value.indexOf("-")?"-":"")+(isFinite(a)?a:0)):e.isFunction(n)?n(t):void 0},e.valHooks.text.set=function(t,a){var i=e(t),n=i.data("numFormat");if(n){var s=e.number(a,n.decimals,n.dec_point,n.thousands_sep);return e.isFunction(l)?l(t,s):t.value=s}return e.isFunction(l)?l(t,a):void 0},e.number=function(e,t,a,i){i="undefined"==typeof i?"1000"!==new Number(1e3).toLocaleString()?new Number(1e3).toLocaleString().charAt(1):"":i,a="undefined"==typeof a?new Number(.1).toLocaleString().charAt(1):a,t=isFinite(+t)?Math.abs(t):0;var n="\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4),l="\\u"+("0000"+i.charCodeAt(0).toString(16)).slice(-4);e=(e+"").replace(".",a).replace(new RegExp(l,"g"),"").replace(new RegExp(n,"g"),".").replace(new RegExp("[^0-9+-Ee.]","g"),"");var s=isFinite(+e)?+e:0,r="",u=function(e,t){return""+ +(Math.round((""+e).indexOf("e")>0?e:e+"e+"+t)+"e-"+t)};return r=(t?u(s,t):""+Math.round(s)).split("."),r[0].length>3&&(r[0]=r[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,i)),(r[1]||"").length<t&&(r[1]=r[1]||"",r[1]+=new Array(t-r[1].length+1).join("0")),r.join(a)}}(jQuery);
// source --> https://lee-lab.net/wp-content/plugins/mangboard/assets/js/jquery.touchSwipe.min.js?ver=195 
/*!
 * @fileOverview TouchSwipe - jQuery Plugin
 * @version 1.6.18
 *
 * @author Matt Bryson http://www.github.com/mattbryson
 * @see https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
 * @see http://labs.rampinteractive.co.uk/touchSwipe/
 * @see http://plugins.jquery.com/project/touchSwipe
 * @license
 * Copyright (c) 2010-2015 Matt Bryson
 * Dual licensed under the MIT or GPL Version 2 licenses.
 *
 */
!function(factory){"function"==typeof define&&define.amd&&define.amd.jQuery?define(["jquery"],factory):factory("undefined"!=typeof module&&module.exports?require("jquery"):jQuery)}(function($){"use strict";function init(options){return!options||void 0!==options.allowPageScroll||void 0===options.swipe&&void 0===options.swipeStatus||(options.allowPageScroll=NONE),void 0!==options.click&&void 0===options.tap&&(options.tap=options.click),options||(options={}),options=$.extend({},$.fn.swipe.defaults,options),this.each(function(){var $this=$(this),plugin=$this.data(PLUGIN_NS);plugin||(plugin=new TouchSwipe(this,options),$this.data(PLUGIN_NS,plugin))})}function TouchSwipe(element,options){function touchStart(jqEvent){if(!(getTouchInProgress()||$(jqEvent.target).closest(options.excludedElements,$element).length>0)){var event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent;if(!event.pointerType||"mouse"!=event.pointerType||0!=options.fallbackToMouseEvents){var ret,touches=event.touches,evt=touches?touches[0]:event;return phase=PHASE_START,touches?fingerCount=touches.length:options.preventDefaultEvents!==!1&&jqEvent.preventDefault(),distance=0,direction=null,currentDirection=null,pinchDirection=null,duration=0,startTouchesDistance=0,endTouchesDistance=0,pinchZoom=1,pinchDistance=0,maximumsMap=createMaximumsData(),cancelMultiFingerRelease(),createFingerData(0,evt),!touches||fingerCount===options.fingers||options.fingers===ALL_FINGERS||hasPinches()?(startTime=getTimeStamp(),2==fingerCount&&(createFingerData(1,touches[1]),startTouchesDistance=endTouchesDistance=calculateTouchesDistance(fingerData[0].start,fingerData[1].start)),(options.swipeStatus||options.pinchStatus)&&(ret=triggerHandler(event,phase))):ret=!1,ret===!1?(phase=PHASE_CANCEL,triggerHandler(event,phase),ret):(options.hold&&(holdTimeout=setTimeout($.proxy(function(){$element.trigger("hold",[event.target]),options.hold&&(ret=options.hold.call($element,event,event.target))},this),options.longTapThreshold)),setTouchInProgress(!0),null)}}}function touchMove(jqEvent){var event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent;if(phase!==PHASE_END&&phase!==PHASE_CANCEL&&!inMultiFingerRelease()){var ret,touches=event.touches,evt=touches?touches[0]:event,currentFinger=updateFingerData(evt);if(endTime=getTimeStamp(),touches&&(fingerCount=touches.length),options.hold&&clearTimeout(holdTimeout),phase=PHASE_MOVE,2==fingerCount&&(0==startTouchesDistance?(createFingerData(1,touches[1]),startTouchesDistance=endTouchesDistance=calculateTouchesDistance(fingerData[0].start,fingerData[1].start)):(updateFingerData(touches[1]),endTouchesDistance=calculateTouchesDistance(fingerData[0].end,fingerData[1].end),pinchDirection=calculatePinchDirection(fingerData[0].end,fingerData[1].end)),pinchZoom=calculatePinchZoom(startTouchesDistance,endTouchesDistance),pinchDistance=Math.abs(startTouchesDistance-endTouchesDistance)),fingerCount===options.fingers||options.fingers===ALL_FINGERS||!touches||hasPinches()){if(direction=calculateDirection(currentFinger.start,currentFinger.end),currentDirection=calculateDirection(currentFinger.last,currentFinger.end),validateDefaultEvent(jqEvent,currentDirection),distance=calculateDistance(currentFinger.start,currentFinger.end),duration=calculateDuration(),setMaxDistance(direction,distance),ret=triggerHandler(event,phase),!options.triggerOnTouchEnd||options.triggerOnTouchLeave){var inBounds=!0;if(options.triggerOnTouchLeave){var bounds=getbounds(this);inBounds=isInBounds(currentFinger.end,bounds)}!options.triggerOnTouchEnd&&inBounds?phase=getNextPhase(PHASE_MOVE):options.triggerOnTouchLeave&&!inBounds&&(phase=getNextPhase(PHASE_END)),phase!=PHASE_CANCEL&&phase!=PHASE_END||triggerHandler(event,phase)}}else phase=PHASE_CANCEL,triggerHandler(event,phase);ret===!1&&(phase=PHASE_CANCEL,triggerHandler(event,phase))}}function touchEnd(jqEvent){var event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent,touches=event.touches;if(touches){if(touches.length&&!inMultiFingerRelease())return startMultiFingerRelease(event),!0;if(touches.length&&inMultiFingerRelease())return!0}return inMultiFingerRelease()&&(fingerCount=fingerCountAtRelease),endTime=getTimeStamp(),duration=calculateDuration(),didSwipeBackToCancel()||!validateSwipeDistance()?(phase=PHASE_CANCEL,triggerHandler(event,phase)):options.triggerOnTouchEnd||options.triggerOnTouchEnd===!1&&phase===PHASE_MOVE?(options.preventDefaultEvents!==!1&&jqEvent.preventDefault(),phase=PHASE_END,triggerHandler(event,phase)):!options.triggerOnTouchEnd&&hasTap()?(phase=PHASE_END,triggerHandlerForGesture(event,phase,TAP)):phase===PHASE_MOVE&&(phase=PHASE_CANCEL,triggerHandler(event,phase)),setTouchInProgress(!1),null}function touchCancel(){fingerCount=0,endTime=0,startTime=0,startTouchesDistance=0,endTouchesDistance=0,pinchZoom=1,cancelMultiFingerRelease(),setTouchInProgress(!1)}function touchLeave(jqEvent){var event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent;options.triggerOnTouchLeave&&(phase=getNextPhase(PHASE_END),triggerHandler(event,phase))}function removeListeners(){$element.unbind(START_EV,touchStart),$element.unbind(CANCEL_EV,touchCancel),$element.unbind(MOVE_EV,touchMove),$element.unbind(END_EV,touchEnd),LEAVE_EV&&$element.unbind(LEAVE_EV,touchLeave),setTouchInProgress(!1)}function getNextPhase(currentPhase){var nextPhase=currentPhase,validTime=validateSwipeTime(),validDistance=validateSwipeDistance(),didCancel=didSwipeBackToCancel();return!validTime||didCancel?nextPhase=PHASE_CANCEL:!validDistance||currentPhase!=PHASE_MOVE||options.triggerOnTouchEnd&&!options.triggerOnTouchLeave?!validDistance&&currentPhase==PHASE_END&&options.triggerOnTouchLeave&&(nextPhase=PHASE_CANCEL):nextPhase=PHASE_END,nextPhase}function triggerHandler(event,phase){var ret,touches=event.touches;return(didSwipe()||hasSwipes())&&(ret=triggerHandlerForGesture(event,phase,SWIPE)),(didPinch()||hasPinches())&&ret!==!1&&(ret=triggerHandlerForGesture(event,phase,PINCH)),didDoubleTap()&&ret!==!1?ret=triggerHandlerForGesture(event,phase,DOUBLE_TAP):didLongTap()&&ret!==!1?ret=triggerHandlerForGesture(event,phase,LONG_TAP):didTap()&&ret!==!1&&(ret=triggerHandlerForGesture(event,phase,TAP)),phase===PHASE_CANCEL&&touchCancel(event),phase===PHASE_END&&(touches?touches.length||touchCancel(event):touchCancel(event)),ret}function triggerHandlerForGesture(event,phase,gesture){var ret;if(gesture==SWIPE){if($element.trigger("swipeStatus",[phase,direction||null,distance||0,duration||0,fingerCount,fingerData,currentDirection]),options.swipeStatus&&(ret=options.swipeStatus.call($element,event,phase,direction||null,distance||0,duration||0,fingerCount,fingerData,currentDirection),ret===!1))return!1;if(phase==PHASE_END&&validateSwipe()){if(clearTimeout(singleTapTimeout),clearTimeout(holdTimeout),$element.trigger("swipe",[direction,distance,duration,fingerCount,fingerData,currentDirection]),options.swipe&&(ret=options.swipe.call($element,event,direction,distance,duration,fingerCount,fingerData,currentDirection),ret===!1))return!1;switch(direction){case LEFT:$element.trigger("swipeLeft",[direction,distance,duration,fingerCount,fingerData,currentDirection]),options.swipeLeft&&(ret=options.swipeLeft.call($element,event,direction,distance,duration,fingerCount,fingerData,currentDirection));break;case RIGHT:$element.trigger("swipeRight",[direction,distance,duration,fingerCount,fingerData,currentDirection]),options.swipeRight&&(ret=options.swipeRight.call($element,event,direction,distance,duration,fingerCount,fingerData,currentDirection));break;case UP:$element.trigger("swipeUp",[direction,distance,duration,fingerCount,fingerData,currentDirection]),options.swipeUp&&(ret=options.swipeUp.call($element,event,direction,distance,duration,fingerCount,fingerData,currentDirection));break;case DOWN:$element.trigger("swipeDown",[direction,distance,duration,fingerCount,fingerData,currentDirection]),options.swipeDown&&(ret=options.swipeDown.call($element,event,direction,distance,duration,fingerCount,fingerData,currentDirection))}}}if(gesture==PINCH){if($element.trigger("pinchStatus",[phase,pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData]),options.pinchStatus&&(ret=options.pinchStatus.call($element,event,phase,pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData),ret===!1))return!1;if(phase==PHASE_END&&validatePinch())switch(pinchDirection){case IN:$element.trigger("pinchIn",[pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData]),options.pinchIn&&(ret=options.pinchIn.call($element,event,pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData));break;case OUT:$element.trigger("pinchOut",[pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData]),options.pinchOut&&(ret=options.pinchOut.call($element,event,pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData))}}return gesture==TAP?phase!==PHASE_CANCEL&&phase!==PHASE_END||(clearTimeout(singleTapTimeout),clearTimeout(holdTimeout),hasDoubleTap()&&!inDoubleTap()?(doubleTapStartTime=getTimeStamp(),singleTapTimeout=setTimeout($.proxy(function(){doubleTapStartTime=null,$element.trigger("tap",[event.target]),options.tap&&(ret=options.tap.call($element,event,event.target))},this),options.doubleTapThreshold)):(doubleTapStartTime=null,$element.trigger("tap",[event.target]),options.tap&&(ret=options.tap.call($element,event,event.target)))):gesture==DOUBLE_TAP?phase!==PHASE_CANCEL&&phase!==PHASE_END||(clearTimeout(singleTapTimeout),clearTimeout(holdTimeout),doubleTapStartTime=null,$element.trigger("doubletap",[event.target]),options.doubleTap&&(ret=options.doubleTap.call($element,event,event.target))):gesture==LONG_TAP&&(phase!==PHASE_CANCEL&&phase!==PHASE_END||(clearTimeout(singleTapTimeout),doubleTapStartTime=null,$element.trigger("longtap",[event.target]),options.longTap&&(ret=options.longTap.call($element,event,event.target)))),ret}function validateSwipeDistance(){var valid=!0;return null!==options.threshold&&(valid=distance>=options.threshold),valid}function didSwipeBackToCancel(){var cancelled=!1;return null!==options.cancelThreshold&&null!==direction&&(cancelled=getMaxDistance(direction)-distance>=options.cancelThreshold),cancelled}function validatePinchDistance(){return null===options.pinchThreshold||pinchDistance>=options.pinchThreshold}function validateSwipeTime(){var result;return result=!options.maxTimeThreshold||!(duration>=options.maxTimeThreshold)}function validateDefaultEvent(jqEvent,direction){if(options.preventDefaultEvents!==!1)if(options.allowPageScroll===NONE)jqEvent.preventDefault();else{var auto=options.allowPageScroll===AUTO;switch(direction){case LEFT:(options.swipeLeft&&auto||!auto&&options.allowPageScroll!=HORIZONTAL)&&jqEvent.preventDefault();break;case RIGHT:(options.swipeRight&&auto||!auto&&options.allowPageScroll!=HORIZONTAL)&&jqEvent.preventDefault();break;case UP:(options.swipeUp&&auto||!auto&&options.allowPageScroll!=VERTICAL)&&jqEvent.preventDefault();break;case DOWN:(options.swipeDown&&auto||!auto&&options.allowPageScroll!=VERTICAL)&&jqEvent.preventDefault();break;case NONE:}}}function validatePinch(){var hasCorrectFingerCount=validateFingers(),hasEndPoint=validateEndPoint(),hasCorrectDistance=validatePinchDistance();return hasCorrectFingerCount&&hasEndPoint&&hasCorrectDistance}function hasPinches(){return!!(options.pinchStatus||options.pinchIn||options.pinchOut)}function didPinch(){return!(!validatePinch()||!hasPinches())}function validateSwipe(){var hasValidTime=validateSwipeTime(),hasValidDistance=validateSwipeDistance(),hasCorrectFingerCount=validateFingers(),hasEndPoint=validateEndPoint(),didCancel=didSwipeBackToCancel(),valid=!didCancel&&hasEndPoint&&hasCorrectFingerCount&&hasValidDistance&&hasValidTime;return valid}function hasSwipes(){return!!(options.swipe||options.swipeStatus||options.swipeLeft||options.swipeRight||options.swipeUp||options.swipeDown)}function didSwipe(){return!(!validateSwipe()||!hasSwipes())}function validateFingers(){return fingerCount===options.fingers||options.fingers===ALL_FINGERS||!SUPPORTS_TOUCH}function validateEndPoint(){return 0!==fingerData[0].end.x}function hasTap(){return!!options.tap}function hasDoubleTap(){return!!options.doubleTap}function hasLongTap(){return!!options.longTap}function validateDoubleTap(){if(null==doubleTapStartTime)return!1;var now=getTimeStamp();return hasDoubleTap()&&now-doubleTapStartTime<=options.doubleTapThreshold}function inDoubleTap(){return validateDoubleTap()}function validateTap(){return(1===fingerCount||!SUPPORTS_TOUCH)&&(isNaN(distance)||distance<options.threshold)}function validateLongTap(){return duration>options.longTapThreshold&&distance<DOUBLE_TAP_THRESHOLD}function didTap(){return!(!validateTap()||!hasTap())}function didDoubleTap(){return!(!validateDoubleTap()||!hasDoubleTap())}function didLongTap(){return!(!validateLongTap()||!hasLongTap())}function startMultiFingerRelease(event){previousTouchEndTime=getTimeStamp(),fingerCountAtRelease=event.touches.length+1}function cancelMultiFingerRelease(){previousTouchEndTime=0,fingerCountAtRelease=0}function inMultiFingerRelease(){var withinThreshold=!1;if(previousTouchEndTime){var diff=getTimeStamp()-previousTouchEndTime;diff<=options.fingerReleaseThreshold&&(withinThreshold=!0)}return withinThreshold}function getTouchInProgress(){return!($element.data(PLUGIN_NS+"_intouch")!==!0)}function setTouchInProgress(val){$element&&(val===!0?($element.bind(MOVE_EV,touchMove),$element.bind(END_EV,touchEnd),LEAVE_EV&&$element.bind(LEAVE_EV,touchLeave)):($element.unbind(MOVE_EV,touchMove,!1),$element.unbind(END_EV,touchEnd,!1),LEAVE_EV&&$element.unbind(LEAVE_EV,touchLeave,!1)),$element.data(PLUGIN_NS+"_intouch",val===!0))}function createFingerData(id,evt){var f={start:{x:0,y:0},last:{x:0,y:0},end:{x:0,y:0}};return f.start.x=f.last.x=f.end.x=evt.pageX||evt.clientX,f.start.y=f.last.y=f.end.y=evt.pageY||evt.clientY,fingerData[id]=f,f}function updateFingerData(evt){var id=void 0!==evt.identifier?evt.identifier:0,f=getFingerData(id);return null===f&&(f=createFingerData(id,evt)),f.last.x=f.end.x,f.last.y=f.end.y,f.end.x=evt.pageX||evt.clientX,f.end.y=evt.pageY||evt.clientY,f}function getFingerData(id){return fingerData[id]||null}function setMaxDistance(direction,distance){direction!=NONE&&(distance=Math.max(distance,getMaxDistance(direction)),maximumsMap[direction].distance=distance)}function getMaxDistance(direction){if(maximumsMap[direction])return maximumsMap[direction].distance}function createMaximumsData(){var maxData={};return maxData[LEFT]=createMaximumVO(LEFT),maxData[RIGHT]=createMaximumVO(RIGHT),maxData[UP]=createMaximumVO(UP),maxData[DOWN]=createMaximumVO(DOWN),maxData}function createMaximumVO(dir){return{direction:dir,distance:0}}function calculateDuration(){return endTime-startTime}function calculateTouchesDistance(startPoint,endPoint){var diffX=Math.abs(startPoint.x-endPoint.x),diffY=Math.abs(startPoint.y-endPoint.y);return Math.round(Math.sqrt(diffX*diffX+diffY*diffY))}function calculatePinchZoom(startDistance,endDistance){var percent=endDistance/startDistance*1;return percent.toFixed(2)}function calculatePinchDirection(){return pinchZoom<1?OUT:IN}function calculateDistance(startPoint,endPoint){return Math.round(Math.sqrt(Math.pow(endPoint.x-startPoint.x,2)+Math.pow(endPoint.y-startPoint.y,2)))}function calculateAngle(startPoint,endPoint){var x=startPoint.x-endPoint.x,y=endPoint.y-startPoint.y,r=Math.atan2(y,x),angle=Math.round(180*r/Math.PI);return angle<0&&(angle=360-Math.abs(angle)),angle}function calculateDirection(startPoint,endPoint){if(comparePoints(startPoint,endPoint))return NONE;var angle=calculateAngle(startPoint,endPoint);return angle<=45&&angle>=0?LEFT:angle<=360&&angle>=315?LEFT:angle>=135&&angle<=225?RIGHT:angle>45&&angle<135?DOWN:UP}function getTimeStamp(){var now=new Date;return now.getTime()}function getbounds(el){el=$(el);var offset=el.offset(),bounds={left:offset.left,right:offset.left+el.outerWidth(),top:offset.top,bottom:offset.top+el.outerHeight()};return bounds}function isInBounds(point,bounds){return point.x>bounds.left&&point.x<bounds.right&&point.y>bounds.top&&point.y<bounds.bottom}function comparePoints(pointA,pointB){return pointA.x==pointB.x&&pointA.y==pointB.y}var options=$.extend({},options),useTouchEvents=SUPPORTS_TOUCH||SUPPORTS_POINTER||!options.fallbackToMouseEvents,START_EV=useTouchEvents?SUPPORTS_POINTER?SUPPORTS_POINTER_IE10?"MSPointerDown":"pointerdown":"touchstart":"mousedown",MOVE_EV=useTouchEvents?SUPPORTS_POINTER?SUPPORTS_POINTER_IE10?"MSPointerMove":"pointermove":"touchmove":"mousemove",END_EV=useTouchEvents?SUPPORTS_POINTER?SUPPORTS_POINTER_IE10?"MSPointerUp":"pointerup":"touchend":"mouseup",LEAVE_EV=useTouchEvents?SUPPORTS_POINTER?"mouseleave":null:"mouseleave",CANCEL_EV=SUPPORTS_POINTER?SUPPORTS_POINTER_IE10?"MSPointerCancel":"pointercancel":"touchcancel",distance=0,direction=null,currentDirection=null,duration=0,startTouchesDistance=0,endTouchesDistance=0,pinchZoom=1,pinchDistance=0,pinchDirection=0,maximumsMap=null,$element=$(element),phase="start",fingerCount=0,fingerData={},startTime=0,endTime=0,previousTouchEndTime=0,fingerCountAtRelease=0,doubleTapStartTime=0,singleTapTimeout=null,holdTimeout=null;try{$element.bind(START_EV,touchStart),$element.bind(CANCEL_EV,touchCancel)}catch(e){$.error("events not supported "+START_EV+","+CANCEL_EV+" on jQuery.swipe")}this.enable=function(){return this.disable(),$element.bind(START_EV,touchStart),$element.bind(CANCEL_EV,touchCancel),$element},this.disable=function(){return removeListeners(),$element},this.destroy=function(){removeListeners(),$element.data(PLUGIN_NS,null),$element=null},this.option=function(property,value){if("object"==typeof property)options=$.extend(options,property);else if(void 0!==options[property]){if(void 0===value)return options[property];options[property]=value}else{if(!property)return options;$.error("Option "+property+" does not exist on jQuery.swipe.options")}return null}}var VERSION="1.6.18",LEFT="left",RIGHT="right",UP="up",DOWN="down",IN="in",OUT="out",NONE="none",AUTO="auto",SWIPE="swipe",PINCH="pinch",TAP="tap",DOUBLE_TAP="doubletap",LONG_TAP="longtap",HORIZONTAL="horizontal",VERTICAL="vertical",ALL_FINGERS="all",DOUBLE_TAP_THRESHOLD=10,PHASE_START="start",PHASE_MOVE="move",PHASE_END="end",PHASE_CANCEL="cancel",SUPPORTS_TOUCH="ontouchstart"in window,SUPPORTS_POINTER_IE10=window.navigator.msPointerEnabled&&!window.PointerEvent&&!SUPPORTS_TOUCH,SUPPORTS_POINTER=(window.PointerEvent||window.navigator.msPointerEnabled)&&!SUPPORTS_TOUCH,PLUGIN_NS="TouchSwipe",defaults={fingers:1,threshold:75,cancelThreshold:null,pinchThreshold:20,maxTimeThreshold:null,fingerReleaseThreshold:250,longTapThreshold:500,doubleTapThreshold:200,swipe:null,swipeLeft:null,swipeRight:null,swipeUp:null,swipeDown:null,swipeStatus:null,pinchIn:null,pinchOut:null,pinchStatus:null,click:null,tap:null,doubleTap:null,longTap:null,hold:null,triggerOnTouchEnd:!0,triggerOnTouchLeave:!1,allowPageScroll:"auto",fallbackToMouseEvents:!0,excludedElements:".noSwipe",preventDefaultEvents:!0};$.fn.swipe=function(method){var $this=$(this),plugin=$this.data(PLUGIN_NS);if(plugin&&"string"==typeof method){if(plugin[method])return plugin[method].apply(plugin,Array.prototype.slice.call(arguments,1));$.error("Method "+method+" does not exist on jQuery.swipe")}else if(plugin&&"object"==typeof method)plugin.option.apply(plugin,arguments);else if(!(plugin||"object"!=typeof method&&method))return init.apply(this,arguments);return $this},$.fn.swipe.version=VERSION,$.fn.swipe.defaults=defaults,$.fn.swipe.phases={PHASE_START:PHASE_START,PHASE_MOVE:PHASE_MOVE,PHASE_END:PHASE_END,PHASE_CANCEL:PHASE_CANCEL},$.fn.swipe.directions={LEFT:LEFT,RIGHT:RIGHT,UP:UP,DOWN:DOWN,IN:IN,OUT:OUT},$.fn.swipe.pageScroll={NONE:NONE,HORIZONTAL:HORIZONTAL,VERTICAL:VERTICAL,AUTO:AUTO},$.fn.swipe.fingers={ONE:1,TWO:2,THREE:3,FOUR:4,FIVE:5,ALL:ALL_FINGERS}});
// source --> https://lee-lab.net/wp-content/plugins/mangboard/assets/js/jquery.tipTip.min.js?ver=195 
 /*
 * TipTip
 * Copyright 2010 Drew Wilson
 * www.drewwilson.com
 * code.drewwilson.com/entry/tiptip-jquery-plugin
 *
 * Version 1.3   -   Updated: Mar. 23, 2010
 *
 * This Plug-In will create a custom tooltip to replace the default
 * browser tooltip. It is extremely lightweight and very smart in
 * that it detects the edges of the browser window and will make sure
 * the tooltip stays within the current window size. As a result the
 * tooltip will adjust itself to be displayed above, below, to the left 
 * or to the right depending on what is necessary to stay within the
 * browser window. It is completely customizable as well via CSS.
 *
 * This TipTip jQuery plug-in is dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function($){$.fn.tipTip=function(options){var defaults={activation:"hover",keepAlive:false,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:false,enter:function(){},exit:function(){}};var opts=$.extend(defaults,options);if($("#tiptip_holder").length<=0){var tiptip_holder=$('<div id="tiptip_holder" style="max-width:'+opts.maxWidth+';"></div>');var tiptip_content=$('<div id="tiptip_content"></div>');var tiptip_arrow=$('<div id="tiptip_arrow"></div>');$("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('<div id="tiptip_arrow_inner"></div>')))}else{var tiptip_holder=$("#tiptip_holder");var tiptip_content=$("#tiptip_content");var tiptip_arrow=$("#tiptip_arrow")}return this.each(function(){var org_elem=$(this);if(opts.content){var org_title=opts.content}else{var org_title=org_elem.attr(opts.attribute)}if(org_title!=""){if(!opts.content){org_elem.removeAttr(opts.attribute)}var timeout=false;if(opts.activation=="hover"){org_elem.hover(function(){active_tiptip()},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}else if(opts.activation=="focus"){org_elem.focus(function(){active_tiptip()}).blur(function(){deactive_tiptip()})}else if(opts.activation=="click"){org_elem.click(function(){active_tiptip();return false}).hover(function(){},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}function active_tiptip(){opts.enter.call(this);tiptip_content.html(org_title);tiptip_holder.hide().removeAttr("class").css("margin","0");tiptip_arrow.removeAttr("style");var top=parseInt(org_elem.offset()['top']);var left=parseInt(org_elem.offset()['left']);var org_width=parseInt(org_elem.outerWidth());var org_height=parseInt(org_elem.outerHeight());var tip_w=tiptip_holder.outerWidth();var tip_h=tiptip_holder.outerHeight();var w_compare=Math.round((org_width-tip_w)/2);var h_compare=Math.round((org_height-tip_h)/2);var marg_left=Math.round(left+w_compare);var marg_top=Math.round(top+org_height+opts.edgeOffset);var t_class="";var arrow_top="";var arrow_left=Math.round(tip_w-12)/2;if(opts.defaultPosition=="bottom"){t_class="_bottom"}else if(opts.defaultPosition=="top"){t_class="_top"}else if(opts.defaultPosition=="left"){t_class="_left"}else if(opts.defaultPosition=="right"){t_class="_right"}var right_compare=(w_compare+left)<parseInt($(window).scrollLeft());var left_compare=(tip_w+left)>parseInt($(window).width());if((right_compare&&w_compare<0)||(t_class=="_right"&&!left_compare)||(t_class=="_left"&&left<(tip_w+opts.edgeOffset+5))){t_class="_right";arrow_top=Math.round(tip_h-13)/2;arrow_left=-12;marg_left=Math.round(left+org_width+opts.edgeOffset);marg_top=Math.round(top+h_compare)}else if((left_compare&&w_compare<0)||(t_class=="_left"&&!right_compare)){t_class="_left";arrow_top=Math.round(tip_h-13)/2;arrow_left=Math.round(tip_w);marg_left=Math.round(left-(tip_w+opts.edgeOffset+5));marg_top=Math.round(top+h_compare)}var top_compare=(top+org_height+opts.edgeOffset+tip_h+8)>parseInt($(window).height()+$(window).scrollTop());var bottom_compare=((top+org_height)-(opts.edgeOffset+tip_h+8))<0;if(top_compare||(t_class=="_bottom"&&top_compare)||(t_class=="_top"&&!bottom_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_top"}else{t_class=t_class+"_top"}arrow_top=tip_h;marg_top=Math.round(top-(tip_h+5+opts.edgeOffset))}else if(bottom_compare|(t_class=="_top"&&bottom_compare)||(t_class=="_bottom"&&!top_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_bottom"}else{t_class=t_class+"_bottom"}arrow_top=-12;marg_top=Math.round(top+org_height+opts.edgeOffset)}if(t_class=="_right_top"||t_class=="_left_top"){marg_top=marg_top+5}else if(t_class=="_right_bottom"||t_class=="_left_bottom"){marg_top=marg_top-5}if(t_class=="_left_top"||t_class=="_left_bottom"){marg_left=marg_left+5}tiptip_arrow.css({"margin-left":arrow_left+"px","margin-top":arrow_top+"px"});tiptip_holder.css({"margin-left":marg_left+"px","margin-top":marg_top+"px"}).attr("class","tip"+t_class);if(timeout){clearTimeout(timeout)}timeout=setTimeout(function(){tiptip_holder.stop(true,true).fadeIn(opts.fadeIn)},opts.delay)}function deactive_tiptip(){opts.exit.call(this);if(timeout){clearTimeout(timeout)}tiptip_holder.fadeOut(opts.fadeOut)}}})}})(jQuery);