(function(P){var M=this,L=M.document,m=P(L),p=P(M),D=!0,c=navigator.userAgent.toLowerCase(),j=M.location.hash.replace(/#\//,""),K=function(){var f=3,e=L.createElement("div"),g=e.getElementsByTagName("i");do{e.innerHTML="<!--[if gt IE "+ ++f+"]><i></i><![endif]-->"}while(g[0]);return f>4?f:void 0}(),k=function(){return{html:L.documentElement,body:L.body,head:L.getElementsByTagName("head")[0],title:L.title}},h=function(){var e=[];P.each("data ready thumbnail loadstart loadfinish image play pause progress fullscreen_enter fullscreen_exit idle_enter idle_exit rescale lightbox_open lightbox_close lightbox_image".split(" "),function(f,g){e.push(g);/_/.test(g)&&e.push(g.replace(/_/g,""))});return e}(),d=function(f){var e;if(typeof f!=="object"){return f}P.each(f,function(l,g){/^[a-z]+_/.test(l)&&(e="",P.each(l.split("_"),function(n,o){e+=n>0?o.substr(0,1).toUpperCase()+o.substr(1):o}),f[e]=g,delete f[l])});return f},x=function(e){if(P.inArray(e,h)>-1){return N[e.toUpperCase()]}return e},i={trunk:{},add:function(g,f,o,n){n=n||!1;this.clear(g);if(n){var l=f,f=function(){l();i.add(g,f,o)}}this.trunk[g]=M.setTimeout(f,o)},clear:function(f){var e=function(l){M.clearTimeout(this.trunk[l]);delete this.trunk[l]},g;if(f&&f in this.trunk){e.call(i,f)}else{if(typeof f==="undefined"){for(g in this.trunk){this.trunk.hasOwnProperty(g)&&e.call(i,g)}}}}},s=[],a=[],b=!1,r=!1,O=function(){return{array:function(e){return Array.prototype.slice.call(e)},create:function(f,e){var g=L.createElement(e||"div");g.className=f;return g},animate:function(){var z=function(B){var A="transition WebkitTransition MozTransition OTransition".split(" "),C;for(C=0;A[C];C++){if(typeof B[A[C]]!=="undefined"){return A[C]}}return !1}((document.body||document.documentElement).style),w={MozTransition:"transitionend",OTransition:"oTransitionEnd",WebkitTransition:"webkitTransitionEnd",transition:"transitionend"}[z],v={_default:[0.25,0.1,0.25,1],galleria:[0.645,0.045,0.355,1],galleriaIn:[0.55,0.085,0.68,0.53],galleriaOut:[0.25,0.46,0.45,0.94],ease:[0.25,0,0.25,1],linear:[0.25,0.25,0.75,0.75],"ease-in":[0.42,0,1,1],"ease-out":[0,0,0.58,1],"ease-in-out":[0.42,0,0.58,1]},u=function(B,A,E){var C={},E=E||"transition";P.each("webkit moz ms o".split(" "),function(){C["-"+this+"-"+E]=A});B.css(C)},n=function(A){u(A,"none","transition");N.WEBKIT&&(u(A,"translate3d(0,0,0)","transform"),A.data("revert")&&(A.css(A.data("revert")),A.data("revert",null)))},l,o,t,g,f,y,e;return function(C,B,A){A=P.extend({duration:400,complete:function(){},stop:!1},A);C=P(C);A.duration?z?(A.stop&&(C.unbind(w),n(C)),l=!1,P.each(B,function(F,E){e=C.css(F);O.parseValue(e)!=O.parseValue(E)&&(l=!0);C.css(F,e)}),l?(o=[],t=A.easing in v?v[A.easing]:v._default,g=" "+A.duration+"ms cubic-bezier("+t.join(",")+")",M.setTimeout(function(){C.one(w,function(E){return function(){n(E);A.complete.call(E[0])}}(C));if(N.WEBKIT&&N.TOUCH&&(f={},y=[0,0,0],P.each(["left","top"],function(F,E){E in B&&(y[F]=O.parseValue(B[E])-O.parseValue(C.css(E))+"px",f[E]=B[E],delete B[E])}),y[0]||y[1])){C.data("revert",f),o.push("-webkit-transform"+g),u(C,"translate3d("+y.join(",")+")","transform")}P.each(B,function(E){o.push(E+g)});u(C,o.join(","));C.css(B)},1)):M.setTimeout(function(){A.complete.call(C[0])},A.duration)):C.animate(B,A):(C.css(B),A.complete.call(C[0]))}}(),forceStyles:function(f,e){f=P(f);f.attr("style")&&f.data("styles",f.attr("style")).removeAttr("style");f.css(e)},revertStyles:function(){P.each(O.array(arguments),function(f,e){e=P(e);e.removeAttr("style");e.attr("style","");e.data("styles")&&e.attr("style",e.data("styles")).data("styles",null)})},moveOut:function(e){O.forceStyles(e,{position:"absolute",left:-10000})},moveIn:function(){O.revertStyles.apply(O,O.array(arguments))},hide:function(f,e,l){f=P(f);f.data("opacity")||f.data("opacity",f.css("opacity"));var g={opacity:0};e?O.animate(f,g,{duration:e,complete:l,stop:!0}):f.css(g)},show:function(f,e,l){var f=P(f),g={opacity:parseFloat(f.data("opacity"))||1};e?O.animate(f,g,{duration:e,complete:l,stop:!0}):f.css(g)},optimizeTouch:function(){var l,e,w,v,u={},t=function(f){f.preventDefault();u=P.extend({},f,!0)},n=function(){this.evt=u},o=function(){this.handler.call(l,this.evt)};return function(f){P(f).bind("touchstart",function(g){l=g.target;for(v=!0;l.parentNode&&l!=g.currentTarget&&v;){e=P(l).data("events"),w=P(l).data("fakes"),e&&"click" in e?(v=!1,g.preventDefault(),P(l).click(t).click(),e.click.pop(),P.each(e.click,n),P(l).data("fakes",e.click),delete e.click):w&&(v=!1,g.preventDefault(),P.each(w,o)),l=l.parentNode}})}}(),addTimer:function(){i.add.apply(i,O.array(arguments));return this},clearTimer:function(){i.clear.apply(i,O.array(arguments));return this},wait:function(f){var f=P.extend({until:function(){return !1},success:function(){},error:function(){N.raise("Could not complete wait function.")},timeout:3000},f),e=O.timestamp(),n,l,g=function(){l=O.timestamp();n=l-e;if(f.until(n)){return f.success(),!1}if(l>=e+f.timeout){return f.error(),!1}M.setTimeout(g,2)};M.setTimeout(g,2)},toggleQuality:function(f,e){if(!(K!==7&&K!==8)&&f){typeof e==="undefined"&&(e=f.style.msInterpolationMode==="nearest-neighbor"),f.style.msInterpolationMode=e?"bicubic":"nearest-neighbor"}},insertStyleTag:function(f){var e=L.createElement("style");k().head.appendChild(e);e.styleSheet?e.styleSheet.cssText=f:(f=L.createTextNode(f),e.appendChild(f))},loadScript:function(f,e){var l=!1,g=P("<script>").attr({src:f,async:!0}).get(0);g.onload=g.onreadystatechange=function(){if(!l&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){l=!0,g.onload=g.onreadystatechange=null,typeof e==="function"&&e.call(this,this)}};k().head.appendChild(g)},parseValue:function(e){return typeof e==="number"?e:typeof e==="string"?(e=e.match(/\-?\d|\./g))&&e.constructor===Array?e.join("")*1:0:0},timestamp:function(){return(new Date).getTime()},loadCSS:function(f,e,o){var n,l=!1,g;P("link[rel=stylesheet]").each(function(){if(RegExp(f).test(this.href)){return n=this,!1}});typeof e==="function"&&(o=e,e=void 0);o=o||function(){};if(n){return o.call(n,n),n}g=L.styleSheets.length;D&&(f+="?"+O.timestamp());P("#"+e).length?(P("#"+e).attr("href",f),g--,l=!0):(n=P("<link>").attr({rel:"stylesheet",href:f,id:e}).get(0),M.setTimeout(function(){var t=P('link[rel="stylesheet"], style');t.length?t.get(0).parentNode.insertBefore(n,t[0]):k().head.appendChild(n);K?g>=31?N.raise("You have reached the browser stylesheet limit (31)",!0):n.onreadystatechange=function(){if(!l&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){l=!0}}:/file:\/\//i.test(f)?l=!0:P.ajax({url:f,success:function(){l=!0},error:function(u){u.isRejected()&&N.WEBKIT&&(l=!0)}})},10));typeof o==="function"&&O.wait({until:function(){return l&&L.styleSheets.length>g},success:function(){M.setTimeout(function(){o.call(n,n)},100)},error:function(){N.raise("Theme CSS could not load",!0)},timeout:10000});return n}}}(),q=function(){var e=function(l,w,v,u){var n=this.getOptions("easing"),o=this.getStageWidth(),t={left:o*(l.rewind?-1:1)},f={left:0};if(v){t.opacity=0,f.opacity=1}P(l.next).css(t);O.animate(l.next,f,{duration:l.speed,complete:function(g){return function(){w();g.css({left:0})}}(P(l.next).add(l.prev)),queue:!1,easing:n});if(u){l.rewind=!l.rewind}if(l.prev){t={left:0};f={left:o*(l.rewind?1:-1)};if(v){t.opacity=1,f.opacity=0}P(l.prev).css(t);O.animate(l.prev,f,{duration:l.speed,queue:!1,easing:n,complete:function(){P(this).css("opacity",0)}})}};return{fade:function(f,g){P(f.next).css("opacity",0).show();O.animate(f.next,{opacity:1},{duration:f.speed,complete:g});f.prev&&(P(f.prev).css("opacity",1).show(),O.animate(f.prev,{opacity:0},{duration:f.speed}))},flash:function(f,g){P(f.next).css("opacity",0);f.prev?O.animate(f.prev,{opacity:0},{duration:f.speed/2,complete:function(){O.animate(f.next,{opacity:1},{duration:f.speed,complete:g})}}):O.animate(f.next,{opacity:1},{duration:f.speed,complete:g})},pulse:function(f,g){f.prev&&P(f.prev).hide();P(f.next).css("opacity",0).show();O.animate(f.next,{opacity:1},{duration:f.speed,complete:g})},slide:function(){e.apply(this,O.array(arguments))},fadeslide:function(){e.apply(this,O.array(arguments).concat([!0]))},doorslide:function(){e.apply(this,O.array(arguments).concat([!1,!0]))}}}(),N=function(){var f=this;this._theme=void 0;this._options={};this._playing=!1;this._playtime=5000;this._active=null;this._queue={length:0};this._data=[];this._dom={};this._thumbnails=[];this._firstrun=this._initialized=!1;this._stageHeight=this._stageWidth=0;this._target=void 0;this._id=Math.random();P.each("container stage images image-nav image-nav-left image-nav-right info info-text info-title info-description thumbnails thumbnails-list thumbnails-container thumb-nav-left thumb-nav-right loader counter tooltip".split(" "),function(v,w){f._dom[w]=O.create("galleria-"+w)});P.each("current total".split(" "),function(v,w){f._dom[w]=O.create("galleria-"+w,"span")});var e=this._keyboard={keys:{UP:38,DOWN:40,LEFT:37,RIGHT:39,RETURN:13,ESCAPE:27,BACKSPACE:8,SPACE:32},map:{},bound:!1,press:function(w){var v=w.keyCode||w.which;v in e.map&&typeof e.map[v]==="function"&&e.map[v].call(f,w)},attach:function(v){var y,w;for(y in v){v.hasOwnProperty(y)&&(w=y.toUpperCase(),w in e.keys?e.map[e.keys[w]]=v[y]:e.map[w]=v[y])}if(!e.bound){e.bound=!0,m.bind("keydown",e.press)}},detach:function(){e.bound=!1;e.map={};m.unbind("keydown",e.press)}},u=this._controls={0:void 0,1:void 0,active:0,swap:function(){u.active=u.active?0:1},getActive:function(){return u[u.active]},getNext:function(){return u[1-u.active]}},t=this._carousel={next:f.$("thumb-nav-right"),prev:f.$("thumb-nav-left"),width:0,current:0,max:0,hooks:[],update:function(){var v=0,y=0,w=[0];P.each(f._thumbnails,function(z,A){A.ready&&(v+=A.outerWidth||P(A.container).outerWidth(!0),w[z+1]=v,y=Math.max(y,A.outerHeight||P(A.container).outerHeight(!0)))});f.$("thumbnails").css({width:v,height:y});t.max=v;t.hooks=w;t.width=f.$("thumbnails-list").width();t.setClasses();f.$("thumbnails-container").toggleClass("galleria-carousel",v>t.width);t.width=f.$("thumbnails-list").width()},bindControls:function(){var v;t.next.bind("click",function(w){w.preventDefault();if(f._options.carouselSteps==="auto"){for(v=t.current;v<t.hooks.length;v++){if(t.hooks[v]-t.hooks[t.current]>t.width){t.set(v-2);break}}}else{t.set(t.current+f._options.carouselSteps)}});t.prev.bind("click",function(w){w.preventDefault();if(f._options.carouselSteps==="auto"){for(v=t.current;v>=0;v--){if(t.hooks[t.current]-t.hooks[v]>t.width){t.set(v+2);break}else{if(v===0){t.set(0);break}}}}else{t.set(t.current-f._options.carouselSteps)}})},set:function(v){for(v=Math.max(v,0);t.hooks[v-1]+t.width>=t.max&&v>=0;){v--}t.current=v;t.animate()},getLast:function(v){return(v||t.current)-1},follow:function(w){if(w===0||w===t.hooks.length-2){t.set(w)}else{for(var v=t.current;t.hooks[v]-t.hooks[t.current]<t.width&&v<=t.hooks.length;){v++}w-1<t.current?t.set(w-1):w+2>v&&t.set(w-v+t.current+2)}},setClasses:function(){t.prev.toggleClass("disabled",!t.current);t.next.toggleClass("disabled",t.hooks[t.current]+t.width>=t.max)},animate:function(){t.setClasses();var v=t.hooks[t.current]*-1;isNaN(v)||O.animate(f.get("thumbnails"),{left:v},{duration:f._options.carouselSpeed,easing:f._options.easing,queue:!1})}},l=this._tooltip={initialized:!1,open:!1,init:function(){l.initialized=!0;O.insertStyleTag(".galleria-tooltip{padding:3px 8px;max-width:50%;background:#ffe;color:#000;z-index:3;position:absolute;font-size:11px;line-height:1.3opacity:0;box-shadow:0 0 2px rgba(0,0,0,.4);-moz-box-shadow:0 0 2px rgba(0,0,0,.4);-webkit-box-shadow:0 0 2px rgba(0,0,0,.4);}");f.$("tooltip").css("opacity",0.8);O.hide(f.get("tooltip"))},move:function(v){var C=f.getMousePosition(v).x,v=f.getMousePosition(v).y,B=f.$("tooltip"),A=v,z=B.outerHeight(!0)+1,y=B.outerWidth(!0),w=z+15,y=f.$("container").width()-y-2,z=f.$("container").height()-z-2;!isNaN(C)&&!isNaN(A)&&(C+=10,A-=30,C=Math.max(0,Math.min(y,C)),A=Math.max(0,Math.min(z,A)),v<w&&(A=w),B.css({left:C,top:A}))},bind:function(v,y){if(!N.TOUCH){l.initialized||l.init();var w=function(z,A){l.define(z,A);P(z).hover(function(){O.clearTimer("switch_tooltip");f.$("container").unbind("mousemove",l.move).bind("mousemove",l.move).trigger("mousemove");l.show(z);N.utils.addTimer("tooltip",function(){f.$("tooltip").stop().show().animate({opacity:1});l.open=!0},l.open?0:500)},function(){f.$("container").unbind("mousemove",l.move);O.clearTimer("tooltip");f.$("tooltip").stop().animate({opacity:0},200,function(){f.$("tooltip").hide();O.addTimer("switch_tooltip",function(){l.open=!1},1000)})})};typeof y==="string"?w(v in f._dom?f.get(v):v,y):P.each(v,function(z,A){w(f.get(z),A)})}},show:function(v){var v=P(v in f._dom?f.get(v):v),y=v.data("tt"),w=function(z){M.setTimeout(function(A){return function(){l.move(A)}}(z),10);v.unbind("mouseup",w)};if(y=typeof y==="function"?y():y){f.$("tooltip").html(y.replace(/\s/,"&nbsp;")),v.bind("mouseup",w)}},define:function(v,y){if(typeof y!=="function"){var w=y,y=function(){return w}}v=P(v in f._dom?f.get(v):v).data("tt",y);l.show(v)}},g=this._fullscreen={scrolled:0,active:!1,keymap:f._keyboard.map,enter:function(v){g.active=!0;O.hide(f.getActiveImage());f.$("container").addClass("fullscreen");g.scrolled=p.scrollTop();O.forceStyles(f.get("container"),{position:"fixed",top:0,left:0,width:"100%",height:"100%",zIndex:10000});var B={height:"100%",overflow:"hidden",margin:0,padding:0},A=f.getData();O.forceStyles(k().html,B);O.forceStyles(k().body,B);g.keymap=P.extend({},f._keyboard.map);f.attachKeyboard({escape:f.exitFullscreen,right:f.next,left:f.prev});if(A&&A.big&&A.image!==A.big){var B=new N.Picture,z=B.isCached(A.big),w=f.getIndex(),y=f._thumbnails[w];f.trigger({type:N.LOADSTART,cached:z,index:w,imageTarget:f.getActiveImage(),thumbTarget:y});B.load(A.big,function(C){f._scaleImage(C,{complete:function(E){f.trigger({type:N.LOADFINISH,cached:z,index:w,imageTarget:E.image,thumbTarget:y});var F=f._controls.getActive().image;F&&P(F).width(E.image.width).height(E.image.height).attr("style",P(E.image).attr("style")).attr("src",E.image.src)}})})}f.rescale(function(){O.addTimer("fullscreen_enter",function(){O.show(f.getActiveImage());typeof v==="function"&&v.call(f)},100);f.trigger(N.FULLSCREEN_ENTER)});p.resize(function(){g.scale()})},scale:function(){f.rescale()},exit:function(v){g.active=!1;O.hide(f.getActiveImage());f.$("container").removeClass("fullscreen");O.revertStyles(f.get("container"),k().html,k().body);M.scrollTo(0,g.scrolled);f.detachKeyboard();f.attachKeyboard(g.keymap);f.rescale(function(){O.addTimer("fullscreen_exit",function(){O.show(f.getActiveImage());typeof v==="function"&&v.call(f)},50);f.trigger(N.FULLSCREEN_EXIT)});p.unbind("resize",g.scale)}},n=this._idle={trunk:[],bound:!1,add:function(w,v){if(w){n.bound||n.addEvent();var w=P(w),z={},y;for(y in v){v.hasOwnProperty(y)&&(z[y]=w.css(y))}w.data("idle",{from:z,to:v,complete:!0,busy:!1});n.addTimer();n.trunk.push(w)}},remove:function(v){v=jQuery(v);P.each(n.trunk,function(y,w){w.length&&!w.not(v).length&&(f._idle.show(v),f._idle.trunk.splice(y,1))});n.trunk.length||(n.removeEvent(),O.clearTimer("idle"))},addEvent:function(){n.bound=!0;f.$("container").bind("mousemove click",n.showAll)},removeEvent:function(){n.bound=!1;f.$("container").unbind("mousemove click",n.showAll)},addTimer:function(){O.addTimer("idle",function(){f._idle.hide()},f._options.idleTime)},hide:function(){f._options.idleMode&&(f.trigger(N.IDLE_ENTER),P.each(n.trunk,function(v,y){var w=y.data("idle");if(w){y.data("idle").complete=!1,O.animate(y,w.to,{duration:f._options.idleSpeed})}}))},showAll:function(){O.clearTimer("idle");P.each(f._idle.trunk,function(v,w){f._idle.show(w)})},show:function(v){var w=v.data("idle");if(!w.busy&&!w.complete){w.busy=!0,f.trigger(N.IDLE_EXIT),O.clearTimer("idle"),O.animate(v,w.from,{duration:f._options.idleSpeed/2,complete:function(){P(this).data("idle").busy=!1;P(this).data("idle").complete=!0}})}n.addTimer()}},o=this._lightbox={width:0,height:0,initialized:!1,active:null,image:null,elems:{},keymap:!1,init:function(){f.trigger(N.LIGHTBOX_OPEN);if(!o.initialized){o.initialized=!0;var v={},z=f._options,y="",z={overlay:"position:fixed;display:none;opacity:"+z.overlayOpacity+";filter:alpha(opacity="+z.overlayOpacity*100+");top:0;left:0;width:100%;height:100%;background:"+z.overlayBackground+";z-index:99990",box:"position:fixed;display:none;width:400px;height:400px;top:50%;left:50%;margin-top:-200px;margin-left:-200px;z-index:99991",shadow:"position:absolute;background:#000;width:100%;height:100%;",content:"position:absolute;background-color:#fff;top:10px;left:10px;right:10px;bottom:10px;overflow:hidden",info:"position:absolute;bottom:10px;left:10px;right:10px;color:#444;font:11px/13px arial,sans-serif;height:13px",close:"position:absolute;top:10px;right:10px;height:20px;width:20px;background:#fff;text-align:center;cursor:pointer;color:#444;font:16px/22px arial,sans-serif;z-index:99999",image:"position:absolute;top:10px;left:10px;right:10px;bottom:30px;overflow:hidden;display:block;",prevholder:"position:absolute;width:50%;top:0;bottom:40px;cursor:pointer;",nextholder:"position:absolute;width:50%;top:0;bottom:40px;right:-1px;cursor:pointer;",prev:"position:absolute;top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;left:20px;display:none;text-align:center;color:#000;font:bold 16px/36px arial,sans-serif",next:"position:absolute;top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;right:20px;left:auto;display:none;font:bold 16px/36px arial,sans-serif;text-align:center;color:#000",title:"float:left",counter:"float:right;margin-left:8px;"},w={};K===8&&(z.nextholder+="background:#000;filter:alpha(opacity=0);",z.prevholder+="background:#000;filter:alpha(opacity=0);");P.each(z,function(B,A){y+=".galleria-lightbox-"+B+"{"+A+"}"});O.insertStyleTag(y);P.each("overlay box content shadow title info close prevholder prev nextholder next counter image".split(" "),function(B,A){f.addElement("lightbox-"+A);v[A]=o.elems[A]=f.get("lightbox-"+A)});o.image=new N.Picture;P.each({box:"shadow content close prevholder nextholder",info:"title counter",content:"info image",prevholder:"prev",nextholder:"next"},function(B,A){var C=[];P.each(A.split(" "),function(F,E){C.push("lightbox-"+E)});w["lightbox-"+B]=C});f.append(w);P(v.image).append(o.image.container);P(k().body).append(v.overlay,v.box);O.optimizeTouch(v.box);(function(A){return A.hover(function(){P(this).css("color","#bbb")},function(){P(this).css("color","#444")})})(P(v.close).bind("click",o.hide).html("&#215;"));P.each(["Prev","Next"],function(A,E){var C=P(v[E.toLowerCase()]).html(/v/.test(E)?"&#8249;&nbsp;":"&nbsp;&#8250;"),B=P(v[E.toLowerCase()+"holder"]);B.bind("click",function(){o["show"+E]()});K<8||N.TOUCH?C.show():B.hover(function(){C.show()},function(){C.stop().fadeOut(200)})});P(v.overlay).bind("click",o.hide);if(N.IPAD){f._options.lightboxTransitionSpeed=0}}},rescale:function(v){var y=Math.min(p.width()-40,o.width),w=Math.min(p.height()-60,o.height),w=Math.min(y/o.width,w/o.height),y=Math.round(o.width*w)+40,w=Math.round(o.height*w)+60,y={width:y,height:w,"margin-top":Math.ceil(w/2)*-1,"margin-left":Math.ceil(y/2)*-1};v?P(o.elems.box).css(y):P(o.elems.box).animate(y,{duration:f._options.lightboxTransitionSpeed,easing:f._options.easing,complete:function(){var z=o.image,A=f._options.lightboxFadeSpeed;f.trigger({type:N.LIGHTBOX_IMAGE,imageTarget:z.image});P(z.container).show();O.show(z.image,A);O.show(o.elems.info,A)}})},hide:function(){o.image.image=null;p.unbind("resize",o.rescale);P(o.elems.box).hide();O.hide(o.elems.info);f.detachKeyboard();f.attachKeyboard(o.keymap);o.keymap=!1;O.hide(o.elems.overlay,200,function(){P(this).hide().css("opacity",f._options.overlayOpacity);f.trigger(N.LIGHTBOX_CLOSE)})},showNext:function(){o.show(f.getNext(o.active))},showPrev:function(){o.show(f.getPrev(o.active))},show:function(v){o.active=v=typeof v==="number"?v:f.getIndex();o.initialized||o.init();if(!o.keymap){o.keymap=P.extend({},f._keyboard.map),f.attachKeyboard({escape:o.hide,right:o.showNext,left:o.showPrev})}p.unbind("resize",o.rescale);var y=f.getData(v),w=f.getDataLength();O.hide(o.elems.info);o.image.load(y.big||y.image,function(z){o.width=z.original.width;o.height=z.original.height;P(z.image).css({width:"100.5%",height:"100.5%",top:0,zIndex:99998});O.hide(z.image);o.elems.title.innerHTML=y.title||"";o.elems.counter.innerHTML=v+1+" / "+w;p.resize(o.rescale);o.rescale()});P(o.elems.overlay).show();P(o.elems.box).show()}};return this};N.prototype={constructor:N,init:function(f,e){var g=this,e=d(e);this._original={target:f,options:e,data:null};this._target=this._dom.target=f.nodeName?f:P(f).get(0);a.push(this);this._target?(this._options={autoplay:!1,carousel:!0,carouselFollow:!0,carouselSpeed:400,carouselSteps:"auto",clicknext:!1,dataConfig:function(){return{}},dataSelector:"img",dataSource:this._target,debug:void 0,easing:"galleria",extend:function(){},fullscreenDoubleTap:!0,height:"auto",idleMode:!0,idleTime:3000,idleSpeed:200,imageCrop:!1,imageMargin:0,imagePan:!1,imagePanSmoothness:12,imagePosition:"50%",initialTransition:void 0,keepSource:!1,lightbox:!1,lightboxFadeSpeed:200,lightboxTransitionSpeed:200,linkSourceTmages:!0,maxScaleRatio:void 0,minScaleRatio:void 0,overlayOpacity:0.85,overlayBackground:"#0b0b0b",pauseOnInteraction:!0,popupLinks:!1,preload:2,protect:!1,queue:!0,show:0,showInfo:!0,showCounter:!0,showImagenav:!0,swipe:!0,thumbCrop:!0,thumbEventType:"click",thumbFit:!0,thumbMargin:0,thumbQuality:"auto",thumbnails:!0,transition:"fade",transitionInitial:void 0,transitionSpeed:400,useCanvas:!1,width:"auto"},this._options.initialTransition=this._options.initialTransition||this._options.transitionInitial,e&&e.debug===!1&&(D=!1),P(this._target).children().hide(),typeof N.theme==="object"?this._init():O.wait({until:function(){return typeof N.theme==="object"},success:function(){g._init.call(g)},error:function(){N.raise("No theme found.",!0)},timeout:5000})):N.raise("Target not found.",!0)},_init:function(){var e=this;if(this._initialized){return N.raise("Init failed: Gallery instance already initialized."),this}this._initialized=!0;if(!N.theme){return N.raise("Init failed: No theme found."),this}P.extend(!0,this._options,N.theme.defaults,this._original.options);(function(f){"getContext" in f&&(r=r||{elem:f,context:f.getContext("2d"),cache:{},length:0})})(L.createElement("canvas"));this.bind(N.DATA,function(){this._original.data=this._data;this.get("total").innerHTML=this.getDataLength();var f=this.$("container"),l={width:0,height:0},g=function(){return e.$("stage").height()};O.wait({until:function(){P.each(["width","height"],function(o,n){l[n]=e._options[n]&&typeof e._options[n]==="number"?e._options[n]:Math.max(O.parseValue(f.css(n)),O.parseValue(e.$("target").css(n)),f[n](),e.$("target")[n]());f[n](l[n])});return g()&&l.width&&l.height>10},success:function(){N.WEBKIT?M.setTimeout(function(){e._run()},1):e._run()},error:function(){g()?N.raise("Could not extract sufficient width/height of the gallery container. Traced measures: width:"+l.width+"px, height: "+l.height+"px.",!0):N.raise("Could not extract a stage height from the CSS. Traced height: "+g()+"px.",!0)},timeout:2000})});this.append({"info-text":["info-title","info-description"],info:["info-text"],"image-nav":["image-nav-right","image-nav-left"],stage:["images","loader","counter","image-nav"],"thumbnails-list":["thumbnails"],"thumbnails-container":["thumb-nav-left","thumbnails-list","thumb-nav-right"],container:["stage","thumbnails-container","info","tooltip"]});O.hide(this.$("counter").append(this.get("current")," / ",this.get("total")));this.setCounter("&#8211;");O.hide(e.get("tooltip"));this.$("container").addClass(N.TOUCH?"touch":"notouch");P.each(Array(2),function(f){var g=new N.Picture;P(g.container).css({position:"absolute",top:0,left:0});e.$("images").append(g.container);e._controls[f]=g});this.$("images").css({position:"relative",top:0,left:0,width:"100%",height:"100%"});this.$("thumbnails, thumbnails-list").css({overflow:"hidden",position:"relative"});this.$("image-nav-right, image-nav-left").bind("click",function(f){e._options.clicknext&&f.stopPropagation();e._options.pauseOnInteraction&&e.pause();f=/right/.test(this.className)?"next":"prev";e[f]()});P.each(["info","counter","image-nav"],function(f,g){e._options["show"+g.substr(0,1).toUpperCase()+g.substr(1).replace(/-/,"")]===!1&&O.moveOut(e.get(g.toLowerCase()))});this.load();if(!this._options.keep_source&&!K){this._target.innerHTML=""}this.$("target").append(this.get("container"));this._options.carousel&&this.bind(N.THUMBNAIL,function(){this.updateCarousel()});this._options.swipe&&(function(y){var w=[0,0],v=[0,0],u=!1,t=0,n,o={start:"touchstart",move:"touchmove",stop:"touchend"},l=function(g){g.originalEvent.touches&&g.originalEvent.touches.length>1||(n=g.originalEvent.touches?g.originalEvent.touches[0]:g,v=[n.pageX,n.pageY],w[0]||(w=v),Math.abs(w[0]-v[0])>10&&g.preventDefault())},f=function(g){y.unbind(o.move,l);g.originalEvent.touches&&g.originalEvent.touches.length||u?u=!u:(O.timestamp()-t<1000&&Math.abs(w[0]-v[0])>30&&Math.abs(w[1]-v[1])<100&&(g.preventDefault(),e[w[0]>v[0]?"next":"prev"]()),w=v=[0,0])};y.bind(o.start,function(g){g.originalEvent.touches&&g.originalEvent.touches.length>1||(n=g.originalEvent.touches?g.originalEvent.touches[0]:g,t=O.timestamp(),w=v=[n.pageX,n.pageY],y.bind(o.move,l).one(o.stop,f))})}(e.$("images")),this._options.fullscreenDoubleTap&&this.$("stage").bind("touchstart",function(){var g,u,t,o,n,l;return function(f){l=N.utils.timestamp();u=(f.originalEvent.touches?f.originalEvent.touches[0]:f).pageX;t=(f.originalEvent.touches?f.originalEvent.touches[0]:f).pageY;l-g<500&&u-o<20&&t-n<20?(e.toggleFullscreen(),f.preventDefault(),e.$("stage").unbind("touchend",arguments.callee)):(g=l,o=u,n=t)}}()));O.optimizeTouch(this.get("container"));return this},_createThumbnails:function(){this.get("total").innerHTML=this.getDataLength();var B,z,y,w,t,n=this,u=this._options,v=function(){var o=n.$("thumbnails").find(".active");if(!o.length){return !1}return o.find("img").attr("src")}(),l=typeof u.thumbnails==="string"?u.thumbnails.toLowerCase():null,e=function(o){return L.defaultView&&L.defaultView.getComputedStyle?L.defaultView.getComputedStyle(y.container,null)[o]:t.css(o)},A=function(C,o,E){return function(){P(E).append(C);n.trigger({type:N.THUMBNAIL,thumbTarget:C,index:o})}},g=function(C){u.pauseOnInteraction&&n.pause();var o=P(C.currentTarget).data("index");n.getIndex()!==o&&n.show(o);C.preventDefault()},f=function(o){o.scale({width:o.data.width,height:o.data.height,crop:u.thumbCrop,margin:u.thumbMargin,canvas:u.useCanvas,complete:function(E){var C=["left","top"],G,F;P.each(["Width","Height"],function(I,H){G=H.toLowerCase();if((u.thumbCrop!==!0||u.thumbCrop===G)&&u.thumbFit){F={},F[G]=E[G],P(E.container).css(F),F={},F[C[I]]=0,P(E.image).css(F)}E["outer"+H]=P(E.container)["outer"+H](!0)});O.toggleQuality(E.image,u.thumbQuality===!0||u.thumbQuality==="auto"&&E.original.width<E.width*3);n.trigger({type:N.THUMBNAIL,thumbTarget:E.image,index:E.data.order})}})};this._thumbnails=[];this.$("thumbnails").empty();for(B=0;this._data[B];B++){w=this._data[B],u.thumbnails===!0?(y=new N.Picture(B),z=w.thumb||w.image,this.$("thumbnails").append(y.container),t=P(y.container),y.data={width:O.parseValue(e("width")),height:O.parseValue(e("height")),order:B},u.thumbFit&&u.thumbCrop!==!0?t.css({width:0,height:0}):t.css({width:y.data.width,height:y.data.height}),y.load(z,f),u.preload==="all"&&y.add(w.image)):l==="empty"||l==="numbers"?(y={container:O.create("galleria-image"),image:O.create("img","span"),ready:!0},l==="numbers"&&P(y.image).text(B+1),this.$("thumbnails").append(y.container),M.setTimeout(A(y.image,B,y.container),50+B*20)):y={container:null,image:null},P(y.container).add(u.keepSource&&u.linkSourceImages?w.original:null).data("index",B).bind(u.thumbEventType,g),v===z&&P(y.container).addClass("active"),this._thumbnails.push(y)}},_run:function(){var e=this;e._createThumbnails();O.wait({until:function(){N.OPERA&&e.$("stage").css("display","inline-block");e._stageWidth=e.$("stage").width();e._stageHeight=e.$("stage").height();return e._stageWidth&&e._stageHeight>50},success:function(){s.push(e);O.show(e.get("counter"));e._options.carousel&&e._carousel.bindControls();if(e._options.autoplay){e.pause();if(typeof e._options.autoplay==="number"){e._playtime=e._options.autoplay}e.trigger(N.PLAY);e._playing=!0}e._firstrun?typeof e._options.show==="number"&&e.show(e._options.show):(e._firstrun=!0,e._options.clicknext&&!N.TOUCH&&(P.each(e._data,function(f,g){delete g.link}),e.$("stage").css({cursor:"pointer"}).bind("click",function(){e._options.pauseOnInteraction&&e.pause();e.next()})),N.History&&N.History.change(function(f){f=parseInt(f.value.replace(/\//,""),10);isNaN(f)?M.history.go(-1):e.show(f,void 0,!0)}),P.each(N.ready.callbacks,function(){this.call(e,e._options)}),e.trigger(N.READY),N.theme.init.call(e,e._options),e._options.extend.call(e,e._options),/^[0-9]{1,4}$/.test(j)&&N.History?e.show(j,void 0,!0):e._data[e._options.show]&&e.show(e._options.show))},error:function(){N.raise("Stage width or height is too small to show the gallery. Traced measures: width:"+e._stageWidth+"px, height: "+e._stageHeight+"px.",!0)}})},load:function(f,e,l){var g=this;this._data=[];this._thumbnails=[];this.$("thumbnails").empty();typeof e==="function"&&(l=e,e=null);f=f||this._options.dataSource;e=e||this._options.dataSelector;l=l||this._options.dataConfig;/^function Object/.test(f.constructor)&&(f=[f]);if(f.constructor===Array){return this.validate(f)?(this._data=f,this._parseData().trigger(N.DATA)):N.raise("Load failed: JSON Array not valid."),this}P(f).find(e).each(function(t,o){var o=P(o),w={},u=o.parent(),n=u.attr("href"),u=u.attr("rel"),v=/\.(png|gif|jpg|jpeg)(\?.*)?$/i;if(v.test(n)){w.image=n,w.big=v.test(u)?u:n}else{if(n){w.link=n}}g._data.push(P.extend({title:o.attr("title")||"",thumb:o.attr("src"),image:o.attr("src"),big:o.attr("src"),description:o.attr("alt")||"",link:o.attr("longdesc"),original:o.get(0)},w,l(o)))});this.getDataLength()?this.trigger(N.DATA):N.raise("Load failed: no data found.");return this},_parseData:function(){var e=this;P.each(this._data,function(f,g){if("thumb" in g===!1){e._data[f].thumb=g.image}if(!1 in g){e._data[f].big=g.image}});return this},splice:function(){Array.prototype.splice.apply(this._data,O.array(arguments));return this._parseData()._createThumbnails()},push:function(){Array.prototype.push.apply(this._data,O.array(arguments));return this._parseData()._createThumbnails()},_getActive:function(){return this._controls.getActive()},validate:function(){return !0},bind:function(f,e){f=x(f);this.$("container").bind(f,this.proxy(e));return this},unbind:function(e){e=x(e);this.$("container").unbind(e);return this},trigger:function(e){e=typeof e==="object"?P.extend(e,{scope:this}):{type:x(e),scope:this};this.$("container").trigger(e);return this},addIdleState:function(){this._idle.add.apply(this._idle,O.array(arguments));return this},removeIdleState:function(){this._idle.remove.apply(this._idle,O.array(arguments));return this},enterIdleMode:function(){this._idle.hide();return this},exitIdleMode:function(){this._idle.showAll();return this},enterFullscreen:function(){this._fullscreen.enter.apply(this,O.array(arguments));return this},exitFullscreen:function(){this._fullscreen.exit.apply(this,O.array(arguments));return this},toggleFullscreen:function(){this._fullscreen[this.isFullscreen()?"exit":"enter"].apply(this,O.array(arguments));return this},bindTooltip:function(){this._tooltip.bind.apply(this._tooltip,O.array(arguments));return this},defineTooltip:function(){this._tooltip.define.apply(this._tooltip,O.array(arguments));return this},refreshTooltip:function(){this._tooltip.show.apply(this._tooltip,O.array(arguments));return this},openLightbox:function(){this._lightbox.show.apply(this._lightbox,O.array(arguments));return this},closeLightbox:function(){this._lightbox.hide.apply(this._lightbox,O.array(arguments));return this},getActiveImage:function(){return this._getActive().image||void 0},getActiveThumb:function(){return this._thumbnails[this._active].image||void 0},getMousePosition:function(e){return{x:e.pageX-this.$("container").offset().left,y:e.pageY-this.$("container").offset().top}},addPan:function(G){if(this._options.imageCrop!==!1){var G=P(G||this.getActiveImage()),F=this,C=G.width()/2,B=G.height()/2,A=parseInt(G.css("left"),10),w=parseInt(G.css("top"),10),y=A||0,z=w||0,u=0,f=0,v=!1,t=O.timestamp(),o=0,e=0,H=function(g,n,l){if(g>0&&(e=Math.round(Math.max(g*-1,Math.min(0,n))),o!==e)){if(o=e,K===8){G.parent()["scroll"+l](e*-1)}else{g={},g[l.toLowerCase()]=e,G.css(g)}}},E=function(g){if(!(O.timestamp()-t<50)){v=!0,C=F.getMousePosition(g).x,B=F.getMousePosition(g).y}};K===8&&(G.parent().scrollTop(z*-1).scrollLeft(y*-1),G.css({top:0,left:0}));this.$("stage").unbind("mousemove",E).bind("mousemove",E);O.addTimer("pan",function(){v&&(u=G.width()-F._stageWidth,f=G.height()-F._stageHeight,A=C/F._stageWidth*u*-1,w=B/F._stageHeight*f*-1,y+=(A-y)/F._options.imagePanSmoothness,z+=(w-z)/F._options.imagePanSmoothness,H(f,z,"Top"),H(u,y,"Left"))},50,!0);return this}},proxy:function(f,e){if(typeof f!=="function"){return function(){}}e=e||this;return function(){return f.apply(e,O.array(arguments))}},removePan:function(){this.$("stage").unbind("mousemove");O.clearTimer("pan");return this},addElement:function(){var e=this._dom;P.each(O.array(arguments),function(f,g){e[g]=O.create("galleria-"+g)});return this},attachKeyboard:function(){this._keyboard.attach.apply(this._keyboard,O.array(arguments));return this},detachKeyboard:function(){this._keyboard.detach.apply(this._keyboard,O.array(arguments));return this},appendChild:function(f,e){this.$(f).append(this.get(e)||e);return this},prependChild:function(f,e){this.$(f).prepend(this.get(e)||e);return this},remove:function(){this.$(O.array(arguments).join(",")).remove();return this},append:function(f){var e,g;for(e in f){if(f.hasOwnProperty(e)){if(f[e].constructor===Array){for(g=0;f[e][g];g++){this.appendChild(e,f[e][g])}}else{this.appendChild(e,f[e])}}}return this},_scaleImage:function(f,e){e=P.extend({width:this._stageWidth,height:this._stageHeight,crop:this._options.imageCrop,max:this._options.maxScaleRatio,min:this._options.minScaleRatio,margin:this._options.imageMargin,position:this._options.imagePosition},e);(f||this._controls.getActive()).scale(e);return this},updateCarousel:function(){this._carousel.update();return this},rescale:function(g,f,o){var n=this;typeof g==="function"&&(o=g,g=void 0);var l=function(){n._stageWidth=g||n.$("stage").width();n._stageHeight=f||n.$("stage").height();n._scaleImage();n._options.carousel&&n.updateCarousel();n.trigger(N.RESCALE);typeof o==="function"&&o.call(n)};N.WEBKIT&&!g&&!f?O.addTimer("scale",l,10):l.call(n);return this},refreshImage:function(){this._scaleImage();this._options.imagePan&&this.addPan();return this},show:function(f,e,g){if(!(f===!1||!this._options.queue&&this._queue.stalled)){if(f=Math.max(0,Math.min(parseInt(f,10),this.getDataLength()-1)),e=typeof e!=="undefined"?!!e:f<this.getIndex(),!g&&N.History){N.History.value(f.toString())}else{return this._active=f,Array.prototype.push.call(this._queue,{index:f,rewind:e}),this._queue.stalled||this._show(),this}}},_show:function(){var C=this,B=this._queue[0],A=this.getData(B.index);if(A){var z=this.isFullscreen()&&"big" in A?A.big:A.image,v=this._controls.getActive(),u=this._controls.getNext(),w=u.isCached(z),y=this._thumbnails[B.index],t=function(n,G,F,E,o){return function(){C._queue.stalled=!1;O.toggleQuality(G.image,C._options.imageQuality);P(F.container).css({zIndex:0,opacity:0}).show();P(G.container).css({zIndex:1,opacity:1}).show();C._controls.swap();C._options.imagePan&&C.addPan(G.image);(n.link||C._options.lightbox)&&P(G.image).css({cursor:"pointer"}).bind("mouseup",function(){n.link?C._options.popupLinks?M.open(n.link,"_blank"):M.location.href=n.link:C.openLightbox()});Array.prototype.shift.call(C._queue);C._queue.length&&C._show();C._playCheck();C.trigger({type:N.IMAGE,index:E.index,imageTarget:G.image,thumbTarget:o.image})}}(A,u,v,B,y);this._options.carousel&&this._options.carouselFollow&&this._carousel.follow(B.index);if(this._options.preload){var e,l,A=this.getNext(),g;try{for(l=this._options.preload;l>0;l--){e=new N.Picture,g=C.getData(A),e.add(this.isFullscreen()&&"big" in g?g.big:g.image),A=C.getNext(A)}}catch(f){}}O.show(u.container);P(C._thumbnails[B.index].container).addClass("active").siblings(".active").removeClass("active");C.trigger({type:N.LOADSTART,cached:w,index:B.index,imageTarget:u.image,thumbTarget:y.image});u.load(z,function(n){C._scaleImage(n,{complete:function(E){"image" in v&&O.toggleQuality(v.image,!1);O.toggleQuality(E.image,!1);C._queue.stalled=!0;C.removePan();C.setInfo(B.index);C.setCounter(B.index);C.trigger({type:N.LOADFINISH,cached:w,index:B.index,imageTarget:E.image,thumbTarget:C._thumbnails[B.index].image});var o=v.image===null&&C._options.initialTransition!==void 0?C._options.initialTransition:C._options.transition;o in q===!1?t():q[o].call(C,{prev:v.container,next:E.container,rewind:B.rewind,speed:C._options.transitionSpeed||400},t)}})})}},getNext:function(e){e=typeof e==="number"?e:this.getIndex();return e===this.getDataLength()-1?0:e+1},getPrev:function(e){e=typeof e==="number"?e:this.getIndex();return e===0?this.getDataLength()-1:e-1},next:function(){this.getDataLength()>1&&this.show(this.getNext(),!1);return this},prev:function(){this.getDataLength()>1&&this.show(this.getPrev(),!0);return this},get:function(e){return e in this._dom?this._dom[e]:null},getData:function(e){return e in this._data?this._data[e]:this._data[this._active]},getDataLength:function(){return this._data.length},getIndex:function(){return typeof this._active==="number"?this._active:!1},getStageHeight:function(){return this._stageHeight},getStageWidth:function(){return this._stageWidth},getOptions:function(e){return typeof e==="undefined"?this._options:this._options[e]},setOptions:function(f,e){typeof f==="object"?P.extend(this._options,f):this._options[f]=e;return this},play:function(e){this._playing=!0;this._playtime=e||this._playtime;this._playCheck();this.trigger(N.PLAY);return this},pause:function(){this._playing=!1;this.trigger(N.PAUSE);return this},playToggle:function(e){return this._playing?this.pause():this.play(e)},isPlaying:function(){return this._playing},isFullscreen:function(){return this._fullscreen.active},_playCheck:function(){var g=this,f=0,o=O.timestamp(),n="play"+this._id;if(this._playing){O.clearTimer(n);var l=function(){f=O.timestamp()-o;f>=g._playtime&&g._playing?(O.clearTimer(n),g.next()):g._playing&&(g.trigger({type:N.PROGRESS,percent:Math.ceil(f/g._playtime*100),seconds:Math.floor(f/1000),milliseconds:f}),O.addTimer(n,l,20))};O.addTimer(n,l,20)}},setIndex:function(e){this._active=e;return this},setCounter:function(f){typeof f==="number"?f++:typeof f==="undefined"&&(f=this.getIndex()+1);this.get("current").innerHTML=f;if(K){var f=this.$("counter"),e=f.css("opacity"),g=f.attr("style");g&&parseInt(e,10)===1?f.attr("style",g.replace(/filter[^\;]+\;/i,"")):this.$("counter").css("opacity",e)}return this},setInfo:function(f){var e=this,g=this.getData(f);P.each(["title","description"],function(l,o){var n=e.$("info-"+o);g[o]?n[g[o].length?"show":"hide"]().html(g[o]):n.empty().hide()});return this},hasInfo:function(f){var e="title description".split(" "),g;for(g=0;e[g];g++){if(this.getData(f)[e[g]]){return !0}}return !1},jQuery:function(f){var e=this,l=[];P.each(f.split(","),function(n,o){o=P.trim(o);e.get(o)&&l.push(o)});var g=P(e.get(l.shift()));P.each(l,function(n,o){g=g.add(e.get(o))});return g},$:function(){return this.jQuery.apply(this,O.array(arguments))}};P.each(h,function(f,e){var g=/_/.test(e)?e.replace(/_/g,""):e;N[e.toUpperCase()]="galleria."+g});P.extend(N,{IE9:K===9,IE8:K===8,IE7:K===7,IE6:K===6,IE:!!K,WEBKIT:/webkit/.test(c),SAFARI:/safari/.test(c),CHROME:/chrome/.test(c),QUIRK:K&&L.compatMode&&L.compatMode==="BackCompat",MAC:/mac/.test(navigator.platform.toLowerCase()),OPERA:!!M.opera,IPHONE:/iphone/.test(c),IPAD:/ipad/.test(c),ANDROID:/android/.test(c),TOUCH:"ontouchstart" in document});N.addTheme=function(f){f.name||N.raise("No theme name specified");f.defaults=typeof f.defaults!=="object"?{}:d(f.defaults);var e=!1,g;typeof f.css==="string"?(P("link").each(function(n,l){g=RegExp(f.css);if(g.test(l.href)){return e=!0,N.theme=f,!1}}),e||P("script").each(function(n,l){g=RegExp("galleria\\."+f.name.toLowerCase()+"\\.");g.test(l.src)&&(e=l.src.replace(/[^\/]*$/,"")+f.css,O.addTimer("css",function(){O.loadCSS(e,"galleria-theme",function(){N.theme=f})},1))}),e||N.raise("No theme CSS loaded")):N.theme=f;return f};N.loadTheme=function(f,e){var l=!1,g=s.length;N.theme=void 0;O.loadScript(f,function(){l=!0});O.wait({until:function(){return l},error:function(){N.raise("Theme at "+f+" could not load, check theme path.",!0)},success:function(){if(g){var n=[];P.each(N.get(),function(v,u){var t=P.extend(u._original.options,{data_source:u._data},e);u.$("container").remove();var o=new N;o._id=u._id;o.init(u._original.target,t);n.push(o)});s=n}},timeout:2000})};N.get=function(e){if(a[e]){return a[e]}else{if(typeof e!=="number"){return a}else{N.raise("Gallery index "+e+" not found")}}};N.addTransition=function(f,e){q[f]=e};N.utils=O;N.log=function(){try{M.console.log.apply(M.console,O.array(arguments))}catch(f){try{M.opera.postError.apply(M.opera,arguments)}catch(e){M.alert(O.array(arguments).split(", "))}}};N.ready=function(e){N.ready.callbacks.push(e)};N.ready.callbacks=[];N.raise=function(f,e){var l=e?"Fatal error":"Error",g=function(n){var o='<div style="padding:4px;margin:0 0 2px;background:#'+(e?"811":"222")+'";>'+(e?"<strong>"+l+": </strong>":"")+n+"</div>";P.each(a,function(){var u=this.$("errors"),t=this.$("target");u.length||(t.css("position","relative"),u=this.addElement("errors").appendChild("target","errors").$("errors").css({color:"#fff",position:"absolute",top:0,left:0,zIndex:100000}));u.append(o)})};if(D){if(g(f),e){throw Error(l+": "+f)}}else{e&&!b&&(b=!0,e=!1,g("Image gallery could not load."))}};N.Picture=function(e){this.id=e||null;this.image=null;this.container=O.create("galleria-image");P(this.container).css({overflow:"hidden",position:"relative"});this.original={width:0,height:0};this.loaded=this.ready=!1};N.Picture.prototype={cache:{},add:function(g){var e=0,o=this,n=new Image,l=function(){if((!this.width||!this.height)&&e<1000){e++,P(n).load(l).attr("src",g+"?"+(new Date).getTime())}o.original={height:this.height,width:this.width};o.cache[g]=g;o.loaded=!0};P(n).css("display","block");if(o.cache[g]){return n.src=g,l.call(n),n}P(n).load(l).error(function(){N.raise("image could not load: "+g)}).attr("src",g);return n},show:function(){O.show(this.image)},hide:function(){O.moveOut(this.image)},clear:function(){this.image=null},isCached:function(e){return !!this.cache[e]},load:function(f,e){var g=this;P(this.container).empty(!0);this.image=this.add(f);O.hide(this.image);P(this.container).append(this.image);O.wait({until:function(){return g.loaded&&g.image.complete&&g.original.width&&g.image.width},success:function(){M.setTimeout(function(){e.call(g,g)},1)},error:function(){M.setTimeout(function(){e.call(g,g)},1);N.raise("image not loaded in 30 seconds: "+f)},timeout:30000});return this.container},scale:function(f){f=P.extend({width:0,height:0,min:void 0,max:void 0,margin:0,complete:function(){},position:"center",crop:!1,canvas:!1},f);if(!this.image){return this.container}var e,o,n=this,l=P(n.container),g;O.wait({until:function(){e=f.width||l.width()||O.parseValue(l.css("width"));o=f.height||l.height()||O.parseValue(l.css("height"));return e&&o},success:function(){var w=(e-f.margin*2)/n.original.width,v=(o-f.margin*2)/n.original.height,u={"true":Math.max(w,v),width:w,height:v,"false":Math.min(w,v)}[f.crop.toString()],w="";f.max&&(u=Math.min(f.max,u));f.min&&(u=Math.max(f.min,u));P.each(["width","height"],function(B,A){P(n.image)[A](n[A]=n.image[A]=Math.round(n.original[A]*u))});P(n.container).width(e).height(o);if(f.canvas&&r){r.elem.width=n.width,r.elem.height=n.height,w=n.image.src+":"+n.width+"x"+n.height,n.image.src=r.cache[w]||function(B){r.context.drawImage(n.image,0,0,n.original.width*u,n.original.height*u);try{return g=r.elem.toDataURL(),r.length+=g.length,r.cache[B]=g}catch(A){return n.image.src}}(w)}var t={},z={},w=function(B,A,E){var C=0;/\%/.test(B)?(B=parseInt(B,10)/100,A=n.image[A]||P(n.image)[A](),C=Math.ceil(A*-1*B+E*B)):C=O.parseValue(B);return C},y={top:{top:0},left:{left:0},right:{left:"100%"},bottom:{top:"100%"}};P.each(f.position.toLowerCase().split(" "),function(B,A){A==="center"&&(A="50%");t[B?"top":"left"]=A});P.each(t,function(B,A){y.hasOwnProperty(A)&&P.extend(z,y[A])});t=t.top?P.extend(t,z):z;t=P.extend({top:"50%",left:"50%"},t);P(n.image).css({position:"relative",top:w(t.top,"height",o),left:w(t.left,"width",e)});n.show();n.ready=!0;f.complete.call(n,n)},error:function(){N.raise("Could not scale image: "+n.image.src)},timeout:1000});return this}};P.extend(P.easing,{galleria:function(g,f,o,n,l){if((f/=l/2)<1){return n/2*f*f*f+o}return n/2*((f-=2)*f*f+2)+o},galleriaIn:function(g,f,o,n,l){return n*(f/=l)*f+o},galleriaOut:function(g,f,o,n,l){return -n*(f/=l)*(f-2)+o}});P.fn.galleria=function(e){return this.each(function(){(new N).init(this,e)})};M.Galleria=N})(jQuery);
