(function(a){})(window.jQuery);$(document).ready(function(){var a=$("#background"),b=document.location.hash,c=a.find(".bg-image"),d=a.find(".bg-image-info"),e=".section-image",f=a.find(".loading"),g=$("h1#logo"),h=$("#wrapper"),i=$("#content"),j=$("#footer"),k=i.find("nav ol"),l=i.find("section"),m=new Array(template_path+"assets/img/sub-nav-bg-farright.png",template_path+"assets/img/sub-nav-bg-double.png",template_path+"assets/img/sub-nav-bg-left.png",template_path+"assets/img/sub-nav-bg-right.png",template_path+"assets/img/sub-nav-bg.png");m.push(c.attr("src"));var n=function(){var a=function(){if(screen.width>320){l.each(function(a){m.push($(this).children(e).attr("src"))});o()}else{n()}y()},n=function(){f.show();$.when(A()).done(function(){$.when(p()).done(function(){f.fadeOut();$.when(h.fadeIn()).done(function(){j.fadeIn();h.find("section").each(function(){var a=$(this);$(this).find(".sub-nav li a").click(function(b){a.find(".sub-nav li").removeClass("active");$(this).parent("li").addClass("active");a.find(".sub-nav-item").hide();$($(this).attr("href")).show();b.preventDefault()});$(this).find(".sub-nav-item:first").show()});k.find("a").each(function(){$(this).bind("click",function(a){h.find("section").hide();$($(this).attr("href")).show();a.preventDefault()})})})})})},o=function(){f.show();$.when(A()).done(function(){$.when(p()).done(function(){f.hide();$.when(r()).done(function(){$.when(q()).done(function(){d.fadeIn();$.when(s("up")).done(function(){if(b){var a=k.find('a[href*="'+b+'"]');if(a.length>0){var c=$(b).find(e);var d=$(b).find(".section-content");$.when(s("down")).done(function(){v(d,c)})}}t()})})})})})},p=function(){return $.Deferred(function(a){z(c);c.fadeIn(1e3,a.resolve)}).promise()},q=function(){var a=$(window).width()-g.outerWidth(true);return $.Deferred(function(b){i.stop().animate({width:a+"px"},1e3,b.resolve)}).promise()},r=function(){return $.Deferred(function(a){g.stop().animate({marginLeft:0},500,a.resolve)}).promise()},s=function(a){return $.Deferred(function(b){l.each(function(c){var d=$('a[href="#'+$(this).attr("id")+'"]'),e,f,g;if(a==="up"){e="0px";f=1;g="easeOutBack"}else if(a==="down"){e="60px";f=0;g="easeInBack"}d.stop().animate({marginTop:e,opacity:f},200+c*200,g,function(){if(c===l.length-1)b.resolve()})})}).promise()},t=function(){l.each(function(a){var b=$(this),c=$('a[href="#'+$(this).attr("id")+'"]'),d=b.find(e),f=b.find(".section-content"),g=f.find(".sub-nav-item"),h=b.find(".sub-nav"),i=f.find(".close");c.bind("click.Menu",function(a){location.assign($(this).attr("href"));$.when(s("down")).done(function(){v(f,d)});return false});i.bind("click.Menu",function(a){x(f);return false});if(h.length>0){h.find("li:first").addClass("first");h.find("li:last").addClass("last");h.find("li a").bind("mouseover.Menu",function(a){$(this).parent().prev().addClass("previous-current");$(this).parent().next().addClass("next-current")});h.find("li a").bind("mouseout.Menu",function(a){$(this).parent().prev().removeClass("previous-current");$(this).parent().next().removeClass("next-current");h.find("li.active").prev().addClass("previous-current");h.find("li.active").next().addClass("next-current")});h.find("li.active").prev().addClass("previous-current");h.find("li.active").next().addClass("next-current");h.find("li a").bind("click.Menu",function(a){h.find("li.active").prev().removeClass("previous-current");h.find("li.active").next().removeClass("next-current");h.find("li.active").removeClass("active");$(this).parent().addClass("active");$(this).parent().prev().addClass("previous-current");$(this).parent().next().addClass("next-current");g.hide();$($(this).attr("href")).fadeIn();v(f,d);a.preventDefault()});u(f)}})},u=function(a){a.find(".sub-nav-item").jScrollPane({verticalGutter:20,horizontalGutter:10}).hide().first().fadeIn()},v=function(a,b){var c=a.find(".section-content-wrap").outerHeight();a.stop().animate({height:c+"px",marginTop:"-"+(Math.ceil(c/2)+20)+"px"},400,function(){if(b!="")w(b)})},w=function(a){src=a.attr("src");alt=a.attr("alt");if(c.attr("src")===src)return false;var b=alt.split(" | ");d.find("a").text(b[0]).attr("href",src).attr("title",alt);image_credit=b[1]==undefined?"":b[1];d.find("small").text(image_credit);var e=$('<img src="'+src+'" alt="'+alt+'" class="bg-image"/>');e.insertBefore(c);z(e);c.fadeOut(1e3,function(){$(this).remove();c=e});e.fadeIn(1e3)},x=function(a){a.stop().animate({height:"0px",marginTop:"0px"},200,function(){s("up")})},y=function(){$(window).bind("resize.Menu",function(a){z(c);if(screen.width>320){var b=$(window).width()-g.outerWidth(true);i.css("width",b+"px")}})},z=function(a){var b=$(window).width(),c=$(window).height(),d=c/b,e=a.width(),f=a.height(),g=f/e,h,i,j,k;if(d>g){i=c;h=c/g}else{i=b*g;h=b}a.css({width:h+"px",height:i+"px",left:(b-h)/2+"px",top:(c-i)/2+"px"})},A=function(){return $.Deferred(function(a){var b=m.length,c=0;for(var d=0;d<b;++d){$("<img/>").load(function(){++c;if(c===b)a.resolve()}).attr("src",m[d])}}).promise()};return{init:a}}();n.init();if(screen.width>320){$("a[class=lightbox], .work-grid li a").colorbox({maxWidth:"80%",maxHeight:"80%",scalePhotos:true});$(".scroll-pane").jScrollPane({verticalGutter:20,horizontalGutter:10})}$("#contact form").submit(function(a){var b=$(this);var c=580;b.find(".message").hide();$.ajax({type:"post",url:b.attr("action"),data:b.serialize(),dataType:"json",success:function(a){b.find("legend").after('<p class="message '+a.message.type+'">'+a.message.info+"</p>").hide().fadeIn();var d=b.parents(".section-content");if(a.message.type=="error"){$.each(a.errors,function(){$("[name="+this.field+"]").after('<span class="message error">'+this.error+"</span>").hide().fadeIn()});d.animate({height:c+"px"})}if(a.message.type=="success"){b.find("input[type=text],input[type=email],textarea").val("")}}});a.preventDefault()})})
