text: $(function(){function a(){function a(){var a=1020;0===$("#c-region-map").length&&d3.json("data/d3/Vicinity_20171109_v5.geojson",function(b){M=b;var c=d3.select("#c-county-map").append("svg").attr("width",e).attr("height",a).attr("id","c-region-map"),d=c.append("g").attr("width",e).attr("height",a).attr("id","counties"),f=c.append("g").attr("width",e).attr("height",a).attr("id","cty_labels_outlines"),g=c.append("g").attr("width",e).attr("height",a).attr("id","cty_labels"),h=d3.geo.mercator().scale(1).translate([0,0]).precision(0),i=d3.geo.path().projection(h),j=i.bounds(b),k=1/Math.max((j[1][0]-j[0][0])/e,(j[1][1]-j[0][1])/a),l=[(e-k*(j[1][0]+j[0][0]))/2,(a-k*(j[1][1]+j[0][1]))/2];h.scale(k).translate(l),d.selectAll("path").data(b.features).enter().append("path").attr("d",i).attr("id",function(a){return"c-"+a.properties.NAME.toLowerCase()}).attr("class","county_outlines").on("mouseover",function(){var a=d3.select(this);a.transition().duration(250).style("fill-opacity","0.8"),a.style("stroke-width","5px")}).on("mouseout",function(){d3.select(this).transition().delay(5).style("stroke-width","2px").style("fill-opacity","1")}).on("click",function(){$("#c-county-prompt").hide();var a=d3.select(this).attr("id").split("-");S=a[1],R=Z[S],window.location.hash="region/"+S+"/"+T});f.selectAll("text").data(b.features).enter().append("text").attr("class","c-county-label-outline").attr("transform",function(a){return"translate("+i.centroid(a)+")"}).text(function(a){return a.properties.NAME}),g.selectAll("text").data(b.features).enter().append("text").attr("class","c-county-label").attr("transform",function(a){return"translate("+i.centroid(a)+")"}).text(function(a){return a.properties.NAME})})}function j(a){switch(a){case"region":$(".c-nav").hide();break;case"network":$(".c-nav-left").hide(),$(".c-nav-right").show(),$("#c-nav-right-label").html("Freight Centers");break;case"freight_centers":$(".c-nav-left").show(),$(".c-nav-right").show(),$("#c-nav-left-label").html("Network"),$("#c-nav-right-label").html("Domestic Trade");break;case"domestic_trade":$(".c-nav-left").show(),$(".c-nav-right").hide(),$("#c-nav-left-label").html("Freight Centers")}}function k(){var a=$("#cty-pic-slider").width()/1.38-59;$(window).width()>=992&&$("#c-county-desc").animate({"min-height":a},500),$("#c-county-desc").html(aa[S]),$("#c-map-legend").hasClass("open")&&$("#c-map-legend").trigger("click"),$("#c-region-network-map").attr("src","lib/images/county/"+S+"_map.png").attr("alt",t(S)+" County Map"),void 0===M?d3.csv("data/d3/county_network.csv",function(a){M=a,l()}):l()}function l(){for(var a=0;a<M.length;a++)if(M[a].NAME===t(S)){var b=M[a],c=a;0===parseInt(b.portTermin)?$("#c-stat-maritime").hide():$("#c-stat-maritime").show();for(var d=0;d<_.length;d++)$(".c-data-"+_[d]).html(b[_[d]]);$(".c-image-caption").html(b.zero),$("#cty-pic-slider").removeData("flexslider"),$("#cty-pic-carousel").removeData("flexslider"),$(".c-slides").html("");for(var e=1;e<8;e++)$(".c-slides").append('<li><img src="lib/images/county/small/'+b.NAME+"/"+e+'.jpg" /></li>')}$(".loading_panel").delay(500).fadeOut("slow"),$("#c-map-legend").delay(500).fadeIn("slow"),$("#cty-pic-slider").flexslider({animation:"fade",controlNav:!1,animationLoop:!1,slideshow:!1,sync:"#cty-pic-carousel",after:function(){var a=V[$("#cty-pic-slider").data("flexslider").currentSlide];$(".c-image-caption").html(M[c][a])}}),$("#cty-pic-carousel").flexslider({animation:"slide",controlNav:!1,animationLoop:!1,slideshow:!1,itemWidth:100,itemMargin:5,asNavFor:"#cty-pic-slider"})}function m(a){return a.replace(/(?:^|\s)\w/g,function(a){return a.toUpperCase()})}function n(a){if("baja california norte"===$("county_outlines"))return a.replace(/(?:^|\s)\w/g,function(a){return a.toLowerCase()})}function o(b){S=b.length>1?b[1]:"none",T=b.length>1?b[2]:"region",R=Z[S];var d=$('#c-steps li a[data-target="c-'+T+'"] ');$(".c-step-current").find("svg.c-step-nav circle:first").attr("r",5),$(".c-step-current").find("svg.c-step-nav circle:nth-child(2)").attr("r",6),$(".c-step-current").toggleClass("c-step-current"),d.closest("li").toggleClass("c-step-current"),d.find("svg.c-step-nav circle:first").attr("r",8),d.find("svg.c-step-nav circle:nth-child(2)").attr("r",3),$(".c-region-tab").hide(),$("#c-"+T).show(),$("#c-name").html(m(S)+" County"),$("#c-name").html(n(S)),$("#c-tab").html(X[T]),j(T),"region"===T?(c=$("#c-explore-emphasis").width(),$("#c-explore-emphasis").css("width",c+"px"),U=$("#content").width(),a(),T="network",S="none",$("#c-name").html("DVRPC Region"),$("#c-explorer-block").fadeOut("slow")):"domestic_trade"===T?($(".loading_panel").show(),u()):"network"===T&&($(".loading_panel").show(),k())}function p(a,b,c){var d=0,e=window.setInterval(function(){a(),++d===c&&window.clearInterval(e)},b)}function q(){$("#c-county-prompt").hasClass("c-light")?$("#c-county-prompt").css("background-color","#312867").toggleClass("c-light"):$("#c-county-prompt").css("background-color","#7a6aa2").toggleClass("c-light")}function r(){p(q,250,10)}function s(a){function b(){c.style("stroke-width","0px"),c.transition().duration(1).attr("r",8),c.style("stroke-opacity",1)}var c=d3.select("#"+a).select("circle");setTimeout(b,351),c.style("stroke-width","1px"),c.transition().duration(348).attr("r",20),c.style("stroke-opacity",0)}function t(a){return a.charAt(0).toUpperCase()+a.slice(1)}function u(){d3.csv("data/d3/commRegions_v2.csv",function(a){d3.csv("data/d3/totalFlowsBEA.csv",function(b){d3.csv("data/d3/commodities.csv",function(c){d3.csv("data/d3/stcc.csv",function(d){d3.json("data/d3/us_states_shapes.js",function(e){da=a,ea=b,fa=c,ga=d,ha=e,"domestic_trade"===T&&v()})})})})})}function v(){if(U=$("#content").width(),0===$("#tradeMap").length){O="in",P="ton",Q="all";var a=d3.select("#content").append("svg").attr("width",U).attr("height",430).attr("id","tradeMap"),b=a.append("g").attr("width",U).attr("height",430).attr("id","states");a.append("g").attr("width",U).attr("height",430).attr("id","metros"),a.append("g").attr("width",U).attr("height",430).attr("id","temp");var c=d3.geo.path().projection(W),d=c.bounds(ha),e=(d[1][0]-d[0][0]-15)/(U-50),f=(d[1][1]-d[0][1])/430,g=e>f?900/e:900,h=e>f?e:1;K=h>1?1/h:1,L=1/h*(d[1][0]-d[0][0])/2;var i=[L,215];W.scale(g).translate(i),b.selectAll("path").data(ha.features).enter().append("path").attr("d",c).attr("class","states_outline");for(var j=[],k=[],l=0;l<ea.length;l++)j.push(parseInt(ea[l].region_id)),k.push(parseInt(ea[l].rel_region_id));j=A(j),k=A(k),ia=A(j.concat(k)),C(ia,3),G(R,O),$(".loading_panel").fadeOut("slow"),ja=!1}else $("#metros").empty(),O="in",P="ton",Q="all",C(ia,3),G(R,O),$("#radio_"+P).trigger("click"),$("#radio_"+O).trigger("click"),$("#"+Q).trigger("click"),$("#comm-in").prop("checked",!0),$("#tradeDirection").html("Inbound <span class='caret'></span>"),$("#comm-ton").prop("checked",!0),$("#tradeMeasure").html("Volume <span class='caret'></span>"),$("#comm-"+P).prop("checked",!0),$(".loading_panel").fadeOut("slow")}function w(a,b,c,d){var e,f=a,g=b,h=c,i=d,j=[];for(e=0;e<fa.length;e++){var k=fa[e];k.dir===h&&parseInt(k.region)===f&&k.mode.toLowerCase()===i&&j.push(k)}y(x(j,g))}function x(a,b){return"ton"===b?a.sort(function(a,b){return b.ton-a.ton}):a.sort(function(a,b){return b.value-a.value}),a}function y(a){function b(a){var b=j(a);"ton"===P?g.push(parseInt(a.ton)):g.push(parseInt(a.value)),f.push(b)}function c(){return d3.svg.axis().scale(q).orient("bottom").ticks(5)}function d(){return"ton"===P?"thousand tons of activity":"million dollars of activity"}function e(a){return"ton"===P?numeral(F(.001*a,2)).format("0,0"):"$ "+numeral(F(1e-6*a,2)).format("0,0")}var f=[],g=[];$("#commChart").empty().html("");var h,i=["#312A6A","#323576","#35478A","#36559A","#2E5EA5","#396ab2","#4276c2","#5584c9","#6992cf","#7ca0d5"],j=function(a){var b,c=null;for(b=0;b<ga.length;b++){var d=ga[b];parseInt(d.stcc)===parseInt(a.stcc4)&&(c=d.name)}return c};if(a.length<10)for(h=0;h<a.length;h++)I=a[h],b(I);else for(h=0;h<10;h++)I=a[h],b(I);var k=$("#topCommoditiesChart").width(),l=305,m=275,n=(l-30)/g.length,o=d3.select("#commChart").attr("width",k).attr("height",l),p=d3.scale.quantize().domain([0,f.length]).range(i),q=d3.scale.linear().range([0,k-250]).domain([0,d3.max(g)]),r=d3.scale.linear().domain([0,f.length]).range([0,m]),s=d3.svg.axis().orient("left").scale(r).ticks(f.length).tickSize(0).tickFormat(function(a,b){return f[b]});o.append("g").attr("class","x axis").attr("transform","translate(220,"+m+")").call(c().tickSize(2).tickFormat(e)),o.append("g").attr("class","grid").attr("transform","translate(220,"+m+")").style("stroke-dasharray","1, 2").call(c().tickSize(-m,0,0).tickFormat(""));o.append("g").attr("transform","translate(220,0)").attr("id","yaxis").call(s).selectAll("text").attr("y",n/2);o.append("text").attr("class","x-label").attr("text-anchor","end").attr("x",k/2+110).attr("y",l-2).text(d),o.append("g").attr("transform","translate(220, 0)").attr("id","bars").selectAll("rect").data(g).enter().append("rect").attr("transform",function(a,b){return"translate(0, "+b*n+")"}).attr("width",0).attr("height",n-2).attr("class","barTip").style("fill",function(a,b){return p(b)}).transition().delay(function(a,b){return 100*b}).duration(400).attr("width",q).attr("val",function(a,b){return a}),$(".barTip").tipsy({gravity:"n",html:!0,title:function(){var a=this.getAttribute("val");return J="ton"===P?numeral(F(.001*a,2)).format("0,0.0")+" ktons":"$ "+numeral(F(1e-6*a,2)).format("0,0.0")+" M"}})}function z(a,b){return a-b}function A(a){a=a.sort(z);var b,c=[];for(b=0;b<a.length;b++)a[b]!==a[b-1]&&c.push(a[b]);return c}function B(a){var b,c=null;for(b=0;b<da.length;b++){var d=da[b];parseInt(d.id)===parseInt(a)&&(c=d)}return c}function C(a,b){var c;d3.geo.albersUsa();for(c=0;c<a.length;c++){var d=B(a[c]);if(d){var e=W([d.lon,d.lat]);d3.select("#metros").append("g").attr("transform","translate("+Math.round(e[0])+","+Math.round(e[1])+")").attr("r",b).attr("id","metro_"+d.id).attr("class","metro related").append("circle").attr("r",b);d.id}}}function D(){$(".flowBtn").attr("disabled",!1),"bucks"===S?$("#dt-county-prev").prop("disabled",!0):"philadelphia"===S?$("#dt-county-next").prop("disabled",!0):($("#dt-county-next").prop("disabled",!1),$("#dt-county-prev").prop("disabled",!1))}function E(a,b){return"ton"===b?a.sort(function(a,b){return b.ton-a.ton}):a.sort(function(a,b){return b.val-a.val}),a}function F(a,b){return Number(Math.round(a+"e"+b)+"e-"+b)}function G(a,b,c){$(".flowBtn").attr("disabled",!0),$("#tradeList").html(""),setTimeout(D,520);var d,e=E(ea,P),f=[],g=[],h=[],j=[],k=0;for(d=0;d<e.length;d++){var l=e[d];parseInt(l.region_id)===a&&l.rel_region_id!=l.region_id&&l.dir===b&&l.mode===Q&&("ton"===P?f.push(parseInt(l.ton)):f.push(parseInt(l.val)))}g=d3.min(f),h=d3.max(f);var m=d3.scale.pow().exponent(.6).domain([g,h]).range([2,35*K]);d3.select("#metros .sel_primary").classed("prevSelection",!0),d3.selectAll("#metros .sel_related").classed("prevSelection",!0),d3.selectAll("#metros .metro").classed("sel_primary",!1).classed("sel_related",!1).classed("in",!1).classed("out",!1),$("svg circle").unbind("mouseenter mouseleave"),d3.select("#metro_"+a).attr("r",15).classed("sel_primary",!0).classed("prevSelection",!1).select("circle").attr("r",15);var n;for(n=0;n<e.length;n++){var o,p,q,r,s=e[n];if("ton"===P?(o=m(s.ton),q=s.ton,r=numeral(F(.001*q,2)).format("0,0.0")+" ktons"):(o=m(s.val),q=s.val,r="$ "+numeral(F(1e-6*q,2)).format("0,0.0")+" M"),parseInt(s.region_id)===a&&s.dir===b&&s.rel_region_id!=s.region_id&&s.mode===Q){var t=d3.select("#metro_"+s.rel_region_id),u=B(s.rel_region_id),v=u.id,x=u.familiar_name;if(q>0){var y="<li class='list-group-item' data-id='"+v+"'><span class='badge partner-val'>"+r+"</span>"+x+"</li>";j.push(y)}t.classed("prevSelection",!1),t.classed("sel_related",!0).attr("r",o).classed(b,!0).select("circle").transition().duration(500).attr("r",o).attr("i",k).attr("val",q).attr("name",x),k++}}var z;if(j.length>0)for(i=0;i<10;i++)z=j[i],$(z).appendTo("#tradeList");else{z="<li class='list-group-item'><b>"+(S.slice(0,1).toUpperCase()+S.slice(1,S.length))+" County</b> has no domestic trade using <b>"+Q+" transportation.</b></li>","air"===Q&&42101===a&&(z+="<li class='list-group-item'>Air transportation through Philadelphia International Airport is captured by Delaware County.</li>"),$(z).appendTo("#tradeList")}d3.selectAll("#metros .prevSelection").classed("prevSelection",!1).attr("r",3).select("circle").transition().duration(500).attr("r",3),H(),$("svg .sel_related circle").tipsy({gravity:"n",html:!0,title:function(){var a=this.getAttribute("val"),b=this.getAttribute("name");F(a,2);return p="ton"===P?numeral(F(.001*a,2)).format("0,0.0")+" ktons":"$ "+numeral(F(1e-6*a,2)).format("0,0.0")+" M","<b>"+b+"</b><br>"+p}}),d3.selectAll(".metro circle").on("mouseover",null),d3.selectAll(".metro circle").on("mouseout",null),d3.selectAll(".sel_related circle").on("mouseover",function(a){d3.select(this).classed("active",!0)}).on("mouseout",function(a){d3.select(this).classed("active",!1)}),w(R,P,b,Q)}function H(){var a=d3.selectAll("#metros .metro")[0];N.elements(a).start()}var I,J,K,L,M,N=sm.packer(),O="in",P="ton",Q="all",R=42017,S="none",T="network",U=$("#content").width(),V={0:"zero",1:"one",2:"two",3:"three",4:"four",5:"five",6:"six",7:"seven"},W=d3.geo.albersUsa().scale(900).translate([U,215]);g<992&&$("#c-region-nav").css({top:"57px",left:"-10px"});var X={region:"Overview",network:"Network",freight_centers:"Freight Centers",domestic_trade:"Domestic Trade Patterns"},Y={Network:"network","Freight Centers":"freight_centers","Domestic Trade":"domestic_trade"},Z={bucks:42017,burlington:34005,camden:34007,gloucester:34015,mercer:34021,chester:42029,delaware:42045,montgomery:42091,philadelphia:42101},_=["IntRouteMi","NatHwyMile","NHS","interch","freightRai","yards","portTermin","ShipCalls","centers","centerEmp","truckStop"],aa={"baja california":"San Diego is a city on the Pacific coast of California known for its beaches, parks and warm climate. Immense Balboa Park is the site of the renowned San Diego Zoo, as well as numerous art galleries, artist studios, museums and gardens. A deep harbor is home to a large active naval fleet, with the USS Midway, an aircraft-carrier-turned-museum, open to the public.",imperial:"Burlington County, New Jersey, is a powerhouse of freight activity with large doses of personal touches. The County is strategically located within the Northeastern United States megalopolis and that makes it an ideal logistics platform for Trenton, Philadelphia, North Jersey, and even New York City. At the same time, the County retains an unmistakable familial quality that springs from the steadfast commitment of key individuals and successive generations to promoting economic development and prosperity.","san diego":"San Diego is a city on the Pacific coast of California known for its beaches, parks and warm climate. Immense Balboa Park is the site of the renowned San Diego Zoo, as well as numerous art galleries, artist studios, museums and gardens. A deep harbor is home to a large active naval fleet, with the USS Midway, an aircraft-carrier-turned-museum, open to the public.",orange:"In Chester County, Pennsylvania, freight delivers, freight flourishes, and freight votes. Illustrations and paintings by the Wyeth family and Horace Pippin have popularized naturalistic, halcyon images of the County. Yet, there also exists a crystal clear reality to an alternative perspective and depiction of the County: one where products of substance and fortitude originate, freight facilities and services thrive, and economic development and sustainable transportation planning principles are shrewdly combined through the County’s award winning <i>Landscapes2</i> initiative.",riverside:"In unrelenting fashion, freight activity in Delaware County, Pennsylvania pulses with vigor and precision. Air, highway, marine, and rail freight facilities operate in a state of perpetual motion throughout the County.  Buoyed by a fully integrated transportation network, the harmonious co-mingling of freight and passenger traffic of all kinds is a daily spectacle.","los angeles":"Agile and formidable—these are the hallmarks of freight activity and freight facilities in Gloucester County, New Jersey.  While worldwide distribution patterns are unpredictable and subject to rapid change, Gloucester County businesses, logistics practices, and transportation facilities exhibit a remarkable ability to evolve and flourish.  With companies like Sony, Home Depot, and Mullica Hill Cold Storage calling Gloucester County home, the County has moved well beyond its agricultural underpinnings and developed an elaborate industrial core and multi-modal freight network.","san bernadino":"At the center of it all, Mercer County, New Jersey is a pivotal, forceful springboard for freight shipments. Its logistical prowess is forever memorialized by the marque <i>TRENTON MAKES THE WORLD TAKES</i> bridge minutes from the New Jersey State House. Today, Mercer County’s freight activity resonates in new and varied forms that capitalize on distinct locational advantages and direct access to some of the world’s most modern transportation facilities and networks."};$(".loading_panel").html("").html('<div class="spin-item"><div class="item-inner"><div class="item-loader-container"><div class="la-ball-spin-clockwise la-2x"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div></div></div>'),$(".c-step-item").css("width",b+"px"),$(".c-step-line").css("width",2*b+"px").css("transform","translate("+h+"px, 0)"),$("#c-region-nav").fadeIn("slow");var ba=document.location.toString();if(ba.match("#")){var ca=ba.split("#")[1].split("/");ca.length>1?o(ca):($("#c-region").fadeIn(),$("#c-name").html("DVRPC Region"),$("#c-tab").html("Overview"),$("#c-explore-emphasis").css("width",c+"px"),a(),$("#c-explorer-block").fadeOut("slow"))}$('a[href="#"]').click(function(a){a.preventDefault()}),$(window).bind("hashchange",function(){if("region"===getLocationHash()){o(window.location.hash.substring(1).split("/"))}}),$(document.body).on("click","#c-steps li a ",function(){T=$(this).attr("data-target").split("-")[1],"none"===S?($("#c-county-prompt").show(),r()):window.location.hash="region"===T?"region":"region/"+S+"/"+T}),$(document.body).on("click",".c-nav",function(){var a=$(this).find("span").text();T=Y[a],window.location.hash="region/"+S+"/"+T}),$(document.body).on("click","#c-map-legend",function(){"closed"===$(this).attr("class")?($(this).css("width","240px").css("height","345px").css("border-radius","4px 20px 4px 4px").toggleClass("closed open"),$("#c-legend-icon i").toggleClass("dynico dynico-layers glyphicon glyphicon-minus"),$(".c-legend-list").show()):($(this).css("width","40px").css("height","40px").css("border-radius","20px").toggleClass("open closed"),$("#c-legend-icon i").toggleClass("glyphicon glyphicon-minus dynico dynico-layers"),$(".c-legend-list").hide()),d}),$(document.body).on("mouseover","#c-explore-emphasis",function(){$("#c-explore-emphasis").css("width",c+f+"px")}),$(document.body).on("mouseout","#c-explore-emphasis",function(){$("#c-explore-emphasis").css("width",c+"px")}),$("#c-county-prompt").on("click",function(){$("#c-county-prompt").hide()}),$("#c-steps li a svg").bind("mouseenter",function(){s($(this).parent().find("svg.c-ripple").attr("id"))}),d3.selection.prototype.moveToFront=function(){return this.each(function(){this.parentNode.appendChild(this)})};var da,ea,fa,ga,ha,ia,ja=!1;$("input[name='dir']").change(function(){O=$(this).val();var a="in"===O?"Inbound":"Outbound";G(R,O),$("#comm-"+O).prop("checked",!0),$("#tradeDirection").html(a+" <span class='caret'></span>")}),$("input[name='measure']").change(function(){P=$(this).val();var a="ton"===P?"Volume":"Value";G(R,O,"measure"),$("#comm-"+P).prop("checked",!0),$("#tradeMeasure").html(a+" <span class='caret'></span>")}),$("input[name='mode']").change(function(){Q=$(this).val(),G(R,O,"measure")}),$("input[name='tradeMeasure']").change(function(){P=$(this).val(),$("#radio_"+P).trigger("click")}),$("input[name='tradeDirection']").change(function(){O=$(this).val(),$("#radio_"+O).trigger("click")}),$(".btn").mouseup(function(){$(this).blur()}),$(document.body).on("mouseover","#tradeList .list-group-item",function(){var a=$(this).attr("data-id");d3.select("#metros #metro_"+a).select("circle").classed("list_circle",!0)}),$(document.body).on("mouseout","#tradeList .list-group-item",function(){var a=$(this).attr("data-id");d3.select("#metros #metro_"+a).select("circle").classed("list_circle",!1)})}executeOnLoad("c-region-nav",a);var b,c,e,f,g=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;g>=1200?(b=(.8333333*(g-30)-480)/5,f=100,c=.5*(.8333333*(g-30)-30)-15,e=.5*(.8333333*(g-30)-30)-15):g<1200&&g>=992?(b=(g-510)/5,f=100,c=.5*(g-60)-15,e=.5*(g-60)-15):g<992&&g>=768?(b=(g-60)/4.3,f=0,c=g-60,e=.5833333333*(g-60)-15):(b=(g-60)/4.3,f=0,c=g-60,e=g-60);var h=b/2*3+18});