!function(e,t){"use strict";function o(o,n){var c=e.extend(!0,{},O,n);return c.overlay.fillColor=c.overlay.fillColor||c.overlay.color||"#888",c.zIndex=c.zIndex||c.overlay.zIndex+1,f(c.offset,t,c),y||(y=e(window).resize(function(){v&&v.stop(!0,!0),x.stop(!0,!0),b&&b.stop(!0,!0),D&&r(D),w&&r(w.parent)}),x=e('
').css({position:"fixed",left:0,top:0,width:"100%",height:"150%",display:"none"}).appendTo(m=e("body")).click(i).on("touchmove",function(){return!1}),e(document).focusin(function(t){D&&!D.has(t.target).length&&(z?z.focus():e(document.activeElement).blur())}).keydown(function(e){return D&&27===e.keyCode?i(e):void 0})),o.each(function(){var t=e(this),o={position:"fixed",display:"none",zIndex:c.zIndex};f(c.offset,o),d(c.closeClass,t),e.each([["open",E],["close",j],["beforeopen",L],["beforeclose",A]],function(e,o){var n=o[0],i=o[1];"function"==typeof c[n]&&t.off(i,c[n]).on(i,c[n])}),t.css(o).data(T,e.extend(!0,{},c)).appendTo(m).on("touchmove",function(){return!1})})}function n(n,l,s){function f(){var o;W.find("a,input,select,textarea,button,object,area,img,map").each(function(){var t=e(this);return t.focus().get(0)===document.activeElement?(z=t,!1):void 0}),j&&w.jqActive&&w.jqActive.length&&w.jqActive.focus(),v=t,D=W,p=!1,o=e.Event(E),j?(o.from=w.child,w=t):A&&(o.isChild=!0),W.trigger(o)}function u(e){var t=e.data(T);return t.child&&t.child.index(W)>-1}var d,b,q,j,A,O,B,H,P,R,W=n.length?n.eq(0):t;if(W){if((l||!(d=W.data(T)))&&(d=o(W,l).data(T)),g||w||!v||h&&v.get(0)===W.get(0)||!d.force||(v.stop(!0,!0),x.stop(!0,!0)),p&&!s)return n;if(!g&&!w&&D&&D.get(0)!==W.get(0)&&(d.force?B=!0:u(D)&&(w={parent:D,child:W.insertAfter(D),jqActive:e(document.activeElement).blur()},B=!0),B))return g=W,i(D),n;null===D&&(p=!0,w&&(j=W.get(0)===w.parent.get(0),A=W.get(0)===w.child.get(0)),q=!g&&!w,b=e.Event(L,{cancelable:q}),j?b.from=w.child:A&&(b.isChild=!0),W.trigger(b),q&&b.isDefaultPrevented()?p=!1:(O=!g&&!w&&!d.fixOverlay,O&&(I||(H=m.get(0).style,I={overflow:H.overflow},P=m.prop("clientWidth"),R=m.prop("clientHeight"),m.css("overflow","hidden"),P-=m.prop("clientWidth"),R-=m.prop("clientHeight"),I.marginRight=H.marginRight,I.marginBottom=H.marginBottom,0>P&&m.css("marginRight","+="+-P),0>R&&m.css("marginBottom","+="+-R)),C=e(document.activeElement).blur(),k===t&&(k={left:y.scrollLeft(),top:y.scrollTop()},y.scroll(a))),z=null,r(W,d),window.setTimeout(function(){j?f():(h=!0,d.effect.open.call(v=W,d.duration,f),A&&c(w.parent,!0,d.duration))},0),O&&x.css({backgroundColor:d.overlay.fillColor,zIndex:d.overlay.zIndex}).fadeTo(d.duration,d.overlay.opacity),D=0))}return n}function i(o){function i(){var i;b&&(I&&(m.css(I),I=t),C&&C.length&&C.focus(),k!==t&&(y.off("scroll",a).scrollLeft(k.left).scrollTop(k.top),k=t)),v=t,D=null,g||d||(p=!1),i=e.Event(j),q?i.from=o:g&&(i.from=g),d&&(i.isChild=!0),r.trigger(i),g?(n(g,t,!0),g=t):d&&n(w.parent,t,!0)}var r,l,s,f,u,d,b,z,q=o instanceof e.Event;return!p&&D&&(r=q||o.index(D)>-1?D:t,r&&(p=!0,w&&(u=r.get(0)===w.parent.get(0),d=r.get(0)===w.child.get(0)),f=!0,s=e.Event(A,{cancelable:f}),q?s.from=o:g&&(s.from=g),d&&(s.isChild=!0),r.trigger(s),f&&s.isDefaultPrevented()?(p=!1,g=t,u&&(w=t)):(l=r.data(T),b=!g&&!w&&!l.fixOverlay,z=g?0:l.duration,window.setTimeout(function(){u?i():(h=!1,l.effect.close.call(v=r,z,i),d&&c(w.parent,!1,l.duration))},0),b&&x.fadeOut(z),D=0))),q?(o.preventDefault(),!1):o}function c(e,o,n,i){function c(e){x.css("opacity",(1-r.overlay.opacity)/(1-e)*-1+1)}var r,l=e.length?e.eq(0):t;if(l&&(r=l.data(T)))return o===t&&(o=!0),n=n||r.duration,b=b||x.clone(!0).appendTo(m),x.stop(!0).css({backgroundColor:r.overlay.fillColor,zIndex:r.overlay.zIndex}),b.stop(!0).css({backgroundColor:r.overlay.fillColor,zIndex:r.zIndex}).insertAfter(l),o?(x.css({opacity:r.overlay.opacity,display:"block"}),b.css({opacity:0,display:"block"}).animate({opacity:r.overlay.opacity},{duration:n,step:c,complete:function(){x.css("display","none"),i&&i()}})):(x.css({opacity:0,display:"block"}),b.css({opacity:r.overlay.opacity,display:"block"}).animate({opacity:0},{duration:n,step:c,complete:function(){b.css("display","none"),i&&i()}})),e}function r(e,t){var o;t=t||e.data(T),"function"==typeof t.offset&&(o=t.offset.call(e))&&e.css({left:o.left,top:o.top,marginLeft:"",marginTop:""})}function l(){this.css({left:"50%",top:"50%",marginLeft:"-"+this.outerWidth()/2+"px",marginTop:"-"+this.outerHeight()/2+"px"})}function a(e){return k!==t&&y.scrollLeft(k.left).scrollTop(k.top),e.preventDefault(),!1}function s(n,i,c){function r(e,t,n){var i=e.data(T)||o(e).data(T);if(O.hasOwnProperty(t)){if(3===arguments.length)switch(t){case"offset":f(n,e,i);break;case"zIndex":u(n,e,i);break;case"closeClass":d(n,e,i);break;default:i[t]=n}return i[t]}}return 2===arguments.length&&"string"==typeof i?n.length?r(n.eq(0),i):t:n.each("string"==typeof i?function(){r(e(this),i,c)}:function(){var t=e(this);e.each(i,function(e,o){r(t,e,o)})})}function f(e,t,o){var n;e?"function"==typeof e&&(e=function(e){return function(){var t=this;return e.call(t,function(){l.call(t)})}}(e)):e=l,!t||"function"==typeof e||o&&"function"!=typeof o.offset&&o.offset.left===e.left&&o.offset.top===e.top||(n=t.jquery?{}:t,n.left=e.left,n.top=e.top,n.marginLeft=n.marginTop="",t.jquery&&t.css(n)),o&&(o.offset=e,t&&D&&t.get(0)===D.get(0)&&r(t,o))}function u(e,t,o){!t||o&&o.zIndex===e||t.css("zIndex",e),o&&(o.zIndex=e)}function d(e,t,o){t&&o&&o.closeClass&&o.closeClass!==e&&t.find("."+o.closeClass).off("click",i),!t||!e||o&&o.closeClass===e||t.find("."+e).off("click",i).click(i),o&&(o.closeClass=e)}var p,g,v,h,y,m,x,b,C,z,I,k,w,T="plainModal",q=T.toLowerCase(),E=q+"open",j=q+"close",L=q+"beforeopen",A=q+"beforeclose",O={duration:200,effect:{open:e.fn.fadeIn,close:e.fn.fadeOut},overlay:{opacity:.6,zIndex:9e3},fixOverlay:!1,offset:t,zIndex:0,closeClass:q+"-close",force:!1,child:t},D=null;e.fn[T]=function(e,t,r,l){return"open"===e?n(this,t):"close"===e?i(this):"blur"===e?c(this,t,r,l):"option"===e?arguments.length<=2?s(this,t):s(this,t,r):o(this,e)}}(jQuery);