(function(a){a.fn.extend({externalHref:function(){return this.find("a[href^='http://']").each(function(){this.target="_blank"})},fixed:function(b){var c={delay:100,easing:"easeOutQuad",duration:300},d=a.extend({},c,b),e=a(window);return this.each(function(){function g(){var a=b.outerHeight(true)<=e.height()?e.scrollTop():0;b.animate({top:a},{duration:d.duration,easing:d.easing,queue:false})}function f(){clearTimeout(c);c=setTimeout(g,d.delay)}var b=a(this),c;e.bind("resize scroll",f)})},top:function(b){var c={duration:500,easing:"easeOutQuad"},d=a.extend({},c,b),e=a(window);return this.each(function(){function c(){var a=e.scrollTop()?1:0;b.stop().fadeTo("slow",a)}var b=a(this);e.bind("resize scroll",c);b.css("cursor","pointer");b.bind("click",function(){a("html").stop().animate({scrollTop:0},{duration:d.duration,easing:d.easing,queue:false})});c()})}});a.fn.Html=function(){a(this).externalHref();a("#header").fixed();if(!a("html").hasClass("touch")){a(".top").top();a(".qtip[title]").qtip({style:{padding:5,background:"#000",color:"#fff",textAlign:"center",border:{width:0,radius:0,color:"#000"},name:"dark","font-family":"times","font-style":"italic","font-size":13,tip:true},position:{corner:{target:"bottomRight",tooltip:"topLeft"}},show:{delay:0,effect:{type:"fade"}},hide:{effect:{type:"fade"},when:{event:"mouseleave click"}}})}return a(this)};a.fn.Page=function(){var b=a(this),c=b.find(".images");if(b.length>0&&c.length>0){c.css("cursor","pointer");c.cycle({timeout:5e3,fx:"scrollHorz",speed:"slow",next:".images"});if(a("html").hasClass("touch")){c.touchwipe({wipeLeft:function(){c.cycle("next")},wipeRight:function(){c.cycle("prev")}})}else{a(window).bind("keyup",function(a){switch(a.keyCode){case 37:c.cycle("prev");break;case 39:c.cycle("next");break}})}}return a(this)};a.fn.Projects=function(){function n(b){if(a("html").hasClass("history")){if(typeof window.history.pushState==="function"){window.history.pushState(null,null,"/")}}d.removeClass("inactive");var c=b?0:h;g.removeClass("active").find(".work-view-container").stop().fadeTo(c,0,function(){g.find(".work-view-content").html("")})}function m(b){if(a("html").hasClass("history")){if(typeof window.history.pushState==="function"){window.history.pushState(null,null,b)}}d.addClass("inactive");g.addClass("active");g.addClass("loading");g.find(".work-view-content").html("").load(b,function(a,b,c){if(b==="success"){g.removeClass("loading");g.find(".work-view-container").stop().fadeTo(h,1,function(){g.find(".work").Work()})}else if(b==="error"){}})}function l(b){a("html").stop().animate({scrollTop:b},"slow","easeOutQuint")}function k(){g.find(".close").bind("click",function(){n();return false})}function j(){if(d.length>0){var c=d.vgrid({easeing:"easeOutQuint",time:400,delay:0,fadeIn:{time:400,delay:200}});e.css("cursor","pointer");if(!a("html").hasClass("touch")){e.bind("mouseenter",function(){if(!g.hasClass("active")){var c=a(this).offset();var d=c.top-5;b.stop().animate({top:d},400,"easeOutQuint");b.find(".work-view-sign").css("visibility","visible");a(this).animate({backgroundColor:"#dd0041"},{duration:300,queue:false})}});e.bind("mouseleave",function(){a(this).animate({backgroundColor:"#000"},{duration:300,queue:false})})}e.bind("click",function(){n(true);var c=a(this).offset();var d=c.top-5;l(d);b.stop().css({top:d});var e=a(this).find("h3 a").attr("href");m(e);_gaq.push(["_trackEvent","Project","Click",e]);return false})}}function i(){c.News(j);k()}var b=a(this).find(".work-view"),c=a(this).find(".news"),d=a(this).find(".works"),e=d.find(".works-item"),f=a(this).find(".pagination"),g=a(this).find(".work-view"),h=400;i();return a(this)};a.fn.News=function(b){function g(){if(typeof b=="function"){b.call(this)}}var c=a(this),d=c.height(),e=c.find(".close"),f=c.find(".news-container");$newsContent=c.find(".news-content");$newsElements=c.find(".news-elements");$newsPager=c.find(".news-pager");if(c.length>0){$newsElements.cycle({timeout:1e4,fx:"scrollHorz",speed:"slow",pager:$newsPager});if(a("html").hasClass("touch")){$newsElements.touchwipe({wipeLeft:function(){$newsElements.cycle("next")},wipeRight:function(){$newsElements.cycle("prev")}})}else{a(window).bind("keyup",function(a){if(f.hasClass("open")){switch(a.keyCode){case 37:$newsElements.cycle("prev");break;case 39:$newsElements.cycle("next");break}}})}e.bind("click",function(){if(f.hasClass("open")){f.removeClass("open");$newsContent.stop().hide();f.stop().animate({height:"40px"},"slow","easeOutQuint",function(){var a=e.qtip("api");a.updateContent(e.attr("data-label-open"));e.html(e.attr("data-label-open"))})}else{f.addClass("open");f.stop().animate({height:d},"slow","easeOutQuint",function(){$newsContent.stop().fadeTo("fast",1);var a=e.qtip("api");a.updateContent(e.attr("data-label-close"));e.html(e.attr("data-label-close"))})}return false});c.slideDown("fast",function(){g()})}else{g()}return a(this)};a.fn.Work=function(){var b=a(this),c=b.find(".movie"),d=a(this).find(".text-container");if(b.length>0){b.externalHref();if(c.length>0){c.find("iframe").each(function(b){var c=a(this);var d=c.attr("width");var e=c.attr("height");var f=649;var g=Math.round(f*e/d);c.attr("width",f);c.attr("height",g)})}if(d.length>0){var e=d.find(".text-toggle-button");var f=d.find(".text");e.css("cursor","pointer");e.bind("click",function(){if(d.hasClass("open")){f.stop().slideUp("fast",function(){d.removeClass("open")})}else{d.addClass("open");f.stop().slideDown("fast")}})}}return a(this)}})(jQuery);$(function(){$("html").Html();$(".page").Page();$(".projects").Projects();$(".work").Work()})
