/*
* boxer v3.0.3 - 2014-01-12
* a jquery plugin for displaying images, videos or content in a modal overlay. part of the formstone library.
* http://formstone.it/boxer/
*
* copyright 2014 ben plum; mit licensed
*/
!function(a,b){"use strict";function c(b){return g.formatter=j,a(this).on("click.boxer",a.extend({},g,b||{}),d)}function d(c){var d=a(this),f=c.data.$object,g=d[0].attributes?d.attr("href")||"":"",i=g.tolowercase().split("."),j=i[i.length-1],l="",m="image"===l||"jpeg"===j||"jpg"===j||"gif"===j||"png"===j||"data:image"===g.substr(0,10),o=g.indexof("youtube.com/embed")>-1||g.indexof("player.vimeo.com/video")>-1,p="url"===l||!m&&!o&&"http"===g.substr(0,4),w="element"===l||!m&&!o&&!p&&"#"===g.substr(0,1),x="undefined"!=typeof f;if(!(a("#boxer").length>1)&&(m||o||p||w||x)){if(d(c),e=a.extend({},{$window:a(b),$body:a("body"),$target:d,$object:f,visible:!1,resizetimer:null,touchtimer:null,gallery:{active:!1},ismobile:f||c.data.mobile},c.data),e.margin*=2,e.containerheight=e.height,e.containerwidth=e.width,e.type=m?"image":o?"video":"element",m||o){var y=e.$target.attr("rel");"undefined"!=typeof y&&y!==!1&&(e.gallery.active=!0,e.gallery.rel=y,e.gallery.$items=a("a[rel= "+e.gallery.rel+"]"),e.gallery.index=e.gallery.$items.index(e.$target),e.gallery.total=e.gallery.$items.length-1)}var z="";return e.ismobile||(z+='
',z+='
'+e.labels.close+"",z+='
",e.$body.append(z),e.$overlay=a("#boxer-overlay"),e.$boxer=a("#boxer"),e.$container=e.$boxer.find(".boxer-container"),e.$content=e.$boxer.find(".boxer-content"),e.$meta=e.$boxer.find(".boxer-meta"),e.$position=e.$boxer.find(".boxer-position"),e.$caption=e.$boxer.find(".boxer-caption"),e.$arrows=e.$boxer.find(".boxer-arrow"),e.$animatables=a("#boxer-overlay, #boxer, .boxer-container"),e.paddingvertical=parseint(e.$boxer.css("paddingtop"),10)+parseint(e.$boxer.css("paddingbottom"),10),e.paddinghorizontal=parseint(e.$boxer.css("paddingleft"),10)+parseint(e.$boxer.css("paddingright"),10),h(),e.gallery.active&&r(),e.$window.on("resize.boxer",h.resize).on("keydown.boxer",s),e.$body.on("touchstart.boxer click.boxer","#boxer-overlay, #boxer .boxer-close",e).on("touchmove.boxer",d),e.gallery.active&&e.$boxer.on("touchstart.boxer click.boxer",".boxer-arrow",q),e.$overlay.stop().animate({opacity:e.opacity},e.duration),e.$boxer.stop().animate({opacity:1},e.duration,function(){m?k(g):o?n(g):p?u(g):w?t(g):x?v(e.$object):a.error("boxer: '"+g+"' is not valid.")}),x?e.$boxer:void 0}}function e(b){d(b),"undefined"!=typeof e.$animatables&&(e.$animatables.stop().animate({opacity:0},e.duration,function(){a(this).remove()}),b(e.resizetimer),e.$window.off(".boxer"),e.$body.off(".boxer").removeclass("boxer-open"),e.gallery.active&&e.$boxer.off(".boxer"),e.ismobile&&"image"===e.type&&e.gallery.active&&e.$container.off(".boxer"),e.$window.trigger("close.boxer"),e={})}function f(){var a=i(),b=0,c=e.ismobile?0:e.duration;e.ismobile||(b=e.$arrows.outerheight(),e.$arrows.css({margintop:(e.contentheight-e.metaheight-b)/2})),!e.visible&&e.ismobile&&e.gallery.active&&e.$content.on("touchstart.boxer",".boxer-image",x),(e.ismobile||e.fixed)&&e.$body.addclass("boxer-open"),e.$boxer.stop().animate({left:a.left,top:a.top},c),e.$container.show().stop().animate({height:e.containerheight,width:e.containerwidth},c,function(){e.$content.stop().animate({opacity:1},e.duration),e.$boxer.removeclass("loading").find(".boxer-close").stop().animate({opacity:1},e.duration),e.visible=!0,e.callback.apply(e.$boxer),e.$window.trigger("open.boxer"),e.gallery.active&&p()})}function g(a){if(a=a||!1,e.visible){var b=i(),c=0;e.ismobile||(c=e.$arrows.outerheight(),e.$arrows.css({margintop:(e.contentheight-e.metaheight-c)/2})),a?(e.$boxer.stop().animate({left:b.left,top:b.top},e.duration),e.$container.show().stop().animate({height:e.containerheight,width:e.containerwidth})):(e.$boxer.css({left:b.left,top:b.top}),e.$container.css({height:e.containerheight,width:e.containerwidth}))}}function h(){var a=i();e.$boxer.css({left:a.left,top:a.top})}function i(){if(e.ismobile)return{left:0,top:0};var a={left:(e.$window.width()-e.containerwidth-e.paddinghorizontal)/2,top:e.top<=0?(e.$window.height()-e.containerheight-e.paddingvertical)/2:e.top};return e.fixed!==!0&&(a.top+=e.$window.scrolltop()),a}function j(a){var b=a.attr("title");return""!==b&&void 0!==b?'
'+b+"
":""}function k(b){e.$image=a("
"),e.$image.one("load.boxer",function(){var a=c(e.$image);e.naturalheight=a.naturalheight,e.naturalwidth=a.naturalwidth,e.retina&&(e.naturalheight/=2,e.naturalwidth/=2),e.$content.prepend(e.$image),""===e.$caption.html()?e.$caption.hide():e.$caption.show(),l(),f()}).attr("src",b).addclass("boxer-image"),(e.$image[0].complete||4===e.$image[0].readystate)&&e.$image.trigger("load")}function l(){var a=0;for(e.windowheight=e.viewportheight=e.$window[0].innerheight,e.windowwidth=e.viewportwidth=e.$window[0].innerwidth,e.containerheight=1/0,e.contentheight=0,e.containerwidth=1/0,e.contentwidth=0,e.imagemargintop=0,e.imagemarginleft=0;e.containerheight>e.viewportheight&&2>a;)e.imageheight=0===a?e.naturalheight:e.$image.outerheight(),e.imagewidth=0===a?e.naturalwidth:e.$image.outerwidth(),e.metaheight=0===a?0:e.metaheight,0===a&&(e.ratiohorizontal=e.imageheight/e.imagewidth,e.ratiovertical=e.imagewidth/e.imageheight,e.iswide=e.imagewidth>e.imageheight),e.imageheight
a&&(e.targetimageheight=a,e.targetimagewidth=e.targetimageheight*e.ratiovertical)):(e.targetimageheight=a,e.targetimagewidth=e.targetimageheight*e.ratiovertical,e.targetimagewidth>b&&(e.targetimagewidth=b,e.targetimageheight=e.targetimagewidth*e.ratiohorizontal)),(e.targetimagewidth>e.imagewidth||e.targetimageheight>e.imageheight)&&(e.targetimageheight=e.imageheight,e.targetimagewidth=e.imagewidth),(e.targetimagewidth'),e.$video=a(''),e.$video.attr("src",b).addclass("boxer-video").prependto(e.$videowrapper),e.$content.prepend(e.$videowrapper),o(),f()}function o(){e.windowheight=e.viewportheight=e.contentheight=e.$window[0].innerheight-e.paddingvertical,e.windowwidth=e.viewportwidth=e.contentwidth=e.$window[0].innerwidth-e.paddinghorizontal,e.videomargintop=0,e.videomarginleft=0,e.ismobile?(e.$meta.css({width:e.windowwidth}),e.metaheight=e.$meta.outerheight(!0),e.viewportheight-=e.metaheight,e.targetvideowidth=e.viewportwidth,e.targetvideoheight=e.targetvideowidth*e.videoratio,e.targetvideoheight>e.viewportheight&&(e.targetvideoheight=e.viewportheight,e.targetvideowidth=e.targetvideoheight/e.videoratio),e.videomargintop=(e.viewportheight-e.targetvideoheight)/2,e.videomarginleft=(e.viewportwidth-e.targetvideowidth)/2):(e.viewportheight=e.windowheight-e.margin,e.viewportwidth=e.windowwidth-e.margin,e.targetvideowidth=e.videowidth>e.viewportwidth?e.viewportwidth:e.videowidth,e.targetvideowidth0&&(b=e.gallery.$items.eq(e.gallery.index-1).attr("href"),b.indexof("youtube.com/embed")<0&&b.indexof("player.vimeo.com/video")<0&&a('')),e.gallery.index'))}function q(b){d(b);var c=a(this);c.hasclass("disabled")||(e.$boxer.addclass("loading"),e.gallery.index+=c.hasclass("next")?1:-1,e.gallery.index>e.gallery.total&&(e.gallery.index=e.gallery.total),e.gallery.index<0&&(e.gallery.index=0),e.$content.stop().animate({opacity:0},e.duration,function(){"undefined"!=typeof e.$image&&e.$image.remove(),"undefined"!=typeof e.$videowrapper&&e.$videowrapper.remove(),e.$target=e.gallery.$items.eq(e.gallery.index),e.$caption.html(e.formatter.apply(e.$body,[e.$target])),e.$position.find(".current").html(e.gallery.index+1);var a=e.$target.attr("href"),b=a.indexof("youtube.com/embed")>-1||a.indexof("player.vimeo.com/video")>-1;b?n(a):k(a),r()}))}function r(){e.$arrows.removeclass("disabled"),0===e.gallery.index&&e.$arrows.filter(".previous").addclass("disabled"),e.gallery.index===e.gallery.total&&e.$arrows.filter(".next").addclass("disabled")}function s(a){!e.gallery.active||37!==a.keycode&&39!==a.keycode?27===a.keycode&&e.$boxer.find(".boxer-close").trigger("click"):(d(a),e.$arrows.filter(37===a.keycode?".previous":".next").trigger("click"))}function t(b){var c=a(b).find(">:first-child").clone();v(c)}function u(b){b+=b.indexof("?")>-1?"&"+g.requestkey+"=true":"?"+g.requestkey+"=true";var c=a('');v(c)}function v(a){e.$content.append(a),w(a),f()}function w(a){e.objectheight=a.outerheight(!0),e.objectwidth=a.outerwidth(!0),e.windowheight=e.$window.height()-e.paddingvertical,e.windowwidth=e.$window.width()-e.paddinghorizontal,e.maxheight=e.windowheight<0?g.minheight:e.windowheight,e.isiframe=a.is("iframe"),e.objectmargintop=0,e.objectmarginleft=0,e.ismobile||(e.windowheight-=e.margin,e.windowwidth-=e.margin),e.contentheight=void 0!==e.dataheight?e.dataheight:e.isiframe?e.windowheight:e.objectheight,e.contentwidth=void 0!==e.datawidth?e.datawidth:e.isiframe?e.windowwidth:e.objectwidth,e.isiframe&&e.ismobile&&(e.contentheight=e.windowheight,e.contentwidth=e.windowwidth),e.containerheight=e.contentheight,e.containerwidth=e.contentwidth,e.$content.css({height:e.contentheight,width:e.contentwidth})}function x(a){if(d(a),b(e.touchtimer),!e.isanimating){var b="undefined"!=typeof a.originalevent.targettouches?a.originalevent.targettouches[0]:null;e.xstart=b?b.pagex:a.clientx,e.leftposition=0,e.touchmax=1/0,e.touchmin=-1/0,e.edge=.25*e.contentwidth,0===e.gallery.index&&(e.touchmax=0),e.gallery.index===e.gallery.total&&(e.touchmin=0),e.$boxer.on("touchmove.boxer",y).one("touchend.boxer",z)}}function y(a){var b="undefined"!=typeof a.originalevent.targettouches?a.originalevent.targettouches[0]:null;e.delta=e.xstart-(b?b.pagex:a.clientx),e.delta>20&&d(a),e.canswipe=!0;var c=-e.delta;ce.touchmax&&(c=e.touchmax,e.canswipe=!1),e.$image.css({transform:"translate3d("+c+"px,0,0)"}),e.touchtimer=a(e.touchtimer,300,function(){z(a)})}function z(a){d(a),b(e.touchtimer),e.$boxer.off("touchmove.boxer touchend.boxer"),e.delta&&(e.$boxer.addclass("animated"),e.swipe=!1,e.canswipe&&(e.delta>e.edge||e.delta<-e.edge)?(e.swipe=!0,e.delta<=e.leftposition?e.$image.css({transform:"translate3d("+e.contentwidth+"px,0,0)"}):e.$image.css({transform:"translate3d("+-e.contentwidth+"px,0,0)"})):e.$image.css({transform:"translate3d(0,0,0)"}),e.swipe&&e.$arrows.filter(e.delta<=e.leftposition?".previous":".next").trigger("click"),a(e.resettimer,e.duration,function(){e.$boxer.removeclass("animated")}))}function a(a,b,c){return b(a),settimeout(c,b)}function b(a){a&&(cleartimeout(a),a=null)}function c(a){var b=a[0],c=new image;return"undefined"!=typeof b.naturalheight?{naturalheight:b.naturalheight,naturalwidth:b.naturalwidth}:"img"===b.tagname.tolowercase()?(c.src=b.src,{naturalheight:c.height,naturalwidth:c.width}):!1}function d(a){a.preventdefault&&(a.stoppropagation(),a.preventdefault())}var e={},f=/android|webos|iphone|ipad|ipod|blackberry/i.test(b.navigator.useragent||b.navigator.vendor||b.opera),g={callback:a.noop,customclass:"",duration:250,fixed:!1,formatter:a.noop,height:100,labels:{close:"close",count:"of",next:"next",previous:"previous"},margin:50,minheight:100,minwidth:100,mobile:!1,opacity:.75,retina:!1,requestkey:"boxer",top:0,videoratio:.5625,videowidth:600,width:100},h={defaults:function(b){return g=a.extend(g,b||{}),a(this)},destroy:function(){return e(),a(this).off(".boxer")},resize:function(){return"undefined"!=typeof e.$boxer&&("element"===e.type?w(e.$content.find(">:first-child")):"image"===e.type?l():"video"===e.type&&o(),g()),a(this)}};a.fn.boxer=function(a){return h[a]?h[a].apply(this,array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?this:c.apply(this,arguments)},a.boxer=function(c,e){return h[c]?h[c].apply(b,array.prototype.slice.call(arguments,1)):d.apply(b,[{data:a.extend({$object:c},g,e||{})}])}}(jquery,window);