(function(E){var B={},K,M,O,J=E.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),A=false;E.tooltip={blocked:false,defaults:{delay:200,fade:false,showURL:true,extraClass:"",top:15,left:15,id:"tooltip"},block:function(){E.tooltip.blocked=!E.tooltip.blocked}};E.fn.extend({tooltip:function(P){P=E.extend({},E.tooltip.defaults,P);H(P);return this.each(function(){E.data(this,"tooltip",P);this.tOpacity=B.parent.css("opacity");this.tooltipText=this.title;E(this).removeAttr("title");this.alt=""}).mouseover(L).mouseout(F).click(F)},fixPNG:J?function(){return this.each(function(){var P=E(this).css("backgroundImage");if(P.match(/^url\(["']?(.*\.png)["']?\)$/i)){P=RegExp.$1;E(this).css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+P+"')"}).each(function(){var Q=E(this).css("position");if(Q!="absolute"&&Q!="relative"){E(this).css("position","relative")}})}})}:function(){return this},unfixPNG:J?function(){return this.each(function(){E(this).css({filter:"",backgroundImage:""})})}:function(){return this},hideWhenEmpty:function(){return this.each(function(){E(this)[E(this).html()?"show":"hide"]()})},url:function(){return this.attr("href")||this.attr("src")}});function H(P){if(B.parent){return }B.parent=E('<div id="'+P.id+'"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide();if(E.fn.bgiframe){B.parent.bgiframe()}B.title=E("h3",B.parent);B.body=E("div.body",B.parent);B.url=E("div.url",B.parent)}function C(P){return E.data(P,"tooltip")}function G(P){if(C(this).delay){O=setTimeout(N,C(this).delay)}else{N()}A=!!C(this).track;E(document.body).bind("mousemove",D);D(P)}function L(){if(E.tooltip.blocked||this==K||(!this.tooltipText&&!C(this).bodyHandler)){return }K=this;M=this.tooltipText;if(C(this).bodyHandler){B.title.hide();var S=C(this).bodyHandler.call(this);if(S.nodeType||S.jquery){B.body.empty().append(S)}else{B.body.html(S)}B.body.show()}else{if(C(this).showBody){var R=M.split(C(this).showBody);B.title.html(R.shift()).show();B.body.empty();for(var Q=0,P;(P=R[Q]);Q++){if(Q>0){B.body.append("<br/>")}B.body.append(P)}B.body.hideWhenEmpty()}else{B.title.html(M).show();B.body.hide()}}if(C(this).showURL&&E(this).url()){B.url.html(E(this).url().replace("http://","")).show()}else{B.url.hide()}B.parent.addClass(C(this).extraClass);if(C(this).fixPNG){B.parent.fixPNG()}G.apply(this,arguments)}function N(){O=null;if((!J||!E.fn.bgiframe)&&C(K).fade){if(B.parent.is(":animated")){B.parent.stop().show().fadeTo(C(K).fade,K.tOpacity)}else{if(B.parent.is(":visible")){B.parent.fadeTo(C(K).fade,K.tOpacity)}else{B.parent.fadeIn(C(K).fade)}}}else{B.parent.show()}D()}function D(S){if(E.tooltip.blocked){return }if(S&&S.target.tagName=="OPTION"){return }if(!A&&B.parent.is(":visible")){E(document.body).unbind("mousemove",D)}if(!K){E(document.body).unbind("mousemove",D);return }B.parent.removeClass("viewport-right").removeClass("viewport-bottom");var U=B.parent[0].offsetLeft;var T=B.parent[0].offsetTop;if(S){U=S.pageX+C(K).left;T=S.pageY+C(K).top;var Q="auto";if(C(K).positionLeft){Q=E(window).width()-U;U="auto"}B.parent.css({left:U,right:Q,top:T})}var P=I(),R=B.parent[0];if(P.x+P.cx<R.offsetLeft+R.offsetWidth){U-=R.offsetWidth+20+C(K).left;B.parent.css({left:U+"px"}).addClass("viewport-right")}if(P.y+P.cy<R.offsetTop+R.offsetHeight){T-=R.offsetHeight+20+C(K).top;B.parent.css({top:T+"px"}).addClass("viewport-bottom")}}function I(){return{x:E(window).scrollLeft(),y:E(window).scrollTop(),cx:E(window).width(),cy:E(window).height()}}function F(R){if(E.tooltip.blocked){return }if(O){clearTimeout(O)}K=null;var Q=C(this);function P(){B.parent.removeClass(Q.extraClass).hide().css("opacity","")}if((!J||!E.fn.bgiframe)&&Q.fade){if(B.parent.is(":animated")){B.parent.stop().fadeTo(Q.fade,0,P)}else{B.parent.stop().fadeOut(Q.fade,P)}}else{P()}if(C(this).fixPNG){B.parent.unfixPNG()}}})(jQuery);jQuery.cookie=function(B,I,L){if(typeof I!="undefined"){L=L||{};if(I===null){I="";L.expires=-1}var E="";if(L.expires&&(typeof L.expires=="number"||L.expires.toUTCString)){var F;if(typeof L.expires=="number"){F=new Date();F.setTime(F.getTime()+(L.expires*24*60*60*1000))}else{F=L.expires}E="; expires="+F.toUTCString()}var K=L.path?"; path="+(L.path):"";var G=L.domain?"; domain="+(L.domain):"";var A=L.secure?"; secure":"";document.cookie=[B,"=",encodeURIComponent(I),E,K,G,A].join("")}else{var D=null;if(document.cookie&&document.cookie!==""){var J=document.cookie.split(";");for(var H=0;H<J.length;H++){var C=jQuery.trim(J[H]);if(C.substring(0,B.length+1)==(B+"=")){D=decodeURIComponent(C.substring(B.length+1));break}}}return D}};OpenLayers.Layer.CloudMade=OpenLayers.Class(OpenLayers.Layer.TMS,{initialize:function(D,C){if(!C.key){throw"Please provide key property in options (your API key)."}C=OpenLayers.Util.extend({attribution:"Data &copy; 2009 <a href='http://openstreetmap.org/'>OpenStreetMap</a>. Rendering &copy; 2009 <a href='http://cloudmade.com'>CloudMade</a>.",maxExtent:new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),maxResolution:156543.0339,units:"m",projection:"EPSG:900913",isBaseLayer:true,numZoomLevels:19,displayOutsideMaxExtent:true,wrapDateLine:true,styleId:1},C);var E=[C.key,C.styleId,256].join("/")+"/";var B=["http://a.tile.cloudmade.com/"+E,"http://b.tile.cloudmade.com/"+E,"http://c.tile.cloudmade.com/"+E];var A=[D,B,C];OpenLayers.Layer.TMS.prototype.initialize.apply(this,A)},getURL:function(E){var D=this.map.getResolution();var A=Math.round((E.left-this.maxExtent.left)/(D*this.tileSize.w));var H=Math.round((this.maxExtent.top-E.top)/(D*this.tileSize.h));var G=this.serverResolutions?OpenLayers.Util.indexOf(this.serverResolutions,D):this.map.getZoom();var B=Math.pow(2,G);if(H<0||H>=B){return"http://cloudmade.com/js-api/images/empty-tile.png"}else{A=((A%B)+B)%B;var C=this.url;var F=G+"/"+A+"/"+H+".png";if(C instanceof Array){C=this.selectUrl(F,C)}return C+F}},CLASS_NAME:"OpenLayers.Layer.CloudMade"});OpenLayers.Layer.DecisionTree=OpenLayers.Class(OpenLayers.Layer.Grid,{DEFAULT_PARAMS:{},df:null,isBaseLayer:false,initialize:function(C,B,D,A){OpenLayers.Layer.Grid.prototype.initialize.apply(this,[C,B,D,A]);OpenLayers.Util.applyDefaults(this.params,this.DEFAULT_PARAMS);if(D.df){this.df=D.df}},destroy:function(){OpenLayers.Layer.Grid.prototype.destroy.apply(this,arguments)},clone:function(A){if(!A){A=new OpenLayers.Layer.DecisionTree(this.name,this.url,this.params,this.options)}A=OpenLayers.Layer.Grid.prototype.clone.apply(this,[A]);return A},getURL:function(B){B=this.adjustBounds(B);var C=this.getImageSize();var D={bbox:B.left+","+B.right+","+B.bottom+","+B.top,height:C.h,width:C.w};if(this.df){this.params.df=this.df}else{this.params.df=""}var A=unescape(this.getFullRequestString(D));return A},setFactors:function(A){if(!A){this.df=null}else{this.df=A}},addTile:function(B,A){return new OpenLayers.Tile.Image(this,A,B,null,this.tileSize)},CLASS_NAME:"OpenLayers.Layer.DecisionTree"});(function(F){var J=[],D,E={},H={};function I(L,K){F.each(J,function(N,M){if(M.AmenityType===L){M.Value=K}})}function G(K){K=K>0?("+"+K):K;return K}function A(){var K=this,O=this.options;var L="";var N=D||J;F.each(N,function(Q,P){var R="";if(!P.Value){P.Value=0}L+=['<li id="dt-factor-',P.AmenityType,'" class="dt-factors-default">',"<label>",P.DisplayName,'</label> <span title="',P.Description,'" class="dt-help" />',"<div></div>","<strong>",G(P.Value),"</strong>","</li>"].join("")});var M=K.element[0].nodeName==="UL"||K.element[0].nodeName==="OL";if(M===false){L='<ul class="dt-factors">'+L+"</ul>"}F(K.element).empty().append(L);if(M){F(K.element).addClass("dt-factors")}}function B(L,K){if(K<0){L.removeClass().addClass("dt-factors-negative-"+Math.abs(K))}else{if(K>0){L.removeClass().addClass("dt-factors-positive-"+K)}else{L.removeClass().addClass("dt-factors-default")}}}function C(K){var L=D||J;F.each(L,function(N,M){var O="#dt-factor-"+M.AmenityType;F(O+" > div").slider({min:K.min,max:K.max,value:M.Value||0,start:function(Q,P){if(K.callbacks.start){K.callbacks.start.apply(this,[Q,P])}},slide:function(Q,P){var S=P.value;var R=F(this).parent();B(R,S);R.children("strong").text(G(S));if(K.callbacks.slide){K.callbacks.slide.apply(this,[Q,P])}},change:function(Q,P){I(M.AmenityType,P.value);if(K.callbacks.change){K.callbacks.change.apply(this,[Q,P])}},stop:function(Q,P){if(K.callbacks.stop){K.callbacks.stop.apply(this,[Q,P,M.AmenityType])}}});B(F(O),M.Value)})}F.widget("ui.dtfactors",{_init:function(){var K=this,L=this.options;J=L.factors;D=L.userFactors;F.each(J,function(N,M){E[M.AmenityType]=M.Value});F.extend(H,L.callbacks);A.call(K);C(L);J=F.extend(true,J,D);if(H.render){H.render.call(this)}},string:function(){var K=this;var L=this.options;var M;F.each(J,function(N,O){if(O.Value!==0){if(M){M+=","}else{M=""}M+=O.ArgName+","+O.Value}});return M},object:function(){return J},defaultFactors:function(){F.each(J,function(L,K){var O="#dt-factor-"+K.AmenityType;var N=F(O);var M=E[K.AmenityType];N.children("div").slider("value",M);B(N,M);N.children("strong").text(G(M))})},zeroFactors:function(){F.each(J,function(L,K){var O="#dt-factor-"+K.AmenityType;var N=F(O);var M=0;N.children("div").slider("value",M);B(N,M);N.children("strong").text(M)})}})})(jQuery);$.extend($.ui.dtfactors,{version:"0.1",defaults:{min:-5,max:5,factors:[],callbacks:{}},getter:"string object",setter:"defaultFactors zeroFactors"});var Walkshed=Walkshed||{};Walkshed.LayoutManager=function(D){var B={},C;var A={containerSel:"#side-panel-inner",prioritySel:"#side-panel-priorities",priorityToolbarSel:"#side-panel-toolbar-priorities",priorityFootSel:"#side-panel-foot-priorities",priorityBtnSel:"#priorities-tab",locationSel:"#side-panel-locations",locationToolbarSel:"#side-panel-toolbar-locations",locationFootSel:"#side-panel-foot-locations",locationBtnSel:"#locations-tab",skipStartupCookie:"walkshed.skip-startup",searchFieldSel:"#address-search-field",siteMsgSel:"#site-message",modalOverlaySel:"#modal-overlay",mapLoadingSel:"#map-loading"};if(D){$.extend(A,D)}B.init=function(E){C=E;$(A.locationBtnSel).click(function(){C.trackEvent("Amenities","ClickTab");B.focusLocationsPane()});$(A.priorityBtnSel).click(function(){C.trackEvent("Priorities","ClickTab");B.focusPrioritiesPane()});$(".side-panel-toolbar img, #calc-walkability-header img").tooltip({delay:100,fade:250,showURL:false});$(C).bind("ws-factorvalues-load",function(H,I){var J=$(A.locationSel).children("ul");J.empty();$.each(I,function(L,K){if(K.IsVector){$('<li id="ws-loc-'+K.AmenityType+'" />').appendTo(J)}})});$(C).bind("ws-cityoptions-load",function(H,I){var J="Enter a "+I.Name+" Address";$(A.searchFieldSel).val(J);$(A.searchFieldSel).focus(function(){var K=$(this).val();if(K===J){$(this).val("")}else{this.select()}});$(A.searchFieldSel).blur(function(){var K=$(this).val();if(!K){$(this).val(J)}})});$(C).bind("ws-modaloverlay-show",function(H){$(A.modalOverlaySel).show()});$(C).bind("ws-modaloverlay-hide",function(H){$(A.modalOverlaySel).hide()});$(C).bind("ws-maploading-show",function(H){$(A.mapLoadingSel).show()});$(C).bind("ws-maploading-hide",function(H){$(A.mapLoadingSel).hide()});$(C).bind("ws-error-fatal",function(H){$(A.mapLoadingSel).hide();$(A.modalOverlaySel).show()});var F=[],G=2;$(C).bind("ws-page-init",function(H,I){F.push(true);if(F.length===G){$(A.mapLoadingSel).hide();$(A.modalOverlaySel).hide()}})};B.focusPrioritiesPane=function(){$(A.locationSel).hide();$(A.locationToolbarSel).hide();$(A.locationFootSel).hide();$(A.prioritySel).show();$(A.priorityToolbarSel).show();$(A.priorityFootSel).show();$(A.priorityBtnSel).addClass("ws-state-active");$(A.locationBtnSel).removeClass("ws-state-active")};B.focusLocationsPane=function(){$(A.prioritySel).hide();$(A.priorityToolbarSel).hide();$(A.priorityFootSel).hide();$(A.locationSel).show();$(A.locationToolbarSel).show();$(A.locationFootSel).show();$(A.priorityBtnSel).removeClass("ws-state-active");$(A.locationBtnSel).addClass("ws-state-active")};B.showMessage=function(F,G){if(!G){G=2500}var E=$(A.siteMsgSel);E.text(F).slideDown();window.setTimeout(function(){E.slideUp()},G)};return B};var Walkshed=Walkshed||{};Walkshed.MapManager=function(O){var M={},D,E,H,L,J,I,G;var B,C;var N={mapTarget:"map-panel",layerOptTarget:"map-layers-outer",citiesUrl:"handlers/cities.ashx",baseLayers:{cloudmade:{label:"OpenStreetMap",layer:null},gStreet:{label:"Streets",layer:new OpenLayers.Layer.Google("Google Streets",{sphericalMercator:true})},gPhysical:{label:"Physical",layer:new OpenLayers.Layer.Google("Google Physical",{type:G_PHYSICAL_MAP,sphericalMercator:true})},gSatellite:{label:"Satellite",layer:new OpenLayers.Layer.Google("Google Satellite",{type:G_SATELLITE_MAP,sphericalMercator:true})},gHybrid:{label:"Hybrid",layer:new OpenLayers.Layer.Google("Google Hybrid",{type:G_HYBRID_MAP,sphericalMercator:true})}}};if(O){$.extend(N,O)}function A(P){$.each(E.getLayersByClass("OpenLayers.Layer.Google"),function(R,Q){$(Q.termsOfUse).hide()});if(P&&P.termsOfUse){$(P.termsOfUse).show()}}function K(){$('<div id="map-layers-options" class="ui-state-default"><span class="ui-icon ui-icon-circle-close"/><div><h4>Base Map</h4><ul id="ws-baselayers"></ul></div><div><h4>Walkshed Overlay</h4><div id="ws-opacity-slider"></div></div></div>').appendTo("#"+N.layerOptTarget).find(".ui-icon").click(function(){D.trackEvent("LayerOptions","Click","HideX");$("#map-layers-options").slideUp()});var P=$("#ws-baselayers");$.each(N.baseLayers,function(Q,R){$('<li><button class="ui-state-default">'+R.label+"</button></li>").appendTo(P).children("button").hover(function(){$(this).addClass("ui-state-hover")},function(){$(this).removeClass("ui-state-hover")}).click(function(){D.trackEvent("LayerOptions","SetBaseMap",$(this).text());E.setBaseLayer(R.layer);P.find(".ui-state-active").removeClass("ui-state-active");$(this).addClass("ui-state-active");$(this).blur();A(R.layer)})});P.find("li:first button").addClass("ui-state-active");$("#map-layers-btn").click(function(){var Q=$("#map-layers-options");if(Q.is(":visible")){Q.slideUp();D.trackEvent("LayerOptions","Click","Hide")}else{Q.slideDown();D.trackEvent("LayerOptions","Click","Show")}});$("#ws-opacity-slider").slider({min:0,max:1,step:0.05,value:0.7,slide:function(R,Q){H.setOpacity(Q.value)},stop:function(R,Q){D.trackEvent("LayerOptions","OpacitySlide",Q.value)}})}OpenLayers.Control.Click=OpenLayers.Class(OpenLayers.Control,{defaultHandlerOptions:{single:true,"double":false,pixelTolerance:0,stopSingle:false,stopDouble:false},initialize:function(P){this.handlerOptions=OpenLayers.Util.extend({},this.defaultHandlerOptions);OpenLayers.Control.prototype.initialize.apply(this,arguments);this.handler=new OpenLayers.Handler.Click(this,{click:this.click},this.handlerOptions)},click:function(P){if(window.console){console.log("The click function has not been implemented.");console.log(P)}}});function F(P){_dtOptions={url:P.DtUrl+"calculations/WeightedOverlay",renderer:P.Renderer,calc_bbox:P.CalcBbox,colors:P.Colors};var R=new OpenLayers.Control.Click({click:function(T){if(T.altKey){var S=E.getLonLatFromViewPortPx(T.xy);D.getTool("search").showAmenities(S)}}});E=new OpenLayers.Map(N.mapTarget,{projection:new OpenLayers.Projection("EPSG:900913"),displayProjection:new OpenLayers.Projection("EPSG:4326"),units:"m",maxZoomLevel:17,minZoomLevel:9,maxExtent:P.DefaultBbox,restrictedExtent:P.MaxBbox,controls:[new OpenLayers.Control.PanPanel(),new OpenLayers.Control.ZoomPanel(),new OpenLayers.Control.Navigation(),new OpenLayers.Control.ArgParser(),new OpenLayers.Control.Attribution(),new OpenLayers.Control.MousePosition(),new OpenLayers.Control.ScaleLine(),R],eventListeners:{zoomend:function(S){$(D).trigger("ws-map-zoomend",E.getZoom())}}});R.activate();H=new OpenLayers.Layer.DecisionTree("Walkshed",P.DtUrl+"calculations/WeightedOverlay.png",{renderer:P.Renderer,calc_bbox:P.CalcBbox,colors:P.Colors,timeout:10000},{singleTile:false,tileSize:new OpenLayers.Size(256,256),buffer:0,opacity:0.7,visibility:false,displayOutsideMaxExtent:false,transitionEffect:"resize",eventListeners:{loadstart:function(S){$(D).trigger("ws-maploading-show")},loadend:function(S){$(D).trigger("ws-maploading-hide")}}});J=new OpenLayers.Layer.Markers("Home");I=new OpenLayers.Layer.Markers("Amenities");N.baseLayers.cloudmade.layer=new OpenLayers.Layer.CloudMade("OpenStreetMap",{key:"639307b9368955d7976b7999333c4208",styleId:998,buffer:0,serverResolutions:[156543.033928,78271.5169639999,39135.7584820001,19567.8792409999,9783.93962049996,4891.96981024998,2445.98490512499,1222.99245256249,611.49622628138,305.748113140558,152.874056570411,76.4370282850732,38.2185141425366,19.1092570712683,9.55462853563415,4.77731426794937,2.38865713397468,1.19432856685505,0.597164283559817],resolutions:[305.748113140558,152.874056570411,76.4370282850732,38.2185141425366,19.1092570712683,9.55462853563415,4.77731426794937,2.38865713397468,1.19432856685505,0.597164283559817]});E.addLayers([N.baseLayers.cloudmade.layer,N.baseLayers.gStreet.layer,N.baseLayers.gPhysical.layer,N.baseLayers.gSatellite.layer,N.baseLayers.gHybrid.layer,H,I,J]);K();E.zoomToExtent(P.DefaultBbox,true);var Q=setInterval(A,250);setTimeout(function(){clearInterval(Q)},10000)}M.init=function(P){D=P;function Q(R){return R.left+","+R.right+","+R.bottom+","+R.top}$.ajax({type:"GET",dataType:"json",data:{alias:N.city},url:N.citiesUrl,timeout:15000,success:function(S,R){S.DefaultBbox=OpenLayers.Bounds.fromString(S.DefaultBbox);S.MaxBbox=OpenLayers.Bounds.fromString(S.MaxBbox);S.CalcBbox=Q(S.DefaultBbox);G=S;F(S);$(D).trigger("ws-cityoptions-load",[G]);$(D).trigger("ws-page-init")},error:function(T,R,S){$(D).trigger("ws-error-fatal");D.getLayoutManager().showMessage("Oops, we couldn't load the city data. Try refreshing the page.",5000)}});$(D).bind("ws-factorvalues-change",function(R,S){if(H){if(S.pyramidString){H.setFactors(S.pyramidString);if(H.getVisibility()){H.redraw()}else{H.setVisibility(true)}}else{H.setVisibility(false)}}});$(D).bind("ws-factorvalues-pyramidchange",function(S,R){if(H){H.setFactors(R);H.redraw()}});return M};M.getMarkerById=function(Q){var P;$.each(I.markers,function(S,R){if(Q===R.id){P=R;return false}});return P};M.addMarkers=function(P){$.each(P,function(R,Q){I.addMarker(Q)})};M.removeMarkers=function(P){$.each(P,function(R,Q){I.removeMarker(Q)})};M.removePopup=function(){if(C){E.removePopup(C)}};M.addPopup=function(Q){D.trackEvent("Amenities","AddPopup",Q.amenity.Name);M.removePopup(C);var S=(Q.amenity.Name||"[No Name]");var P="[No Address]";if(Q.amenity.Url){S='<a href="'+Q.amenity.Url+'" target="_blank">'+S+"</a>"}if(Q.amenity.Address&&G.Name&&G.State){P=Q.amenity.Address+"<br />"+G.Name+", "+G.State}var R='<div class="popup-container"><div class="popup-icon marker_'+Q.factor.AmenityType+'"></div><div class="popup-title">'+S+'</div><div class="popup-content" id="popup-address"><span class="popup-label">Address</span>'+P+'</div><div class="popup-content" id="popup-category"><span class="popup-label">Category</span>'+Q.factor.DisplayName+'</div><div class="clear"></div><div class="popup-content source-'+Q.factor.Source+'" id="popup-datasource"><span class="popup-label">Data provided by</span><a href="'+Q.factor.SourceUrl+'" class="source-image" target="_blank"></a></div>';C=new OpenLayers.Popup.FramedCloud("popup_"+Q.id,Q.lonlat,new OpenLayers.Size(200,200),R,null,true);E.addPopup(C,true)};M.getWalkshedLayer=function(){return H};M.getAmenitiesLayer=function(){return I};M.getHomeLayer=function(){return J};M.getMap=function(){return E};M.getDecisionTreeOptions=function(){return _dtOptions};M.zoomToLonLat=function(R,Q){var P=new OpenLayers.Projection("EPSG:4326");E.setCenter(R.transform(P,E.getProjectionObject()),Q)};M.clearAmenities=function(){J.clearMarkers();I.clearMarkers();M.removePopup()};return M};var Walkshed=Walkshed||{};Walkshed.ApplicationManager=function(E){var C={};var B;var D;var A={city:"",tools:{},managers:{}};if(E){$.extend(A,E)}D=(A.managers.layout||Walkshed.LayoutManager)();B=(A.managers.map||Walkshed.MapManager)({city:A.city});C.init=function(){(D&&D.init(C));(B&&B.init(C));$.each(A.tools,function(G,F){F.init(C)});return C};C.getTool=function(F){return A.tools[F]};C.getMapManager=function(){return B};C.getLayoutManager=function(){return D};C.trackEvent=function(G,I,F,H){try{_pageTracker._trackEvent(G,I,F,H)}catch(J){if(window.console){console.log(G+", "+I+", "+F+", "+H)}}};C.getOption=function(F){return A[F]};return C};var Walkshed=Walkshed||{};Walkshed.Factors=function(O){var H={},C,K,F,D,E=2,A;var G,N;var M={factorListSel:"#side-panel-priorities > ul",calcBtnSel:"#calculate-button",defaultFactorsBtnSel:"#factor-default-button",zeroFactorsBtnSel:"#factor-zero-button",kmlExportEl:"#google-earth-download",cookieSuffix:".default-factors",factorsUrl:"handlers/factors.ashx",priorityMessageSel:"#priority-message",render:function(){},zoomLevelArgMapping:{"default":"20m_",0:"50m_",1:"40m_",2:"30m_",3:"20m_",4:"10m_",5:"10m_",6:"5m_",7:"5m_",8:"5m_",9:"5m_"}};if(O){$.extend(M,O)}function J(R,U){var P,T,S;var Q;if(U||U===0){Q=M.zoomLevelArgMapping[U];if(!Q){Q=M.zoomLevelArgMapping["default"]}}else{Q=M.zoomLevelArgMapping["default"]}if(R&&Q){T=R.split(",");for(P=0;P<T.length;P+=2){T[P]=Q+T[P]}S=T.join(",")}else{S=R}return S}H.calculate=function(){if(G){F=G.dtfactors("object");K=G.dtfactors("string");var P;if(K){P=J(K,E);N.removeClass("disabled");C.trackEvent("Priorities","Calculate",K)}else{N.addClass("disabled")}$.cookie(A,K,30);$(C).trigger("ws-factorvalues-change",[{object:F,string:K,pyramidString:P}])}};function B(){G.dtfactors({factors:F,userFactors:D,callbacks:{render:function(){$(".dt-help").tooltip({delay:100,fade:250})},stop:function(R,Q,P){C.trackEvent("Priorities","Slide",P,(Q.value+5))}}});$(M.calcBtnSel).click(function(){H.calculate()});$(M.defaultFactorsBtnSel).click(function(){C.trackEvent("Priorities","DefaultValues");G.dtfactors("defaultFactors")});$(M.zeroFactorsBtnSel).click(function(){C.trackEvent("Priorities","ZeroValues");G.dtfactors("zeroFactors")})}function I(P){$(M.priorityMessageSel).removeClass().addClass("loading").show().html("Loading...");$.ajax({type:"GET",dataType:"json",data:{alias:P.Alias},url:M.factorsUrl,timeout:15000,success:function(U,R){U.sort(function(X,W){if(X.SortOrder>W.SortOrder){return 1}else{if(X.SortOrder<W.SortOrder){return -1}else{if(X.DisplayName>W.DisplayName){return 1}else{if(X.DisplayName<W.DisplayName){return -1}else{return 0}}}}});F=U;var Q=$.cookie(A);var V,T,S;if(Q){D=$.extend(true,[],F);V=Q.split(",");for(S=0;S<D.length;S++){D[S].Value=0;for(T=0;T<V.length;T+=2){if(D[S].ArgName===V[T]){D[S].Value=V[T+1];break}}}}$(M.priorityMessageSel).removeClass().hide();$(C).trigger("ws-factorvalues-load",[F]);$(C).trigger("ws-page-init");B();H.calculate()},error:function(S,Q,R){$(C).trigger("ws-error-fatal");C.getLayoutManager().showMessage("Oops, we couldn't load the decision factors. Try refreshing the page.",5000);$(M.priorityMessageSel).removeClass().addClass("error").show().html("Could not load the decision factors.")}})}H.init=function(P){C=P;A=C.getOption("city")+M.cookieSuffix;G=$(M.factorListSel);N=$(M.kmlExportEl);N.addClass("disabled").click(function(){if(!$(this).hasClass("disabled")){C.trackEvent("Links","Click","GoogleEarth");window.open(L())}});$(C).bind("ws-cityoptions-load",function(Q,R){I(R)});$(C).bind("ws-map-zoomend",function(Q,R){if(K){E=R;zoomLevelFactorVals=J(K,E);$(C).trigger("ws-factorvalues-pyramidchange",[zoomLevelFactorVals])}})};function L(){var Q=C.getMapManager().getDecisionTreeOptions();var P=Q.url+".kml?df="+J(K,"default")+"&width=3613&height=3861&renderer="+Q.renderer+"&colors="+Q.colors+"&bbox="+Q.calc_bbox;return P}return H};var Walkshed=Walkshed||{};Walkshed.Search=function(E){var F={},V,M,D,B={},S;var L={buttonSel:"#address-search-btn",clearButtonSel:"#loc-clear-btn",checkAllBtnSel:"#loc-checkbox-btn",slideListBtnSel:"#loc-list-btn",resetListBtnSel:"#loc-reset-btn",locationListToggle:"#side-panel-locations > ul > li > div",checkboxSel:".ws-loc-checkbox",inputSel:"#address-search-field",zoomLevel:6,amenitiesUrl:"handlers/amenities.ashx",factorToolId:"factors",messageSel:"#location-message",defaultMessage:"Search for an address to see nearby amenities.",onGeocode:function(){}};var R;if(E){$.extend(L,E)}function Q(){var W=new OpenLayers.Size(42,39);var Y=new OpenLayers.Pixel(-13,-36);var X=new OpenLayers.Icon("client/walkshed/css/images/map_marker.png",W,Y);V.getMapManager().getHomeLayer().addMarker(new OpenLayers.Marker(D,X))}function O(){$(L.messageSel).addClass("note").html(L.defaultMessage).show()}function J(Y,W){var Z=[],X;if(Y&&$.isArray(Y)){X=new OpenLayers.Format.WKT();$.each(Y,function(e,c){var d=X.read(c.Shape).geometry;var f=new OpenLayers.Icon("client/walkshed/css/images/pixel.png",new OpenLayers.Size(33,32));$(f.imageDiv).css("backgroundImage","url(client/walkshed/css/images/marker-sprite.png)").addClass("ws-marker").addClass("marker_"+W.AmenityType);var b=new OpenLayers.Marker(new OpenLayers.LonLat(d.x,d.y),f);b.amenity=c;b.factor=W;b.id=W.AmenityType+"_"+c.UniqueId;b.events.register("click",b,function(){V.getMapManager().addPopup(this)});Z.push(b)})}return Z}function I(){O();V.getMapManager().clearAmenities();$.each(R,function(X,W){$("#ws-loc-"+W.AmenityType).empty().hide()})}function C(a,Y){var X,Z;var W=V.getMapManager().getAmenitiesLayer();var b='checked="checked"',c="open";$(L.messageSel).removeClass().hide();if(!Y){b="";c="closed"}X=$("#ws-loc-"+a.AmenityType);if(B[a.AmenityType]==="error"){Z='<div class="ws-state-'+c+'"><span title="'+a.Description+'" class="dt-help" /></span><span class="ws-loc-name error">'+a.DisplayName+"</span></div>";Z+='<ul class="location-list"><li><label><span class="label-text">Error loading '+a.DisplayName+"</span></label></li></ul>";X.append(Z).show()}else{if(B[a.AmenityType].length>0){if(Y){V.getMapManager().addMarkers(B[a.AmenityType])}Z='<div class="ws-state-'+c+'"><span title="'+a.Description+'" class="dt-help" /></span><input rel="'+a.AmenityType+'" class="ws-loc-checkbox" type="checkbox" '+b+' /><span class="ws-loc-name">'+a.DisplayName+'</span></div><ul class="location-list">';$.each(B[a.AmenityType],function(e,d){Z+='<li id="'+d.id+'"><label><span class="location-distance">'+(d.amenity.Distance/1609).toFixed(2)+'mi</span><span class="label-text">'+(d.amenity.Name||"[No Name]")+"</span></label></li>"});Z+="</ul>";X.append(Z).find(".dt-help").tooltip({delay:100,fade:250}).end().find("ul > li").hover(function(){var d=V.getMapManager().getMarkerById($(this).attr("id"));if(d){$(d.icon.imageDiv).addClass("hover")}},function(){var d=V.getMapManager().getMarkerById($(this).attr("id"));if(d){$(d.icon.imageDiv).removeClass("hover")}}).click(function(){var d=V.getMapManager().getMarkerById($(this).attr("id"));V.trackEvent("Amenities","ClickListItem",$("label > .label-text",$(this)).text());if(d){V.getMapManager().addPopup(d)}}).end().find("ul > li:even").addClass("odd").end().find("input").click(function(d){var e=V.getMapManager();if($(this).is(":checked")){e.addMarkers(B[a.AmenityType]);V.trackEvent("Amenities","ClickCheckboxShow",a.AmenityType)}else{e.removePopup();e.removeMarkers(B[a.AmenityType]);V.trackEvent("Amenities","ClickCheckboxHide",a.AmenityType)}d.stopPropagation()}).end().find(".dt-help").click(function(d){d.stopPropagation()}).end().find("div.ws-state-closed ~ ul").hide().end().show()}}}function A(){if(D){I();Q();V.getLayoutManager().focusLocationsPane();$(L.messageSel).removeClass().addClass("loading").show().html("Loading...");$.each(R,function(Y,X){var W=false;if(X){W=true}if(X.IsVector){if(B&&B[X.AmenityType]){C(X,W)}else{$.ajax({type:"GET",dataType:"json",timeout:15000,data:{type:X.AmenityType,alias:X.CityAlias,x:D.lon,y:D.lat},url:L.amenitiesUrl,success:function(a,Z){B[X.AmenityType]=J(a,X);C(X,W)},error:function(b,Z,a){B[X.AmenityType]="error";C(X,W)}})}}})}}F.showAmenities=function(W){D=W;V.getMapManager().getMap().setCenter(D,L.zoomLevel);B={};$(V).trigger("ws-search-change",D);A()};function G(W){V.trackEvent("Address","Search",W);M.getLatLng((W+" "+S.Name+", "+S.State),function(Z){if(Z){var Y=new OpenLayers.Projection("EPSG:4326");var a=new OpenLayers.LonLat(Z.x,Z.y);var X=a.transform(Y,V.getMapManager().getMap().getProjectionObject());F.showAmenities(X);if(L.onGeocode){L.onGeocode(D)}}else{V.getLayoutManager().showMessage(W+" could not be found.")}})}function U(W){W.removeClass("ws-state-open").addClass("ws-state-closed").next("ul").slideUp()}function N(W){W.removeClass("ws-state-closed").addClass("ws-state-open").next("ul").slideDown()}function H(W){if(W.hasClass("ws-state-closed")){V.trackEvent("Amenities","ToggleList","Show");N(W)}else{U(W);V.trackEvent("Amenities","ToggleList","Hide")}}function K(){var W=[];$.each($(L.checkboxSel+":not(:checked)"),function(Y,X){var Z=$(this).attr("checked","checked").attr("rel");$.each(B[Z],function(b,a){W.push(a)})});V.getMapManager().addMarkers(W)}function P(){var W=[];$.each($(L.checkboxSel+":checked"),function(Y,X){var Z=$(this).attr("checked","").attr("rel");$.each(B[Z],function(b,a){W.push(a)})});V.getMapManager().removePopup();V.getMapManager().removeMarkers(W)}function T(){if($(L.checkboxSel).is(":not(:checked)")){V.trackEvent("Amenities","ToggleCheckboxes","CheckAll");K()}else{V.trackEvent("Amenities","ToggleCheckboxes","UnCheckAll");P()}}F.init=function(W){V=W;M=new GClientGeocoder();O();$(L.buttonSel).click(function(){var X=$(L.inputSel).val();G(X)});$(L.clearButtonSel).click(function(){V.trackEvent("Amenities","ClearList");D=null;I();V.getLayoutManager().focusPrioritiesPane();$(V).trigger("ws-search-change",D)});$(L.checkAllBtnSel).click(function(){T()});$(L.slideListBtnSel).click(function(){H($(L.locationListToggle))});$(L.resetListBtnSel).click(function(){V.trackEvent("Amenities","ResetListView");A()});$(L.inputSel).keydown(function(X){if(X.keyCode===13){G($(L.inputSel).val())}});$(L.locationListToggle).live("click",function(){H($(this))});$(V).bind("ws-factorvalues-load",function(X,Y){R=Y});$(V).bind("ws-cityoptions-load",function(X,Y){S=Y})};F.getSearchPoint=function(){return D};return F};var Walkshed=Walkshed||{};Walkshed.Score=function(L){var I={},D;var J={contentSel:"#calc-walkability-content",histSel:"#calc-walkability-hist",scoreSel:"#calc-walkability-score",histMsgSel:"#calc-walkability-hist-msg",scoreMsgSel:"#calc-walkability-score-msg",histogramUrl:"handlers/histogram.ashx"};if(L){$.extend(J,L)}var K,A,C,H;function G(M){var N=false;if(K){N=true;$(M).removeClass().addClass("loading").html("").show();A.parent().fadeIn()}else{A.parent().fadeOut()}return N}function F(P){var N=[],O,M;for(M=0;M<P.length-1;M++){if(M===0){O=Math.round((P[0]+P[1])/2)}else{O=Math.round((N[M-1]+P[M+1])/2)}N.push(O)}return N}function E(){var M=$(J.histSel);var N=$(J.histMsgSel);if(G(N)){$.ajax({type:"GET",dataType:"json",data:{df:K,alias:C},url:J.histogramUrl,success:function(R,Q){var S="",W=35000,P;var O=0,U=0,V=0;var T=R.hist.slice(1);T=F(T);T=F(T.reverse()).reverse();$.each(T,function(X,Y){if(Y>U){V=U;U=Y;O=X+1}else{if(Y>V){V=Y}}});W=Math.round(V+((U-V)/100));S='<img src="http://chart.apis.google.com/chart?cht=bvs&chs=110x31&chbh=1,0,0&chxt=x&chxl=0:|0|50|100|&chxp=0,0,50,100&chxs=0,ffffff,9&chf=bg,s,5E7F7F&chds=0,'+W+"&chd=t:"+T.join(",")+'&chco=d73027|d7342a|d8382d|d93c30|da4033|db4536|db4939|dc4d3c|dd513f|de5642|df5a46|df5e49|e0624c|e1664f|e26b52|e36f55|e47358|e4775b|e57c5e|e68061|e78465|e88868|e88c6b|e9916e|ea9571|eb9974|ec9d77|eda27a|eda67d|eeaa80|efae84|f0b287|f1b78a|f1bb8d|f2bf90|f3c393|f4c896|f5cc99|f6d09c|f6d49f|f7d8a3|f8dda6|f9e1a9|fae5ac|fae9af|fbeeb2|fcf2b5|fdf6b8|fefabb|ffffbf|fafcbc|f5faba|f1f8b8|ecf6b6|e8f4b3|e3f2b1|def0af|daeead|d5ecab|d1eaa8|cce8a6|c8e6a4|c3e4a2|bee29f|bae09d|b5de9b|b1db99|acd997|a7d794|a3d592|9ed390|9ad18e|95cf8b|91cd89|8ccb87|87c985|83c783|7ec580|7ac37e|75c17c|71bf7a|6cbd77|67bb75|63b873|5eb671|5ab46f|55b26c|50b06a|4cae68|47ac66|43aa63|3ea861|3aa65f|35a45d|30a25b|2ca058|279e56|239c54|1e9a52|1a984f" alt="" />';M.append(S);N.hide()},error:function(Q,O,P){N.removeClass().addClass("error").html('<a href="javascript:void(0);">Try again</a>').find("a").click(function(){E()}).show()}})}}function B(){var P,M=50;var O=$(J.scoreSel);var N=$(J.scoreMsgSel);if(G(N)){if(H){O.show();P=[H.lon-M,H.lon+M,H.lat-M,H.lat+M].join(",");$.ajax({type:"GET",dataType:"json",data:{df:K,bbox:P,alias:C},url:J.histogramUrl,success:function(U,S){var T="";var W=0,Q=0,R=0;var V=U.hist.slice(1);$.each(V,function(X,Y){if(Y>Q){Q=Y;W=X+1}});O.append('<div id="score-numerator">'+Math.round(W)+'</div> <div id="score-denominator">out of 100</div>');N.hide()},error:function(S,Q,R){N.removeClass().addClass("error").html('<a href="javascript:void(0);">Try again</a>').find("a").click(function(){B(P)}).show()}})}else{N.hide();$(J.scoreSel).hide()}}}I.init=function(M){D=M;A=$(J.contentSel);$(D).bind("ws-factorvalues-change",function(N,Q){var O=Q.string;var P=O.split(",");for(i=0;i<P.length;i+=2){P[i]="50m_"+P[i]}K=P.join(",");$(J.histMsgSel).siblings().remove();$(J.scoreMsgSel).siblings().remove();E();B()});$(D).bind("ws-search-change",function(N,O){$(J.scoreMsgSel).siblings().remove();H=O;B()});$(D).bind("ws-cityoptions-load",function(N,O){C=O.Alias})};return I};