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