var as3cfModal=function($){var modal={prefix:"as3cf",loading:false,dismissible:true};var modals={};function targetToKey(target){return target.replace(/[^a-z]/g,"")}modal.exists=function(target){var key=targetToKey(target);if(undefined!==modals[key]){return true}if($(target).length){return true}return false};modal.open=function(target,callback,customClass){var key=targetToKey(target);$("body").append('
');var $overlay=$("#as3cf-overlay");if(modal.dismissible){$overlay.append('
×
')}else{$overlay.append('
')}var $modal=$("#as3cf-modal");if(undefined===modals[key]){var content=$(target);modals[key]=content.clone(true).css("display","block");content.remove()}$modal.data("as3cf-modal-target",target).append(modals[key]);if(undefined!==customClass){$modal.addClass(customClass)}if("function"===typeof callback){callback(target)}$("body").addClass("as3cf-modal-open");$overlay.fadeIn(150);$modal.fadeIn(150);$("body").trigger("as3cf-modal-open",[target])};modal.close=function(callback){if(modal.loading||!modal.dismissible){return}var target=$("#as3cf-modal").data("as3cf-modal-target");$("#as3cf-overlay").fadeOut(150,(function(){$("body").removeClass("as3cf-modal-open");$(this).remove();if("function"===typeof callback){callback(target)}}));$("body").trigger("as3cf-modal-close",[target])};modal.setLoadingState=function(state){modal.loading=state};modal.setDismissibleState=function(state){modal.dismissible=state};$(document).ready((function(){$("body").on("click","[data-as3cf-modal]",(function(e){e.preventDefault();modal.open($(this).data("as3cf-modal")+"."+modal.prefix)}));$("body").on("click","#as3cf-overlay, .close-as3cf-modal",(function(e){if("A"===e.target.tagName){return}e.preventDefault();if(e.target!==this){return false}modal.close()}))}));return modal}(jQuery);