(function(b){var a;a=b.fn.galleria=function(e){if(!a.hasCSS()){return false}b.historyInit(a.onPageLoad);var j={insert:".galleria_container",history:true,clickNext:true,onImage:function(l,k,i){},onThumb:function(i){}};var f=b.extend(j,e);for(var h in f){b.galleria[h]=f[h]}var d=(b(f.insert).is(f.insert))?b(f.insert):jQuery(document.createElement("div")).insertBefore(this);var c=b(document.createElement("div")).addClass("galleria_wrapper");var g=b(document.createElement("span")).addClass("caption");d.addClass("galleria_container").append(c).append(g);return this.each(function(){b(this).addClass("galleria");b(this).children("li").each(function(q){var m=b(this);var k=b.meta?b.extend({},f,m.data()):f;k.clickNext=b(this).is(":only-child")?false:k.clickNext;var p=b(this).find("a").is("a")?b(this).find("a"):false;var l=b(this).children("img").css("display","none");var r=p?p.attr("href"):l.attr("src");var o=p?p.attr("title"):l.attr("title");var n=new Image();if(k.history&&(window.location.hash&&window.location.hash.replace(/\#/,"")==r)){m.siblings(".active").removeClass("active");m.addClass("active")}b(n).load(function(){b(this).attr("alt",l.attr("alt"));var t=p?p.find("img").addClass("thumb noscale").css("display","none"):l.clone(true).addClass("thumb").css("display","none");if(p){p.replaceWith(t)}if(!t.hasClass("noscale")){var i=Math.ceil(l.width()/l.height()*m.height());var s=Math.ceil(l.height()/l.width()*m.width());if(i<s){t.css({height:"auto",width:m.width(),marginTop:-(s-m.height())/2})}else{t.css({width:"auto",height:m.height(),marginLeft:-(i-m.width())/2})}}else{window.setTimeout(function(){t.css({marginLeft:-(t.width()-m.width())/2,marginTop:-(t.height()-m.height())/2})},1)}t.attr("rel",r);t.attr("title",o);t.click(function(){b.galleria.activate(r)});t.hover(function(){b(this).addClass("hover")},function(){b(this).removeClass("hover")});m.hover(function(){m.addClass("hover")},function(){m.removeClass("hover")});m.prepend(t);t.css("display","block");k.onThumb(jQuery(t));if(m.hasClass("active")){b.galleria.activate(r)}l.hide()}).error(function(){m.html('<span class="error" style="color:red">Error loading image: '+r+"</span>")}).attr("src",r)})})};a.nextSelector=function(c){return b(c).is(":last-child")?b(c).siblings(":first-child"):b(c).next()};a.previousSelector=function(c){return b(c).is(":first-child")?b(c).siblings(":last-child"):b(c).prev()};a.hasCSS=function(){b("body").append(b(document.createElement("div")).attr("id","css_test").css({width:"1px",height:"1px",display:"none"}));var c=(b("#css_test").width()!=1)?false:true;b("#css_test").remove();return c};a.onPageLoad=function(f){var d=b(".galleria_wrapper");var e=b('.galleria img[rel="'+f+'"]');if(f){if(b.galleria.history){window.location=window.location.href.replace(/\#.*/,"")+"#"+f}e.parents("li").siblings(".active").removeClass("active");e.parents("li").addClass("active");var c=b(new Image()).attr("src",f).addClass("replaced");d.empty().append(c);d.siblings(".caption").text(e.attr("title"));b.galleria.onImage(c,d.siblings(".caption"),e);if(b.galleria.clickNext){c.css("cursor","pointer").click(function(){b.galleria.next()})}}else{d.siblings().andSelf().empty();b(".galleria li.active").removeClass("active")}b.galleria.current=f};b.extend({galleria:{current:"",onImage:function(){},activate:function(c){if(b.galleria.history){b.historyLoad(c)}else{a.onPageLoad(c)}},next:function(){var c=b(a.nextSelector(b('.galleria img[rel="'+b.galleria.current+'"]').parents("li"))).find("img").attr("rel");b.galleria.activate(c)},prev:function(){var c=b(a.previousSelector(b('.galleria img[rel="'+b.galleria.current+'"]').parents("li"))).find("img").attr("rel");b.galleria.activate(c)}}})})(jQuery);jQuery.extend({historyCurrentHash:undefined,historyCallback:undefined,historyInit:function(d){jQuery.historyCallback=d;var c=location.hash;jQuery.historyCurrentHash=c;if(jQuery.browser.msie){if(jQuery.historyCurrentHash==""){jQuery.historyCurrentHash="#"}$("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');var a=$("#jQuery_history")[0];var b=a.contentWindow.document;b.open();b.close();b.location.hash=c}else{if($.browser.safari){jQuery.historyBackStack=[];jQuery.historyBackStack.length=history.length;jQuery.historyForwardStack=[];jQuery.isFirst=true}}jQuery.historyCallback(c.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 a=$("#jQuery_history")[0];var d=a.contentDocument||a.contentWindow.document;var f=d.location.hash;if(f!=jQuery.historyCurrentHash){location.hash=f;jQuery.historyCurrentHash=f;jQuery.historyCallback(f.replace(/^#/,""))}}else{if($.browser.safari){if(!jQuery.dontCheck){var b=history.length-jQuery.historyBackStack.length;if(b){jQuery.isFirst=false;if(b<0){for(var c=0;c<Math.abs(b);c++){jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop())}}else{for(var c=0;c<b;c++){jQuery.historyBackStack.push(jQuery.historyForwardStack.shift())}}var e=jQuery.historyBackStack[jQuery.historyBackStack.length-1];if(e!=undefined){jQuery.historyCurrentHash=location.hash;jQuery.historyCallback(e)}}else{if(jQuery.historyBackStack[jQuery.historyBackStack.length-1]==undefined&&!jQuery.isFirst){if(document.URL.indexOf("#")>=0){jQuery.historyCallback(document.URL.split("#")[1])}else{var f=location.hash;jQuery.historyCallback("")}jQuery.isFirst=true}}}}else{var f=location.hash;if(f!=jQuery.historyCurrentHash){jQuery.historyCurrentHash=f;jQuery.historyCallback(f.replace(/^#/,""))}}}},historyLoad:function(d){var e;if(jQuery.browser.safari){e=d}else{e="#"+d;location.hash=e}jQuery.historyCurrentHash=e;if(jQuery.browser.msie){var a=$("#jQuery_history")[0];var c=a.contentWindow.document;c.open();c.close();c.location.hash=e;jQuery.historyCallback(d)}else{if(jQuery.browser.safari){jQuery.dontCheck=true;this.historyAddHistory(d);var b=function(){jQuery.dontCheck=false};window.setTimeout(b,200);jQuery.historyCallback(d);location.hash=e}else{jQuery.historyCallback(d)}}}});$(document).ready(function(){$("ul.gallery").galleria({history:false,clickNext:true,insert:"#mainimg",onImage:function(g,e,d){g.css("display","none").fadeIn(1000);e.css("display","none").fadeIn(1000);var f=d.parents("li");f.siblings().children("img.selected").fadeTo(500,0.5);d.fadeTo("fast",1).addClass("selected");g.attr("title","Next image >>")},onThumb:function(d){var f=d.parents("li");var e=f.is(".active")?"1":"0.5";d.css({display:"none",opacity:e}).fadeIn(1500);d.hover(function(){d.fadeTo("fast",1)},function(){f.not(".active").children("img").fadeTo("fast",0.5)})}});function b(){$.galleria.next();gtimer=setInterval("$.galleria.next()",3000)}function c(){clearInterval(gtimer);delete gtimer}function a(){if(typeof(gtimer)=="undefined"){b();document.getElementById("autoplay").innerHTML="Pause";$("#autoplay").css("background","url(/img/pause.png) no-repeat top left");this.blur()}else{c();document.getElementById("autoplay").innerHTML="Auto-play";$("#autoplay").css("background","url(/img/listing.png) no-repeat -10px -10.5px");this.blur()}return false}(function(d){d.fn.jFav=function(j){var i=d.extend({},d.fn.jFav.defaults,j);var h=i.msg;this.each(function(){if(!d(this).attr("href")||d(this).attr("href")=="#"){d(this).attr("href",window.location.href)}if(!d(this).attr("title")){d(this).attr("title",document.title)}if(d.browser.opera){d(this).attr("link",d(this).attr("href")).attr("href","").attr("href","javascript:void(0)").attr("onClick",'$.fn.jFav.OperaBookmark(this,"'+d(this).attr("title")+'","'+d(this).attr("link")+'")')}else{d(this).click(g)}});function g(f){var e=d(this).attr("href");var k=d(this).attr("title");e=e.replace("file:///","http://file/");if(d.browser.msie){window.external.AddFavorite(e,k)}else{if(d.browser.mozilla){window.sidebar.addPanel(k,e,"")}else{if(navigator.userAgent.toLowerCase().indexOf("chrome")>-1){alert(h)}else{if(d.browser.safari){alert(h)}}}}f.preventDefault()}return this};d.fn.jFav.defaults={msg:'Press "Ctrl + D" or "CMD + D" for MAC, to add this page to your bookmarks.'};d.fn.jFav.OperaBookmark=function(h,g,f){h.rel="sidebar";h.title=g;h.href="";h.href=f;h.click();return false}})(jQuery);$("#autoplay").click(a);$("#bookmark").jFav();$("#print").click(function(){window.print();return false})});
