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