/*
 Galleria v 1.2.4 2011-06-07
 http://galleria.aino.se

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