var JOINT=JOINT||{};JOINT.Bootstrap=new function(){this.init=function(){a();d();b();c()};function a(){$("a[rel=external]").attr("target","_blank")}function d(){if(typeof JOINT.Header!=="undefined"){JOINT.Header.init()}}function b(){if(typeof JOINT.Menu!=="undefined"){JOINT.Menu.init()}}function c(){$(document).click(function(e){JOINT.Menu.deselect()})}};$(document).ready(function(a){JOINT.Bootstrap.init()});var JOINT=JOINT||{};JOINT.Homepage=new function(){this.initialize=function(){var d={url:VIDEO_PLAYER_JSON,beforeSend:b,error:a,success:c};JOINT.Webservice.broadcast(d)};function b(){}function a(d,f,e){}function c(d){JOINT.Videoplayer.initialize({autoPlay:false,autoNext:false,closeable:false,controllable:false,data:d,information:false,mode:"auto",width:950,height:534})}};$(document).ready(function(a){if($("#homepage").length===0||IS_MOBILE){return}JOINT.Homepage.initialize()});var JOINT=JOINT||{};JOINT.Casestudies=new function(){var d;var f;var b=false;this.initialize=function(){var h={url:VIDEO_PLAYER_JSON,beforeSend:e,error:c,success:g};JOINT.Casestudies.Menu.initialize();if(IS_MOBILE){return}JOINT.Webservice.broadcast(h);JOINT.Casestudies.Project.initialize()};this.displayVideo=function(h){d=h;$("#project-controls").fadeOut(250,"easeOutQuint");$(".project-list").fadeOut(250,"easeOutQuint",a)};this.hideVideo=function(){$("#player").hide();$("#project-controls").fadeIn(250,"easeOutQuint");$(".project-list").fadeIn(250,"easeOutQuint")};function e(){}function c(h,j,i){}function g(h){f=h;b=true;if(d!==undefined){d.data=h;JOINT.Videoplayer.initialize(d)}}function a(){$("#player").show();if(b){d.data=f;JOINT.Videoplayer.initialize(d)}}};JOINT.Casestudies.Menu=(function(){var c={};var g="client";var l="featured";var e;c.initialize=function(){$(".button-all").click(j);$("a.sort-featured","#project-controls").click(i);$("a.sort-client","#project-controls").click(k);d()};function j(n){n.preventDefault();var m={autoPlay:true,autoNext:true,mode:"auto",width:790,height:444,current:0,closeable:true,controllable:true,information:true};JOINT.Casestudies.displayVideo(m)}function d(){e=[];$("li",".project-list").each(function(){var m=$(this),n={};n.id=m.attr("id");n.featured=parseInt(m.data("featured"),10);n.client=m.data("client");e.push(n)})}function k(m){m.preventDefault();a(g)}function i(m){m.preventDefault();a(l)}function a(q){var p=$(".project-list");var n;$(".last",".project-list").removeClass("last");d();f(q);n=$('<ul class="project-list clearfix">');for(var m=0;m<e.length;m++){var o=$("#"+e[m]["id"],p);if(m%3===2){o.attr("class","last")}n.append(o)}p.replaceWith(n)}function f(m){switch(m){case g:e.sort(h);break;case l:e.sort(b);break}}function h(o,n){var m=o.client.toLowerCase(),p=n.client.toLowerCase();if(m<p){return -1}if(m>p){return 1}return 0}function b(o,n){var m=parseInt(o.featured,10),p=parseInt(n.featured,10);if(m>p){return 1}if(m<p){return -1}return 0}return c}());JOINT.Casestudies.Project=new function(){this.initialize=function(){$("a",".project-list li").click(a).clearQueue().mouseenter(c).clearQueue().mouseleave(b)};function a(e){e.preventDefault();var f=$(this).parent().data("featured");var d={autoPlay:true,autoNext:false,closeable:true,controllable:true,current:f,mode:"auto",width:790,height:444};JOINT.Casestudies.displayVideo(d)}function c(d){$(".overlay",this).fadeIn(300,"easeOutSine")}function b(d){$(".overlay",this).fadeOut(300,"easeOutSine")}};$(document).ready(function(a){if($("#casestudies").length===0){return}JOINT.Casestudies.initialize()});var JOINT=JOINT||{};JOINT.Browser=new function(){var a=navigator.userAgent;this.isChrome=function(){return a.match(/chrome/i)?true:false};this.isFirefox=function(){return a.match(/firefox/i)?true:false};this.isOpera=function(){return a.match(/opera/i)?true:false};this.isSafari=function(){return a.match(/safari/i)?!(this.isChrome()):false};this.supportsFlash=function(){return swfobject.hasFlashPlayerVersion("9.0.45")};this.supportsVideo=function(){return !!document.createElement("video").canPlayType}};var JOINT=JOINT||{};JOINT.Tracking=new function(){this.trackEvent=function(d,e,a,c){try{_gaq.push(["_trackEvent",d,e,a,c])}catch(b){}};this.trackPage=function(b){try{_gaq.push(["_trackPageview",b])}catch(a){}}};var JOINT=JOINT||{};JOINT.Webservice=new function(){this.broadcast=function(b){a(b)};function a(b){$.ajax({type:b.type||"get",url:b.url,dataType:b.dataType||"json",beforeSend:function(){if(typeof b.beforeSend==="function"){b.beforeSend()}},error:function(c,e,d){if(typeof b.error==="function"){b.error(c,e,d)}},success:function(c){if(typeof b.success==="function"){b.success(c)}}})}};var JOINT=JOINT||{};JOINT.Header=new function(){var f=$(".button-expand");var e=$("#header-border");var b=$("#about");var a=false;var d={expandClickHandler:function(g){g.preventDefault();if(!a){JOINT.Header.expand()}else{JOINT.Header.collapse()}if(JOINT.Videoplayer.getVideo()){JOINT.Videoplayer.pause()}},expandMouseoverHandler:function(g){f.addClass("selected");e.addClass("selected")},expandMouseoutHandler:function(g){if(!a){f.removeClass("selected");e.removeClass("selected")}}};this.init=function(){f.click(d.expandClickHandler).mouseover(d.expandMouseoverHandler).mouseout(d.expandMouseoutHandler)};this.expand=function(){if(!a){c();a=true}};this.collapse=function(){if(a){c();a=false}};this.autoCollapse=function(){if(a){this.collapse();f.removeClass("selected");e.removeClass("selected")}};this.isExpanded=function(){return(a===true?true:false)};function c(){b.animate({height:"toggle",opacity:1},450,"easeInOutQuint")}};var JOINT=JOINT||{};JOINT.Menu=new function(){var f=0;var d;var b;var i;var e=false;var a;var h;var g={menuItemClickHandler:function(l){l.preventDefault();l.stopPropagation();h=$(this).parent().index();if(JOINT.Header.expanded){JOINT.Header.toggleExpansion()}k($(this))},menuDropdownClickHandler:function(l){l.stopPropagation()}};this.init=function(){d=$("#menu");b=$("a","#menu");i=$("#menu-dropdown");b.click(g.menuItemClickHandler);i.click(g.menuDropdownClickHandler)};this.deselect=function(){$("a.selected",d).removeClass("selected");e=false;c()};function k(l){if(l.hasClass("selected")){b.removeClass("selected");e=false}else{$("a.selected",d).removeClass("selected");l.addClass("selected");e=true}c()}function j(){var l=$(".container",i).eq(h).outerHeight(true);return l}function c(){if(e){$(".container",i).eq(a).fadeOut(250,"easeInOutQuint");$(".container",i).eq(h).delay(150).fadeIn(250,"easeInOutQuint");JOINT.Header.autoCollapse();i.animate({height:j()},500,"easeInOutQuint")}else{i.animate({height:f},500,"easeInOutQuint",function(){$(".container",this).hide()})}a=h}};var JOINT=JOINT||{};JOINT.Videoplayer=new function(){var q="stateEnd";var f="stateEnter";var p="stateLeave";var B="stateMove";var l="statePause";var I="statePlay";var w={autoPlay:false,autoNext:true,closeable:false,controllable:true,current:0,data:[],information:true,mode:"auto",width:790,height:444};var u=$(document);var O=$("#player");var c=$("#player-poster");var m=$("#embed-container");var K=$("#player-controls");var E=$(".button-play");var j=$("#player-gutter");var i=false;var n=0;var N=null;var b=null;var G;var e={posterClickHandler:function(R){R.preventDefault();c.hide();JOINT.Videoplayer.play()},closeClickHandler:function(R){R.preventDefault();JOINT.Videoplayer.pause();JOINT.Casestudies.hideVideo()},nextClickHandler:function(R){R.preventDefault();JOINT.Videoplayer.navigateToNext()},previousClickHandler:function(R){R.preventDefault();JOINT.Videoplayer.navigateToPrevious()},playClickHandler:function(R){R.preventDefault();c.hide();JOINT.Videoplayer.togglePlay()}};this.initialize=function(R){w=$.extend(w,R);if(!i){r();y();M();h();C();i=true}else{this.load()}};this.getOptions=function(){return w};this.getVideo=function(){var S;try{S=document.getElementById("video")}catch(R){S=swfobject.getObjectById("video")}return S};this.getVideoCurrentTime=function(){return this.getVideo().currentTime};this.setVideoCurrentTime=function(R){this.getVideo().currentTime=R};this.getVideoDuration=function(){return this.getVideo().duration};this.getVideoPaused=function(){return this.getVideo().paused};this.getVideoEnded=function(){return this.getVideo().ended};this.navigateTo=function(R){if(R>w.data.length&&w.data.length<=1){return}this.pause();this.load()};this.navigateToNext=function(S){if(S){if(!w.autoNext){c.show();return}}var R=(w.current+1)%w.data.length;w.current=R;this.navigateTo(w.current)};this.navigateToPrevious=function(){var R=(w.current-1);if(R<0){R=w.data.length+R}w.current=R;this.navigateTo(w.current)};this.load=function(){M();C();h()};this.pause=function(){if(this.getVideo()){this.getVideo().pause()}};this.play=function(){this.getVideo().play()};this.togglePlay=function(){if(this.getVideoPaused()||this.getVideoEnded()){this.getVideo().play()}else{this.getVideo().pause()}};this.seek=function(S){try{this.setVideoCurrentTime(S)}catch(R){}};function r(){if(w.closeable){$close=$('<a href="#" class="button-close ir">Close</a>').appendTo(O);$close.click(e.closeClickHandler)}if(w.controllable&&w.data.length>1){$next=$('<a href="#" class="button-next ir">Next</a>').appendTo(O);$previous=$('<a href="#" class="button-previous ir">Previous</a>').appendTo(O);$next.click(e.nextClickHandler);$previous.click(e.previousClickHandler)}}function y(){E.click(e.playClickHandler);$("body").mousemove(s);c.click(e.posterClickHandler);j.mousedown(a)}function M(){if(w.autoPlay){c.hide()}else{c.show()}if(N===null){N=$(new Image());c.append(N)}N.attr("src",w.data[w.current].image)}function h(){m.empty();if(JOINT.Browser.supportsVideo()&&(w.mode==="auto"||w.mode==="html5")){b=document.createElement("video");b.id="video";b.width=w.width;b.height=w.height;b.autoplay=w.autoPlay;b.preload="auto";source=document.createElement("source");source.src=w.data[w.current].video+".webm";source.type="video/webm";b.appendChild(source);source=document.createElement("source");source.src=w.data[w.current].video+".mp4";source.type="video/mp4";b.appendChild(source);source=document.createElement("source");source.src=w.data[w.current].video+".ogv";source.type="video/ogg";b.appendChild(source);m.append(b);b.addEventListener("click",F,false);b.addEventListener("ended",L,false);b.addEventListener("pause",P,false);b.addEventListener("play",k,false);b.addEventListener("seeked",A,false);b.addEventListener("timeupdate",D,false);b.load()}else{if(JOINT.Browser.supportsFlash()&&(w.mode==="auto"||w.mode==="flash")){K.remove();var S={};S.autoPlay=w.autoPlay;S.video=w.data[w.current].video+".mp4";S.width=w.width;S.height=w.height;S.assetFactory=VIDEO_PLAYER_FLASH_ASSET;var U={};U.allowscriptaccess="always";U.bgcolor="#000000";U.menu=false;U.wmode="transparent";var T={};T.id="video";T.name="video";var R=$(document.createElement("div"));R.attr("id","videoplayer-temp");m.append(R);swfobject.embedSWF(VIDEO_PLAYER_FLASH,R.attr("id"),w.width,w.height+35,"9.0.45",null,S,U,T)}else{G='<div class="error">';G+='<div class="icon-warning"><span>Warning</span></div>';G+='<div class="message">This content requires enabling Adobe Flash. Get the player here: <a href="http://get.adobe.com/flashplayer" target="_blank">http://get.adobe.com/flashplayer</a></div>';G+="</div>";m.html(G)}}}function C(){if(w.information){var T=w.data[w.current];$(".title",".information").html(T.title);var R=$("<ul>");var S;$.each(T,function(U,V){S=$(document.createElement("li"));if(U.toLowerCase()==="client"&&T[U]!=null){S.html("<em>Client:</em> "+T[U]);R.append(S)}if(U.toLowerCase()==="office"&&T[U]!=null){S.html("<em>Office:</em> "+T[U]);R.append(S)}if(U.toLowerCase()==="credits"){$.each(V,function(W){S=$(document.createElement("li"));S.html("<em>"+V[W].role+":</em> "+V[W].name);R.append(S)})}});$("ul",".information").replaceWith(R)}}function z(){n=setInterval(t,2000)}function g(){if(n!==null){clearInterval(n);n=null}}function F(R){JOINT.Videoplayer.togglePlay()}function L(R){J(q);if(w.autoNext&&w.data.length>1){JOINT.Videoplayer.navigateToNext()}else{c.show()}}function P(R){J(l)}function k(R){J(I)}function A(R){J(I)}function D(S){var R=JOINT.Videoplayer.getVideoCurrentTime()/JOINT.Videoplayer.getVideoDuration()*100;if(R<=0){R=0}if(R>=100){return}v(R)}function t(){J(p)}function o(R){J(f)}function x(R){J(p)}function s(R){J(B)}function a(R){Q(R);u.bind("mousemove",d).bind("mouseup",H);JOINT.Videoplayer.pause()}function d(R){Q(R)}function H(R){u.unbind("mousemove",d).unbind("mouseup",H);JOINT.Videoplayer.play()}function J(R){switch(R){case"stateEnd":$("span","a.button-play").html("Play");$("#player-controls, .button-close, .button-next, .button-previous").fadeIn(250);break;case"stateEnter":$("#player-controls, .button-close, .button-next, .button-previous").fadeIn(250);break;case"stateLeave":g();$("#player-controls, .button-close, .button-next, .button-previous").fadeOut(250);break;case"stateMove":g();z();$("#player-controls, .button-close, .button-next, .button-previous").fadeIn(250);break;case"statePause":$("span","a.button-play").html("Play");break;case"statePlay":$("span","a.button-play").html("Pause");break;default:break}}function Q(S){var R=S.pageX-$("#player-gutter").offset().left;var T=JOINT.Videoplayer.getVideoDuration()*(R/$("#player-gutter").width());JOINT.Videoplayer.seek(T)}function v(R){$("#player-progress").css("width",R+"%")}};
