!function(a){function b(){var a=navigator.userAgent.toLowerCase();return a.indexOf("msie")>-1?parseInt(a.split("msie")[1]):!1}function c(){var a=!1,b=document.createElement("p");for(var c in p)if(p.hasOwnProperty(c)&&void 0!==b.style[c]){a={property:c};break}return document.body.appendChild(b),a.property&&(b.style[a.property]="translate3d(1px,1px,1px)",a.has3d="none"!=window.getComputedStyle(b).getPropertyValue(p[a.property])),document.body.removeChild(b),a}function d(a){var b=document.createElement("p").style,c=["ms","O","Moz","Webkit"];if(""==b[a])return a;a=a.charAt(0).toUpperCase()+a.slice(1);for(var d=0,e=c.length;e>d;d++)if(""==b[c[d]+a])return c[d]+a}function e(b,c,d,e,f){e=!!e,b&&(f?b.removeEventListener?b.removeEventListener(c,d,e):a(b).off(c):b.addEventListener?b.addEventListener(c,d,e):a(b).on(c,d))}function f(a,b){var c=" "+a.className+" ";return b=" "+b+" ",c.replace(/[\r\n\t\f]+/g," ").indexOf(b)>-1?!0:!1}function g(){var a="ontouchstart"in window;return a?["touchstart","touchmove","touchend","touchcancel"]:["mousedown","mousemove","mouseup","mouseleave"]}function h(a){function b(a){var b,c=q[a];if(c.params.transform){var d=c.layer.css(p[c.params.transform.property]).match(/(-?[0-9\.]+)/g);b=d.length>6?d[13]:d[4]}else b=c.layer.css("left");return parseInt(b)}function c(){m.isSlide&&(m.isThumbs?h():k.params.transition&&e()),m={},k.root.removeClass(k.params._dragging)}function d(){var b,c=k.params.slidesOnScreen;(0==k.current&&m.shiftX>0||k.current+c-1==k.last&&m.shiftX<0)&&(m.shiftX=m.shiftX/3),b=m.shiftX+m.startShift,k.layer.css(t.setIndent(a,Math.round(b),"px"))}function e(){if(Math.abs(m.shiftX)>.05*k.viewportWidth){var b,c=m.shiftX/k.viewportWidth*k.params.slidesOnScreen;b=m.shiftX<0?k.current-Math.floor(c):k.current-Math.ceil(c),0>b&&(b=0),b+k.params.slidesOnScreen-1>k.last&&(b=k.last-k.params.slidesOnScreen+1),t.go(a,b)}else t.go(a,k.current)}function g(){var b=m.shiftX+m.thumbsStartX,c=-1*(k.thumbsLayerWidth-k.thumbsWidth);b>0&&(b/=3),c>b&&(b=c+(b-c)/3),k.thumbsIndent=b,k.thumbsLayer.css(t.setIndent(a,k.thumbsIndent,"px"))}function h(){if(k.thumbsDragging&&m.isSlide){var b=m.shiftX<0?-1:1;m.t2=new Date,k.thumbsIndent=i(k.thumbsIndent,b),k.thumbsLayer.css("transition-duration",".24s").css(t.setIndent(a,k.thumbsIndent,"px"))}}function i(a,b){var c,d,e=Math.abs(10*m.shiftX/(m.t2-m.t1));return c=b*parseInt(Math.pow(e,2))+a,d=k.thumbs.outerWidth()-k.thumbsLayer.outerWidth(),c>0?0:d>c?d:c}function j(a,b){for(var c=0,d=a.length;d>c;c++)k.events.push({element:a[c],event:b,handler:function(a){return a.preventDefault&&a.preventDefault(),!1}})}var k=q[a],l=k.thumbs,m={},n=k.viewport[0].getElementsByTagName("a"),o=k.viewport[0].getElementsByTagName("img");s.onStart=function(a){k.freeze||(m.x1=a.clientX||a.touches&&a.touches[0].clientX,m.y1=a.clientY||a.touches&&a.touches[0].clientY,m.t1=new Date,m.isPressed=!0,m.isThumbs=f(this,k.params.thumbs),m.thumbsStartX=k.thumbsIndent,k.layer.css("transition-duration","0s"),k.thumbsLayer.css("transition-duration","0s"))},s.onMove=function(e){if(m.isPressed&&!k.freeze){if(m.shiftX=(e.clientX||e.touches&&e.touches[0].clientX)-m.x1,m.shiftY=(e.clientY||e.touches&&e.touches[0].clientY)-m.y1,m.shiftXAbs=Math.abs(m.shiftX),m.shiftYAbs=Math.abs(m.shiftY),m.isMultitouch=m.isMultitouch||!!e.touches&&e.touches.length>1,m.isMultitouch)return void c();m.isSlide||m.isScroll||(m.shiftYAbs>=5&&m.shiftYAbs>m.shiftXAbs&&(m.isScroll=!0),m.shiftXAbs>=5&&m.shiftXAbs>m.shiftYAbs&&(k.root.addClass(k.params._dragging),m.isSlide=!0,m.startShift=b(a))),m.isSlide&&(m.isThumbs?k.thumbsDragging&&g():k.params.transition&&d(),e.preventDefault&&e.preventDefault())}},s.onEnd=function(b){if(!m.isSlide&&!m.isScroll&&m.isPressed){if(f(b.target,k.params.prev)&&t.prev(a),f(b.target,k.params.next)&&t.next(a),f(b.target,k.params.thumbImg)||f(b.target,k.params.thumb)){var d=parseInt(b.target.getAttribute("data-rel"));d+k.params.slidesOnScreen-1>k.last&&(d=k.last-k.params.slidesOnScreen+1),t.go(a,d)}b.stopPropagation&&b.preventDefault&&(b.stopPropagation(),b.preventDefault())}c()},k.events.push({element:k.viewport[0],event:r[0],handler:s.onStart},{element:k.viewport[0],event:r[1],handler:s.onMove,capture:!0},{element:k.viewport[0],event:r[2],handler:s.onEnd},{element:k.viewport[0],event:r[3],handler:s.onEnd},{element:l[0],event:r[0],handler:s.onStart},{element:l[0],event:r[1],handler:s.onMove,capture:!0},{element:l[0],event:r[2],handler:s.onEnd},{element:l[0],event:r[3],handler:s.onEnd}),j(k.thumb,"click"),j(k.thumbImg,"dragstart"),j(n,"dragstart"),j(o,"dragstart")}function i(a){if(!s.resize){var b=q[a];b.events.push({element:window,event:"resize",handler:t.update})}}function j(a){var b=q[a];s.keydown=function(b){var c=b.which||b.keyCode,d=b.target.nodeName.toLowerCase(),e=!!b.target.attributes.contenteditable;if("input"!=d&&"textarea"!=d&&"select"!=d&&!e)switch(c){case 32:t.next(a);break;case 37:t.prev(a);break;case 39:t.next(a)}},b.events.push({element:window,event:"keydown",handler:s.keydown})}function k(a){var b=q[a],c=["webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","transitionend"];s.transitionEnd=function(b){var c=b.propertyName;(c.lastIndexOf("transform")==c.length-"transform".length||"left"==c)&&l(a)};for(var d=0,e=c.length;e>d;d++)b.events.push({element:b.layer[0],event:c[d],handler:s.transitionEnd})}function l(a){var b=q[a];b.root.removeClass(b.params._animated),b.layer[0].style.transitionDuration=0,m(a,b.current),b.params.onShow&&b.params.onShow.call(b)}function m(a,b){for(var c=q[a],d=0,e=c.count;e>d;d++){var f=c.root.find("."+c.params.slide+"."+c.params.modifierPrefix+d),g=c.params.slidesOnScreen;d>=c.current-g&&d<=c.current+2*g-1||d>=b-g&&b+2*g-1>=d?f.removeClass(c.params._hidden):f.addClass(c.params._hidden)}}function n(a,b){var c=new Image;c.onload=function(){c.onload=null,b.call(this,!0,a)},c.onerror=function(){c.onerror=null,b.call(this,!1,a)},c.src=a}if("undefined"!=typeof window){var o,p={transform:"transform",WebkitTransform:"-webkit-transform",MozTransform:"-moz-transform",msTransform:"-ms-transform",OTransform:"-o-transform"},q=[],r=g(),s=[],t={init:function(e){var f="photor__";return o=a.extend({control:f+"viewportControl",next:f+"viewportControlNext",prev:f+"viewportControlPrev",thumbs:f+"thumbs",thumbsLayer:f+"thumbsWrap",thumb:f+"thumbsWrapItem",thumbImg:f+"thumbsWrapItemImg",thumbFrame:f+"thumbsWrapFrame",viewport:f+"viewport",layer:f+"viewportLayer",slide:f+"viewportLayerSlide",slideImg:f+"viewportLayerSlideImg",_loading:"_loading",_error:"_error",_current:"_current",_dragging:"_dragging",_disabled:"_disabled",_alt:"_alt",_single:"_single",_animated:"_animated",_hidden:"_hidden",_html:"_html",_freeze:"_freeze",_auto:"_auto",_center:"_center",_portrait:"_portrait",_landscape:"_landscape",_draggable:"_draggable",single:!1,current:0,count:0,last:-1,duration:300,loop:!1,showThumbs:"thumbs",keyboard:!0,modifierPrefix:"_",ieClassPrefix:"_ie",slidesOnScreen:1,transform:c(),transition:d("transition"),ie:b()},e),this.each(function(){var b=a(this),c=this.id||q.length,d={},e={},f={url:"",thumb:"",caption:"",width:0,height:0,loaded:!1,classes:""},g=!1;if(!b.attr("data-photor-id")){if(d.params=a.extend({},o),d.root=b,d.control=b.find("."+d.params.control),d.next=b.find("."+d.params.next),d.prev=b.find("."+d.params.prev),d.thumbs=b.find("."+d.params.thumbs),d.thumbsLayer=b.find("."+d.params.thumbsLayer),d.viewport=b.find("."+d.params.viewport),d.layer=b.find("."+d.params.layer),d.slides=[],d.params.data&&d.params.data.length)for(var h=0,i=d.params.data.length;i>h;h++)d.slides.push(a.extend({},f,d.params.data[h]));else{var j=b.find("."+d.params.layer+" > *");j.length&&j.each(function(){var b="IMG"==this.nodeName;b?d.slides.push(a.extend({},f,{url:this.src,caption:this.alt,thumb:a(this).data("thumb"),classes:this.className})):(g=!0,d.slides.push(a.extend({},f,{html:this.outerHTML,loaded:!0})))})}g&&"thumbs"==d.params.showThumbs&&(d.params.showThumbs="dots"),1!=d.params.slidesOnScreen&&(d.params.showThumbs=null),e=t.getHTML(d.params,d.slides),d._layerDOM=d.layer[0].innerHTML,d._thumbsLayerDOM=d.thumbsLayer.first().innerHTML,d.layer.html(e.slides),d.thumbsLayer.html(e.thumbs),d.thumb=b.find("."+d.params.thumb),d.thumbImg=b.find("."+d.params.thumbImg),d.thumbFrame=b.find("."+d.params.thumbFrame),d.slide=b.find("."+d.params.slide),d.slideImg=b.find("."+d.params.slideImg),d.slide.each(function(b){a(this).css("left",100*b+"%")}),d.current=d.params.current,d.count=d.slides.length,d.last=d.count-1,d.thumbsDragging=!1,d.thumbsIndent=0,d.events=[],d.viewportWidth=window.getComputedStyle?parseFloat(window.getComputedStyle(d.viewport[0]).width):d.viewport.outerWidth(),d.viewportHeight=d.viewport.outerHeight(),d.thumbsWidth=d.thumbs.outerWidth(),d.thumbsHeight=d.thumbs.outerHeight(),q[c]=d,b.attr("data-photor-id",c),d.params.showThumbs&&b.addClass(d.params.modifierPrefix+d.params.showThumbs),d.params.ie&&b.addClass(d.params.ieClassPrefix+d.params.ie),1==d.slides.length&&b.addClass(d.params._single),"thumbs"==d.params.showThumbs&&t.loadThumbs(c),(d.slides.length>1||d.params.single)&&t.handlers(c),t.go(c,d.current,0),l(c)}})},update:function(){function a(a){var b=q[a];b.viewportWidth=window.getComputedStyle?parseFloat(window.getComputedStyle(b.viewport[0]).width):b.viewport.outerWidth(),b.viewportHeight=b.viewport.outerHeight(),b.thumbsWidth=b.thumbs.outerWidth(),b.thumbsHeight=b.thumbs.outerHeight(),b.thumbsLayerWidth=b.thumbsLayer.outerWidth(),b.slide.each(function(b){t.position(a,b)}),"thumbs"==b.params.showThumbs&&t.getThumbsSize(a),b.layer.css("transition-duration","0s").css(t.setIndent(a,-100*b.current))}for(var b in q)q.hasOwnProperty(b)&&a(b)},destroy:function(a){function b(a){for(var b=q[a],c=0,d=b.events.length;d>c;c++)e(b.events[c].element,b.events[c].event,b.events[c].handler,b.events[c].capture,1);b.layer[0].innerHTML=b._layerDOM,b.thumbsLayer[0].innerHTML=b._thumbsLayerDOM,b.layer.attr("style",""),b.root.removeAttr("data-photor-id"),delete q[a]}if("undefined"!=typeof a)b(a);else for(var c in q)q.hasOwnProperty(c)&&b(c)},handlers:function(a){var b=q[a];h(a),i(a),k(a),b.params.keyboard&&j(a);for(var c=0,d=b.events.length;d>c;c++)e(b.events[c].element,b.events[c].event,b.events[c].handler,b.events[c].capture)},go:function(a,b,c){var d=q[a];d.freeze||(m(a,b),c=null==c?d.params.duration:c,d.root.addClass(d.params._animated),d.layer.css("transition-duration",c+"ms").css(t.setIndent(a,-b*(d.viewportWidth/d.params.slidesOnScreen),"px")),d.current=b,t.loadSlides(a,b),t.checkButtons(a),t.setCurrentThumb(a,b),d.slide.removeClass(d.params._current),d.slide.filter("."+d.params.modifierPrefix+b).addClass(d.params._current),d.params.transition||l(a))},next:function(a){var b=q[a];b.current+b.params.slidesOnScreen-10?t.go(a,b.current-1):t.go(a,b.params.loop?b.last-c+1:0)},loadSlides:function(a,b){for(var c=q[a],d=c.params.slidesOnScreen,e=0>b-d?0:b-d,f=b+2*d-1>c.last?c.last:b+2*d-1,g=e;f>=g;g++)c.slides[g]&&!c.slides[g].loaded&&t.loadSlide(a,g)},loadSlide:function(b,c){var d=q[b],e=d.root.find("."+d.params.slide+"."+d.params.modifierPrefix+c),f=e.find("."+d.params.slideImg),g=d.slides[c].caption;n(d.slides[c].url,function(g,h){g?(d.slides[c].loaded=!0,d.slides[c].width=this.width,d.slides[c].height=this.height,t.position(b,c),e.removeClass(d.params._loading),d.params.ie&&d.params.ie<9?f.attr("src",h):f.css("background-image","url("+h+")")):(e.removeClass(d.params._loading),e.addClass(d.params._error),a.error("Image wasn't loaded: "+h))}),g&&f.addClass(d.params._alt).attr("data-alt",g)},loadThumbs:function(b){var c=q[b],d=c.count,e=c.slides,f=0;c.galleryThumbs=[],c.galleryThumbsLoaded=!1;for(var g=0;d>g;g++)n(e[g].thumb,function(e,g){e?(f++,f==d&&(c.galleryThumbsLoaded=!0,t.getThumbsSize(b))):a.error("Image wasn't loaded: "+g)})},getThumbsSize:function(b){var c=q[b],d=c.thumb;d.each(function(b){var d=a(this);c.galleryThumbs[b]={},c.galleryThumbs[b].width=d.outerWidth(),c.galleryThumbs[b].height=d.outerHeight(),c.galleryThumbs[b].top=d.position().top+parseInt(d.css("margin-top")),c.galleryThumbs[b].left=d.position().left+parseInt(d.css("margin-left"))}),c.thumbsLayerWidth=c.thumbsLayer.outerWidth(),t.setCurrentThumb(b,c.current,1)},setCurrentThumb:function(a,b,c){function d(a){if(a>0||!e.thumbsDragging)return 0;var b=k-l;return b>a?b:a}var e=q[a];if("thumbs"==e.params.showThumbs){var f,g,h=e.thumbFrame,i={},j=e.galleryThumbs&&e.galleryThumbs[b],k=e.thumbs.outerWidth(),l=e.thumbsLayer.outerWidth(),m=c?"0s":.8*e.params.duration/1e3+"s";if(e.thumbsDragging=l>k,e.galleryThumbsLoaded){if(i.width=j.width+"px",i.height=j.height+"px",e.params.transform){var n=p[e.params.transform.property];i[n]=e.params.transform.has3d?"translate3d("+j.left+"px, "+j.top+"px, 0)":"translateX("+j.left+"px) translateY("+j.top+"px)"}else i.top=j.top+"px",i.left=j.left+"px";f=.5*(k-j.width)-j.left,g=d(f),e.thumbsIndent=g,h.css("transition-duration",m).css(i),e.thumbsLayer.css("transition-duration",m).css(t.setIndent(a,g,"px"))}}e.thumb.removeClass(e.params._current),e.thumb.filter("."+e.params.modifierPrefix+b).addClass(e.params._current)},position:function(a,b){var c=q[a],d=c.root.find("."+c.params.slide+"."+c.params.modifierPrefix+b),e=c.slides[b],f=c.viewportWidth/c.viewportHeight,g=e.width/e.height;c.viewportWidth>e.width&&c.viewportHeight>e.height?(c.slides[b].algorithm="center",d.removeClass(c.params._auto).addClass(c.params._center)):(c.slides[b].algorithm="auto",d.removeClass(c.params._center).addClass(c.params._auto)),g>=f?(c.slides[b].orientation="landscape",d.removeClass(c.params._portrait).addClass(c.params._landscape)):(c.slides[b].orientation="portrait",d.removeClass(c.params._landscape).addClass(c.params._portrait))},checkButtons:function(a){var b=q[a];0==b.current?b.prev.addClass(b.params._disabled):b.prev.removeClass(b.params._disabled),b.current+b.params.slidesOnScreen-1==b.last?b.next.addClass(b.params._disabled):b.next.removeClass(b.params._disabled)},setIndent:function(a,b,c){var d=q[a],e={};if(c=c||"%",d.params.transform){var f=p[d.params.transform.property];e[f]=d.params.transform.has3d?"translate3d("+b+c+", 0, 0)":"translateX("+b+c+")"}else e.left=b+c;return e},freeze:function(a){var b=q[a];b.freeze=!0,b.root.addClass(b.params._freeze)},unfreeze:function(a){var b=q[a];b.freeze=!1,b.root.removeClass(b.params._freeze)},getHTML:function(a,b){for(var c="",d="",e=0,f=b.length;f>e;e++)"thumbs"==a.showThumbs&&b[e].url&&(c+=''),d+='
',d+=b[e].html?b[e].html:a.ie&&a.ie<9?'':'
',d+="
";return"thumbs"==a.showThumbs&&(c+='
'),{thumbs:c,slides:d}}};a.fn.photor=function(b){return t[b]?t[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?void a.error("Unknown method: "+b):t.init.apply(this,arguments)},a.fn.photor.data=q}}(jQuery);