﻿(function(a){var b;b=a.fn.galleria=function(f){if(!b.hasCSS())return false;a.historyInit(b.onPageLoad);var e={insert:".galleria_container",history:true,clickNext:true,onImage:function(){},onThumb:function(){}},c=a.extend(e,f);for(var d in c)if(d)a.galleria[d]=c[d];var g=a(c.insert).is(c.insert)?a(c.insert):jQuery(document.createElement("div")).insertBefore(this),i=a(document.createElement("div")).addClass("galleria_wrapper"),h=a(document.createElement("span")).addClass("caption");g.addClass("galleria_container").append(i).append(h);return this.each(function(){a(this).addClass("galleria");a(this).children("li").each(function(){var b=a(this),g=a.meta?a.extend({},c,b.data()):c;g.clickNext=a(this).is(":only-child")?false:g.clickNext;var e=a(this).find("a").is("a")?a(this).find("a"):false,d=a(this).children("img").css("display","none"),f=e?e.attr("href"):d.attr("src"),i=e?e.attr("title"):d.attr("title"),h=new Image;if(g.history&&(window.location.hash&&window.location.hash.replace(/\#/,"")==f)){b.siblings(".active").removeClass("active");b.addClass("active")}a(h).load(function(){a(this).attr("alt",d.attr("alt"));var c=e?e.find("img").addClass("thumb noscale").css("display","none"):d.clone(true).addClass("thumb").css("display","none");if(e)e.replaceWith(c);if(!c.hasClass("noscale")){var j=Math.ceil(d.width()/d.height()*b.height()),h=Math.ceil(d.height()/d.width()*b.width());if(j<h)c.css({height:"auto",width:b.width(),marginTop:-(h-b.height())/2});else c.css({width:"auto",height:b.height(),marginLeft:-(j-b.width())/2})}else window.setTimeout(function(){c.css({marginLeft:-(c.width()-b.width())/2,marginTop:-(c.height()-b.height())/2})},1);c.attr("rel",f);c.attr("title",i);c.click(function(){a.galleria.activate(f)});c.hover(function(){a(this).addClass("hover")},function(){a(this).removeClass("hover")});b.hover(function(){b.addClass("hover")},function(){b.removeClass("hover")});b.prepend(c);c.css("display","block");g.onThumb(jQuery(c));if(b.hasClass("active"))a.galleria.activate(f);d.remove()}).error(function(){b.html('<span class="error" style="color:red">Error loading image: '+f+"</span>")}).attr("src",f)})})};b.nextSelector=function(b){return a(b).is(":last-child")?a(b).siblings(":first-child"):a(b).next()};b.previousSelector=function(b){return a(b).is(":first-child")?a(b).siblings(":last-child"):a(b).prev()};b.hasCSS=function(){a("body").append(a(document.createElement("div")).attr("id","css_test").css({width:"1px",height:"1px",display:"none"}));var b=a("#css_test").width()!=1?false:true;a("#css_test").remove();return b};b.onPageLoad=function(b){var c=a(".galleria_wrapper"),d=a('.galleria img[rel="'+b+'"]');if(b){if(a.galleria.history)window.location=window.location.href.replace(/\#.*/,"")+"#"+b;d.parents("li").siblings(".active").removeClass("active");d.parents("li").addClass("active");var e=a(new Image).attr("src",b).addClass("replaced");c.empty().append(e);c.siblings(".caption").text(d.attr("title"));a.galleria.onImage(e,c.siblings(".caption"),d);if(a.galleria.clickNext)e.css("cursor","pointer").click(function(){a.galleria.next()})}else{c.siblings().andSelf().empty();a(".galleria li.active").removeClass("active")}a.galleria.current=b};a.extend({galleria:{current:"",onImage:function(){},activate:function(c){if(a.galleria.history)a.historyLoad(c);else b.onPageLoad(c)},next:function(){var c=a(b.nextSelector(a('.galleria img[rel="'+a.galleria.current+'"]').parents("li"))).find("img").attr("rel");a.galleria.activate(c)},prev:function(){var c=a(b.previousSelector(a('.galleria img[rel="'+a.galleria.current+'"]').parents("li"))).find("img").attr("rel");a.galleria.activate(c)}}})})(jQuery);jQuery.extend({historyCurrentHash:undefined,historyCallback:undefined,historyInit:function(c){jQuery.historyCallback=c;var a=location.hash;jQuery.historyCurrentHash=a;if(jQuery.browser.msie){if(jQuery.historyCurrentHash==="")jQuery.historyCurrentHash="#";$("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');var d=$("#jQuery_history")[0],b=d.contentWindow.document;b.open();b.close();b.location.hash=a}else if($.browser.safari){jQuery.historyBackStack=[];jQuery.historyBackStack.length=history.length;jQuery.historyForwardStack=[];jQuery.isFirst=true}jQuery.historyCallback(a.replace(/^#/,""));setInterval(jQuery.historyCheck,100)},historyAddHistory:function(a){jQuery.historyBackStack.push(a);jQuery.historyForwardStack.length=0;this.isFirst=true},historyCheck:function(){if(jQuery.browser.msie){var e=$("#jQuery_history")[0],f=e.contentDocument||e.contentWindow.document,a=f.location.hash;if(a!=jQuery.historyCurrentHash){location.hash=a;jQuery.historyCurrentHash=a;jQuery.historyCallback(a.replace(/^#/,""))}}else if($.browser.safari){if(!jQuery.dontCheck){var c=history.length-jQuery.historyBackStack.length;if(c){jQuery.isFirst=false;var b;if(c<0)for(b=0;b<Math.abs(c);b++)jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop());else for(b=0;b<c;b++)jQuery.historyBackStack.push(jQuery.historyForwardStack.shift());var d=jQuery.historyBackStack[jQuery.historyBackStack.length-1];if(d!==undefined){jQuery.historyCurrentHash=location.hash;jQuery.historyCallback(d)}}else if(jQuery.historyBackStack[jQuery.historyBackStack.length-1]===undefined&&!jQuery.isFirst){if(document.URL.indexOf("#")>=0)jQuery.historyCallback(document.URL.split("#")[1]);else{a=location.hash;jQuery.historyCallback("")}jQuery.isFirst=true}}}else{a=location.hash;if(a!=jQuery.historyCurrentHash){jQuery.historyCurrentHash=a;jQuery.historyCallback(a.replace(/^#/,""))}}},historyLoad:function(b){var a;if(jQuery.browser.safari)a=b;else{a="#"+b;location.hash=a}jQuery.historyCurrentHash=a;if(jQuery.browser.msie){var d=$("#jQuery_history")[0],c=d.contentWindow.document;c.open();c.close();c.location.hash=a;jQuery.historyCallback(b)}else if(jQuery.browser.safari){jQuery.dontCheck=true;this.historyAddHistory(b);var e=function(){jQuery.dontCheck=false};window.setTimeout(e,200);jQuery.historyCallback(b);location.hash=a}else jQuery.historyCallback(b)}})
