function bindArguments(B){var A=[];for(var C=1;C<arguments.length;C++){A.push(arguments[C])}return function(){return B.apply(this,A)}}function WSEvent(){this.evts=[];this.builtinEvts=[]}WSEvent.prototype.getActionIdx=function(C,E,F){if(C){var B=this.evts[C];if(B){var A=B.length;for(var D=A-1;D>=0;D--){if(B[D].action==E&&B[D].binding==F){return D}}}else{return -1}}return -1};WSEvent.prototype.addListener=function(B,C,D){if(this.evts[B]){if(this.getActionIdx(B,C,D)==-1){var A=this.evts[B];A[A.length]={action:C,binding:D}}}else{this.evts[B]=[];this.evts[B][0]={action:C,binding:D}}};WSEvent.prototype.removeListener=function(B,C,D){if(this.evts[B]){var A=this.actionExists(B,C,D);if(A>=0){this.evts[B].splice(A,1)}}};WSEvent.prototype.fireEvent=function(F,A,B){if(!B){B=[]}if(this.evts){var D=this.evts[A];if(D){for(var C=0;C<D.length;C++){var E=D[C].action;if(D[C].binding){if(E){E.apply(D[C].binding,B)}}else{if(E){E(B,F)}}}}}return false};var appEvents=new WSEvent();function DataFetcher(A){this.setProfile=function(B){this.profile=window.wst_profile||B};this.setProfile(A);ensureWSUnderscoreMixins();this.reqDefs={isRankingsCity:"irc",cityUserRank:"ur",hoodInfo:"hi",compareData:"cd",scoreQueries:"sq",overviewQueries:"oq",customQueries:"cq",commercialQueries:"tcq",travelQueries:"ttq",transitScore:"ts"};this.replyDefs={irc:"isRankingsCityAvailable",ur:"cityUserRankAvailable",hi:"hoodInfoAvailable",cd:"compareDataAvailable",sq:"scoreQueriesAvailable",oq:"overviewQueriesAvailable",cq:"customQueriesAvailable",tcq:"commercialQueriesAvailable",ttq:"travelQueriesAvailable",ts:"transitScoreAvailable"};this.queuedRequests=new Array();this.hasRunDeferredRequests=false;this.isFirstBatch=true;this.responseCache=new LocalCache().setDefault({});this.request=function(C,B){if(!this.hasRunDeferredRequests||!B){this.addToQueue(C)}else{if(this.addToQueue(C)){this.runRequestsInternal(this.reqDefs[C],B)}}};this.addToQueue=function(B){if(paramIsSet(this.reqDefs[B])){if(!_(this.queuedRequests).detect(function(C){return C==B})){this.queuedRequests.push(B);return true}}return false};this.runDeferredRequests=function(C){this.hasRunDeferredRequests=true;var B=_(this.queuedRequests).map(_(function(E){return this.reqDefs[E]}).bind(this)).join(",");this.runRequestsInternal(B,C);var D=this;if(!this.timeout){this.timeout=_.delay(_(this.deferredRequestsTimeout).bind(this,B),6000)}};this.requestPrivate=function(B,C,D){this.privateContinuation=D;this.runRequestsInternal(this.reqDefs[B],C)};this.runRequestsInternal=function(L,K){var B=this.responseCache.setKey("_ws_data_"+this.profile).setLocation(K).fetch();var J=L.split(",");this.handleResponse(_(B).slice(J));L=_(J).reject(function(M){return B[M]}).join();if(!L){return }var E=this;var I=L;var F=K.getCity();var D=K.getAdminArea();var H=K.getTransitScoreCity();var G=(this.profile!="walkscore")?("&profile="+this.profile):"";F=this.fixNYBoroughs(F,D);var C="/data/get-data.php?req="+encodeURI(I)+"&lat="+encodeURI(K.getLat())+"&lon="+encodeURI(K.getLng())+"&city="+encodeURI(F)+"&transit_score_city="+encodeURI(H)+"&state="+encodeURI(D)+"&cc="+encodeURI(K.getCountryCode())+G;$.ajax({url:C,type:"GET",success:function(M){E.receiveData(M)},error:_(function(){if(_(J).include("ts")){this.handleResponse({ts:null});this.runRequestsInternal(_(J).reject(function(M){return M=="ts"}).join(","),K)}else{E.receiveData(null)}}).bind(this)})};this.receiveData=function(B){clearTimeout(this.timeout);var C=parseJson(B);if(C){this.handleResponse(C)}};this.handleResponse=function(C){var B=this.responseCache.fetch();_(B).extend(C);this.responseCache.store(B);for(var D in C){if(this.privateContinuation){this.privateContinuation(B[D])}else{appEvents.fireEvent(null,this.replyDefs[D],[B[D]])}this.dequeueRequest(D,B)}};this.dequeueRequest=function(D,C){for(var B in this.queuedRequests){if(this.reqDefs[this.queuedRequests[B]]==D){this.queuedRequests.splice(B,1)}}if(this.isFirstBatch&&_(this.queuedRequests).isEmpty()){this.isFirstBatch=false;appEvents.fireEvent(null,"dataRequestsComplete",[C])}};this.deferredRequestsTimeout=function(B){if(this.isFirstBatch){this.isFirstBatch=false;appEvents.fireEvent(null,"dataRequestsComplete")}};this.fetchWalkScore=function(E,C,G,F){var D=G;var B="/data/get-walkscore.php?lat="+encodeURI(E)+"&lon="+encodeURI(C);if(F){B+="&scoredetails=true"}$.ajax({url:B,type:"GET",success:function(H){D(H)},error:function(){D("{}")}})};this.fixNYBoroughs=function(C,B){return fixNYBoroughs(C,B)}}function WalkScoreCore(C,A,E,D,B){this.profile=C;this.dataFetcher=A;this.amenityService=E;this.geocoder=D;this.optionFlags=defaultIfNotSet(B,{});this.scorer=null;this.geoData=null;this.score=null;this.fromCookie=false;this.scoringComplete=false;this.dataFetchesComplete=false;this.init=function(G,H){this.geoData=G;appEvents.addListener("dataRequestsComplete",this.onDataRequestsComplete,this);var F=(this.app&&this.app.doesGeolocation&&this.geoData.query=="");this.coreCookie=((H&&!F&&!DEBUG_BLOCK_COOKIE)?new CoreCookie(H,getLocationKey(this.geoData)):null);if(this.coreCookie&&this.coreCookie.hasData()){this.fromCookie=true;this.geoData.fillDataFromGeoData(this.coreCookie.getGeoData());_(_(function(){this.geocodeComplete();this.onScoringCompleted(this.coreCookie.getScore())}).bind(this)).defer()}else{if(this.coreCookie){this.coreCookie.deleteCookie()}this.geocoder.autoFillPartialGeoData(this.geoData,bindCallback(this,this.geocodeComplete))}};this.geocodeComplete=function(){if(this.geoData.latLng==null){appEvents.fireEvent(null,"coreGeocodeFailed",[this.geoData]);return }this.amenityService.setLocation(this.geoData);appEvents.fireEvent(null,"coreGeocode",[this.geoData]);this.dataFetcher.runDeferredRequests(this.geoData);if(!this.fromCookie){this.scorer=new Scorer(this);this.scorer.scoreLocation(this.geoData,bindCallback(this,this.onScoringCompleted),bindCallback(this,this.onScoreDetailsReceived))}};this.onScoringCompleted=function(F){appEvents.fireEvent(null,"scoreCompleted",[F]);this.score=F;this.scoringComplete=true;this.checkAllServicesCompleted()};this.onScoreDetailsReceived=function(F){appEvents.fireEvent(null,"scoreDetails",[F])};this.onDataRequestsComplete=function(){this.dataFetchesComplete=true;this.checkAllServicesCompleted()};this.checkAllServicesCompleted=function(){if(this.coreCookie&&!this.fromCookie&&this.geoData.hasData()&&this.scoringComplete&&this.dataFetchesComplete){this.coreCookie.save(this.geoData,this.score)}};this.request=function(G,F){this.dataFetcher.request(G,F)};this.getGeocoder=function(){return this.geocoder};this.getAmenityService=function(){return this.amenityService};this.getScorer=function(){if(this.scorer==null){this.scorer=new Scorer(this)}return this.scorer}}function BingGeocoder(){}(function(){var B={"United States":"US","United Kingdom":"GB",Australia:"AU",Canada:"CA",Ireland:"IE","New Zealand":"NZ"};var A=function(C){return B[C]||"DEFAULT"};BingGeocoder.prototype.geocode=function(E,G){var D=function(H){var K=_(H).spelunk(["resourceSets",0,"resources",0]);if(!K){return G([])}var J=K.address;var I=K.point.coordinates;var L=new ws.LatLng(I[0],I[1]);G([{geometry:{location:L},formatted_address:K.name,address_components:_([["street_number",J.addressLine],["locality",J.locality],["postal_code",J.postalCode],["administrative_area_level_1",J.adminDistrict],["country",J.countryRegion,A(J.countryRegion)]]).map(function(M){return{types:[M[0]],long_name:M[1],short_name:M[2]||M[1]}})}])};var C=E.address?"/data/bing-geocode-address.php":"/data/bing-geocode-latlng.php";var F=E.latLng?[E.latLng.lat(),E.latLng.lng()].join(","):"";$.ajax({type:"GET",url:C,data:{query:E.address,latlng:F},success:D,error:_(D).bind(null),dataType:"json"})}})();function GoogleGeocoder(){}(function(){var A;GoogleGeocoder.prototype.geocode=function(B,C){A||(A=new google.maps.Geocoder());if(B.latLng){B.latLng=B.latLng.ws_coerce("google")}return A.geocode(B,C)}})();function Geocoder(){ensure_ws();this.geocoding=false;var A=have_google?new GoogleGeocoder():new BingGeocoder();this.isGeocoding=function(){return this.geocoding};this.confirmSuccess=function(){this.geocoding=false;clearTimeout(this.geoTimeout)};this.timeOut=function(){this.geocoding=false;clearTimeout(this.geoTimeout)};this.autoFillPartialGeoData=function(C,E){var B=_(function(){appEvents.fireEvent(null,"coreGeocodeFailed",[this.geoData]);if(this.failHandler){this.failHandler("Failed to find the specified location")}else{dbug("Failed to find your location")}}).bind(this);this.autoFillCallback_func=E;this.autoFillTarget=C;if(DEBUG_AUDIT_GEOCODE){dbug("auto geocode for geoData with:");dbug("query: "+C.getQuery());dbug("latlng: "+dumpGLL(C.getLatLng()))}if(C.latLng){if(C.query.length>0){C.locBase=C.LOCBASE_REVERSE_GEOCODE_WITH_ADDRESS_OVERRIDE;if(DEBUG_AUDIT_GEOCODE){dbug("locBase: LOCBASE_REVERSE_GEOCODE_WITH_ADDRESS_OVERRIDE")}}else{C.locBase=C.LOCBASE_REVERSE_GEOCODE;if(DEBUG_AUDIT_GEOCODE){dbug("locBase: LOCBASE_REVERSE_GEOCODE")}}this.reverseGeocode(C.getPreSnapLatLng(),bindCallback(this,this.autoFillCallback))}else{if(C.query.length>0){C.locBase=C.LOCBASE_GEOCODE;if(DEBUG_AUDIT_GEOCODE){dbug("locBase: LOCBASE_GEOCODE")}this.geocode(C.query,bindCallback(this,this.autoFillCallback))}else{if(this.tryCurrentLocation&&navigator.geolocation){try{C.locBase=C.LOCBASE_REVERSE_GEOCODE;if(window.ws_map_splash){ws_map_splash()}_(locate_to_accuracy_for_seconds(150,10,_(function(F){this.reverseGeocode(new ws.LatLng(F.coords.latitude,F.coords.longitude),bindCallback(this,this.autoFillCallback))},B).bind(this))).defer()}catch(D){return false}}else{B();return false}}}return true};this.autoFillCallback=function(C){if(this.autoFillTarget){if(C){this.autoFillTarget.fillDataFromGeoData(C)}var B=this.autoFillTarget.locBase}if(this.autoFillTarget&&C&&isEmptyString(this.autoFillTarget.getThoroughfare())&&B==this.autoFillTarget.LOCBASE_GEOCODE){if(DEBUG_AUDIT_GEOCODE){dbug("...didn't get a thoroughfare.  Running reverse geocode for more info.")}if(DEBUG_AUDIT_GEOCODE){dbug("reverse geo on : "+dumpGLL(this.autoFillTarget.getLatLng())+"(locBase now set to LOCBASE_GEOCODE_PLUS_REVERSE)")}this.autoFillTarget.locBase=this.autoFillTarget.LOCBASE_GEOCODE_PLUS_REVERSE;this.reverseGeocode(this.autoFillTarget.getPreSnapLatLng(),bindCallback(this,this.autoFillCallback))}else{var E=this.autoFillCallback_func;var D=this.autoFillTarget;this.autoFillCallback_func=null;this.autoFillTarget=null;if(DEBUG_AUDIT_GEOCODE){dbug("final latlng after geocoding: "+dumpGLL(D.getLatLng()))}E&&E(D)}};this.geocode=function(B,C){this.geocoding=true;this.callback_func=C;this.activeQuery=B;A.geocode({address:B},_(this.geocodeReturn).bind(this));this.geoTimeout=setTimeout(bindCallback(this,this.timeOut),15000)};this.reverseGeocode=function(C,B){this.geocoding=true;this.callback_func=B;this.activeQuery="";A.geocode({latLng:C},_(this.geocodeReturn).bind(this));this.geoTimeout=setTimeout(bindCallback(this,this.timeOut),15000)};this.geocodeReturn=function(C){var B=lat=lng=D=latLng=countryCode=formattedAddress=administrativeArea=administrativeAreaName=thoroughfare=locality=localityName=postalCode=null;_(C).detect(function(F){var G=F.geometry.location;latLng=new ws.LatLng(G.lat(),G.lng());formattedAddress=F.formatted_address;thoroughfare_parts=[];_(F.address_components).each(function(H){_(H.types).each(function(I){switch(I){case"street_number":thoroughfare_parts.unshift(H.long_name);break;case"route":thoroughfare_parts.push(H.long_name);break;case"locality":localityName=H.long_name;break;case"country":countryName=H.long_name;countryCode=H.short_name;break;case"administrative_area_level_1":administrativeAreaName=H.short_name;break;case"postal_code":postalCode=H.long_name;break}});thoroughfare=thoroughfare_parts.join(" ")});return countryCode});if(countryCode){if(DEBUG_AUDIT_GEOCODE){dbug("---NEW GEOCODE---");dbug("query: "+this.activeQuery);dbug("latlng: "+dumpGLL(latLng));dbug("countryCode: "+countryCode);dbug("countryName: "+countryName);dbug("formattedAddress: "+formattedAddress);dbug("administrativeAreaName: "+administrativeAreaName);dbug("thoroughfare: "+thoroughfare);dbug("localityName: "+localityName);dbug("postalCode: "+postalCode);dbug("---------------")}var D=new GeoData(this.activeQuery,latLng,countryCode,countryName,formattedAddress,administrativeAreaName,thoroughfare,localityName,postalCode)}else{if(C.Placemark){for(var E=1;E<C.Placemark.length;E++){if(C.Placemark[E].AddressDetails.Country){countryCode=String(C.Placemark[E].AddressDetails.Country.CountryNameCode);break}}var D=new GeoData(this.activeQuery,latLng,countryCode)}}this.activeQuery="";this.callback_func(D);this.geocoding=false}}function Scorer(A){this.walkScoreCore=A;this.dataFetcher=A.dataFetcher;this.amenityService=A.amenityService;this.amenityManager=A.amenityManager;this.geoData=A.geoData;this.rtcCache=new LocalCache().setLocation(this.geoData);this.SCOREBASE_JS=10;this.SCOREBASE_API=11;this._get_walk_shed=this.walkScoreCore.optionFlags.walk_shed==true;this.getScore=function(){return this.walkScore};this.isFinalScore=function(){return this.scoringCompleted};this.scoreLocation=function(B,C,D){this.geoData=B;this.completionCallback=C;this.scoreDetailsCallback=D;this.scoreBase=this.SCOREBASE_JS;this.snappedLatLng=new ws.LatLng(snapToGrid(B.getLat()),snapToGrid(B.getLng()));if(DEBUG_AUDIT_GEOCODE){dbug("snapped latlng for scoring: from "+dumpGLL(B.getLatLng())+" to "+this.snappedLatLng)}this.scoringCompleted=false;this.walkScore=0;if(DEBUG_BLOCK_API||this.walkScoreCore.optionFlags.forceRealTimeCalc){this.scoreRealTime(D)}else{if(this.walkScoreCore.optionFlags.forceRealTimeCalcRouted){this.scoreRealTimeRouted(D)}else{this.dataFetcher.fetchWalkScore(this.snappedLatLng.lat(),this.snappedLatLng.lng(),bindCallback(this,this.receiveFromWSAPI),this.walkScoreCore.optionFlags.getScoreDetails)}}};this.receiveFromWSAPI=function(B){var C=parseJson(B);if(C.walkscore!=null){this.scoreBase=this.SCOREBASE_API;this.scoringCompleted=true;this.walkScore=C.walkscore;this.completionCallback(this.walkScore);if(this.scoreDetailsCallback&&C.scoredetails){this.scoreDetailsCallback(C)}}else{this.scoreRealTime(this.scoreDetailsCallback)}};this.scoreRealTime=function(C,B){ensure_ws_v3_extensions();this._do_routed=B;this._rtc_response_handler=C;if(this.walkScoreCore.scoringQueryDefs){this.ScoreFromAmenities(this.walkScoreCore.scoringQueryDefs)}else{appEvents.addListener("scoreQueriesAvailable",this.ScoreFromAmenities,this);this.dataFetcher.request("scoreQueries",this.geoData)}};this.scoreRealTimeRouted=function(B){this.scoreRealTime(B,true)};this.ScoreFromAmenities=function(B){if(!B){dbug("no json for scoring queries")}this.rtcCache.setKey("_ws_rtc_"+B.profile_spec);this.queryDefs=B;this.walkScoreCore.scoringQueryDefs=B;this.queryList=new QueryList(B,"score");this.amenityService.setLocation(this.geoData);if(this.walkScoreCore.debug_no_send_amenities){this.RTCAllSystemsGo()}else{this.amenityService.runQueryList(this.queryList,bindCallback(this,this.onQueryCompleted),bindCallback(this,this.onAllQueriesCompleted))}};this.onQueryCompleted=function(B){this.amenityManager.makeAmenitiesFromRawResults(B)};this.tryRTCPost=function(G,D){var C=this.rtcCache.fetch();var E=(C&&!C.walk_sheds&&G.walk_sheds==true);if(C&&C.status&&!E){return this.handleRTCResponse(C)}var F=1;if(typeof D=="undefined"){D=F}else{if(D<=0){this._rtc_response_handler(null);trackEvent(ACTIVE_COMPONENT,"RTC aborted request");return }}var H=this;try_again=function(){H.tryRTCPost(G,D-1)};var B=this._do_routed?(isIE()?"/data/get-walkscore-rtc.php":"http://rtc.walkscore.com/score/"):"/realtime-calculator/score/";$.ajax({type:"POST",url:B,data:G,success:bindCallback(this,this.handleRTCResponse),error:try_again,dataType:"json",timeout:120000})};this.onAllQueriesCompleted=function(){this.amenityService.fetchCuratedPlaceData(this.geoData,this.amenityManager.furthestAmenityDistance(),bindCallback(this,this.RTCAllSystemsGo))};this.RTCAllSystemsGo=function(){this.tryRTCPost({lat:this.geoData.getLat(),lng:this.geoData.getLng(),profile:this.queryDefs.profile_spec,routed:this._do_routed,walk_sheds:this._get_walk_shed,amenity_cache:JSON.stringify(this.prepareRTCAmenities())})};this.handleRTCResponse=function(B,C){if(B){trackEvent(ACTIVE_COMPONENT,"RTC response received");this.walkScore=B.walkscore;this.scoringCompleted=true;this.rtcCache.store(B);if(this.completionCallback){this.completionCallback(this.walkScore)}}if(this._rtc_response_handler){this._rtc_response_handler(B,C)}};this.prepareRTCAmenities=function(){var F=this.walkScoreCore.amenityManager.untrimmed_list;var B=this.queryDefs.amenity_categories;var C={};for(var D=0;D<B.length;D++){var E=B[D];if(F.hasOwnProperty(E.name)){C[E.id]=[];_(F[E.name]).chain().reject(function(G){return G.isRemoved()}).each(_(function(G){C[E.id].push(this[{google:"trimGoogleAmenity",curation:"trimGoogleAmenity",education:"trimEducationAmenity",parks:"trimParksAmenity"}[G.originQuery.api]](G))}).bind(this))}}return C};this.trimGoogleAmenity=function(B){return{api:B.originQuery.api,city:B.city,country:"",phoneNumbers:[{number:B.phoneNumber}],lat:B.point.lat(),lng:B.point.lng(),region:B.region,streetAddress:B.streetAddress,titleNoFormatting:B.name}};this.trimParksAmenity=function(B){return{api:B.originQuery.api,name:B.name,url:B.url,center:[B.point.lat(),B.point.lng()]}};this.trimEducationAmenity=function(B){return{api:B.originQuery.api,school:{city:B.city,phonenumber:B.phoneNumber,latitude:B.point.lat(),longitude:B.point.lng(),address:B.streetAddress,schoolname:B.name,url:B.url}}};this.fake_rtc_response='{ "status": 1,"walkscore": "91","scoredetails": { "profile": "walkscore2", "is_routed": true, "percent_routable": 1.0, "locale": "us", "unroutable_origin": false, "is_suspicious": false, "is_supported_country": true },"roadmetrics": { "link_node_ratio": {"contribution": 0.0, "score": 75.254237288135585, "value": 1.7525423728813558 }, "intersection_density": {"contribution": 0.0, "score": 90.718317562380349, "value": 362.8732702495214 }, "average_block_length": {"contribution": 0.0, "score": 88.09442884397086, "value": 89.881963945036418 } },"categoryscores": { "rest_and_bars": {"contribution": 17.862223266052606, "score": 89.311116330263047, "results": [ { "distance": 0.2100571285864663, "weight": 0.75, "lon": -122.342612, "score": 99.678339031421245, "lat": 47.655546000000001, "contribution": 4.9839169515710617 },{ "distance": 0.25681229278817774, "weight": 0.45000000000000001, "lon": -122.34083699999999, "score": 97.565171655252854, "lat": 47.659272000000001, "contribution": 2.9269551496575859 },{ "distance": 0.37401545297480576, "weight": 0.25, "lon": -122.34448999999999, "score": 88.947353652853565, "lat": 47.654055999999997, "contribution": 1.4824558942142261 },{ "distance": 0.4005639935621797, "weight": 0.25, "lon": -122.34038099999999, "score": 86.355724070744941, "lat": 47.661225000000002, "contribution": 1.4392620678457491 },{ "distance": 0.40603615506267865, "weight": 0.22500000000000001, "lon": -122.34242999999999, "score": 85.794357817441949, "lat": 47.660342999999997, "contribution": 1.2869153672616291 },{ "distance": 0.41837267432459391, "weight": 0.22500000000000001, "lon": -122.338549, "score": 84.495929834609299, "lat": 47.661611000000001, "contribution": 1.2674389475191394 },{ "distance": 0.43108337602893021, "weight": 0.22500000000000001, "lon": -122.340067, "score": 83.111800586178376, "lat": 47.661290999999999, "contribution": 1.2466770087926757 },{ "distance": 0.4328312824927904, "weight": 0.22500000000000001, "lon": -122.336556, "score": 82.917882626944419, "lat": 47.660471000000001, "contribution": 1.2437682394041663 },{ "distance": 0.5019799197028143, "weight": 0.20000000000000001, "lon": -122.341953, "score": 74.617891017387791, "lat": 47.661774999999999, "contribution": 0.99490521356517059 },{ "distance": 0.50488846537963772, "weight": 0.20000000000000001, "lon": -122.336178, "score": 74.244631966590276, "lat": 47.651888999999997, "contribution": 0.98992842622120369 }] }, "grocery": {"contribution": 19.307654034120894, "score": 96.538270170604477, "results": [ { "distance": 0.27503531576654561, "weight": 3, "lon": -122.33614, "score": 96.538270170604477, "lat": 47.655745000000003, "contribution": 19.307654034120894 }] }, "shopping": {"contribution": 12.383465983987589, "score": 92.875994879906926, "results": [ { "distance": 0.19261328423956986, "weight": 0.5, "lon": -122.342203, "score": 100, "lat": 47.656413999999998, "contribution": 3.3333333333333335 },{ "distance": 0.21934004759211503, "weight": 0.45000000000000001, "lon": -122.34224, "score": 99.317262050127724, "lat": 47.657670000000003, "contribution": 2.9795178615038318 },{ "distance": 0.33829413380117834, "weight": 0.40000000000000002, "lon": -122.342736, "score": 92.073552371899211, "lat": 47.653441000000001, "contribution": 2.4552947299173122 },{ "distance": 0.36613372927968979, "weight": 0.34999999999999998, "lon": -122.341883, "score": 89.673449725849053, "lat": 47.659678999999997, "contribution": 2.0923804936031445 },{ "distance": 0.48991761717617355, "weight": 0.29999999999999999, "lon": -122.33690799999999, "score": 76.146978281498477, "lat": 47.6614, "contribution": 1.5229395656299693 }] }, "entertainment": {"contribution": 3.4732019556155382, "score": 52.098029334233075, "results": [ { "distance": 0.6639084213042914, "weight": 1, "lon": -122.332989, "score": 52.098029334233075, "lat": 47.661310999999998, "contribution": 3.4732019556155382 }] }, "coffee": {"contribution": 12.178169482728345, "score": 91.336271120462584, "results": [ { "distance": 0.20239670588220929, "weight": 1.25, "lon": -122.34220000000001, "score": 99.955128909243669, "lat": 47.657384999999998, "contribution": 8.3295940757703057 },{ "distance": 0.48330734759501665, "weight": 0.75, "lon": -122.336918, "score": 76.971508139160747, "lat": 47.661299999999997, "contribution": 3.8485754069580378 }] }, "parks": {"contribution": 6.666666666666667, "score": 100.0, "results": [ { "distance": 0.27410084065695495, "weight": 1, "lon": -122.33740075599999, "score": 100, "lat": 47.658569548599999, "contribution": 6.666666666666667 }] }, "schools": {"contribution": 6.666666666666667, "score": 100.0, "results": [ { "distance": 0.092052619426166729, "weight": 1, "lon": -122.33850099999999, "score": 100, "lat": 47.656833599999999, "contribution": 6.666666666666667 }] }, "books": {"contribution": 6.2741653346366029, "score": 94.112480019549039, "results": [ { "distance": 0.311806582070359, "weight": 1, "lon": -122.34272300000001, "score": 94.112480019549039, "lat": 47.653827999999997, "contribution": 6.2741653346366029 }] }, "banks": {"contribution": 6.62706143396416, "score": 99.405921509462402, "results": [ { "distance": 0.21712696297769182, "weight": 1, "lon": -122.342643, "score": 99.405921509462402, "lat": 47.655189, "contribution": 6.62706143396416 }] } }}'}function AmenityQuery(A,F,C,E){var D={service:safeString,api:safeString,name:safeString,id:safeString,search:null,icon:safeString,short_name:safeString,exceptions:function(G){return G?_(G).map(function(H){return H.toLowerCase()}):null},includes:_(function(G){if(!G){return null}return _(G).map(_(function(H){return new AmenityQuery(H,F,C,this)}).bind(this))}).bind(this),weights:null};for(key in D){var B=D[key];this[key]=B?B(A[key]):A[key]}this.isCustomQuery=C;this.groupName=defaultIfNotSet(F,null);this.isChild=this.parentQuery=function(){return E}}(function(){var A=AmenityQuery.prototype;A.getService=function(){return this.service};A.getName=function(){return this.name};A.getShortName=function(){return this.short_name};A.getIconName=function(){return this.icon};A.getSearch=function(B){return this.search[B]};A.getNumSearches=function(){return this.search.length};A.getExceptions=function(B){return this.exceptions};A.isCustom=function(){return this.isCustomQuery};A.getGroupName=function(){return this.groupName};A.actsLikeCustom=function(){return this.isCustomQuery||this.showOnCustomCard}})();function QueryList(A,B){this.groupName=defaultIfNotSet(B,null);this.list=[];this.by_name={};this.addQuery=function(C){this.list.push(C);this.by_name[C.getName()]=C;if(C.includes){_(C.includes).each(_(function(D){this.addQuery(D)}).bind(this))}};this.removeQuery=function(D){var C=D.name;this.list=_(this.list).reject(function(E){return E.name==C});delete this.by_name[C]};this.length=function(){return this.list.length};this.getAllQueries=function(){return this.list};this.getGroupName=function(){return this.groupName};this.getQuery=function(C){return this.list[C]};this.getQueryByName=function(C){return this.by_name[C]};this.getNonemptyQueries=function(){return _(this.list).select(function(C){return C.getService()})};if(paramIsSet(A)){_(A.amenity_categories).each(_(function(C){this.addQuery(new AmenityQuery(C,B))}).bind(this))}}function RawResults(A,B){this.results=A;this.query=B}RawResults.prototype.gotData=function(){return this.results!=null};RawResults.prototype.getService=function(){return this.query.service};RawResults.prototype.getGroupName=function(){return this.query.groupName};RawResults.prototype.getResults=function(){return this.results};RawResults.prototype.getResult=function(A){return(this.results==null)?null:this.results[A]};RawResults.prototype.getResultsLength=function(){return(this.results==null)?0:this.results.length};RawResults.prototype.getQuery=function(){return this.query};RawResults.prototype.filterOutExceptions=function(E){var B=this.query.getExceptions();if(B&&E){var C=[];for(var A in this.results){var D=(E(this.results[A])||"").toLowerCase();if(!D){continue}if(!_(B).detect(function(F){return D.indexOf(F)!=-1})){C.push(this.results[A])}}this.results=C}};function AmenityService(A){this.app=A;this.dataSourceManager=A.dataSourceManager.setAmenityService(this);this.cache=new SimpleCache();this.queue=new ActionQueue();this.localCache=new LocalCache("_ws_amenity_cache");this.curationCache=new LocalCache("_ws_curation_cache");this.activeCount=0;this.targetResultSetSize=8;this.countDownLists=[];this.requestsOut={};this.populateCache=function(B){for(var C in B){if(B.hasOwnProperty(C)){this.cache.put(C,B[C])}}};this.q_d=function(B,C){return this.dataSourceManager.dispatch(B.getService(),C)};this.INITIAL_CURATED_QUERY_RANGE=5000;this.setTargetResultSetSize=function(B){this.targetResultSetSize=B};this.setLocation=function(B){this.geoData=B;this.localCache.setLocation(B);if(!this.noAmenityLocalStorage){this.populateCache(this.localCache.fetch()||{})}};this.isIdle=function(){return(this.activeCount==0&&this.queue.length()==0)};this.runQueryList=function(C,D,B){if(C.getGroupName()&&B){this.countDownLists.push(new CountDownHash(_(C.getNonemptyQueries()).map(function(E){return E.getName()}),B))}if(window.wsProfiler&&!this._didProfile){this._didProfile=true;this.countDownLists.push(new CountDownHash(_(C.getNonemptyQueries()).map(function(E){return E.getName()}),function(){wsProfiler.event("all queries complete")}))}_(C.getNonemptyQueries()).each(_(function(E){this.runQuery(E,D,true)}).bind(this))};this.runQuery=function(C,D,B){if(!B){_(C.includes||[]).each(_(function(E){this.runQuery(E,D)}).bind(this))}if(!C.getService()){return }this.queue.add(C,D);if(this.activeCount==0){this.runNextQuery()}};this.runNextQuery=function(){if(this.queue.length()>0){var B=this.queue.getCurrentData();if(this.q_d(B,"is_ready")()){var C=this.queue.getCurrentCallback();this.queue.removeCurrent();this.activeCount++;this.q_d(B,"fetch")(B,C)}}};this.handleResults=function(B,E,C){B.filterOutExceptions(C);E(B);this.activeCount--;var D=B.getQuery().getName();_(this.countDownLists).each(function(F){F(D)});if(B.getService()=="Google"||this.activeCount==0){this.runNextQuery()}if(this.isIdle()&&!this.noAmenityLocalStorage){this.localCache.store(this.cache.data)}};this.fetchCuratedPlaceData=function(H,K,I){var D=this.curationCache.setLocation(H).fetch();if(D&&D.range>=K){this.curationCache.store(D);I(D.data);return }var C=H.getLatLng();var J=getPointFromOrig(C,0,K);var G=getPointFromOrig(C,90,K);var F=getPointFromOrig(C,180,K);var E=getPointFromOrig(C,270,K);if(DEBUG_CURATION){this.app.getMap().renderBox(J.lat(),G.lng(),F.lat(),E.lng())}var B="/data/curate.php?act=getdata&lat1="+J.lat()+"&lng1="+G.lng()+"&lat2="+F.lat()+"&lng2="+E.lng();$.ajax({url:B,type:"GET",success:_(function(M){var L=parseJson(M);this.curationCache.setLocation(H).store({data:L,range:K});I(L)}).bind(this),error:function(){I()}})}}AmenityService.prototype.removeFlagHtml=function(A){if(this.canHandleRemoves){window.currently_open_amenity=A;return'<a class="remove-flag" onclick="app.showRemoveAmenityDialog(currently_open_amenity);"></a>'}else{var B=this.app.map.geoData.getUrl()+"?utm_source="+tileDomain+"&utm_campaign=ws_tile&show="+encodeURIComponent(A.getKey())+"&act=remove";return'<a class="remove-flag" href="'+B+'&utm_medium=bubble_flag" target="_blank" title="Remove this place" onclick="trackEvent(\'tile\', \'remove result clickthrough\', \''+A.getCategory()+"');\"></a>"}};function DataSourceManager(A){this.app=A;this.init()}(function(){var C={"":{is_ready:function(){return true},fetch:function(G,I){var H=this.id+"_"+(G.search?G.search.join("_"):"");var F=this.p.as.cache.get(H);if(this.requestOut&&!F){return _(_(this.fetch).bind(this,G,I)).delay(250)}this.query=G;this.callback=I;this.cacheKey=H;if(F){return _(_(this.receiveResults).bind(this,F)).defer()}this.requestOut=true;var E=_(this.handleAjaxResponse).bind(this);$.ajax(_(_(this.ajaxRequest(G)).extend({success:E,error:E})).extend(this.extraAjaxParams()));this.p.as.listPointer++;this.p.as.runNextQuery()},params:function(E){return{lat:encodeURI(this.p.as.geoData.getLat()),lon:encodeURI(this.p.as.geoData.getLng())}},ajaxRequest:function(E){return{type:"GET",url:this.url(E),data:this.params(E)};return retval},extraAjaxParams:function(){return{}},handleAjaxResponse:function(E,G){var F=typeof E=="string"?parseJson(E):E;if(this.resultListFinder){F=this.resultListFinder(F)}delete (this.requestOut);if(F){this.p.as.cache.put(this.cacheKey,F)}this.receiveResults(F)},receiveResults:function(E){this.p.as.handleResults(new RawResults(E||null,this.query),this.callback,this.nameFinder)},makeAmenitiesFromRawResults:function(G){var I=G.getQuery();var E=this.app.amenityManager.getIconAndIconSel(I);var F=E[0];var K=E[1];var H=I.getName();var J=this.app.geoData.getLatLng();return _(_(G.results||[]).map(_(function(L){return this.createAmenity(L,J,F,K,I)||[]}).bind(this))).flatten()},buildHTML:function(N,G){var E=this.app.map;var L=[];var J=(this.app.nearbyManager&&N.displayQuery.actsLikeCustom());if(E.optionFlags.infoWindow==AmenityMap.SMALL_INFO_WINDOWS){var F=E.geoData.getUrl()+"?utm_source="+tileDomain+"&utm_campaign=ws_tile&show="+encodeURIComponent(N.getKey());var P=F+"&act=remove";if(J){F=F.replace("/score/","/nearby/")}var H="iw";var O="";var M="";if(G&&G.yelpBiz){H="iw iw-yelp";var K=G.yelpBiz;O=E.yelpHelper.getSmallIWYelpInfoHtml(K,N.getCategory());var I=(K.photo_url.indexOf("static")==-1||K.photo_url.indexOf("blank")==-1)?K.photo_url_small:"";M=(I)?'<img class="business-image" id="yelp-image" width="40px" height="40px" src="'+I+'"/>':"";if(!nolink_bubbles){M='<a href="'+F+'&utm_medium=bubble_name" target="_blank" title="Click for more info" onclick="trackEvent(\'tile\', \'result image clickthrough\', \''+N.getCategory()+"');\">"+M+"</a>"}}L.push('<div class="'+H+'">');L.push('<div class="iw-title">');if(!nolink_bubbles){L.push('<a href="'+F+'&utm_medium=bubble_name" target="_blank" title="Click for more info" onclick="trackEvent(\'tile\', \'result name clickthrough\', \''+N.getCategory()+"');\">"+N.name+"</a>")}else{L.push(N.name)}L.push("</div>");L.push(M);L.push('<div class="iw-address">'+N.getStreetAddress()+"</div>");L.push(O);if(!nolink_bubbles){L.push('<div style="clear:left;"><a href="'+F+'&utm_medium=bubble_details" target="_blank" title="Click for more info" onclick="trackEvent(\'tile\', \'result details clickthrough\', \''+N.getCategory()+"');\">View details</a></div>")}if(J){L.push('<div><a onclick="amenityMapApp.nearbyManager.removeCurrentQuery()">Remove '+N.displayQuery.name+"</a></div>")}L.push(this.p.as.removeFlagHtml(N));L.push("</div>");if(E.optionFlags.showReviews&&!G){E.yelpHelper.getAmenityData(E.gmap||E.bingMap.map,N,_(E.updateAmenityInfoWithYelp).bind(E))}}else{var O="";var M="";if(G&&G.yelpBiz){var K=G.yelpBiz;O=E.yelpHelper.getYelpInfoHtml(K,N.getCategory());var I=(K.photo_url.indexOf("static")==-1||K.photo_url.indexOf("blank")==-1)?K.photo_url:"";M=(I)?'<img class="business-image" id="yelp-image" width="100px" height="100px" src="'+I+'"/>':""}else{if(G){O='<div class="yelp-block">No reviews found.</div>'}else{if(E.optionFlags.showReviews){O=(N.phoneNumber!=null)?"<div class='yelp-block'>Searching for reviews...</div>":""}}}L.push('<div class="iw">');if(N.url){L.push('<div class="iw-title"><a href="'+N.url+'" target="_blank" title="Click to view details" onclick="trackEvent(\''+ACTIVE_COMPONENT+"', 'result  clickthrough', '"+N.getCategory()+"');\">"+N.name+"</a></div>")}else{L.push('<div class="iw-title">'+N.name+"</div>")}L.push(M);L.push(N.getLocation(true)+"<br />");if(N.getPhoneNumber()){L.push(N.getPhoneNumber())}L.push(O);L.push(E.htmlCurationLinks(N));L.push("</div>");if(E.optionFlags.showReviews&&!G){E.yelpHelper.getAmenityData(E.gmap||E.bingMap.map,N,_(E.updateAmenityInfoWithYelp).bind(E))}}return L.join("")},createAmenity:function(E,L,F,K,I){var G=I.getName();var H=this.resultClass();var J=this.resultParameters(E,I);if(!J){return }return new H(_({app:this.app,rawCenter:L,icon:F,iconSel:K,category:G,dataSource:this.id,address:"",city:"",region:"",phoneNumber:""}).extend(J))}},Curated:{},"app-created":{buildHTML:function(E){return E.getResultHTML()}},Google:{is_ready:function(){return !this.queryOut},fetchResults:function(F){var E=this.query.getSearch(F);var G=this.p.as.cache.get(E);if(G){return _(_(this.receiveResults).bind(this,G,F)).defer()}else{this.pagesPerSearch=Math.ceil(this.p.as.targetResultSetSize/(this.query.getNumSearches()*8));if(!this.gLocalSearch){this.gLocalSearch=new GlocalSearch();this.gLocalSearch.setResultSetSize(GSearch.LARGE_RESULTSET);this.gLocalSearch.setAddressLookupMode(GlocalSearch.ADDRESS_LOOKUP_DISABLED);this.gLocalSearch.setCenterPoint({x:this.p.as.geoData.getLng(),y:this.p.as.geoData.getLat()})}this.gLocalSearch.setSearchCompleteCallback(this.gLocalSearch,_(function(){var I=this.gLocalSearch.cursor;if(!this.allResults||(I&&I.currentPageIndex==0)){this.allResults=[]}for(var H=0;H<this.gLocalSearch.results.length;H++){this.allResults.push(this.gLocalSearch.results[H])}if(I&&I.pages.length>I.currentPageIndex+1&&I.currentPageIndex+1<this.pagesPerSearch){this.gLocalSearch.gotoPage(I.currentPageIndex+1)}else{this.onCallback(F)}}).bind(this),[F]);this.queryOut=true;this.gLocalSearch.execute(E)}},onCallback:function(E){this.queryOut=false;this.p.as.cache.put(this.query.getSearch(E),this.allResults);this.receiveResults(this.allResults,E)},receiveResults:function(G,E){for(var F=0;F<G.length;F++){this.results.push(G[F])}E++;if(E<this.query.getNumSearches()){this.fetchResults(E)}else{this.p.as.handleResults(new RawResults(this.results.length?this.results:null,this.query),this.callback,function(H){return H.titleNoFormatting})}},fetch:function(E,F){this.query=E;this.callback=F;this.results=[];this.allResults=[];this.fetchResults(0)},resultClass:function(){return AmenityResult},resultParameters:function(E){var F=E.phoneNumbers;var G=(F!=null&&F.length>0)?F[0].number:null;var I=(E.city!=null&&E.city.length>0)?E.city:null;var H=(E.region!=null&&E.region.length>0)?E.region:null;return{lat:E.lat,lng:E.lng,url:E.url,name:E.titleNoFormatting,address:E.streetAddress,city:I,region:H,phoneNumber:G}}},"Transit-API":{url:function(){return"/data/get-transit-data.php"},params:function(){return{q:"stops",lat:encodeURI(this.p.as.geoData.getLat()),lon:encodeURI(this.p.as.geoData.getLng())}},makeAmenitiesFromRawResults:function(E){this.app.amenityManager.initializeTransitResultsAndRoutes(E,this.app.geoData);return this.app.amenityManager.getFeaturedTransitResults()},buildHTML:function(J){var E=this.app.map;var H=[];var L=J.getRoutes();var N=new RouteList();var M=new StringList();for(var G in L){M.addIfUnique(L[G].getAgencyUrl());N.add(L[G])}N.sortByTypeAndName();if(E.optionFlags.infoWindow==AmenityMap.SMALL_INFO_WINDOWS){var F=E.geoData.getUrl()+"?utm_source="+tileDomain+"&utm_campaign=ws_tile&show=t_"+encodeURIComponent(J.getKey());H.push('<div class="iw">');H.push('<div class="iw-title">');if(nolink_bubbles){H.push(J.name)}else{H.push('<a href="'+F+'&utm_medium=bubble_details" target="_blank" title="Click for more info" onclick="trackEvent(\'tile\', \'result name clickthrough\', \''+J.getCategory()+"');\">"+J.name+"</a>")}H.push("</div>");H.push('<div class="iw-body">');var I=Math.min(14,N.length());for(var G=0;G<I;G++){var K=N.getRoute(G);if(G>0){H.push(", ")}H.push(K.getName())}H.push("</div>");H.push("</div>")}else{H.push('<div class="iw">');H.push('<div class="iw-title">'+J.name+"</div>");H.push('<div class="iw-body">');var I=Math.min(14,N.length());for(var G=0;G<I;G++){var K=N.getRoute(G);H.push('<div class="iw-transit-route '+K.getCategory()+'">'+K.getName()+"</div>")}if(I<N.length()){H.push('<div style="float:right;">and '+(N.length()-I)+" additional routes</div>")}H.push("</div>");for(var G=0;G<M.length();G++){H.push('<div class="iw-body" style="clear: both;"><a href="'+M.get(G)+'" target="_blank" onclick="trackEvent(\''+ACTIVE_COMPONENT+"', 'transit result agency clickthrough', '"+trimURL(M.get(G))+"');\">"+trimURL(M.get(G))+"</a></div>")}H.push("</div>")}return H.join("")}},"Education.com":{url:function(){return"/data/get-school-data.php"},resultClass:function(){return AmenityResult},resultParameters:function(E){var F=E.school;if(!(F&&F.enrollment&&F.enrollment>=10)){return }return{lat:F.latitude,lng:F.longitude,url:F.url,name:F.schoolname,address:F.address,city:F.city,region:F.state,phoneNumber:F.phonenumber,stuTeaRatio:F.studentteacherratio,gradelevel:F.gradelevel,gradesserved:F.gradesserved,schooltype:F.schooltype,enrollment:F.enrollment}},buildHTML:function(E){var I=this.app.map;var H=[];if(I.optionFlags.infoWindow==AmenityMap.SMALL_INFO_WINDOWS){var G=I.geoData.getUrl()+"?utm_source="+tileDomain+"&utm_campaign=ws_tile&show="+encodeURIComponent(E.getKey());var F=G+"&act=remove";H.push('<div class="iw iw-school">');H.push('<div class="iw-title">');if(!nolink_bubbles){H.push('<a href="'+G+'" target="_blank" title="Click to view details" onclick="trackEvent(\''+ACTIVE_COMPONENT+"', 'result  clickthrough', '"+E.getCategory()+"');\">"+E.name+"</a>")}else{H.push(E.name)}H.push("</div>");H.push("<div>"+E.getStreetAddress()+"</div>");if(!nolink_bubbles){H.push('<div><a href="'+G+'&utm_medium=bubble_details" target="_blank" title="Click for more info" onclick="trackEvent(\'tile\', \'result details clickthrough\', \''+E.getCategory()+"');\">View details</a></div>")}H.push(this.p.as.removeFlagHtml(E));H.push("</div>")}else{H.push('<div class="iw iw-school">');H.push('<div class="iw-title"><a href="'+E.url+'" target="_blank" title="Click to view details" onclick="trackEvent(\''+ACTIVE_COMPONENT+"', 'result  clickthrough', '"+E.getCategory()+"');\">"+E.name+"</a></div>");if(E.schooltype){H.push("<strong>Type:</strong> "+E.schooltype+"<br />")}if(E.gradesserved){H.push("<strong>Grades:</strong> "+E.gradesserved+"<br />")}if(E.stuTeaRatio){H.push("<strong>Student/Teacher ratio:</strong> "+E.stuTeaRatio+"<br />")}if(E.enrollment){H.push("<strong>Enrollment:</strong> "+E.enrollment+"<br />")}H.push(E.getLocation(true)+"<br />");if(E.phoneNumber!=null){H.push(E.getPhoneNumber())}H.push('<div class="schools-logo"><a target="_blank" href="'+E.url+'" onclick="trackEvent(\''+ACTIVE_COMPONENT+"', 'result attribution clickthrough', 'education.com');\"><img src=\"http://cdn.walkscore.com/images/education-logo.jpg\"></a></div>");H.push(I.htmlCurationLinks(E));H.push("</div>")}return H.join("")}},"Parks-API":{url:function(){return"/data/get-parks-data.php"},resultClass:function(){return AmenityResult},extraAjaxParams:function(){return{timeout:60000}},resultParameters:function(E){if(!(E.name&&E.center)){return }return{lat:E.center[0],lng:E.center[1],url:safeString(E.url),name:E.name}},buildHTML:function(E){var I=this.app.map;var H=[];if(I.optionFlags.infoWindow==AmenityMap.SMALL_INFO_WINDOWS){H.push('<div class="iw iw-park">');H.push('<div class="iw-title">');var G=I.geoData.getUrl()+"?utm_source="+tileDomain+"&utm_campaign=ws_tile&show="+encodeURIComponent(E.getKey());var F=G+"&act=remove";if(!nolink_bubbles){H.push('<a href="'+G+'" target="_blank" title="Click to view details" onclick="trackEvent(\''+ACTIVE_COMPONENT+"', 'result  clickthrough', '"+E.getCategory()+"');\">"+E.name+"</a>")}else{H.push(E.name)}H.push("</div>");if(!nolink_bubbles){H.push('<div><a href="'+G+'&utm_medium=bubble_details" target="_blank" title="Click for more info" onclick="trackEvent(\'tile\', \'result details clickthrough\', \''+E.getCategory()+"');\">View details</a></div>")}H.push(this.p.as.removeFlagHtml(E));H.push("</div>")}else{H.push('<div class="iw iw-park">');H.push('<div class="iw-title">');var G=(E.url)?E.url:null;if(G){H.push('<a href="'+G+'" target="_blank" title="Click to view details" onclick="trackEvent(\''+ACTIVE_COMPONENT+"', 'result  clickthrough', '"+E.getCategory()+"');\">"+E.name+"</a>")}else{H.push(E.name)}H.push("</div>");H.push('<div id="iw-body">Park data from <a href="http://www.openstreetmap.org/" target="_blank" onclick="trackEvent(\''+ACTIVE_COMPONENT+"', 'result attribution clickthrough', 'openstreetmap');\">OpenStreetMap</a></div>");H.push(I.htmlCurationLinks(E));H.push("</div>")}return H.join("")}},SimpleGeo:{fetch:function(G,J){var I=this.id+"_"+G.search.join("_");var F=this.p.as.cache.get(I);if(this.requestOut&&!F){return _(_(this.fetch).bind(this,G,J)).delay(250)}this.query=G;this.callback=J;this.cacheKey=I;if(F){return _(_(this.receiveResults).bind(this,F)).defer()}this.requestOut=true;var E=_(this.handleAjaxResponse).bind(this);if(!this.placesClient){this.placesClient=new simplegeo.PlacesClient("efUr8pFxSG55RpVWVC24QdVLLpMhmQAX")}var H=this.app.geoData.getLatLng();this.placesClient.search(H.lat(),H.lng(),{q:G.search.join(" ")},E);this.p.as.listPointer++;this.p.as.runNextQuery()},handleAjaxResponse:function(F,E){delete (this.requestOut);E=(E||{}).features;if(E){this.p.as.cache.put(this.cacheKey,E)}this.receiveResults(E)},nameFinder:function(E){return((((E||{}).properties||{}).name)||"")},resultClass:function(){return AmenityResult},resultParameters:function(E,G){var H=E.properties;if(!H){return }var F=_(H.classifiers).select(function(K){var J=K.category.toLowerCase();var I=K.subcategory.toLowerCase();return _(G.search).select(function(L){L=L.toLowerCase();return L==J||L==I}).length}).length;if(!F){return }return{lat:E.geometry.coordinates[1],lng:E.geometry.coordinates[0],url:safeString(H.href),name:H.name,address:H.address,city:H.city,region:H.state,phoneNumber:H.phone}}},Bing:{url:function(){return"/data/get-bing-phonebook-results.php"},params:function(E){return{lat:this.p.as.geoData.getLat(),lng:this.p.as.geoData.getLng(),q:encodeURI(E.search.join(" & "))}},resultListFinder:function(E){return _(E).spelunk(["SearchResponse","Phonebook","Results"])},nameFinder:function(E){return E.Business},resultClass:function(){return AmenityResult},resultParameters:function(E,F){return{lat:E.Latitude,lng:E.Longitude,url:safeString(E.Url),name:E.Business,address:E.Address,city:E.City,region:E.State,phoneNumber:E.PhoneNumber}}},Places:{url:function(){return"/data/get-google-places-results.php"},params:function(E){return{latlng:[this.p.as.geoData.getLat(),this.p.as.geoData.getLng()].join(","),types:encodeURI(E.search.join("|"))}},resultListFinder:function(E){return E.results},nameFinder:function(E){return E.name},resultClass:function(){return AmenityResult},resultParameters:function(E,F){return{lat:E.geometry.location.lat,lng:E.geometry.location.lng,name:E.name}}},Local:{fetch:function(E,F){this.p.app.localAmenityService.withCategory(E.name,_(function(G){this.query=E;this.callback=F;this.receiveResults(G)}).bind(this))},nameFinder:function(E){return E.stdname},resultClass:function(){return AmenityResult},resultParameters:function(E,I){var H=function(K,J){return _([_(J).map(function(L){return E[L]||[]})]).flatten().join(K)};var G=H(" ",["housenumber","predirectional","streetname","streettype","postdirectional","apttype","aptnumber"]);var F=H("-",["areacode","exchange","phonenumber"]);return{pid:E.pid,lat:E.lat,lng:E.lng,name:E.stdname,address:G,city:E.city,region:E.state,phoneNumber:F}}},Localeze:{url:function(){return"http://192.168.1.222/localeze"},params:function(E){return{lat:this.p.as.geoData.getLat(),lng:this.p.as.geoData.getLng(),cat:encodeURI(E.search.join("|"))}},resultListFinder:function(E){return E.list},nameFinder:function(E){return E.name},resultClass:function(){return AmenityResult},resultParameters:function(E,F){return{lat:E.lat,lng:E.lng,name:E.name}}},LocalezePaid:{url:function(){return"http://192.168.1.222/localeze-paid"},params:function(E){return{lat:this.p.as.geoData.getLat(),lng:this.p.as.geoData.getLng(),cat:encodeURI(E.search.join("|"))}},resultListFinder:function(E){return E.list},nameFinder:function(E){return E.name},resultClass:function(){return AmenityResult},resultParameters:function(E,F){return{lat:E.lat,lng:E.lng,name:E.name}}},Yelp:{url:function(){return"http://api.yelp.com/v2/search"},ajaxRequest:function(K){var J={consumerKey:"YeAjHh30B0O9ktMHfR2DxA",consumerSecret:"I4Bus4pi8HfFre3lIa2vCDsPutA",accessToken:"XnTIdBWQmqSdTe_YitwmUwvyzcKKP3Ma",accessTokenSecret:"N8fHqMQTV1KiqAFKSEADWiKfB8s",serviceProvider:{signatureMethod:"HMAC-SHA1"}};var G=K.search.join(",");var F={consumerSecret:J.consumerSecret,tokenSecret:J.accessTokenSecret};var L=this.app.geoData.getLatLng();var I=[["category_filter",K.search.join(",")],["ll",L.lat()+","+L.lng()],["callback","cb"],["oauth_consumer_key",J.consumerKey],["oauth_consumer_secret",J.consumerSecret],["oauth_token",J.accessToken],["oauth_signature_method","HMAC-SHA1"]];var H={action:this.url(K),method:"GET",parameters:I};OAuth.setTimestampAndNonce(H);OAuth.SignatureMethod.sign(H,F);var E=OAuth.getParameterMap(H.parameters);return{url:H.action,data:E,dataType:"jsonp",jsonpCallback:"cb",cache:true};return retval},resultListFinder:function(E){return E.businesses},nameFinder:function(E){return E.name},resultClass:function(){return AmenityResult},resultParameters:function(E,F){var H=E.location||{};var G=H.coordinate||{};return{lat:G.latitude,lng:G.longitude,url:safeString(E.Url),name:E.name,address:(H.address||[])[0],city:H.city,region:H.state_code,phoneNumber:E.phone}}},Factual:{url:function(){return"/data/get-factual-results.php"},params:function(F){var G=this.app.geoData.getLatLng();var E={"$and":[{"$loc":{"$within":{"$center":[[G.lat(),G.lng()],5000]}}},{"$or":_(F.search).map(function(H){return{category:{"$eq":escape(H)}}})}]};return{filters:JSON.stringify(E),table:"bi0eJZ"}},handleAjaxResponse:function(E){var F=parseJson(E);var G=F.response.fields;F=_(F.response.data).map(function(H){return _(_(G.length).range()).reduce(function(I,J){I[G[J]]=H[J];return I},{})});delete (this.requestOut);if(F){this.p.as.cache.put(this.cacheKey,F)}this.receiveResults(F)},nameFinder:function(E){return E.name},resultClass:function(){return AmenityResult},resultParameters:function(E,F){if(!E.latitude){return }return{lat:E.latitude,lng:E.longitude,url:safeString(E.website),name:E.name,address:E.address,city:E.city,region:E.region,phoneNumber:E.telephone}}}};for(var B in C){C[B].id=B}var A=DataSourceManager.prototype;var D=function(H,G){var F=function(I){_(this).extend(I)};F.prototype=new (G||function(){})();for(var E in H){F.prototype[E]=H[E]}return F};A.init=function(){var E=D(C[""]);this.p=this;this.m=_(_(C).keys()).reduce(_(function(F,G){F[G]=new (D(C[G],E))(this);return F}).bind(this),{})};A.setAmenityService=function(E){this.as=E;return this};A.dispatch=function(F,E){return _(this.m[F][E]).bind(this.m[F])}})();function ActionQueue(){this.list=[]}ActionQueue.prototype.length=function(){return this.list.length};ActionQueue.prototype.add=function(A,B){this.list.push({data:A,callback:B})};ActionQueue.prototype.getCurrentData=function(){return this.list[0].data};ActionQueue.prototype.getCurrentCallback=function(){return this.list[0].callback};ActionQueue.prototype.getDataAt=function(A){return this.list[A].data};ActionQueue.prototype.getCallbackAt=function(A){return this.list[A].callback};ActionQueue.prototype.removeCurrent=function(){this.list.splice(0,1)};ActionQueue.prototype.removeAt=function(A,B){var B=defaultIfNotSet(B,1);this.list.splice(A,B)};function CoreCookie(B,A){this.cookie=new BasicCookie(B,A);this.hasData=function(){return this.cookie.hasData()};this.getScore=function(){return this.cookie.getData("score")};this.getGeoData=function(){return this.cookie.getGeoData("geoData")};this.save=function(C,D){this.cookie.addGeoData("geoData",C);this.cookie.addData("score",D);this.cookie.save()};this.deleteCookie=function(){this.cookie.deleteCookie()}}function BasicCookie(B,A){if(!B||typeof B!="string"||B.length==0){dbug("bad cookie name: "+B);return }this.name=B;this.clear();this.setExtraId(A);this.data=parseJson(get_cookie(this.name));if(this.hasData()&&this.data.version!="17495"){this.deleteCookie()}else{if(!this.hasData()){this.clear()}}}BasicCookie.prototype.clear=function(){this.data=null};BasicCookie.prototype.hasData=function(){return(this.data&&(!this.extraId||this.extraId==this.data.extraId))};BasicCookie.prototype.hasDataFor=function(A){return(this.data&&(A==this.data.extraId))};BasicCookie.prototype.setExtraId=function(A){this.extraId=defaultIfNotSet(A,null)};BasicCookie.prototype.getData=function(A){if(!paramIsSet(A)){return this.data}return(this.data!==null&&this.data[A]!==null)?this.data[A]:null};BasicCookie.prototype.addData=function(A,B){if(!this.data){this.data=new Object()}this.data[A]=B};BasicCookie.prototype.getGeoData=function(B){var C=this.getData(B);if(!C){return null}var A=new GeoData();A.loadJSON(C);return A};BasicCookie.prototype.addGeoData=function(B,A){this.addData(B,A.toJSON())};BasicCookie.prototype.save=function(){if(!this.data){return false}if(this.extraId){this.data.extraId=this.extraId}this.data.version="17495";var A=JSON.stringify(this.data);set_cookie(this.name,A,7,"/","walkscore.com");return true};BasicCookie.prototype.deleteCookie=function(){delete_cookie(this.name);this.clear()};function RoutingService(){this.routesPerRequest=4;this.queue=new ActionQueue();this.progressPtr=0;this.cache=new SimpleCache();this.gdirections=new google.maps.DirectionsService();this.setDefaultStart=function(A){this.start=A};this.queueRoute=function(E,D,A,C,B){if(!_(this.queue.list).detect(function(F){return(F.data.id&&F.data.id==E)})){if(!B){var B={}}B.id=E;B.start=D;B.end=A;this.queue.add(B,C)}};this.runQueuedRequests=function(){var G=[];while(this.progressPtr<this.routesPerRequest&&this.progressPtr<this.queue.length()){var D=this.queue.getDataAt(this.progressPtr);var C=this.cache.get(D.id);if(C){var F=this.queue.getCallbackAt(this.progressPtr);F(C,D);this.queue.removeAt(this.progressPtr)}else{G.push(D.start);G.push(D.end);this.progressPtr++}}if(this.progressPtr>0){var B=this.start.ws_coerce("google");var E={origin:B,destination:B,travelMode:google.maps.TravelMode.WALKING,waypoints:_(G).map(function(H){return{location:H.ws_coerce("google")}})};var A=_(this.onGoogDirectionsReceived).bind(this);this.gdirections.route(E,A)}};this.onGoogDirectionsReceived=function(F,I){var H=(google.maps.DirectionsStatus.OK==I)?F.routes[0].legs.slice(1):[];var C=H.length;if(C!=2*this.progressPtr){dbug("WRONG NUMBER OF ROUTES returned from goog")}else{for(var B=0;B<this.progressPtr;B++){var E=H[B*2];var D=this.getPolylineFromRoute(E);var A=this.queue.getDataAt(B);var G=this.queue.getCallbackAt(B);G(D,A);this.cache.put(A.id,D)}this.queue.removeAt(0,this.progressPtr);this.progressPtr=0;this.runQueuedRequests()}};this.getPolylineFromRoute=function(A){var C=A.steps.length;var D=[];for(var B=0;B<C;B++){D.push(A.steps[B].start_location)}D.push(A.end_location);return new google.maps.Polyline({path:D,strokeColor:"blue",strokeOpacity:0.45,strokeWeight:5})};this.getCachedRoute=function(A){return this.cache.get(A)}}function AmenityMap(A){this.app=A;this.dataSourceManager=(A||{}).dataSourceManager;this.cache=new SimpleCache();this.DEFAULT_ZOOM=AmenityMap.DEFAULT_ZOOM}AmenityMap.DEFAULT_ZOOM=15;AmenityMap.LARGE_INFO_WINDOWS=30;AmenityMap.SMALL_INFO_WINDOWS=31;AmenityMap.prototype.init=function(E,A,B){this.elem=E;this.geoData=A;this.optionFlags=B;var D=(typeof this.optionFlags.zoom=="number")?this.optionFlags.zoom:this.DEFAULT_ZOOM;if(this.mapWidget){this.mapWidget.goTo(A.getLatLng(),D);this.gmap=this.mapWidget.map}if(A){this.mod_do("goTo")(A.getPreSnapLatLng(),D)}if(!$.browser.msie){E.click(_(this.closePreviouslyOpenedWindow).bind(this))}var G=E;this.transitShedMaxTime=this.optionFlags.transitShedMaxTime||60;if(A){var F=_(_(function(){if(this.activeModule){this.activateModule(this.activeModule)}else{_(F).delay(100)}}).bind(this)).max_attempts(300);if(this.optionFlags.enableRecenter){this.recenter=function(){this.mod_do("resize")()}}if(this.optionFlags.enableJiggle){if(G.height()==0){var C=_(function(){if(G.height()){this.mod_do("resize")();_(F).delay(100)}else{_(C).delay(100)}}).bind(this);C()}else{$(window).bind("mouseover mousedown",_(_(function(){if(have_google){google.maps.event.trigger(this.gmap,"resize")}F()}).bind(this)).memoize(function(){return"only once"}))}}}this.shown={};this.onlyVisibleCat=null;this.yelpHelper=new YelpHelper();if(this.optionFlags.showContextMenu){this.activateContextMenu()}};AmenityMap.prototype.GMap=function(){return this.gmap};AmenityMap.prototype.showResult=function(A){this.mod_do("addOverlay")(A.getMarker())};AmenityMap.prototype.a_d=function(A,C){var B=A.query?A.query.getService():A.getDataSource();return this.dataSourceManager.dispatch(B,C)};AmenityMap.prototype.addCustomTypeControl=function(A){this.customTypeControl=new CustomMapTypeControl(this.gmap);this.customTypeControl.addToContainer(this.elem.parent());return this.customTypeControl};AmenityMap.prototype.routeAllAmenities=function(){var B=_(this.shown).flattenObject(1);for(var A=0;A<B.length;A++){this.queueAmenityRoute(B[A],true)}this.fetchQueuedRoutes()};AmenityMap.prototype.enableRouting=function(){this.displayedRoutes={};this.permanentRoutes={};this.routing=new RoutingService();this.routing.setDefaultStart(this.geoData.getPreSnapLatLng())};AmenityMap.prototype.hidePermanentRoutesExcept=function(A){for(var B in this.permanentRoutes){if(B!=A.getHighResKey()){this.hideRoute(B,true)}}};AmenityMap.prototype.restorePermanentRoutes=function(){for(var A in this.permanentRoutes){if(!this.displayedRoutes[A]){this.showRoute(A)}}};AmenityMap.prototype.queueAmenityRoute=function(A,C){var B=A.getHighResKey();if(!this.displayedRoutes[B]&&!A.isRemoved()){this.routing.queueRoute(B,this.geoData.getPreSnapLatLng(),A.getPoint(),bindCallback(this,this.onRouteReceived),{permanent:C,name:A.getName()});this.displayedRoutes[B]=true}if(C){this.permanentRoutes[B]=true}};AmenityMap.prototype.fetchQueuedRoutes=function(){this.routing.runQueuedRequests()};AmenityMap.prototype.onRouteReceived=function(A,B){if(A&&this.displayedRoutes[B.id]){this.mod_do("addOverlay")(A)}};AmenityMap.prototype.showRoute=function(B){var A=this.routing.getCachedRoute(B);if(A){this.displayedRoutes[B]=true;this.mod_do("addOverlay")(A)}};AmenityMap.prototype.hideRoute=function(B,C){if(this.displayedRoutes[B]&&(C||!this.permanentRoutes[B])){var A=this.routing.getCachedRoute(B);if(A){this.mod_do("removeOverlay")(A)}delete this.displayedRoutes[B]}};AmenityMap.prototype.showAmenityMarkers=function(A,B){_(B||[]).each(_(function(C){if(!C.isRemoved()){this.attemptShowMarker(A,C)}else{if(C.isRemoved()){this.attemptRemoveMarker(A,C)}}}).bind(this))};AmenityMap.prototype.updateAmenityMarkers=function(B,C){for(var A in this.shown[B]){this.attemptRemoveMarker(B,this.shown[B][A])}this.showAmenityMarkers(B,C)};AmenityMap.prototype.removeAmenityMarkers=function(B,C){if(C&&C.length>0){for(var A=0;A<C.length;A++){this.attemptRemoveMarker(B,C[A])}}};AmenityMap.prototype.attemptShowMarker=function(B,A){if(typeof this.shown[B]!="object"){this.shown[B]={}}if(!this.shown[B][A.getHighResKey()]){this.shown[B][A.getHighResKey()]=A;if((!this.onlyVisibleCat||this.onlyVisibleCat==B)&&(!this.onlyShowCustom||A.displayQuery.isCustom())){this.mod_do("addOverlay")(A.getMarker())}}};AmenityMap.prototype.attemptRemoveMarker=function(B,A){if(this.shown[B]&&this.shown[B][A.getHighResKey()]){delete this.shown[B][A.getHighResKey()];this.mod_do("deselectAmenityMarker")(A);this.mod_do("removeOverlay")(A.getMarker());this.closePreviouslyOpenedWindow()}};AmenityMap.prototype.onlyShowCat=function(B){this.onlyVisibleCat=B;this.onlyShowCustom=false;if(this.lastSelected&&this.lastSelected.category!=B){this.closePreviouslyOpenedWindow()}for(var A in this.shown){if(A!=B){_(this.shown[A]).each(_(function(C){this.mod_do("setMarkerVisibility")(C.getMarker(),false)}).bind(this))}}if(_(this.shown[B]).size()>1){this.mod_do("fitBounds")(_(this.shown[B]).reduce(function(C,D){return C.extend(D.getPoint())},new ws.LatLngBounds(this.geoData.getLatLng())))}};AmenityMap.prototype.onlyShowCustomCats=function(){this.onlyShowCustom=true;this.onlyVisibleCat=null;if(this.lastSelected&&!this.lastSelected.displayQuery.actsLikeCustom()){this.closePreviouslyOpenedWindow()}var B=[];for(var A in this.shown){_(this.shown[A]).each(_(function(C){if(C.displayQuery.actsLikeCustom()){B.push(C);this.mod_do("setMarkerVisibility")(C.getMarker(),true)}else{this.mod_do("setMarkerVisibility")(C.getMarker(),false)}}).bind(this))}if(B.length>1){this.mod_do("fitBounds")(_(B).reduce(function(C,D){return C.extend(D.getPoint())},new ws.LatLngBounds(this.geoData.getLatLng())))}};AmenityMap.prototype.restoreAllCats=function(){this.closePreviouslyOpenedWindow();this.mod_do("goTo")(this.geoData.getPreSnapLatLng(),AmenityMap.DEFAULT_ZOOM);for(var A in this.shown){if(A!=this.onlyVisibleCat){_(this.shown[A]).each(_(function(B){this.mod_do("setMarkerVisibility")(B.getMarker(),true)}).bind(this))}}this.onlyVisibleCat=this.onlyShowCustom=null};AmenityMap.prototype.selectAmenityMarker=function(B,C){if(this.yelpUpdateInProgress){return }this.deselectLastSelectedAmenityMarker();var A=this.mod_do("selectAmenityMarker",_(function(){this.lastSelected=B}).bind(this));if(this.optionFlags.highlightSelectedAmenity){A(B,C)}else{A(null)}if(this.optionFlags.showRouteOnSelect){this.hidePermanentRoutesExcept(B)}};AmenityMap.prototype.deselectLastSelectedAmenityMarker=function(){if(this.yelpUpdateInProgress){return }if(this.lastSelected){if(this.optionFlags.highlightSelectedAmenity&&this.lastSelected.getMarkerSel){this.mod_do("deselectAmenityMarker")(this.lastSelected)}if(this.optionFlags.showRouteOnSelect){this.restorePermanentRoutes()}}this.lastSelected=null};AmenityMap.prototype.getCachedIWContent=function(A){return(A.getUniqueId)?this.cache.get(A.getUniqueId()):null};AmenityMap.prototype.cacheIWContent=function(A,B,C){if(A.getUniqueId){this.cache.put(A.getUniqueId(),[B,C])}};AmenityMap.prototype.showAmenityInfoWithSlowPan=function(B,A,D,C){this.showAmenityInfo(B,C,A,D)};AmenityMap.prototype.showAmenityInfo=function(B,D,A,G){if(this.selectHandler){GEvent.removeListener(this.selectHandler);this.selectHandler=null}var F=this.getCachedIWContent(B);if(F){var C=F[0];var E=F[1]}else{var C=this.buildAmenityHTML(B);var E=false;this.cacheIWContent(B,C,false)}this.showAmenityInfoInternal(B,C,E,D);if(this.optionFlags.autoShowTransit&&B.getDataSource()=="Transit-API"){this.addTransitLayer()}this.mod_do("customPanTo")(B.getPoint(),A,G)};AmenityMap.prototype.forceClosePreviouslyOpenedWindow=function(){if(this.previouslyOpenedWindow){this.mod_do("closeInfoWindow")(this.previouslyOpenedWindow)}this.previouslyOpenedWindow=null;this.deselectLastSelectedAmenityMarker()};AmenityMap.prototype.closePreviouslyOpenedWindow=(function(){ensureWSUnderscoreMixins();return _(function(){this.forceClosePreviouslyOpenedWindow();this.mod_deselect()}).recharge(50)})();AmenityMap.prototype.showAmenityInfoInternal=function(A,C,F,E){if(DEBUG_CURATION){dbug("showing: "+A.getName()+" with key: "+A.getKey())}var D=this.optionFlags.infoWindow==AmenityMap.SMALL_INFO_WINDOWS;var B=new ws.InfoWindow({content:C,isSmall:D});B.setOptions({});this[this.yelpUpdateInProgress?"forceClosePreviouslyOpenedWindow":"closePreviouslyOpenedWindow"]();this.mod_do("openInfoWindow",_(function(){this.previouslyOpenedWindow=B}).bind(this))(B,A,E);if(!D){this.wireUpCurationLinks(A)}this.selectAmenityMarker(A,E)};AmenityMap.prototype.wireUpCurationLinks=function(A){var B=this.app;var C=function(D,G,E){var F=function(){$(".curate-links").children().eq(D).unbind().click(function(H){G&&B[G](A,H.pageX,H.pageY);E&&E(H)})};_([750,1500]).each(function(H){_(F).delay(H)})};C(0,"showRemoveAmenityDialog");if(_(["Curated","Local"]).include(A.getDataSource())){C(1,"showEditAmenityDialog")}else{if(A.getDataSource()=="Google"){C(1,null,function(D){window.open(A.getUrl()+"&mode=edit","edit")})}}};AmenityMap.prototype.addTransitLayer=function(){this.gmap.addTransitLayer()};AmenityMap.prototype.removeTransitLayer=function(){this.gmap.removeTransitLayer();GEvent.removeListener(this.transitLayerListener)};AmenityMap.prototype.buildAmenityHTML=function(A){return this.a_d(A,"buildHTML")(A)};AmenityMap.prototype.updateAmenityInfoWithYelp=function(A,C){var B=(C&&true);if(B||this.optionFlags.infoWindow!=AmenityMap.SMALL_INFO_WINDOWS){var D=this.a_d(A,"buildHTML")(A,{yelpBiz:C});this.cacheIWContent(A,D,B);this.yelpUpdateInProgress=true;this.showAmenityInfoInternal(A,D,B);this.yelpUpdateInProgress=false}};AmenityMap.prototype.htmlTitle=function(){};AmenityMap.prototype.htmlCurationLinks=function(A){var B=[];B.push('<div class="curate-links dull-link"><a class="flagged">Remove place</a>');if(_(["Curated","Google","Local"]).include(A.getDataSource())){B.push("<a>Edit</a>")}B.push("</div>");return B.join("")};AmenityMap.prototype.activateContextMenu=function(){this.mod_do("activateContextMenu")()};AmenityMap.prototype.showAds=function(){var A=Array.prototype.slice.call(arguments);var B=_(_(function(){if(this.gmap){showAdsOnMap.apply(this.gmap,A)}else{_(B).delay(100)}}).bind(this)).max_attempts(100);B()};AmenityMap.prototype.isBigEnoughForAds=_(function(){return this.elem.width()*this.elem.height()>=100368}).memoize(function(){return"only once"});AmenityMap.prototype.renderBox=function(F,E,A,C){var B=[new ws.LatLng(F,E),new ws.LatLng(F,C),new ws.LatLng(A,C),new ws.LatLng(A,E),new ws.LatLng(F,E)];var D=new google.maps.Polygon({paths:B,fillColor:"#4ead42",strokeWeight:1,strokeOpacity:0.5,strokeColor:"#4ead42",fillOpacity:0.2});this.mod_do("addOverlay")(D)};var mapKeyDisplayer=function(B,A){return function(){var D=$("#g-overlay");var C="dunno";_(function(){var F=D.find(".enticement");var G=F.length?"yes":"no";if(G==C){return }C=G;$("#"+B).remove();var E=$("<div />",{id:B,"class":"map_key"}).css("right",F.width()+16+"px").css("height",F.height()+"px");_(A()).each(function(H){E.append(H)});D.after(E)}).thump(250,40)}};AmenityMap.prototype.showWalkabilityKey=mapKeyDisplayer("walkability_map_key",function(){return[$("<img />",{id:"walkability_map_spectrum",src:"http://cdn.walkscore.com/images/map-spectrum.png"}),$("<div />",{"class":"worst"}).html("0"),$("<div />",{"class":"best"}).html("100"),$("<div />",{"class":"background"})]});AmenityMap.prototype.hideWalkabilityKey=function(){$("#walkability_map_key").remove()};AmenityMap.prototype.showWalkShedKey=mapKeyDisplayer("walkshed_map_key",function(){return[$("<div />",{"class":"walkshed_color"}),$("<div />",{"class":"walkshed_label"}).html("15 min walk"),$("<div />",{"class":"background_solid"})]});AmenityMap.prototype.hideWalkShedKey=function(){$("#walkshed_map_key").remove()};AmenityMap.prototype.showTransitKey=mapKeyDisplayer("transit_map_key",function(){return[$("<div />",{"class":"transit_label"}),$("<div />",{"class":"background_solid"})]});AmenityMap.prototype.hideTransitKey=function(){$("#transit_map_key").remove()};AmenityMap.prototype.showTransitSlider=function(){var D=$("#transit_map_key");var B=D.find(".transit_label");var A=$("<div />",{id:"transit_slider"}).css("width","200px").css("right",(D.width()+$("#g-overlay").width())+"px");$("#g-overlay").after(A);var C=_(function(F){B.html(F+" min transit");this.transitShed.setTravelTime(F)}).bind(this);var E=this.transitShedMaxTime;A.slider({range:false,min:0,value:E,max:this.transitShedMaxTime,slide:function(G,F){C(F.value)}});_(_(function(){this.gmap.fitBounds(this.transitShed.getBoundingBox());this.gmap.setZoom(this.gmap.getZoom()+1);this.transitShed.setMap(this.gmap);C(E)}).bind(this)).delay(100)};AmenityMap.prototype.hideTransitSlider=function(){this.transitShed.setMap(null);$("#transit_slider").remove()};(function(){var C=[{name:"Google Map",id:"mod_google_map",api:"google",is_default:true,enable:function(I){this.googleMap||(this.googleMap=new GoogleMap(this.app));this.gmap||(this.gmap=this.googleMap.ensure());I&&I(this.gmap)},activate:function(){this.googleMap.activate()},deactivate:function(){this.googleMap.deactivate()},resize:function(){this.googleMap.resize();var I=this.gmap.lastCenter;google.maps.event.trigger(this.gmap,"resize");if(I){this.gmap.setCenter(I)}},goTo:function(I,J){this.gmap.goTo(I,J)},addOverlay:function(I){this.gmap.addOverlay(I)},fitBounds:function(I){this.gmap.fitBounds(I)},removeOverlay:function(I){this.gmap.removeOverlay(I)},setMarkerVisibility:function(I,J){I.ws_with("google",function(K){K.setVisible(J)})},customPanTo:function(J,I,K){this.gmap.customPanTo(J,I,K)},selectAmenityMarker:function(I){var J=this.gmap;if(I&&I.getMarkerSel){I.getMarkerSel().ws_with("google",function(K){J.addOverlay(K)})}},deselectAmenityMarker:function(I){var J=this.gmap;if(I&&I.getMarkerSel){I.getMarkerSel().ws_with("google",function(K){J.removeOverlay(K)})}},openInfoWindow:function(J,I){J.removeClass("transparent").removeClass("nonub");var K=this.gmap;J.ws_with("google",function(L){if(I){I.getMarker().ws_with("google",function(M){L.open(K,M)})}else{L.open(K)}})},closeInfoWindow:function(I){I.ws_with("google",function(J){J.close()})},handleNewCategory:function(){_(_(function(){delete this.mod_catchup.handleNewCategory}).bind(this)).defer()},activateContextMenu:_(function(){var I;var J=$("<a />",{id:"context-menu-score-link"}).html("Get Walk Score").click(function(){if(I){trackEvent(ACTIVE_COMPONENT,"map context menu get score");goToAddress("loc",I.lat(),I.lng())}});var K=$("<div />",{"class":"context"}).css("visibility","hidden").css("width","100px").append(J).append("<img src='http://cdn.walkscore.com/images/crosshairs.gif'>");$("#"+this.googleMap.div_id).append(K);google.maps.event.addListener(this.googleMap.map,"rightclick",function(L){I=L.latLng;K.css("top",L.pixel.y).css("left",L.pixel.x).css("visibility","visible")});google.maps.event.addListener(this.googleMap.map,"click",function(L){K.css("visibility","hidden")})}).memoize(function(){return"only once"})},{name:"Street View",id:"mod_street_view",is_default:true,prereq:"mod_google_map",enable:function(I){if(!this.gmap){return I(false)}this.svPano=this.gmap.getStreetView();this.svPano.setEnableCloseButton(false);this.svService=new google.maps.StreetViewService();this.svService.getPanoramaByLocation(this.geoData.getLatLng(),100,function(K,J){I(J==google.maps.StreetViewStatus.OK)})},activate:function(){this.svPano.setVisible(true)},deactivate:function(){this.svPano.setVisible(false)},goTo:function(I,J){this.gmap.customPanTo(I)},selectAmenityMarker:function(I,J){if(!J&&I&&I.getMarkerSel){this.gmap.addOverlay(I.getMarkerSel())}},openInfoWindow:function(J,I,K){if(J.isSmall&&!K){J.addClass("transparent").addClass("nonub").ws_with("google",_(function(L){L.open(this.svPano,I?I.getMarker():null)}).bind(this))}},closeInfoWindow:function(I){if(I.isSmall){I.ws_with("google",function(J){J.close()})}},handleNewCategory:function(){this.activateModule("mod_google_map")}},{name:"Bing Map",id:"mod_bing_map",api:"bing",is_default:false,not_in_all:true,enable:function(I){if(have_bing){this.bingMap||(this.bingMap=new BingMap(this.app))}I(have_bing)},activate:function(){this.bingMap.activate()},deactivate:function(){this.bingMap.deactivate()},resize:function(){this.bingMap.resize();var I=this.bingMap.map.lastCenter;if(I){this.bingMap.map.setCenter(I)}},fitBounds:function(I){this.bingMap.map.fitBounds(I)},selectAmenityMarker:function(I){if(I&&I.getMarkerSel){this.bingMap.map.addOverlay(I.getMarkerSel())}},deselectAmenityMarker:function(I){if(I&&I.getMarkerSel){this.bingMap.map.removeOverlay(I.getMarkerSel())}},goTo:function(I,J){this.bingMap.map.goTo(I,J)},addOverlay:function(I){if(I.visible){this.bingMap.map.addOverlay(I)}else{this.bingMap.map.removeOverlay(I)}},removeOverlay:function(I){this.bingMap.map.removeOverlay(I)},setMarkerVisibility:function(I,J){I.visible=J;this.mod_do("addOverlay")(I)},openInfoWindow:function(J,I){this.bingMap.map.openInfoWindow(J.removeClass("transparent").removeClass("nonub"),I?I.getMarker():null)},closeInfoWindow:function(I){this.bingMap.map.removeOverlay(I)},customPanTo:function(J,I,K){this.bingMap.map.customPanTo(J,I,K)}},{name:"Bird's Eye",id:"mod_birds_eye",is_default:true,fallback:"mod_bing_map",prereq:"mod_bing_map",enable:function(I){if(have_bing){this.bingMap||(this.bingMap=new BingMap(this.app))}I(have_bing)},activate:function(){this.bingMap.map.setMapType(Microsoft.Maps.MapTypeId.birdseye)},deactivate:function(){this.bingMap.map.setMapType(Microsoft.Maps.MapTypeId.road)},fitBounds:function(I){},customPanTo:function(K,I,L){var J=this.bingMap.map;J.customPanTo(K,I,L);_(_(J.setView).bind(J,{zoom:J.getZoomRange().max})).delay(1000)},goTo:function(J,K){var I=this.bingMap.map;I.goTo(J,K);_(_(I.setView).bind(I,{zoom:I.getZoomRange().max})).delay(1000)},selectAmenityMarker:function(){},deselectAmenityMarker:function(){},openInfoWindow:function(){},closeInfoWindow:function(){}},{name:"MapQuest Map",id:"mod_mapquest_map",api:"mapquest",not_in_all:true,enable:function(I){Modernizr.load({load:"http://open.mapquestapi.com/sdk/js/v6.1.0/mqa.toolkit.js",complete:_(function(){this.mqMap||(this.mqMap=new MapQuestMap(this.app));I(true)}).bind(this)})},activate:function(){this.mqMap.activate()},deactivate:function(){this.mqMap.deactivate()},resize:function(){this.mqMap.resize()},fitBounds:function(I){this.mqMap.map.fitBounds(I)},selectAmenityMarker:function(I){if(I&&I.getMarkerSel){this.mqMap.map.removeOverlay(I.getMarker());this.mqMap.map.addOverlay(I.getMarkerSel())}},deselectAmenityMarker:function(I){if(I&&I.getMarkerSel){this.mqMap.map.addOverlay(I.getMarker());this.mqMap.map.removeOverlay(I.getMarkerSel())}},goTo:function(I,J){this.mqMap.map.goTo(I,J)},addOverlay:function(I){if(I.visible){this.mqMap.map.addOverlay(I)}else{this.mqMap.map.removeOverlay(I)}},removeOverlay:function(I){this.mqMap.map.removeOverlay(I)},setMarkerVisibility:function(I,J){I.visible=J;this.mod_do("addOverlay")(I)},openInfoWindow:function(J,I){this.mqMap.map.openInfoWindow(J.removeClass("transparent").removeClass("nonub"),I?I.getMarker():null)},closeInfoWindow:function(I){I=(I._ws_||{}).mq_infobox;I&&I.close()},customPanTo:function(J,I,K){this.mqMap.map.customPanTo(J,I,K)}},{name:"Walkability Map",id:"mod_walkability",is_default:true,prereq:"mod_google_map",enable:function(I){this.googleMap||(this.googleMap=new GoogleMap(this.app));this.gmap||(this.gmap=this.googleMap.ensure());appEvents.addListener("isRankingsCityAvailable",_(function(J){var K=(window.google&&google.maps&&google.maps.ImageMapType&&J&&J[0]&&J[0].isRankingsCity);if(K){this.heatMap=new google.maps.ImageMapType({getTileUrl:CustomGetTileUrl,opacity:0.45,tileSize:new google.maps.Size(256,256),isPng:true})}I(K)}).bind(this));this.app.walkScoreCore.request("isRankingsCity")},activate:function(){this.gmap.overlayMapTypes.push(this.heatMap);this.showWalkabilityKey()},deactivate:function(){this.gmap.overlayMapTypes.pop();this.hideWalkabilityKey()}},{name:"Walkability Map",id:"mod_walkability_bing",is_default:false,not_in_all:true,prereq:"mod_bing_map",fallback:"mod_bing_map",enable:function(I){if(have_bing){this.bingMap||(this.bingMap=new BingMap(this.app));this.heatMap=new Microsoft.Maps.TileLayer({visible:false,opacity:0.6,mercator:new Microsoft.Maps.TileSource({uriConstructor:"/bing_tile?qk={quadkey}"})})}appEvents.addListener("isRankingsCityAvailable",_(function(K){var L=(this.bingMap&&K&&K[0]&&K[0].isRankingsCity);if(L){I(true);var J=_(_(function(){if(!_(this).spelunk(["bingMap","map","entities"])){return _(J).delay(100)}this.bingMap.map.entities.push(this.heatMap)}).bind(this)).max_attempts(1000);_(J).defer()}else{I(false)}}).bind(this));this.app.walkScoreCore.request("isRankingsCity")},activate:function(){this.heatMap.setOptions({visible:true});this.showWalkabilityKey()},deactivate:function(){this.heatMap.setOptions({visible:false});this.hideWalkabilityKey()}},{name:"15 Minute Walk",id:"mod_walkshed",is_default:true,prereq:"mod_google_map",enable:function(I){this.googleMap||(this.googleMap=new GoogleMap(this.app));this.gmap||(this.gmap=this.googleMap.ensure());if(have_google){this.walkShedService=(new WalkShedService()).setLocation(this.geoData).withWalkShed(I)}else{I(false)}},activate:function(){var I=_(this.walkShedService.getPoints()||[]).map(function(J){return new google.maps.LatLng(J[1],J[0])});if(!I.length){return }if(!this.walkShedPolygon){this.walkShedPolygon=new google.maps.Polygon({fillColor:"#4ead42",strokeColor:"#4ead42",fillOpacity:0.2,strokeOpacity:0.4});this.walkShedPolygon.setPath(I)}this.walkShedPolygon.setMap(this.gmap);_(_(function(){this.gmap.fitBounds(_(I).reduce(function(J,K){return J.extend(K)},new ws.LatLngBounds(this.geoData.getLatLng())).ws_coerce("google"));this.gmap.setZoom(this.gmap.getZoom()+1)}).bind(this)).defer();this.showWalkShedKey()},deactivate:function(){if(this.walkShedPolygon){this.walkShedPolygon.setMap(null)}this.hideWalkShedKey()}},{name:"Nearby Photos",id:"mod_panoramio",prereq:"mod_google_map",enable:function(I){this.googleMap||(this.googleMap=new GoogleMap(this.app));this.gmap||(this.gmap=this.googleMap.ensure());if(have_google&&!this.panoramioLayer){this.panoramioLayer=new google.maps.panoramio.PanoramioLayer()}I(this.panoramioLayer)},activate:function(){this.panoramioLayer.setMap(this.gmap)},deactivate:function(){this.panoramioLayer.setMap(null)}},{name:"Transit Shed",id:"mod_transit",is_default:false,not_in_all:true,prereq:"mod_google_map",enable:function(I){this.googleMap||(this.googleMap=new GoogleMap(this.app));this.gmap||(this.gmap=this.googleMap.ensure());Modernizr.load({load:"http://cdn.walkscore.com/js/sheds_v17495.js",complete:_(function(){var J={traversal_time:this.transitShedMaxTime,computation_timeslice:200};this.transitShed=new Sheds.transit(J).setLocation(this.app.geoData.getLatLng()).onDataReceived(I)}).bind(this)})},activate:function(){this.showTransitKey();this.showTransitSlider()},deactivate:function(){this.hideTransitSlider();this.hideTransitKey()}}];var H=_(C).reduce(function(J,I){J[I.id]=I;return J},{});var B=false;var E=function(I){$("#map-module-selector").removeClass("active");B=false};var F=function(I){$("#map-module-selector").addClass("active");B=true};var G=function(I){if(B){E()}else{F()}I.stopPropagation()};var A=AmenityMap.prototype;A.initModuleControls=function(){var K=this.modules_enabled;this.have_initialized=true;var J=_(C).select(function(N){return K[N.id]});$("body").click(E);var L=$("#map-module-selector");if(J.length>1){var I=$("<div />",{"class":"options"});L.empty().append($("<div />",{"class":"enticement"}).bind("selectstart mousedown",function(){return false}).html(J[1].name+"...").click(G)).append(I);_(J).each(_(function(O){var N=$("<div />",{id:O.id}).bind("selectstart mousedown",function(){return false}).html(O.name).click(_(this.activateModule).bind(this,O.id)).click(E);if(O.id==this.activeModule){N.addClass("selected")}I.append(N)}).bind(this));E();$("#g-overlay").css("opacity",0).removeClass("disabled").addClass("visible").animate({opacity:1},500)}else{$("#g-overlay").addClass("disabled")}if(this.activate_on_initialization){var M=this.activate_on_initialization;delete (this.activate_on_initialization);if(!this.modules_enabled[M]){M="any"}this.activateModule(M)}};A.allModules=function(){return _(C).chain().reject(function(I){return I.not_in_all}).map(function(I){return I.id}).value()};A.defaultModules=function(){return(_(C).chain().select(function(I){return I.is_default}).map(function(I){return I.id}).value())};var D={};A.enableModule=function(K){if(!this.modules_enabled){this.modules_enabled={}}var J=H[K];if(!J){return }var I=_(_(function(L){this.modules_enabled[K]=L;delete (D[K]);if(!_(D).keys().length){this.initModuleControls()}}).bind(this)).memoize(function(){return"only_once"});D[K]=_(J.enable||function(L){L(true)}).bind(this,I);_(function(){I(false)}).delay(5000)};A.finalizeModules=function(){_(_(D).keys()).each(function(I){D[I]()})};A.activateModule=function(M,K){var J=this.modules_enabled;if(!this.have_initialized&&!J[M]){return this.activate_on_initialization=M}else{if(!J[M]&&!K){M=_(C).select(function(N){return J[N.id]})[0].id}}var I=H[M];this.deactivateModule();this.activeModule=M;$("#"+M).addClass("selected");var L=I.prereq;if(L){(H[L].activate||function(){}).call(this)}(I.activate||function(){}).call(this);if(this.mod_catchup){for(todo in this.mod_catchup){this.mod_catchup[todo]()}}};A.deactivateModule=function(){var J=this.activeModule;if(!J){return }this.forceClosePreviouslyOpenedWindow();$("#"+J).removeClass("selected");(H[J].deactivate||function(){}).call(this);var I=H[J].prereq;if(I){(H[I].deactivate||function(){}).call(this)}};(function(){var I;A.lock=function(J){if(I){throw new Error("Already locked")}I=this.activeModule;if(J&&J!=I){this.activateModule(J)}$("#g-overlay").css("visibility","hidden")};A.unlock=function(){if(I!=this.activeModule){this.activateModule(I)}I=null;$("#g-overlay").css("visibility","visible")}})();A.mod_do=function(K,I){var J=_(function(){var S=this.activeModule;var P=H[S]||{};var N=Array.prototype.slice.call(arguments);var R=(P.api||H[P.fallback||"mod_google_map"]["api"]||H.mod_google_map["api"]);var L=_(N).map(function(T){return(S&&(T||{}).ws_coerce&&R)?T.ws_coerce(R):T});if(S){(P[K]||H[P.fallback||"mod_google_map"][K]||H.mod_google_map[K]).apply(this,L)}this.mod_catchup||(this.mod_catchup={});var M=N[0];var O=_(["addOverlay","setMarkerVisibility"]).include(K)?[K,M.id].join("_"):K;this.mod_catchup[O]=_(J).bindsplat(this,N);var Q={goTo:["fitBounds"],fitBounds:["goTo"],removeOverlay:[["addOverlay",(M||{}).id].join("_")],addOverlay:[["removeOverlay",(M||{}).id].join("_")]};_(Q[K]||[]).each(_(function(T){delete (this.mod_catchup[T])}).bind(this));if(I){I()}}).bind(this);return J};A.mod_deselect=function(){_(["selectAmenityMarker","openInfoWindow"]).each(_(function(I){delete this.mod_catchup[I]}).bind(this))}})();var MobileAmenityMap=(function(){function B(C){this.app=C;this.cache=new SimpleCache();this.DEFAULT_ZOOM=16}B.prototype=new AmenityMap();var A=B.prototype;A.buildAmenityHTML=function(C,E){var D=this.app.resultPanels;var F=D.pageId(C);D.makeAmenityPage(C);return'<a href="#'+F+'" id="info_'+F+'">'+C.getName()+"</a>"};return B})();var SenchaAmenityMap=(function(){function B(D,C){this.app=D;this.mapWidget=C;this.gmap=C.map;this.cache=new SimpleCache();this.DEFAULT_ZOOM=16}B.prototype=new AmenityMap();var A=B.prototype;A.cacheIWContent=function(){};A.buildAmenityHTML=function(D,G){var C;if(D instanceof SimpleMarker){var H=this.app.score;if(H){C='<div class="ws_text ws_iw">Walk Score: '+H+'</div><div class="ws_text ws_iw">'+getScoreDescription(H)+"</div>"}else{C="Walk Score"}}else{if(D instanceof AmenityResult||D instanceof TransitResult){var F=this.app.resultPanels;C=($("<div />").addClass("ws_text").addClass("ws_iw").html(D.getName()).append($("<div />",{"class":"next-icon"}))[0]);var E=_(function(){var I=$(".ws_miniwindow");if(I[0]){I.click(_(F.showAmenityPage).bind(F,D))}else{_(E).delay(50)}}).max_attempts(100);_(E).defer()}else{C=""}}return C};return B})();function YelpHelper(){this.callback=null;this.getAmenityData=function(E,B,G){if(B.yelpLookupDone||B.phoneNumber==null){return }this.callback=G;var A=E.getBounds();var D="http://www.walkscore.com/data/get-yelp-data.php?phone="+encodeURI(cleanNumber(replaceAll(B.phoneNumber,"#"," ")));var F=this;var C=B;$.ajax({url:D,type:"GET",success:function(H){F.yelpResultsCallback(H,C)},error:function(){F.yelpResultsCallback("",C)}})};this.yelpResultsCallback=function(A,B){var F=parseJson(A);var C=null;var G=null;var E;if(!F||F==""||F.businesses.length==0||F.businesses[0].reviews.length==0){var D=null}else{var D=F.businesses[0]}this.callback(B,D)};this.getYelpInfoHtml=function(A,C){if(!A){return'<div class="yelp-block">No reviews found.</div>'}var B=[];B.push('<div class="yelp-block"><img class="ratings-image" src="'+A.rating_img_url_small+'"/> based on ');B.push(A.review_count+" reviews<br/>");B.push("<a onclick=\"trackEvent('"+ACTIVE_COMPONENT+"', 'yelp clickthrough', '"+C+'\')" href="'+A.url+'" target="_blank">Read the reviews</a></div>');return B.join("")};this.getYelpInfoMobile=function(B,D){if(!B){return'<div class="yelp-block">No reviews found.</div>'}var C=[];var A=B.rating_img_url;C.push('<div class="yelp-block">');C.push('<img class="ratings-image" src="'+A+'"/>');C.push("<a onclick=\"trackEvent('"+ACTIVE_COMPONENT+"', 'yelp clickthrough', '"+D+'\')" href="'+B.url+'" target="_blank">Read reviews ('+B.review_count+")</a></div>");return C.join("")};this.getSmallIWYelpInfoHtml=function(A,C){if(!A){return""}var B=[];B.push('<div class="iw-reviews">');B.push("<a onclick=\"trackEvent('"+ACTIVE_COMPONENT+"', 'yelp clickthrough', '"+C+'\')" href="'+A.url+'" target="_blank">');B.push('<img class="yelp-logo" width="37px" height="14px" src="http://cdn.walkscore.com/images/tile/yelp.gif" /><img class="ratings-image" src="'+A.rating_img_url_small+'"/>');B.push("</a>");B.push("</div>");return B.join("")}}function SecondaryMap(){}(function(){var B=SecondaryMap.prototype;var A=0;B.activate=function(){this.show();this.ensure()};B.deactivate=function(){this.hide()};B.show=function(){var C=this.app.map.elem;var D=this._ensure_div();D.offset(C.offset())};B.hide=function(){$("#"+this.div_id).offset({top:-1000,left:-1000})};B.ensure=function(){this._ensure_div();return this._ensure_map()};B.resize=function(){var C=this.app.map.elem;var D=$("#"+this.div_id);D.width(C.width()).height(C.height()).offset(C.offset())};B._ensure_div=function(){var C=this.app.map.elem,D=$("#"+this.div_id);if(C[0]&&!this._did_make_div){this._did_make_div=true;this.div_id+="-"+(A++);D=$("<div />",{id:this.div_id}).insertAfter(C);D.css("position","absolute").css("z-index",(C.css("z-index")||0)).width(C.width()).height(C.height()).offset({top:-1000,left:-1000})}return D}})();function GoogleMap(A){this.app=A;this.div_id="google-map-element"}(function(){var A=GoogleMap.prototype=new SecondaryMap();A._ensure_map=function(){if(this.map){return this.map}ensure_ws_v3_extensions();if(!have_google){return null}var B=this.app.map;var D=_(B.optionFlags.gmapOptions||{}).extend({styles:[{featureType:"poi.business",stylers:[{visibility:"off"}]}]});var E=this.map=(this.app.map.gmap||new google.maps.Map($("#"+this.div_id)[0],D));E._ws_=B;google.maps.event.addListener(E,"click",_(B.closePreviouslyOpenedWindow).bind(B));var C=function(){E.lastCenter=E.getCenter()};google.maps.event.addListener(E,"center_changed",C);google.maps.event.addListener(E,"zoom_changed",C);return E}})();function BingMap(A){this.app=A;this.div_id="bing-map-element"}(function(){var A=BingMap.prototype=new SecondaryMap();A._ensure_map=function(){if(this.map){return this.map}ensure_ws_bing_extensions();var E=$("#"+this.div_id);var B=this.app.map;var D=_({credentials:"AtX92KDrTaB4704zm7Gny87y1H4qvO-CVhaSo84YdAhe1kTmNb69K3QgOEDuvkxJ",mapTypeId:Microsoft.Maps.MapTypeId.road,enableSearchLogo:false,enableClickableLogo:false,showMapTypeSelector:false}).extend(B.optionFlags.bingOptions||{});var G=this.map=new Microsoft.Maps.Map(E[0],D);E.click(_(B.closePreviouslyOpenedWindow).bind(B));var C=function(){G.lastCenter=G.getCenter()};var F=function(H,I){Microsoft.Maps.Events.addHandler(G,H,I)};F("viewchangeend",C);F("viewchangestart",function(){G.in_viewchange_=true});F("viewchangeend",function(){G.in_viewchange_=false});if(!D.enableMouseWheel){F("mousewheel",function(H){H.handled=true})}return G}})();function MapQuestMap(A){this.app=A;this.div_id="mq-map-element"}(function(){var A=MapQuestMap.prototype=new SecondaryMap();A._ensure_map=function(){if(this.map){return this.map}ensure_ws_mapquest_extensions();var B=this.map=new MQA.TileMap($("#"+this.div_id)[0],null,null,"map");MQA.withModule("largezoom",function(){B.addControl(new MQA.LargeZoom(),new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT,new MQA.Size(5,5)))});return B}})();function LocalAmenityService(){}(function(){var C=LocalAmenityService.prototype;C.setQueryList=function(W){V=W;return this};C.setBucketMin=function(W){D=W;return this};C.setLocation=function(W){I=W;U();return this};C.withCategory=function(W,X){Q(W,X);return this};C.withFiltered=function(W,X){Q(W,X,true);return this};C.withAll=function(W){Q("",W);return this};C.withAllFiltered=function(W){Q("",W,true);return this};C.expect=function(W){K(W);return this};C.populate=function(W,X){E(W,X);return this};var S={};var P={};var A={};var G={};var R=false;var L=false;var N=false;var F=1;var D=8;var H;var I;var V;var B=($.browser.msie&&$.browser.version<8);var Q=function(W,Y,X){S[W]||(S[W]=[]);S[W].push([Y,X]);M()};var M=function(){if(!L){return }for(var W in S){if(G[W]){continue}var X=S[W];S[W]=[];_(X).each(function(Z){var Y=Z[0];var b=Z[1];var a=_(W?[P[W]||[],_((V.by_name[W]||{}).includes||[]).map(function(c){return P[c.name]||[]})]:[_(P).values()]).flatten();if(b){J(a,Y)}else{Y(a)}})}};var K=function(W){if(R){throw new Error("Must call expect before setLocation")}G[W]=true};var E=function(W,X){if(!G[W]){throw new Error("Receiving amenities for unexpected category: "+W)}delete (G[W]);P[W]=X;M()};var U=_(function(){R=true;if(B){T(null)}else{if(V){O()}else{(new DataFetcher("local_counts")).requestPrivate("overviewQueries",I,O)}}}).memoize(function(){return"only once"});var O=function(X){V||(V=new QueryList(X,"counts"));var W=_(V.getAllQueries()).chain().map(function(a){if((a.api||"")!="local"){return[]}var Z=a.search||[];_(Z).each(function(c){A[c]=a.name});var b=a;while(b.isChild()){b=b.parentQuery()}return b.name}).flatten().uniq().value();var Y={custom:"customize",travelQueries:"tile-travel",commercialQueries:"tile-commercial"}[V.groupName||""]||"";$.ajax({url:"/local-amenities",type:"GET",dataType:"json",timeout:60000,success:T,error:_(T).bind({},null),data:{lat:I.latLng.lat(),lng:I.latLng.lng(),bucket_min:D,slice:Y,r:1,buckets:W.join("||")}})};var J=function(W,X){H||(H=new WalkShedService());H.setLocation(I)[N?"withWalkShed":"withNothing"](function(a){var Z;if(a){var b=new OpenLayers.Geometry.Polygon(new OpenLayers.Geometry.LinearRing(_(a).map(function(c){return new OpenLayers.Geometry.Point(c[1],c[0])})));Z=_(W||[]).filter(function(e){var c=new OpenLayers.Geometry.Point(e.lat,e.lng);return c.intersects(b)})}else{var Y=I.latLng;Z=_(W||[]).filter(function(e){var c=new ws.LatLng(e.lat,e.lng);return((c.distanceFrom(Y)/1000)*0.621371192<F)})}X(Z)})};var T=function(W){_(W||[]).each(function(Y){var X=A[Y.category]||"";P[X]||(P[X]=[]);P[X].push(Y)});L=true;M()}})();function WalkShedService(){}(function(){var H=WalkShedService.prototype;H.setLocation=function(K){J=K;return this};H.noAjax=function(K){F=true;return this};H.withWalkShed=function(K){B(K);C();return this};H.withNothing=function(K){K(null);return this};H.setWalkShed=function(K){E(K);return this};H.getPoints=function(){return I};var G=[];var F;var J;var I;var B=function(K){G.push(K);A()};var A=function(){if(!I){return }while(G.length){G.shift()(I)}};var C=function(){if(F){return }F=true;$.ajax({url:"/data/get-walkshed.php",type:"GET",dataType:"json",success:_(D).bind(this),error:_(D).bind(this,null),data:{lat:J.latLng.lat(),lng:J.latLng.lng()}})};var D=function(L){var K=L||{status:-1};if(K.status==1&&!K.walk_shed.is_suspicious){E(K.walk_shed)}else{E(null)}};var E=function(K){if(K){I=K.geometry.coordinates[0]}else{if(false){I=_(new OpenLayers.Geometry.Polygon.createRegularPolygon(new OpenLayers.Geometry.Point(J.latLng.lat(),J.latLng.lng()),0.75/69.04,20).components[0].components).map(function(L){return[L.y,L.x]})}}A()}})();
