(function(f){var c=f(document),d,e="",a=/MSIE/.test(navigator.userAgent),g=false,i=false;function b(){if(e!=(e=document.location.hash)){if(!g&&a){h(e)}g=false;c.trigger("hashChange",[e])}setTimeout(b,42)}function h(j){if(!d){d=f('<iframe style="display:none" src="javascript:false;"></iframe>').appendTo("body")[0]}var k=d.contentDocument||(d.contentWindow?d.contentWindow.document:d.document);k.open();k.write("<html><head><title>"+document.title+"</title></head><body>");k.write(f("<div/>").append(f('<div id="hashdiv"></div>').text(j)).html());k.write('<script>window._hash = document.getElementById("hashdiv").innerText;window.onload = parent._historyRead;<\/script>');i=true;k.close()}if("onpropertychange" in document&&"attachEvent" in document){document.attachEvent("onpropertychange",function(){if(event.propertyName=="location"){b()}})}if(a){window._historyRead=function(){if(!i){var j=this._hash;if(document.location.hash!=j){g=true;document.location.hash=j}}i=false}}f(function(){setTimeout(b,1)})})(jQuery);var uGallery={};uGallery.core=function(a){var d=function(e){var f=false;return function(g){if(undefined===g){return f}f=g;if(f){this.previewEl.addClass(e);this.viewEl.addClass(e)}else{this.previewEl.removeClass(e);this.viewEl.removeClass(e)}}};var b=function(){var e=0;return function(g,f){if(undefined===g){return e}e=parseInt(g,10);if(!f){this.previewContentEl.css("left",e)}}};var c={previewEl:null,previewContainerEl:null,previewContentEl:null,previewPicturesEl:null,viewEl:null,animated:d("animate"),eventDispatcher:null,previewLeft:b(),loader:null,busy:d("busy"),preloaderWidth:0,paused:d("pause")};return $.extend({},c,a?a:{})};uGallery.abstractLoader=function(b){var f=null,e=[],h={},a={},i=0;function c(m){if(undefined===m){return f}f=m}function d(){return l(f)}function k(o,n){e.push(o);var m=i;if(n){i--}else{m+=e.length-1}e[e.length-1].index=m;h[m]=e.length-1;a[l(m).id]=m;uGallery.loadImage(l(m).preview.src)}function l(m){return undefined===h[m]?false:e[h[m]]}function j(m){return undefined===a[m]?false:l(a[m])}function g(m){return undefined===a[m]?false:a[m]}return{count:function(){return e.length},first:function(){return i},indexById:g,insert:k,item:l,itemById:j,selectedIndex:c,selected:d}};uGallery.ajaxLoader=function(a,q){q=$.extend({},{tryCount:3,ajaxParams:{},limit:30},q);var g,p,n,c=false,e=false,l,b,j=uGallery.abstractLoader(a);function o(s,r){l=s;b=r;q.ajaxParams.limit=q.limit;var t={};$.extend(t,q.ajaxParams);t.id=q.imageId;g={id:t.id,counter:1,params:t};k(t)}function d(){if(0>=j.count()){return false}if(g||p||c){return false}var r=j.item(j.first());if(!r){return}var s={};$.extend(s,q.ajaxParams);s.id=r.id;s.direction=-1;p={id:s.id,counter:1,params:s};k(s);return true}function f(){if(0>=j.count()){return false}if(g||n||e){return false}var r=j.item(j.first()+j.count()-1);if(!r){return}var s={};$.extend(s,q.ajaxParams);s.id=r.id;s.direction=1;n={id:s.id,counter:1,params:s};k(s);return true}function k(s){try{$.ajax({imageId:s.id,data:s,dataType:"html",error:i,success:h,timeout:20000,type:"GET",url:q.ajaxUrl})}catch(r){}}function h(w,x){if(!("success"==x&&w)){return}var v=$(w),u=v.find(">.photo"),s=v.find(">.preview_src_prefix").text(),r=v.find(">.image_src_prefix").text();if(p&&p.id==this.imageId){p=false;for(var t=u.length-1;t>=0;t--){j.insert(m(u.eq(t),s,r),true)}if(!v.find(">.has_prev").length){c=true}b&&b()}else{if(n&&n.id==this.imageId){n=false;u.each(function(){j.insert(m($(this),s,r))});if(!v.find(">.has_next").length){e=true}b&&b()}else{if(g&&g.id==this.imageId){g=false;u.each(function(){j.insert(m($(this),s,r))});if(!v.find(">.has_prev").length){c=true}if(!v.find(">.has_next").length){e=true}l&&l()}}}}function i(){if(p&&this.imageId==p.id){if(q.tryCount>=++p.counter){k(p.params)}else{p=false;c=true}}else{if(n&&this.imageId==n.id){if(q.tryCount>=++n.counter){k(n.params)}else{n=false;e=true}}}}function m(u,s,r){var v=u.find(">.preview"),y=u.find(">.image"),x=u.attr("id"),t=v[0].onfocus(),w=y[0].onfocus();return{id:x,href:u.attr("href"),preview:{src:s+t[0],width:t[1],height:t[2]},image:{src:r+w[0],width:w[1],height:w[2]},info:u[0]}}return{count:j.count,first:j.first,init:o,indexById:j.indexById,isLeftBorder:function(){return c},isRightBorder:function(){return e},item:j.item,itemById:j.itemById,loadNext:f,loadPrev:d,selectedIndex:j.selectedIndex,selected:j.selected}};uGallery.jsonLoader=function(a,q){q=$.extend({},{tryCount:3,ajaxParams:{},limit:30},q);var g,p,n,c=false,e=false,l,b,j=uGallery.abstractLoader(a);function o(s,r){l=s;b=r;q.ajaxParams.limit=q.limit;var t={};$.extend(t,q.ajaxParams);t.id=q.imageId;g={id:t.id,counter:1,params:t};k(t)}function d(){if(0>=j.count()){return false}if(g||p||c){return false}var r=j.item(j.first());if(!r){return}var s={};$.extend(s,q.ajaxParams);s.id=r.id;s.direction=-1;p={id:s.id,counter:1,params:s};k(s);return true}function f(){if(0>=j.count()){return false}if(g||n||e){return false}var r=j.item(j.first()+j.count()-1);if(!r){return}var s={};$.extend(s,q.ajaxParams);s.id=r.id;s.direction=1;n={id:s.id,counter:1,params:s};k(s);return true}function k(s){try{$.ajax({imageId:s.id,data:s,dataType:"json",error:i,success:h,timeout:2000,type:"GET",url:q.ajaxUrl})}catch(r){}}function h(s,t){if(!("success"==t&&s)){return}var r=s.images;if(p&&p.id==this.imageId){p=false;r.reverse();$.each(r,function(){j.insert(m(this,s.pSrcPrefix,s.iSrcPrefix),true)});if(1!=s.hasPrev){c=true}b&&b()}else{if(n&&n.id==this.imageId){n=false;$.each(r,function(){j.insert(m(this,s.pSrcPrefix,s.iSrcPrefix))});if(1!=s.hasNext){e=true}b&&b()}else{if(g&&g.id==this.imageId){g=false;$.each(r,function(){j.insert(m(this,s.pSrcPrefix,s.iSrcPrefix))});if(1!=s.hasPrev){c=true}if(1!=s.hasNext){e=true}l&&l()}}}}function i(){if(p&&this.imageId==p.id){if(q.tryCount>=++p.counter){k(p.params)}else{p=false;c=true}}else{if(n&&this.imageId==n.id){if(q.tryCount>=++n.counter){k(n.params)}else{n=false;e=true}}}}function m(t,s,r){if(s){t.preview.src=s+t.preview.src}if(r){t.image.src=r+t.image.src}return t}return{count:j.count,first:j.first,indexById:j.indexById,init:o,isLeftBorder:function(){return c},isRightBorder:function(){return e},item:j.item,itemById:j.itemById,loadPrev:d,loadNext:f,selectedIndex:j.selectedIndex,selected:j.selected}};uGallery.arrayLoader=function(a,f){var d=uGallery.abstractLoader(a),c={},b=null;function e(g){$.each(f,function(h){if(undefined===this.id){this.id=h}d.insert(this)});g&&g()}return{count:d.count,first:d.first,indexById:d.indexById,init:e,isLeftBorder:function(){return true},isRightBorder:function(){return true},item:d.item,itemById:d.itemById,loadPrev:function(){return false},loadNext:function(){return false},selectedIndex:d.selectedIndex,selected:d.selected}};uGallery.state=function(d,c,k){var i=0;k=$.extend({},{maxDeviation:150,margin:0,screens:4},k?k:{});d.busy(true);d.loader.init(h,e);function h(){d.eventDispatcher.bind("previewsUpdate",function(){e()});d.eventDispatcher.bind("imageSelect",function(m){g(m.data.index,function(){d.eventDispatcher.dispatch("imageSelected",{index:m.data.index,imageInfo:m.data.imageInfo})})});d.eventDispatcher.bind("pause",function(){d.paused(true)});d.eventDispatcher.bind("resume",function(){d.paused(false);e()});$(window).resize(e);e();d.busy(false);var l=d.loader.indexById(c);if(false!==l){d.eventDispatcher.dispatch("previewClick",{current:d.loader.item(l),prev:d.loader.item(l-1),next:d.loader.item(l+1)})}d.eventDispatcher.dispatch("loaded")}function e(){if(d.animated()||d.paused()){return}var t=d.previewContainerEl.width();if(!t){return}var l;if(k.screens){l=Math.floor(t*k.screens/(k.maxWidth+k.margin));if(d.loader.count()<l&&d.loader.isLeftBorder()&&d.loader.isRightBorder()){l=d.loader.count()}}else{l=d.loader.count()}b(l);var r=d.previewPicturesEl.width(),p=d.previewPicturesEl.find("img").length,s=p?d.previewPicturesEl.find("img:first").data("uIndex"):d.loader.first();var q=0>t-r?t-r:0,m=0;if(d.loader.first()+d.loader.count()>s+p||!d.loader.isRightBorder()){q-=d.preloaderWidth}if(d.loader.first()<s||!d.loader.isLeftBorder()){m+=d.preloaderWidth}if(d.previewLeft()<q){d.previewLeft(q)}else{if(m<d.previewLeft()){d.previewLeft(m)}}var n=d.previewLeft()+Math.round((r-t)/2),o=0;if(k.maxDeviation<n){o=f(n,l)}else{if(-k.maxDeviation>n){o=j(n)}}d.eventDispatcher.dispatch("previewsUpdated",{moveX:o})}function b(l){var q=d.previewPicturesEl.find("img").length,r=q?d.previewPicturesEl.find("img:first").data("uIndex"):d.loader.first();var n;if(k.screens){n=l-q;if(0<n){var m=r+d.previewPicturesEl.find(".active").length;if(d.loader.first()+d.loader.count()<m+n){n=d.loader.first()+d.loader.count()-m;d.loader.loadNext()}for(var o=0;o<n;o++){var p=$("<img />").appendTo(d.previewPicturesEl);a(p,m+o)}}else{if(0>n){d.previewPicturesEl.find("img").eq(l-1).nextAll("img").remove()}}}else{var m=r+d.previewPicturesEl.find(".active").length;n=d.loader.first()+d.loader.count()-m;d.loader.loadNext();for(var o=0;o<n;o++){var p=$("<img />").appendTo(d.previewPicturesEl);a(p,m+o)}}}function f(q,m){var n=m-d.previewPicturesEl.find("img").length,p=0,r=d.previewPicturesEl.find("img:first").data("uIndex");while(p<q){var l=d.loader.item(r-1);if(!l){d.loader.loadPrev();break}var o;if(!k.screens||0<n){o=$("<img />").prependTo(d.previewPicturesEl);n--}else{o=d.previewPicturesEl.find("img:last").prependTo(d.previewPicturesEl)}a(o,r-1);p+=l.preview.width+k.margin;r--}if(!p){return 0}d.previewLeft(d.previewLeft()-p);return -p}function j(p){var o=0,q=d.previewPicturesEl.find("img:first").data("uIndex"),n=d.previewPicturesEl.find("img").length,l=q;while(o<-p){if(!d.loader.item(q+n)){d.loader.loadNext();break}var m=d.previewPicturesEl.find("img:first").attr("class","").appendTo(d.previewPicturesEl);a(m,q+n);o+=d.loader.item(q).preview.width+k.margin;q++}if(!o){return 0}d.previewLeft(d.previewLeft()+o);return o}function a(m,l){var n=d.loader.item(l);m.removeAttr("src").removeAttr("class").addClass("active i_"+l).data("uIndex",l);m[0].src=n.preview.src;m[0].height=n.preview.height;m[0].width=n.preview.width}function g(o,K){var A=d.previewContainerEl.width(),J=d.previewPicturesEl.find("img:first").data("uIndex"),s=d.previewPicturesEl.find("img").length;if(o>=J&&o<J+s){var x=Math.round(d.previewPicturesEl.find(".i_"+o).offset().left-d.previewContainerEl.offset().left);if(0<x&&x+d.loader.item(o).preview.width<A){K&&K();return}}var N=0,E=0,l=0,H=0,L=0,v=0,m=0,y=0,M=d.previewPicturesEl.width();var w=d.loader.first();for(var I=o-1;I>=w;I--){if(N>=A/2||!d.loader.item(I)){break}N+=d.loader.item(I).preview.width+k.margin;E++}w=d.loader.first()+d.loader.count();for(var I=o+1;I<w;I++){if(l>=A-N||!d.loader.item(I)){break}l+=d.loader.item(I).preview.width+k.margin;H++}if(N+l<A){var q=o-1-E;w=d.loader.first();for(var I=q;I>=w;I--){if(N+l>=A||!d.loader.item(I)){break}N+=d.loader.item(I).preview.width+k.margin;E++}}while(true){var G=d.loader.item(J+L);if(!G){break}var D=G.preview.width+k.margin;if(0<=d.previewLeft()+v+D){break}v+=D;L++}while(true){var G=d.loader.item(J+s-1-m);if(!G){break}var D=G.preview.width+k.margin;if(d.previewLeft()+M-y-D<=A){break}y+=D;m++}if(o<J){var z=0,F=E+H+1,p=o+H;if(p>=J){var B=p-J+1;F-=B;p-=B}for(var I=p;I>=o-E;I--){var n;if(m){n=d.previewPicturesEl.find("img:last");m--}else{n=$("<img />")}n.prependTo(d.previewPicturesEl);a(n,I);z+=d.loader.item(I).preview.width+k.margin}d.previewLeft(d.previewLeft()-z);d.eventDispatcher.dispatch("previewsUpdated",{moveX:-z});d.eventDispatcher.dispatch("previewsMove",{toLeft:0,onComplete:function(){d.previewPicturesEl.find(".i_"+(o+H)).nextAll("img").remove();K&&K()}})}else{if(o>=J+s){var C=0,F=E+H+1,p=o-E;if(p<=J+s-1){var B=J+s-p;F-=B;p+=B}for(var I=p;I<=o+H;I++){var n;if(L){n=d.previewPicturesEl.find("img:first");C+=d.loader.item(n.data("uIndex")).preview.width+k.margin;L--}else{n=$("<img />")}n.appendTo(d.previewPicturesEl);a(n,I)}d.previewLeft(d.previewLeft()+C);d.eventDispatcher.dispatch("previewsUpdated",{moveX:C});var r=d.previewPicturesEl.width();d.eventDispatcher.dispatch("previewsMove",{toLeft:A-r,onComplete:function(){d.previewPicturesEl.find(".i_"+(o-E)).prevAll("img").remove();var t=d.previewPicturesEl.width();d.previewLeft(d.previewLeft()+r-t);d.eventDispatcher.dispatch("previewsUpdated",{moveX:r-t});K&&K()}})}else{if(!d.previewPicturesEl.find(".i_"+o).length){K&&K();return}if(J>o-E){var F=E>m?m:E,z=0;for(var I=0;I<F;I++){var n=d.previewPicturesEl.find("img:last");a(n,J-1);n.prependTo(d.previewPicturesEl);z+=d.loader.item(J-1).preview.width+k.margin;J--}d.previewLeft(d.previewLeft()-z);d.eventDispatcher.dispatch("previewsUpdated",{moveX:-z})}else{if(J+s-1<o+H){var F=H>L?L:H,C=0;for(var I=0;I<F;I++){var n=d.previewPicturesEl.find("img:first");C+=d.loader.item(J).preview.width+k.margin;a(n,J+s);n.appendTo(d.previewPicturesEl);J++}d.previewLeft(d.previewLeft()+C);d.eventDispatcher.dispatch("previewsUpdated",{moveX:C})}}M=d.previewPicturesEl.width();var u=Math.round(A/2-d.previewPicturesEl.find(".i_"+o).position().left);if(0<u){u=0}else{if(A-M>u){u=A-M}}d.eventDispatcher.dispatch("previewsMove",{toLeft:u,onComplete:function(){K&&K()}})}}d.previewPicturesEl.find(".i_"+d.loader.selectedIndex()).addClass("selected")}};uGallery.pictures=function(b){var c={};b.previewContainerEl.click(f);b.eventDispatcher.bind("imageSelected",function(g){d(g.data.index)});function f(g){if(b.busy()||b.animated()||!$(g.target).hasClass("active")){return}var h=$(g.target).data("uIndex");if(undefined===h){return}if(b.loader.selectedIndex()==h){return}b.eventDispatcher.dispatch("previewClick",{current:b.loader.item(h),prev:b.loader.item(h-1),next:b.loader.item(h+1)});for(var j=h-2;j<=h+2;j++){e(j)}}function e(g){if(c[g]){return false}var i=b.loader.item(g);if(!i){return false}var h=new Image();$(h).load(function(){c[g]=2;b.eventDispatcher.dispatch("imageLoaded",{index:g})});h.src=i.image.src;c[g]=1;return true}function a(g){return c[g]&&2==c[g]}function d(g){if(g==b.loader.selectedIndex()){return false}b.loader.selectedIndex(g);b.previewContentEl.find(".selected").removeClass("selected");b.previewContentEl.find(".i_"+g).addClass("selected");for(var h=g-2;h<=g+2;h++){e(h)}return true}return{loadImage:e,isLoaded:a,setCurrent:d}};uGallery.previewMover=function(c,d){var f={dndInertiaTime:1};d=$.extend({},f,d?d:{});var e=1/30;c.eventDispatcher.bind("previewsMove",function(g){g.data.speed?a(g.data.speed,g.data.onComplete?g.data.onComplete:null):b(g.data.toLeft,g.data.onComplete?g.data.onComplete:null)});function b(g,i){var h=c.previewLeft();c.animated(true);c.previewContentEl.animate({moveX:1},{duration:300,easing:"easeOutQuad",step:function(j,k){c.previewLeft(h+Math.round((g-h)*k.pos))},complete:function(){c.animated(false);i&&i();c.eventDispatcher.dispatch("previewsUpdate")}})}function a(l,k){var q=c.previewPicturesEl.find("img:first").data("uIndex"),n=c.previewPicturesEl.find("img").length,p=c.previewPicturesEl.width(),r=c.previewContainerEl.width(),m=(0<l&&(c.loader.first()<q||!c.loader.isLeftBorder()))||(0>l&&(c.loader.first()+c.loader.count()-1>q+n||!c.loader.isRightBorder()))?c.preloaderWidth:0,h=0<l?Math.abs(c.previewLeft())+m:Math.abs(r-p-c.previewLeft())+m,g=Math.abs(l*d.dndInertiaTime/(e/d.dndInertiaTime-2)),i=c.previewLeft(),o;c.animated(true);if(g<h){o=0<l?c.previewLeft()+g:c.previewLeft()-g;c.previewContentEl.animate({moveX:1},{duration:d.dndInertiaTime*1000,easing:"easeOutQuad",step:function(s,u){c.previewLeft(i+Math.round((o-i)*u.pos))},complete:function(){c.animated(false);k&&k();c.eventDispatcher.dispatch("previewsUpdate")}});return}var t=2<Math.abs(l)/3000?2:Math.abs(l)/3000,j=e/(uGallery.cubic(t/(t+1),0,(1-Math.abs(l)*e/h)/(t+1)).x[0]+1);jQuery.extend(jQuery.easing,{uGallery:function(u,v,s,y,w){return y*((v=v/w-1)*v*((t+1)*v+t)+1)+s}});o=0<l?c.previewLeft()+h:c.previewLeft()-h;c.previewContentEl.animate({moveX:1},{duration:j*1000,easing:"uGallery",step:function(s,u){c.previewLeft(i+Math.round((o-i)*u.pos))},complete:function(){c.animated(false);c.eventDispatcher.dispatch("previewsUpdate")}})}};uGallery.previewArrowScrolling=function(d,i){var h={animateStep:50};i=$.extend({},h,i);var a=d.previewEl.find(".prev"),c=d.previewEl.find(".next"),f;a.mousedown(function(){e(true)});c.mousedown(function(){e(false)});d.eventDispatcher.bind("previewsUpdated",g);function e(k){if(d.busy()||(k&&0<=d.previewLeft())||(!k&&d.previewLeft()+d.previewPicturesEl.width()<=d.previewContainerEl.width())){return}d.previewContentEl.stop();var j=function(){clearTimeout(f)};k?a.one("mouseup",j):c.one("mouseup",j);b(k)}function b(j){d.previewLeft(j?d.previewLeft()+i.animateStep:d.previewLeft()-i.animateStep);f=setTimeout(function(){b(j)},Math.round(1000/15));d.eventDispatcher.dispatch("previewsUpdate");g()}function g(){var k=d.previewPicturesEl.width(),j=d.previewContainerEl.width();0<=d.previewLeft()?a.addClass("disabled"):a.removeClass("disabled");d.previewLeft()+k<=j?c.addClass("disabled"):c.removeClass("disabled")}return{updateState:g}};uGallery.previewDnd=function(b,i){i=$.extend({},{dndDuration:100},i?i:{});var d=false,c=[],g;b.previewContentEl.mousedown(h);function h(j){if(b.busy()||b.previewPicturesEl.width()<b.previewContainerEl.width()){return false}b.previewContentEl.stop();b.animated(false);b.eventDispatcher.dispatch("previewsUpdate");g=parseInt(j.pageX);d=false;$(document).mousemove(a).mouseup(e);return false}function a(j){d=true;var k=b.previewLeft();k+=parseInt(j.pageX)-g;g=parseInt(j.pageX);c.push({x:k,time:uGallery.getTime()});b.previewLeft(k);return false}function e(r){$(document).unbind("mousemove",a).unbind("mouseup",e);if(!d||b.busy()){return false}var o=b.previewPicturesEl.width(),q=b.previewContainerEl.width();if(o<q){return false}if(0<b.previewLeft()||b.previewLeft()<q-o){b.eventDispatcher.dispatch("previewsMove",{toLeft:b.previewLeft()<q-o?q-o:0});return false}var l=uGallery.getTime(),k=0,p,j=3;for(var n=c.length-1;n>=0;n--){if(c[n].time+i.dndDuration<l&&0>=j){break}k=b.previewLeft()-c[n].x;p=c[n].time;j--}c=[];var m=k?Math.round(k/(l-p)*1000/1.5):0;m?b.eventDispatcher.dispatch("previewsMove",{speed:m}):b.eventDispatcher.dispatch("previewsUpdate");return false}function f(j){b.previewContentEl.unbind("mouseup",f);return false}};uGallery.previewRunner=function(c){var a=c.previewContentEl.find(".selected_runner"),b=c.previewEl.find(".selected_left"),d=c.previewEl.find(".selected_right");b.click(g);d.click(g);c.eventDispatcher.bind("imageSelected",function(h){e(h.data.index)});c.eventDispatcher.bind("previewsUpdated",function(h){f(a.position().left-h.data.moveX)});function e(i){var h=c.previewPicturesEl.find(".i_"+i);if(!h.length){return false}f(Math.round(h.position().left+c.loader.item(i).preview.width/2));return true}function f(h){a.css("left",h);var i=a.offset().left-c.previewContainerEl.offset().left;b[0>i?"removeClass":"addClass"]("hidden");d[i>c.previewContainerEl.width()?"removeClass":"addClass"]("hidden")}function g(){if(c.busy()){return false}c.eventDispatcher.dispatch("imageSelect",{index:c.loader.selectedIndex(),imageInfo:c.loader.selected()});return true}return{changeSelected:g,moveToImage:e,setPos:f}};uGallery.previewPreloader=function(b){var c=b.previewContentEl.find(".preloader");b.eventDispatcher.bind("previewsUpdated",a);function a(){var f=b.previewPicturesEl.find("img:first").data("uIndex"),d=b.previewPicturesEl.find("img").length,e;e=b.loader.isLeftBorder&&f==b.loader.first()?"hidden":"visible";c.eq(0).css("visibility",e);e=b.loader.isRightBorder&&f+d==b.loader.first()+b.loader.count()?"hidden":"visible";c.eq(1).css("visibility",e)}return{updateStates:a}};uGallery.history=function(b,k){k=$.extend({},{anchorPrefix:"image_",firstId:null},k);var i=null,e,g,d=document.location.hash;j();b.eventDispatcher.bind("imageSelected",function(l){h(l.data.index)});b.eventDispatcher.bind("pause",function(){$(document).unbind("hashChange",f)});b.eventDispatcher.bind("resume",j);function j(){a(d);$(document).bind("hashChange",f)}function f(l,m){a(m)}function a(o){var m=k.firstId;if(o&&k.anchorPrefix==o.substr(1,k.anchorPrefix.length)){var n=o.substr(k.anchorPrefix.length+1);m=parseInt(n,10);if(!(n==m&&0<m)){m=k.firstId}}if(i&&i!=m){var l=b.loader.indexById(i);if(false!==l){c(l)}}i=m}function h(m){clearTimeout(e);var l=b.loader.item(m).id;if(l!=i){i=l;document.location.hash="#"+k.anchorPrefix+i}}function c(l){clearTimeout(e);if(b.busy()||b.animated()){e=setTimeout(function(){c(l)},200)}else{b.eventDispatcher.dispatch("previewClick",{current:b.loader.item(l),prev:b.loader.item(l-1),next:b.loader.item(l+1)})}}return{getId:function(){return i}}};uGallery.loadImage=function(c,a){var b=new Image();$(b).load(function(){a&&a()});b.src=c};uGallery.cubic=function(l,j,i){var f=(l*l-3*j)/9,e=(l*(2*l*l-9*j)+27*i)/54,g=f*f*f;if(e*e<g){var m=Math.acos(e/Math.sqrt(g));l/=3;f=-2*Math.sqrt(f);return{type:3,x:[f*Math.cos(m/3)-l,f*Math.cos((m+2*Math.PI)/3)-l,f*Math.cos((m-2*Math.PI)/3)-l]}}e=Math.abs(e);var d=-Math.pow(e+Math.sqrt(e*e-g),1/3),h=0==d?0:f/d;l/=3;f=d+h;e=Math.abs(d-h);var k=[f-l,-0.5*f-l,(Math.sqrt(3)*0.5)*e];return{type:0==k[2]?2:1,x:k}};uGallery.getTime=function(){return new Date().getTime()};uGallery.eventDispatcher=(function(){function a(){var g={},f={};function h(m,n,j){if(!n instanceof Function){throw new Error("Listener isn't a function")}var l=j?f:g;m="string"==typeof(m)?m.split(" "):m;for(var k=0;k<m.length;k++){if(!l[m[k]]){l[m[k]]=[n]}else{l[m[k]].push(n)}}}function c(i){return("undefined"!=typeof g[i]||"undefined"!=typeof f[i])}function e(n,o){if(!c(n)){return false}var p=[g,f];for(var m=0;m<p.length;m++){var k=p[m][n];for(var l=0;l<k.length;l++){k[l]==o&&k.splice(l,1)}}return true}function d(q,o){if(!c(q)){return false}var r=[g,f],l=new b(q,this,o);for(var n=0;n<r.length;n++){var k=r[n][q];if(k){for(var p=0,m=k.length;p<m;p++){k[p](l)}}}if(f[q]){delete f[q]}return true}return{bind:h,hasBinds:c,unbind:e,dispatch:d}}function b(c,e,d){this.type=c;this.target=e;if(d){this.data=d}}return function(){return new a()}})();(function(){var a="image_",c="id",b=document.location.hash;if(b&&a==b.substr(1,a.length)){var d=parseInt(b.substr(a.length+1),10);if(d){location.href=location.href.split("?")[0]+"?"+c+"="+d}}})();function gallery(g,e,b,d,f){photoSizer.getScale();g=$(g);var a=uGallery.core({previewEl:g,previewContainerEl:g.find(".previews .container"),previewContentEl:g.find(".previews .content"),previewPicturesEl:g.find(".previews .pictures"),eventDispatcher:uGallery.eventDispatcher(),viewEl:$(e),preloaderWidth:g.find(".preloader").innerWidth()});a.loader=uGallery.ajaxLoader(a,{ajaxUrl:d,imageId:b});uGallery.previewRunner(a);uGallery.pictures(a);uGallery.previewArrowScrolling(a);uGallery.previewDnd(a);uGallery.previewMover(a);uGallery.previewPreloader(a);var h=uGallery.history(a,{firstId:b});var c=h.getId();uGallery.state(a,c?c:b,{maxHeight:55,maxWidth:75,margin:4,screens:4});galleryPictures(a);galleryInfoChanger(a);galleryTabChanger(a);galleryTeaserChanger(a,f)}function galleryPictures(x){var O={duration:400,easing:"easeInOutCubic"};var S={height:"",left:"",opacity:"",position:"",top:"",width:""};var e,I="isActive",u=null;var w=$(document.documentElement),C=$(document.body),r=x.viewEl.find(".slideshow"),s=$("#slideshow"),q=s.find(".close"),i=s.find(".controls"),H=i.find(".play").data(I,false),h=i.find(".pause"),d=i.find(".prev").data(I,false),D=i.find(".next").data(I,false);var t=false,N=false,K=false;var j,J;x.viewEl.find("a.picture").click(R);$(".current .picture, .slideshow",x.viewEl[0]).live("mouseenter",n);$(".current .picture",x.viewEl[0]).live("mouseleave",k);s.find(".close").click(L);x.eventDispatcher.bind("previewClick",b);D.click(l);d.click(M);H.click(P);h.click(E);function P(){if(N){return}N=true;H.addClass("hidden");h.removeClass("hidden");m()}function E(){if(!N){return}N=false;H.removeClass("hidden");h.addClass("hidden");clearTimeout(J)}function F(){if(!t){return}if(N){E()}else{P()}}$c.shortcuts.bind({keyCode:$c.keyCode("Right")},function(){if(x.busy()||x.animated()){return false}if(w.hasClass("slideshow_mode")){l()}else{v(false)}});$c.shortcuts.bind({keyCode:$c.keyCode("Left")},function(){if(x.busy()||x.animated()){return false}if(w.hasClass("slideshow_mode")){M()}else{v(true)}});$c.shortcuts.bind({keyCode:$c.keyCode("Escape")},L);$c.shortcuts.bind({keyCode:$c.keyCode("Space")},F);function n(){}function k(){}function l(){y(false)}function M(){y(true)}function y(Z){var X=s.find("img"),V=x.loader.selectedIndex()+(Z?-1:1),Y=x.loader.item(V-1),ac=x.loader.item(V),U=x.loader.item(V+1);if(!ac){return false}var W=x.viewEl.find(".prev .picture"),ab=x.viewEl.find(".current .picture"),aa=x.viewEl.find(".next .picture");z(W.find("img"),Y);z(ab.find("img"),ac);z(aa.find("img"),U);if(Y){W.attr("href",Y.image.src)}if(U){aa.attr("href",U.image.src)}if(!K){K=true;A(ac.image.width)}X.fadeOut(300,function(){X.remove();var ad=f(ac);ad.hide().fadeIn(300,function(){x.eventDispatcher.dispatch("imageSelect",{index:V,imageInfo:ac});m();G()})})}function R(U){if(x.busy()||x.animated()){return false}var V=false;if($(this).parent().hasClass("prev")){V=true}else{if(!$(this).parent().hasClass("next")){B();return false}}v(V);return false}function B(){if(x.busy()||x.animated()){return false}if(!x.loader.selected()){return false}f(x.loader.selected());w.addClass("slideshow_mode");$(window).scrollTop(0);T();C.mousemove(p).mousedown(T);t=true;P();G()}function p(U){var V=U.pageX+"--"+U.pageY;if(u!=null&&V!=u){T("mousemove")}u=V}function L(){w.removeClass("slideshow_mode");C.unbind("mousemove",p).unbind("mousedown",T);s.find("img").remove();clearTimeout(J);t=false;E();H.removeClass("hidden");h.addClass("hidden")}function m(){clearTimeout(J);if(N){J=setTimeout(l,5000)}}function f(V){var U=Q(V.image.width,V.image.height);return $("<img />").attr({src:V.image.src,width:V.image.width,height:V.image.height}).addClass(U).prependTo(s).data("type",U)}function Q(V,U){if(V/U>$(window).width()/$(window).height()){return"by_width"}return"by_height"}function T(){clearTimeout(j);if($c.browser.msie&&9>parseInt($c.browser.version)){i.removeClass("hidden");q.removeClass("hidden")}else{i.fadeIn();q.fadeIn()}j=setTimeout(function(){if($c.browser.msie&&9>parseInt($c.browser.version)){i.addClass("hidden");q.addClass("hidden")}else{i.fadeOut(300);q.fadeOut(300)}},3000)}function G(){curIndex=x.loader.selectedIndex();if(!x.loader.item(curIndex-1)&&d.data(I)){d.data(I,false).removeClass("prev_active")}else{if(x.loader.item(curIndex-1)&&!d.data(I)){d.data(I,true).addClass("prev_active")}}if(!x.loader.item(curIndex+1)&&D.data(I)){D.data(I,false).removeClass("next_active")}else{if(x.loader.item(curIndex+1)&&!D.data(I)){D.data(I,true).addClass("next_active")}}if(!x.loader.item(curIndex+1)&&H.data(I)){H.data(I,false).removeClass("play_active");E()}else{if(x.loader.item(curIndex+1)&&!H.data(I)){H.data(I,true).addClass("play_active")}}}function v(V){var U=V?x.loader.selectedIndex()-1:x.loader.selectedIndex()+1;if(!x.loader.item(U)){return}a({current:x.loader.item(U),prev:x.loader.item(U-1),next:x.loader.item(U+1)},V)}function a(aA,Z){x.animated(true);x.busy(true);var ao=Z?"next":"prev",af=Z?"prev":"next",ax=x.viewEl.offset(),aC=Z?aA.next:aA.prev,ak=x.viewEl.find(".current"),aE=ak.find(".picture"),V=aE.find("img"),aD=ak.offset(),av=aE.offset(),U=ak.width(),az=Math.round(U/aC.image.width*aC.image.height);var al=aA.current,X=x.viewEl.find("."+af),aa=X.find(".picture"),ac=aa.find("img"),ae=X.offset(),ai=aa.offset(),aj=X.width(),aq=Math.round(aj/al.image.width*al.image.height);var au=x.viewEl.find("."+ao),at=au.find(".picture"),ay=at.find("img"),ab=au.offset(),aB=at.offset(),ag=au.width(),ah=au.height();var ad=Z?aA.prev:aA.next,am=g(ad,!Z),ap=ad?aj/ad.image.width*ad.image.height:0,an=Math.round(U/al.image.width*al.image.height),aw=Math.round(ag/aC.image.width*aC.image.height);aE.height(az>an?az:an);aa.height(aq>ap?aq:ap);at.height(ah>aw?ah:aw);x.viewEl.find(".picture img").css("position","absolute");ay.css("top",Math.round(aB.top-ab.top));V.css("top",Math.round(av.top-aD.top));ac.css("top",Math.round(ai.top-ae.top));am.css({opacity:0,top:Math.round(ai.top-ae.top)});var W=4,ar=function(){W--;W||c()},Y=function(){W--;W||o()};V.animate({left:Math.round(ab.left-av.left),top:Math.round(aB.top-ab.top),width:ag},$.extend({},O,{complete:Z?ar:Y}));ac.animate({left:Math.round(aD.left-ai.left),top:Math.round(av.top-aD.top),width:U},$.extend({},O,{complete:Z?ar:Y}));ay.animate({opacity:0},$.extend({},O,{easing:"swing",complete:Z?ar:Y}));am.animate({opacity:1},$.extend({},O,{easing:"swing",complete:Z?ar:Y}));e=aA.current.index}function c(){var U=x.viewEl.find(".current .picture"),Y=x.viewEl.find(".next .picture"),Z=x.viewEl.find(".prev .picture img"),X=U.find("img"),V=Y.find("img");V.remove();X.appendTo(Y);Z.eq(0).removeClass("hid");Z.eq(1).appendTo(U);x.viewEl.find(".picture").css("height","");x.viewEl.find(".picture img").css(S);x.animated(false);x.busy(false);var W=x.loader.item(e);if(!K){K=true;A(W.image.width)}x.eventDispatcher.dispatch("imageSelect",{index:e,imageInfo:W})}function o(){var V=x.viewEl.find(".current .picture"),U=x.viewEl.find(".prev .picture"),W=x.viewEl.find(".next .picture img"),Z=V.find("img"),Y=U.find("img");Y.remove();Z.appendTo(U);W.eq(0).removeClass("hid");W.eq(1).appendTo(V);x.viewEl.find(".picture").css("height","");x.viewEl.find(".picture img").css(S);x.animated(false);x.busy(false);var X=x.loader.item(e);if(!K){K=true;A(X.image.width)}x.eventDispatcher.dispatch("imageSelect",{index:e,imageInfo:X})}function b(U){if(x.busy()||x.animated()){return}var V=x.viewEl.find(".prev .picture"),W=x.viewEl.find(".current .picture"),X=x.viewEl.find(".next .picture");z(V.find("img"),U.data.prev);z(W.find("img"),U.data.current);z(X.find("img"),U.data.next);U.data.prev&&V.attr("href",U.data.prev.image.src);U.data.next&&X.attr("href",U.data.next.image.src);if(!K){K=true;A(U.data.current.image.width)}x.eventDispatcher.dispatch("imageSelect",{index:U.data.current.index,imageInfo:U.data.current})}function g(W,V){var U=$('<img alt="" class="hid" />');z(U,W);return U.prependTo(x.viewEl.find(V?".next .picture":".prev .picture"))}function z(U,V){if(V){U.attr({height:V.image.height,src:V.image.src,width:V.image.width}).css("visibility","")}else{U.removeAttr("height").removeAttr("src").removeAttr("width").css("visibility","hidden")}}function A(U){if(800>U){photoSizer.setScale(0)}}}function galleryTabChanger(a){var b=a.previewEl.find(".navigation .item").not(".selected"),d=a.previewEl.find(".labels .label");a.eventDispatcher.bind("imageSelected",function(e){c(e.data.imageInfo)});function c(k){var i=$(k.info),l=i.find(">.place"),j=i.find(">.city"),h=i.find(">.country"),g=i.find(">.continent"),f=i.find(">.section"),e=i.find(">.author");b.each(function(){var p=$(this),m,o;if(p.hasClass("destination")){if(l.length&&l.find(">a").text()){m=l.find(">a").attr("href");o=l.find(">a").text()}else{if(j.length&&j.find(">a").text()){m=j.find(">a").attr("href");o=j.find(">a").text()}else{if(h.length&&h.find(">a").length){m=h.find(">a").attr("href");o=h.find(">a").text()}else{if(g.length&&g.find(">a").text()){m=g.find(">a").attr("href");o=g.find(">a").text()}else{var n=d.filter(".earth").find("a");m=n.attr("href");o=n.text()}}}}p.attr("href",m);p.find("em").text(o)}else{if(p.hasClass("section")){if(f.length){m=f.find(">a").attr("href");o=f.find(">a").text()}else{var n=d.filter(".all_themes").find("a");m=n.attr("href");o=n.text()}p.attr("href",m);p.find("em").text(o)}else{if(p.hasClass("author")){if(e){p.attr("href",e.find(">a").attr("href"));p.find("em").text(e.find(">a").text())}else{p.attr("href","#").find("em").text("")}}}}})}}function galleryInfoChanger(b){var a=$("#content .picture_info");b.eventDispatcher.bind("imageSelected",function(d){c(d.data.imageInfo)});function c(i){var h=$(i.info),e=h.find(">.author"),j=h.find(">.place"),g=h.find(">.city"),f=h.find(">.country");a.find(".name").html(h.find(">.name").text());a.find(".author").attr("href",e.find(".href").text()).html(e.find(">a").text());a.find(".photo_home a").attr("href",h.find(".name").attr("href"));var d=[];if(j.length&&j.find(">a").text()){d.push('<a href="'+j.find(".href").text()+'">'+j.find(">a").text()+"</a>")}if(g.length&&g.find(">a").text()){d.push('<a href="'+g.find(".href").text()+'">'+g.find(">a").text()+"</a>")}if(f.length&&f.find(">a").text()){d.push('<a href="'+f.find(".href").text()+'">'+f.find(">a").text()+"</a>")}a.find(".destination").html(d.join(", "))}}function galleryTeaserChanger(c,b){var d={},f=$("#content .extra"),e=f.find(".teaser .content"),h=f.find(".teaser .back");c.eventDispatcher.bind("imageSelected",function(i){a(i.data.imageInfo.id)});colorPicker.bind(function(i){h.css("background-color",i)});h.css("background-color",colorPicker.color());function a(i){if(undefined===d[i]){g("");teaser(b+"/photo/"+i+"/",function(j){d[i]=j;if(c.loader.selected().id==i){g(j)}})}else{g(d[i])}}function g(i){if(i){f.css("display","block");e.html(i)}else{f.css("display","none");e.html("")}}}$.browser.msie&&8>parseInt($.browser.version)&&$(function(){var e=$("#gallery .prev"),a=$("#gallery .next");if(!(e.length&&a.length)){return}var b=e.find(".icon ins").position().top;var c=function(){$(this).addClass("hover").find(".icon ins").css("top","")};var d=function(){$(this).removeClass("hover").find(".icon ins").css("top",b)};e.hover(c,d);a.hover(c,d)});
