!function(e){e.fn.poptrox_disableSelection=function(){return e(this).css("user-select","none").css("-khtml-user-select","none").css("-moz-user-select","none").css("-o-user-select","none").css("-webkit-user-select","none")},e.fn.poptrox=function(o){if(0==this.length)return e(this);if(this.length>1){for(var t=0;t'),u=e(window),d=[],h=0,g=!1,f=new Array,x=function(){p=u.width(),i=u.height()+n.windowHeightPad;var e=Math.abs(s.width()-s.outerWidth()),o=Math.abs(s.height()-s.outerHeight()),t=p-2*n.windowMargin-e,r=i-2*n.windowMargin-o;s.css("min-width",n.popupWidth).css("min-height",n.popupHeight),b.children().css("max-width",t).css("max-height",r)};n.usePopupLoader||(n.popupLoaderSelector=null),n.usePopupCloser||(n.popupCloserSelector=null),n.usePopupCaption||(n.popupCaptionSelector=null),n.usePopupNav||(n.popupNavPreviousSelector=null,n.popupNavNextSelector=null);var v,w,b=(s=n.popupSelector?e(n.popupSelector):e('
'+(n.popupLoaderSelector?'
'+n.popupLoaderText+"
":"")+'
'+(n.popupCaptionSelector?'
':"")+(n.popupCloserSelector?''+n.popupCloserText+"":"")+(n.popupNavPreviousSelector?'':"")+(n.popupNavNextSelector?'':"")+"
")).find(".pic"),m=e(),C=s.find(n.popupLoaderSelector),y=s.find(n.popupCaptionSelector),S=s.find(n.popupCloserSelector),P=s.find(n.popupNavNextSelector),k=s.find(n.popupNavPreviousSelector),T=P.add(k);n.usePopupDefaultStyling&&(s.css("background",n.popupBackgroundColor).css("color",n.popupTextColor).css("padding",n.popupPadding+"px"),y.length>0&&(s.css("padding-bottom",n.popupCaptionHeight+"px"),y.css("position","absolute").css("left","0").css("bottom","0").css("width","100%").css("text-align","center").css("height",n.popupCaptionHeight+"px").css("line-height",n.popupCaptionHeight+"px"),n.popupCaptionTextSize&&y.css("font-size",popupCaptionTextSize)),S.length>0&&S.html(n.popupCloserText).css("font-size",n.popupCloserTextSize).css("background",n.popupCloserBackgroundColor).css("color",n.popupCloserTextColor).css("display","block").css("width","40px").css("height","40px").css("line-height","40px").css("text-align","center").css("position","absolute").css("text-decoration","none").css("outline","0").css("top","0").css("right","-40px"),C.length>0&&C.html("").css("position","relative").css("font-size",n.popupLoaderTextSize).on("startSpinning",function(o){var t=e("
"+n.popupLoaderText+"
");t.css("height",Math.floor(n.popupHeight/2)+"px").css("overflow","hidden").css("line-height",Math.floor(n.popupHeight/2)+"px").css("text-align","center").css("margin-top",Math.floor((s.height()-t.height()+(y.length>0?y.height():0))/2)).css("color",n.popupTextColor?n.popupTextColor:"").on("xfin",function(){t.fadeTo(300,.5,function(){t.trigger("xfout")})}).on("xfout",function(){t.fadeTo(300,.05,function(){t.trigger("xfin")})}).trigger("xfin"),C.append(t)}).on("stopSpinning",function(e){C.find("div").remove()}),2==T.length&&(T.css("font-size","75px").css("text-align","center").css("color","#fff").css("text-shadow","none").css("height","100%").css("position","absolute").css("top","0").css("opacity","0.35").css("cursor","pointer").css("box-shadow","inset 0px 0px 10px 0px rgba(0,0,0,0)").poptrox_disableSelection(),n.usePopupEasyClose?(v="100px",w="100px"):(v="75%",w="25%"),P.css("right","0").css("width",v).html('
>
'),k.css("left","0").css("width",w).html('
<
')));return u.on("resize orientationchange",function(){x()}),y.on("update",function(e,o){o&&0!=o.length||(o=n.popupBlankCaptionText),y.html(o)}),S.css("cursor","pointer").on("click",function(e){return e.preventDefault(),e.stopPropagation(),s.trigger("poptrox_close"),!0}),P.on("click",function(e){e.stopPropagation(),e.preventDefault(),s.trigger("poptrox_next")}),k.on("click",function(e){e.stopPropagation(),e.preventDefault(),s.trigger("poptrox_previous")}),l.css("position","fixed").css("left",0).css("top",0).css("z-index",n.baseZIndex).css("width","100%").css("height","100%").css("text-align","center").css("cursor","pointer").appendTo(n.parent).prepend('
').append('
').hide().on("touchmove",function(e){return!1}).on("click",function(e){e.preventDefault(),e.stopPropagation(),s.trigger("poptrox_close")}),s.css("display","inline-block").css("vertical-align","middle").css("position","relative").css("z-index",1).css("cursor","auto").appendTo(l).hide().on("poptrox_next",function(){var e=h+1;e>=d.length&&(e=0),s.trigger("poptrox_switch",[e])}).on("poptrox_previous",function(){var e=h-1;e<0&&(e=d.length-1),s.trigger("poptrox_switch",[e])}).on("poptrox_reset",function(){x(),s.data("width",n.popupWidth).data("height",n.popupHeight),C.hide().trigger("stopSpinning"),y.hide(),S.hide(),T.hide(),b.hide(),m.attr("src","").detach()}).on("poptrox_open",function(e,o){if(g)return!0;g=!0,n.useBodyOverflow&&a.css("overflow","hidden"),n.onPopupOpen&&n.onPopupOpen(),s.addClass("loading"),l.fadeTo(n.fadeSpeed,1,function(){s.trigger("poptrox_switch",[o,!0])})}).on("poptrox_switch",function(o,t,p){var i,r,a,c;if(!p&&g)return!0;(g=!0,s.addClass("loading").css("width",s.data("width")).css("height",s.data("height")),y.hide(),m.attr("src")&&m.attr("src",""),m.detach(),i=d[t],(m=i.object).off("load"),b.css("text-indent","-9999px").show().append(m),"ajax"==i.type?e.get(i.src,function(e){m.html(e),m.trigger("load")}):m.attr("src",i.src),"image"!=i.type)&&(a=i.width,c=i.height,"%"==a.slice(-1)&&(a=parseInt(a.substring(0,a.length-1))/100*u.width()),"%"==c.slice(-1)&&(c=parseInt(c.substring(0,c.length-1))/100*u.height()),m.css("position","relative").css("outline","0").css("z-index",n.baseZIndex+100).width(a).height(c));C.trigger("startSpinning").fadeIn(300),s.show(),n.popupIsFixed?(s.removeClass("loading").width(n.popupWidth).height(n.popupHeight),m.on("load",function(){m.off("load"),C.hide().trigger("stopSpinning"),r="function"==typeof n.caption?n.caption(i.a):i.captionText,y.trigger("update",[r]).fadeIn(n.fadeSpeed),S.fadeIn(n.fadeSpeed),b.css("text-indent",0).hide().fadeIn(n.fadeSpeed,function(){g=!1}),h=t,T.fadeIn(n.fadeSpeed)})):m.on("load",function(){x(),m.off("load"),C.hide().trigger("stopSpinning");var e=m.width(),o=m.height(),p=function(){r="function"==typeof n.caption?n.caption(i.a):i.captionText,y.trigger("update",[r]).fadeIn(n.fadeSpeed),S.fadeIn(n.fadeSpeed),b.css("text-indent",0).hide().fadeIn(n.fadeSpeed,function(){g=!1}),h=t,T.fadeIn(n.fadeSpeed),s.removeClass("loading").data("width",e).data("height",o).css("width","auto").css("height","auto")};e==s.data("width")&&o==s.data("height")?p():s.animate({width:e,height:o},n.popupSpeed,"swing",p)}),"image"!=i.type&&m.trigger("load")}).on("poptrox_close",function(){if(g&&!n.usePopupForceClose)return!0;g=!0,s.hide().trigger("poptrox_reset"),n.onPopupClose&&n.onPopupClose(),l.fadeOut(n.fadeSpeed,function(){n.useBodyOverflow&&a.css("overflow","auto"),g=!1})}).trigger("poptrox_reset"),n.usePopupEasyClose?(y.on("click","a",function(e){e.stopPropagation()}),s.css("cursor","pointer").on("click",function(e){e.stopPropagation(),e.preventDefault(),s.trigger("poptrox_close")})):s.on("click",function(e){e.stopPropagation()}),u.keydown(function(e){if(s.is(":visible"))switch(e.keyCode){case 37:case 32:if(n.usePopupNav)return s.trigger("poptrox_previous"),!1;break;case 39:if(n.usePopupNav)return s.trigger("poptrox_next"),!1;break;case 27:return s.trigger("poptrox_close"),!1}}),r.find(n.selector).each(function(o){var t,p=e(this),i=p.find("img"),r=p.data("poptrox");if("ignore"!=r&&p.attr("href")){if(t={a:p,src:p.attr("href"),captionText:i.attr("title"),width:null,height:null,type:null,object:null,options:null},n.caption){if("function"==typeof n.caption)c=n.caption(p);else if("selector"in n.caption){var a;a=p.find(n.caption.selector),"attribute"in n.caption?c=a.attr(n.caption.attribute):(c=a.html(),!0===n.caption.remove&&a.remove())}}else c=i.attr("title");if(t.captionText=c,r){var l=r.split(",");0 in l&&(t.type=l[0]),1 in l&&(u=l[1].match(/([0-9%]+)x([0-9%]+)/))&&3==u.length&&(t.width=u[1],t.height=u[2]),2 in l&&(t.options=l[2])}if(!t.type)switch((!(u=t.src.match(/\/\/([a-z0-9\.]+)\/.*/))||u.length<2)&&(u=[!1]),u[1]){case"api.soundcloud.com":t.type="soundcloud";break;case"youtu.be":t.type="youtube";break;case"vimeo.com":t.type="vimeo";break;case"wistia.net":t.type="wistia";break;case"bcove.me":t.type="bcove";break;default:t.type="image"}switch(u=t.src.match(/\/\/[a-z0-9\.]+\/(.*)/),t.type){case"iframe":t.object=e(''),t.object.on("click",function(e){e.stopPropagation()}).css("cursor","auto"),t.width&&t.height||(t.width="600",t.height="400");break;case"ajax":t.object=e('
'),t.object.on("click",function(e){e.stopPropagation()}).css("cursor","auto").css("overflow","auto"),t.width&&t.height||(t.width="600",t.height="400");break;case"soundcloud":t.object=e(''),t.src="//w.soundcloud.com/player/?url="+escape(t.src)+(t.options?"&"+t.options:""),t.width="600",t.height="166";break;case"youtube":t.object=e(''),t.src="//www.youtube.com/embed/"+u[1]+(t.options?"?"+t.options:""),t.width&&t.height||(t.width="800",t.height="480");break;case"vimeo":t.object=e(''),t.src="//player.vimeo.com/video/"+u[1]+(t.options?"?"+t.options:""),t.width&&t.height||(t.width="800",t.height="480");break;case"wistia":t.object=e(''),t.src="//fast.wistia.net/"+u[1]+(t.options?"?"+t.options:""),t.width&&t.height||(t.width="800",t.height="480");break;case"bcove":t.object=e(''),t.src="//bcove.me/"+u[1]+(t.options?"?"+t.options:""),t.width&&t.height||(t.width="640",t.height="360");break;default:var u;if(t.object=e(''),n.preload)(u=document.createElement("img")).src=t.src,f.push(u);t.width=p.attr("width"),t.height=p.attr("height")}"file:"==window.location.protocol&&t.src.match(/^\/\//)&&(t.src="http:"+t.src),d.push(t),i.removeAttr("title"),p.removeAttr("href").css("cursor","pointer").css("outline",0).on("click",function(e){e.preventDefault(),e.stopPropagation(),s.trigger("poptrox_open",[o])})}}),r.prop("_poptrox",n),r}}(jQuery);