(function(){var a=function(b,c){return function(){return b.apply(c,arguments)}};this.hostURL="http://ea.dev.xib.ca";this.baseURL="http://www.eaphoto.ca/mk2/";this.pathAdjuster="mk2/";window.callbackCount=0;window.callbacks={};this.getList=function(e,f){var c,d,b;c="json_list.php";d="callback_"+(window.callbackCount++);window.callbacks[d]=f;b="";$H(e).each(function(g){return b+=""+(encodeURI(g.key))+"="+(encodeURI(g.value))+"&"});return $("let_ie_find_body").insert(new Element("script",{src:""+baseURL+"/"+c+"?callback=callbacks."+d+"&"+b,type:"text/javascript"}))};this.setSectionTo=function(d,b){var c;window.section=d;window.subSection=b;window.slideshowCount=1;if(!(d==="us"&&b==="contact")){$$(".contact_view").first().hide()}if(!(d==="us"&&b==="friends")){$$(".friends_view").first().hide()}c=$$(".thumb_drawer .toggle_slideshow").first();c.addClassName("paused");if(d==="home"&&b==="default"){c.removeClassName("paused")}if(d==="us"&&b==="about"){c.removeClassName("paused")}return document.body.className="section-"+(d.sub(/^\d\d-/,"").gsub(/\W/,"_").toLowerCase())};Event.observe(window,"resize",function(){return centerImage()});Event.observe(window,"load",function(){return setTimeout(a(function(){var c,b;b=window.location.hash.sub(/^#/,"");c=$$('a[href="'+b+'"]').first();if(c!=null){return c.fire("route:fire")}},this),100)});if(less.env==="development"){less.watch()}}).call(this);(function(){this.Routes=[{route:"/gallery/show/(path:.+)",namespace:"ImageController",action:"loadGallery"},{route:"/menu/show/",namespace:"NavigationController",action:"showMenu"},{route:"/menu/show/(section:.+)",namespace:"NavigationController",action:"showMenu"},{route:"/image/show/(imageUrl:.+)",namespace:"ImageController",action:"show"},{route:"/image/next",namespace:"ImageController",action:"next"},{route:"/image/previous",namespace:"ImageController",action:"previous"},{route:"/us/contact",namespace:"NavigationController",action:"showContact"},{route:"/us/friends",namespace:"NavigationController",action:"showFriends"},{route:"/thumbs/scroll/left",namespace:"NavigationController",action:"scrollThumbsLeft"},{route:"/thumbs/scroll/right",namespace:"NavigationController",action:"scrollThumbsRight"},{route:"/slideshow/toggle",namespace:"SlideshowController",action:"toggle"}]}).call(this);(function(){var d,c,b;var a=function(e,f){return function(){return e.apply(f,arguments)}};c={};d=(function(){function e(f){var g;this.parameterNames=((g=f.route.match(/(\w+):/g))!=null?g.invoke("replace",/:/,""):void 0)||[];this.routeRegEx=new RegExp("^"+f.route.gsub(/([\w\d]+):/,"")+"$");this.silent=f.silent;this.controller=c[f.namespace]||new window[f.namespace];this.action=f.action;c[f.namespace]=this.controller}e.prototype.invoke=function(h,g,i){var j;try{j=this.parameterNames.inject({},function(k,m,l){k[m]=h[l+1];return k});j.element=g;j.matchedRoute=i;return this.controller[this.action](j)}catch(f){return console.log("Something went wrong: "+f.message+" \n source: "+f.sourceURL+" \n line: "+f.line)}};return e})();b=(function(){function e(){document.observe("click",this.doRouteWithPath.bind(this));document.observe("route:fire",this.doRouteWithPath.bind(this));this.parseRoutes()}e.prototype.parseRoutes=function(){this.routes=[];if(typeof Routes==="undefined"||Routes===null){return}return Routes.each(a(function(f){return this.routes.push(new d(f))},this))};e.prototype.doRouteWithPath=function(f){var k,l,n,g,i,m,j,h;k=f.findElement("[href]");if(k==null){return}g=k.readAttribute("href");j=this.routes;h=[];for(i=0,m=j.length;i<m;i++){n=j[i];l=g.match(n.routeRegEx);if(l){n.invoke(l,k,g);f.stop();break}}return h};e.prototype.parseRoutes=function(){this.routes=[];if(typeof Routes==="undefined"||Routes===null){return}return Routes.each(a(function(f){return this.routes.push(new d(f))},this))};return e})();Event.observe(window,"load",function(){return new b})}).call(this);(function(){var a=function(b,c){return function(){return b.apply(c,arguments)}};this.ImageController=(function(){b.prototype.imageThumbTemplate='<a href="/image/show/'+baseURL+"slir/?w1450-h900-p1/"+pathAdjuster+'{{full_path}}" style="background-image: url('+baseURL+"slir/?w55-h55-c1:1/"+pathAdjuster+'{{full_path}});"></a>';function b(){this.centerImage=a(this.centerImage,this);this.preloadImages=a(this.preloadImages,this);this.previous=a(this.previous,this);this.next=a(this.next,this);this._loadGallery=a(this._loadGallery,this);this.imagePane=$$(".image_pane")[0];this.thumbDrawer=$$(".thumb_drawer")[0];this.thumbDrawerInner=this.thumbDrawer.down(".scroller .inner");this.imageLoader=$$(".loading_wrapper")[0];this.loadGallery({path:"galleries/hidden/default/"});window.centerImage=this.centerImage;setTimeout((a(function(){return this.centerImage()},this)),500);setTimeout((a(function(){return this.centerImage()},this)),1000);setTimeout((a(function(){return this.centerImage()},this)),2500);setTimeout((a(function(){return this.centerImage()},this)),2000);setTimeout((a(function(){return this.centerImage()},this)),2500);setTimeout((a(function(){return this.centerImage()},this)),3000)}b.prototype.loadGallery=function(e){var d,c;d=e.path.split("/")[1].sub(/^\d\d-/,"");c=e.path.split("/")[2];if(d==="hidden"){this.thumbDrawer.addClassName("locked");if(c==="default"){d="home"}if(c==="about"){d="us"}}else{this.thumbDrawer.removeClassName("locked")}setSectionTo(d,c);return getList({path:e.path},this._loadGallery)};b.prototype._loadGallery=function(c){var d,e;this.thumbDrawerInner.update();c.each(a(function(f){var g;g={full_path:encodeURI(f.full_path)};return this.thumbDrawerInner.insert(Mustache.to_html(this.imageThumbTemplate,g))},this));e=this.thumbDrawerInner.down("a").getLayout().get("margin-box-width");this.thumbDrawerInner.setStyle({width:""+(e*c.length)+"px"});this.thumbDrawerInner.setStyle({left:"30px"});d=c.map(function(f){return""+baseURL+(encodeURI(f.full_path))});setTimeout((a(function(){return this.preloadImages(d)},this)),5000);return this.thumbDrawerInner.down("a").fire("route:fire")};b.prototype.next=function(e){var c,d;c=(d=this.thumbDrawerInner.down(".selected"))!=null?d.next():void 0;if(c==null){c=this.thumbDrawerInner.childElements().first()}return $(c).fire("route:fire")};b.prototype.previous=function(d){var c;c=this.thumbDrawerInner.down(".selected").previous();if(c==null){c=this.thumbDrawerInner.childElements().last()}return $(c).fire("route:fire")};b.prototype.show=function(d){var c;$$("*[href="+d.matchedRoute+"]").each(function(e){e.addClassName("selected");return e.siblings().invoke("removeClassName","selected")});this.imageLoader.addClassName("show");c=new Image();c.src=d.imageUrl;return c.observe("load",a(function(){this.centerImage();this.imagePane.setStyle({opacity:"0"});return setTimeout((a(function(){this.imagePane.src=c.src;this.centerImage();return setTimeout((a(function(){this.imageLoader.removeClassName("show");return this.imagePane.setStyle({opacity:"1"})},this)),350)},this)),350)},this))};b.prototype.preloadImages=function(c,d){var e;if(d==null){d=0}if(c.length===d){return}e=new Element("img",{src:c[d]});if(d<=3){return e.observe("load",a(function(f){return this.preloadImages(c,++d)},this))}};b.prototype.centerImage=function(){var e,d,c,g,f,j,i,h;h=document.viewport.getWidth();j=document.viewport.getHeight()-94;i=h/j;this.imagePane.setStyle({height:"auto",width:"auto"});c=this.imagePane.getHeight();f=this.imagePane.getWidth();g=f/c;if(c==null){return}d=null;e=null;if(g<i){e=j;d=e*g}else{d=h;e=d/g}return this.imagePane.setStyle({height:""+e+"px",width:""+d+"px",top:""+((j-e)/2)+"px",left:""+((h-d)/2)+"px"})};return b})()}).call(this);(function(){var a=function(b,c){return function(){return b.apply(c,arguments)}};this.NavigationController=(function(){b.prototype.menuTemplate='<div class="menu_wrapper">\n	<div class="menu">\n		{{#items}}\n			<a href="{{url}}">{{text}}</a>\n		{{/items}}\n	</div>\n</div>';function b(){this.populateGallerySectionMenu=a(this.populateGallerySectionMenu,this);this._buildGallerySections=a(this._buildGallerySections,this);this.footer=$$(".footer .footer_inner_for_map").first();this.thumbDrawer=$$(".thumb_drawer").first();this.thumbDrawerInner=this.thumbDrawer.down(".scroller .inner");this.contactView=$$(".contact_view").first();this.friendsView=$$(".friends_view").first();this.buildGallerySections()}b.prototype.buildGallerySections=function(){return getList({path:"galleries/"},this._buildGallerySections)};b.prototype._buildGallerySections=function(c){return c.reverse().each(a(function(f){var d,e;if(f.name==="hidden"){return}if(f.name.startsWith("-")){return}e=new Element("a",{href:"/menu/show/"+(f.name.sub(/^\d\d-/,""))}).update(f.name.sub(/^\d\d-/,""));this.footer.insert(e);d=this.populateGallerySectionMenu.bind(this,e);return getList({path:""+f.full_path+"/"},d)},this))};b.prototype.populateGallerySectionMenu=function(d,e){var c;c=e.map(function(f){return{text:f.name,url:"/gallery/show/"+f.full_path+"/"}});return d.writeAttribute("menu_content",Object.toJSON(c))};b.prototype.scrollThumbsBy=function(e){var c,d;if(!(this.thumbDrawerInner.getWidth()>this.thumbDrawerInner.up(".scroller").getWidth())){return}c=parseInt(this.thumbDrawerInner.getStyle("left"));d=c+e;d=Math.min(30,d);d=Math.max(-(this.thumbDrawerInner.getWidth()-this.thumbDrawerInner.up(".scroller").getWidth()-30+56),d);return this.thumbDrawerInner.setStyle({left:""+d+"px"})};b.prototype.scrollThumbsLeft=function(d){var c;c=this.thumbDrawerInner.down("a").getLayout().get("margin-box-width");return this.scrollThumbsBy(c*7)};b.prototype.scrollThumbsRight=function(d){var c;c=this.thumbDrawerInner.down("a").getLayout().get("margin-box-width");return this.scrollThumbsBy(c*7*-1)};b.prototype.showMenu=function(h){var f,c,g,e,d,i;if(h.section){document.body.className="section-"+(h.section.sub(/^\d\d-/,"").gsub(/\W/,"_").toLowerCase())}c=h.element.readAttribute("menu_content").evalJSON();if(Object.isString(c)){c=c.evalJSON()}f={items:c};document.body.insert(Mustache.to_html(this.menuTemplate,f));e=$$(".menu_wrapper").first();g=e.down(".menu");i=h.element.getLayout().toObject();d=i.left+i["margin-box-width"]/2+5;g.setStyle({left:""+(d-g.getWidth()/2)+"px"});return e.observe("click",function(j){return setTimeout(a(function(){return e.remove()},this),100)})};b.prototype.showContact=function(c){this.contactView.show();this.thumbDrawer.addClassName("locked");return setSectionTo("us","contact")};b.prototype.showFriends=function(c){this.friendsView.show();this.thumbDrawer.addClassName("locked");return setSectionTo("us","friends")};return b})()}).call(this);(function(){var a=function(b,c){return function(){return b.apply(c,arguments)}};this.SlideshowController=(function(){function b(){this.tick=a(this.tick,this);this.toggleButton=$$(".thumb_drawer .toggle_slideshow").first();this.nextButton=$$(".image_view .next").first();this.defaultTrigger=6;window.slideshowCount=1;setTimeout(this.tick,1000)}b.prototype.toggle=function(){window.slideshowCount=-5;return this.toggleButton.toggleClassName("paused")};b.prototype.tick=function(){var c;c=this.defaultTrigger;if(section==="us"&&subSection==="about"){c=30}if(slideshowCount%c===0&&slideshowCount!==0){if(!this.toggleButton.hasClassName("paused")){this.nextButton.fire("route:fire")}}slideshowCount++;return setTimeout(this.tick,1000)};return b})()}).call(this);
