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