function TabHeader(B,A){this.walkScoreCore=B;this.geoData=A;this.hoodName=null;this.fromCookie=true;this.isRankingsCity=false;this.hoodName=null;this.init=function(){if(this.geoData.getQuery()&&!this.geoData.latLng){$("#street").val(this.geoData.getQuery())}if(!$("#your-score").eq(0).html()){this.fromCookie=false;var C=$("#badge");C.children(".progress").css("display","block");$("#score-details").css("display","none")}appEvents.addListener("coreGeocode",this.onGeocode,this);appEvents.addListener("coreGeocodeFailed",this.onFailedGeocode,this);appEvents.addListener("scoreCompleted",this.onScoringCompleted,this);appEvents.addListener("isRankingsCityAvailable",this.updateRankingsCity,this);appEvents.addListener("hoodInfoAvailable",this.updateHoodInfo,this);appEvents.addListener("scoreDetails",this.onScoreDetailsReceived,this);this.walkScoreCore.request("isRankingsCity");this.walkScoreCore.request("hoodInfo");this.hoodTabChecklist=new Checklist(["hood","rankings"],bindCallback(this,this.updateHoodTab))};this.onGeocode=function(C){this.geoData=C;if(!this.fromCookie){$("#geo-address").html(C.getBestFormattedAddress())}};this.onFailedGeocode=function(){showMessage(WS_M_NOT_FOUND,"alert")};this.onScoringCompleted=function(D){this.score=D;if(!this.fromCookie){var C=$("#badge");C.find("#your-score").html(D);C.children(".progress").remove();C.children("#score-helptext").html("Out of 100").fadeIn(1000);$("#score-description").html(getScoreDescription(D));$("#score-details").fadeIn(1000)}if(_.indexOf(["US","CA","NZ","AU"],this.geoData.countryCode)==-1){this.showScoreAlert("unsupported country")}};this.updateRankingsCity=function(C){if(C){this.isRankingsCity=C.isRankingsCity;this.hoodTabChecklist.check("rankings")}};this.updateHoodInfo=function(C){if(C&&C.status==200&&C.neighborhood&&C.neighborhood.name){this.hoodName=C.neighborhood.name}this.hoodTabChecklist.check("hood")};this.updateHoodTab=function(){var D=(this.hoodName)?this.hoodName:this.geoData.getPostalCode();if(this.isRankingsCity&&D){var C=this.geoData;$("#hoodtab").fadeIn(1000).click(function(){goToHoodTab(C,D)}).children().html(D);this.hoodCookie=new BasicCookie("hood",getLocationKey(this.geoData));this.hoodCookie.addData("hoodName",D);this.hoodCookie.save();var E={isHood:(this.hoodName!=null),locationName:D};appEvents.fireEvent(null,"hoodOrZipAvailable",[E])}};this.onScoreDetailsReceived=function(D){var C=(this.geoData.countryCode=="IE"||this.geoData.countryCode=="UK"||this.geoData.countryCode=="GB");if(ACTIVE_COMPONENT=="score-report"&&D&&D.scoredetails){if(C||D.scoredetails.is_supported_country===false){this.showScoreAlert("unsupported country")}else{if(ACTIVE_COMPONENT=="score-report"&&(!D||D.scoredetails.is_routed===false)){this.showScoreAlert("street smart unavailable")}}}};this.showScoreAlert=function(D){if(this._scoreAlert){return }this._scoreAlert=D;if(D=="unsupported country"){var F=this.geoData.getCountryName();var C=[];C.push("<h3>Unsupported Country</h3>");C.push("<p>Walk Score is not yet supported in "+F+". ");C.push("We do not have enough data to ensure an accurate score.</p>")}else{if(D=="street smart unavailable"){var C=[];C.push("<h3>Street Smart Walk Score Unavailable</h3>");C.push("<p>The score for this address was calculated using crow-flies distances rather than walking distances. ");C.push("Our map is not accurate enough in this location to calculate walking distances.</p>")}}if(C){var E=_(function(G){showDialog(G,"alert",true,100,100)}).bind({},C.join(""));$("#your-score").append('<div id="score-alert"></div>');$("#score-alert").click(E);trackEvent(ACTIVE_COMPONENT,"show score alert",D)}}}function CommentsWidget(E,C,B){this.app=E;this.geoData=C;this.locationName=null;this.loaded=false;appEvents.addListener("hoodOrZipAvailable",this.hoodOrZipAvailable,this);appEvents.addListener("facebookScriptLoaded",this.onFacebookScriptLoaded,this);this.subcats={"Getting Around":["Walking","Biking","Transit","Driving"],Safety:["Crime Safety","Pedestrian Safety","Other"],Places:["Best Places","Public Spaces","Problem Spots","Other"],Schools:["Public Schools","Private Schools","Walking to School","Other"],Community:["People","Pretty or Not","Economy","Noise","Other"],Other:""};this.segments={"Getting Around":"",Safety:"/safety",Places:"/places",Schools:"/schools",Community:"",Other:""};var D=this;$("#comment-cat input[type=radio]").customInput();$("#comment-cat input").change(function(F){D.setCommentCat($(this).val())});var A="getting-around";if(B){A=B.replace(/\s+/g,"-")}$("#i-"+A).trigger("click").trigger("updateState").trigger("change");$("#comment-cat input").change(function(F){trackEvent("User Comments","Category Checked",$(this).val())})}CommentsWidget.prototype.hoodOrZipAvailable=function(A){if(A&&A.locationName&&this.geoData.countryCode=="US"){this.locationName=A.locationName;this.isHood=A.isHood;$("#neighborhood-comments").css("display","block").children("h2").html("Comment on "+this.locationName);this.updateFBWidget()}};CommentsWidget.prototype.setCommentCat=function(A){this.currentCat=A;if(this.currentSegment!=this.segments[A]){this.currentSegment=this.segments[A];this.updateFBWidget()}var D="";if(A=="Other"){$("#subcat-helptext").html("What category is your comment?");D+="<input type='text' id='user-other-cat' name='user-other-cat'>"}else{$("#subcat-helptext").html("Check the boxes related to your comment:");for(var C in this.subcats[A]){var B=this.subcats[A][C];var E=B.replace(/\s+/g,"_");D+="<input type='checkbox' name='subcat' value='"+E+"' /> <label for='"+E+"' >"+B+"</label> &nbsp;&nbsp;&nbsp;"}}$("#subcat-radios").html(D);$("#subcat-radios input").change(function(F){trackEvent("User Comments","Subcategory Checked",$(this).val())})};CommentsWidget.prototype.updateFBWidget=function(){if(this.locationName){this.commentsHref="http://www.walkscore.com"+getHoodUrl(this.geoData,this.locationName)+this.currentSegment;var A='<fb:comments href="'+this.commentsHref+'" num_posts="2" width="475"></fb:comments>';$("#fb-comment-div").html(A);if(typeof FB!="undefined"){FB.XFBML.parse(document.getElementById("fb-comment-div"))}if(window.position_ads){_(position_ads).thump(500,20)}}};CommentsWidget.prototype.onFacebookScriptLoaded=function(){FB.Event.subscribe("comment.create",_(function(A,B){this.recordComment(A.href,A.commentID)}).bind(this));FB.Event.subscribe("comment.remove",_(function(A){this.deleteComment(A.href,A.commentID)}).bind(this));this.updateFBWidget()};CommentsWidget.prototype.recordComment=function(A,B){activeComment=B;var E="";var C=this.currentCat;if(this.currentCat=="Other"){C=$("#user-other-cat").val();trackEvent("User Comments","Other text",C)}else{E=_($("#subcat-radios input[type=checkbox]:checked")).map(function(F,G){return F.value.replace(/\_+/g," ")}).join(",")}var D={id:B,url:A,category:C,subcategories:E,origin_url:String(document.location.href),lat:this.geoData.preSnapLatLng.lat(),lng:this.geoData.preSnapLatLng.lng(),hood:(this.isHood)?this.locationName:"",postal:this.geoData.postalCode,city:this.geoData.locality,region:this.geoData.adminArea,country:this.geoData.countryCode};this.create(D);trackEvent("User Comments","Comment Saved",C)};CommentsWidget.prototype.create=function(A){$.ajax({url:"/auth/comments/create",type:"GET",cache:false,dataType:"json",data:A})};CommentsWidget.prototype.deleteComment=function(){};function Sharer(A,B){this.geoData=A;this.score=B;this.showShareOptions=function(C,F,E,D){C=defaultIfNotSet(C,null);F=defaultIfNotSet(F,null);this.showShareScore("all",C-110,F+20,E,D);trackEvent(ACTIVE_COMPONENT,"share score: activate","share your score");return false};this.showShareScore=function(F,I,G,D,J){I=defaultIfNotSet(I,null);G=defaultIfNotSet(G,null);if(F=="facebook"){var K=window.location.href;var L="Check out my Walk Score, then find out your own on WalkScore.com";window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(K)+"&t="+encodeURIComponent(L),"sharer","toolbar=0,status=0,width=626,height=436");hideDialog();trackEvent(ACTIVE_COMPONENT,"share score: execute","facebook")}else{if(F=="twitter"){var L="I just got a Walk Score of "+this.score+". What's yours? http://www.walkscore.com";window.open("http://twitter.com/intent/tweet?text="+encodeURIComponent(L));hideDialog();trackEvent(ACTIVE_COMPONENT,"share score: execute","twitter")}else{if(F=="email"){document.location="/tell-a-friend.shtml?score="+this.score+"&url="+escape(window.location.href);trackEvent(ACTIVE_COMPONENT,"share score: execute","email")}else{if(F=="onyoursite"){document.location="/professional/";trackEvent(ACTIVE_COMPONENT,"share score: execute","on your site")}else{var H=(D)?D:"Share Your Walk Score";var M=(J)?J:"Share your score with a friend or add Walk Score to a real estate listing.";var E=[];E.push("<h3>"+H+"</h3>");E.push("<p class='tight-bot'>"+M+"</p>");E.push("<div class='share-twitter'><span>Twitter</span></div>");E.push("<div class='share-email'><span>Email</span></div>");E.push("<div class='share-facebook'><span>Facebook</span></div>");E.push("<div class='share-onyoursite'><span>On Your Site</span></div>");showDialog(E.join(""),"share-score",true,I,G);var C=this;$(".share-twitter").bind("click",function(){C.showShareScore("twitter")});$(".share-email").bind("click",function(){C.showShareScore("email")});$(".share-facebook").bind("click",function(){C.showShareScore("facebook")});$(".share-onyoursite").bind("click",function(){C.showShareScore("onyoursite")})}}}}}}var GPANEL_VIEW_MAP=0;var GPANEL_VIEW_STREET=1;function StreetViewController(B,A){this.customControl=A;this.customControl.setStreetViewCallback(bindCallback(this,this.streetViewOnOff));this.visible=false;this.view=GPANEL_VIEW_MAP;this.streetview=B;this.popupShown=false}StreetViewController.prototype.streetViewOnOff=function(A){if(A){this.showStreet()}else{this.hideStreet()}};StreetViewController.prototype.update=function(A){if(A==GPANEL_VIEW_STREET){}else{if(this.streetview.hasImagery()){if(!this.visible){this.customControl.showStreetViewButton();this.visible=true}this.customControl.enableStreetViewButton()}else{if(this.visible){this.customControl.disableStreetViewButton()}}}this.view=A};StreetViewController.prototype.updateStreetviewAvailability=function(A){if(A){this.hidePopupMessage()}else{this.setMessage("");this.showPopupMessage()}this.update(this.view)};StreetViewController.prototype.hideStreet=function(){this.streetview.hide();$("#pano-wrap").hide();this.update(GPANEL_VIEW_MAP);trackEvent(ACTIVE_COMPONENT,"show mapview")};StreetViewController.prototype.showStreet=function(){$("#pano-wrap").css("display","block");this.update(GPANEL_VIEW_STREET);this.streetview.show();trackEvent(ACTIVE_COMPONENT,"show streetview")};StreetViewController.prototype.findResult=function(A){this.setMessage(A.getLocation());this.findTarget(A.getPoint())};StreetViewController.prototype.findTarget=function(A){this.streetview.findTarget(A)};StreetViewController.prototype.setMessage=function(A){$("#pano-message").html("<p>"+A+"</p>")};StreetViewController.prototype.showPopupMessage=function(A){if(!this.popupShown){$("#pano-popup-message").css("display","block");this.popupShown=true}};StreetViewController.prototype.hidePopupMessage=function(A){if(this.popupShown){$("#pano-popup-message").hide();this.popupShown=false}};function DataCurator(B,A){this.app=B;this.fbConnector=A;this.activeAmenity=null}DataCurator.COMMENT_MAX_LENGTH=500;DataCurator.prototype.initRemovePlace=function(B,A,E){this.x=A+20;this.y=E-70;var C=[];C.push("<h3>Remove This Place?</h3>");C.push('<form name="curate-form" id="curate-form" method="post">');C.push('<p class="pad-top tight-bot">Reason for removing '+B.getName()+":</p>");C.push('<ul class="bulletless">');C.push('<li class="tight-bot"><label for="rem1"><input type="radio" name="removeType" id="rem1" value="closed or not exist"> Closed or doesn\'t exist</label></li>');C.push('<li class="tight-bot"><label for="rem2"><input type="radio" name="removeType" id="rem2" value="wrong category"> Doesn\'t belong in '+B.getCategory()+"</label></li>");C.push('<li class="tight-bot"><label for="rem3"><input type="radio" name="removeType" id="rem3" value="duplicate"> Duplicate listing</label></li>');C.push('<li><label for="rem4"><input type="radio" name="removeType" id="rem4" value="other"> Other</label></li>');C.push('</ul><div class="pad-top"><label>Comments: <span class="extra comments-required" style="display: none;">(required)</span> <span id="char-counter"></span></label><br />');C.push('<textarea name="comments" id="comments" style="width:95%;" rows="2" ></textarea></div>');C.push('<div id="facebook-user-login"></div>');C.push('<div><input id="curate-confirm" type="button" value="Remove Place" /> &nbsp; <input id="curate-cancel" type="button" value="Cancel" /></div>');C.push('<div id="curation-messaging"><p class="tight-bot">&nbsp;</p></div>');C.push("</form>");showDialog(C.join(""),"curate-place",true,this.x,this.y);this.updateFacebookLoginInfo();this.activeAmenity=B;var D=this;$("#curate-form").submit(function(){D.saveRemovedPlace()});$("#curate-confirm").click(bindCallback(this,this.saveRemovedPlace));$("#curate-cancel").click(hideDialog);$("#curate-form").find("input[type=radio]").click(bindCallback(this,this.updateUI));$("#comments").keyup(function(){limitText($("#comments"),$("#char-counter"),DataCurator.COMMENT_MAX_LENGTH)});trackEvent("Curation","Show remove dialog",document.location.href)};DataCurator.prototype.getFacebookParams=function(A){var B="";B+=urlifyParam("&fbid",A.id);B+=urlifyParam("&fbn",A.name);B+=urlifyParam("&fbfirst",A.first);B+=urlifyParam("&fblast",A.last);B+=urlifyParam("&fbem",A.email);B+=urlifyParam("&fbg",A.gender);B+=urlifyParam("&fbloc",this.fbConnector.getUserLocation());B+=urlifyParam("&fbwrk",this.fbConnector.getUserWorkJson());return B};DataCurator.prototype.saveRemovedPlace=function(){var A=this.fbConnector.getUser();if(!A){return }var E=$("#curate-form");var H=E.find("textarea").val();var D=E.find("input:radio[name=removeType]:checked").blur().val();if(D==undefined){$("#curation-messaging").children().addClass("form-error-message").html("Please select a reason for removing.");return }else{if(D=="other"&&H.length==0){$("#curation-messaging").children().addClass("form-error-message").html("Please comment on the reason for removing this place.");return }}if(DEBUG_CURATION){dbug("saving removed place: "+this.activeAmenity.getName())}var C=this.activeAmenity.getKey();if(isUserAddedAmenity(C)&&!this.activeAmenity.local_source){this.deleteAmenity()}else{var B=this.activeAmenity.local_source;if(B){this.deleteAmenity(true);this.activeAmenity=B;B.key=generateAmenityKey(B.name,B.point,"Local");C=B.getKey()}var F="";F+=urlifyParam("act","remove");F+=urlifyParam("&key",C);F+=urlifyParam("&lat",this.activeAmenity.getPoint().lat());F+=urlifyParam("&lng",this.activeAmenity.getPoint().lng());F+=urlifyParam("&reason",D);F+=urlifyParam("&comment",H);F+=urlifyParam("&cat",this.activeAmenity.getCategory());F+=urlifyParam("&ws_url",document.location.href);F+=this.getFacebookParams(A);var G=this;this.submitData(F,function(I){G.onRemoveComplete(parseJson(I))});$("#curate-confirm").attr("disabled",true);$("#curation-messaging").children().removeClass("form-error-message").addClass("progress").html("Saving your change...")}};DataCurator.prototype.onRemoveComplete=function(A){if(A&&A.report=="success"){this.app.removeAmenities([this.activeAmenity.getKey()]);this.showCuratePlaceThanks();trackEvent("Curation","Remove amenity",document.location.href);this.activeAmenity=null}else{$("#curation-messaging").children().removeClass("progress").addClass("form-error-message").html("Couldn't save your change, try reloading this page.");$("#curate-confirm").attr("disabled",false)}};DataCurator.prototype.showCuratePlaceThanks=function(){var A=[];A.push("<h3>Thank You!</h3>");A.push("<p>We've updated the listing for "+this.activeAmenity.getName()+".</p>");A.push('<p><a id="curate-thanks-close">Close this window</a></p>');showDialog(A.join(""),"curate-place",true,this.x,this.y);$("#curate-thanks-close").click(hideDialog)};DataCurator.prototype.initRestorePlace=function(B,A,E){this.x=A+20;this.y=E-70;var C=[];C.push("<h3>Restore This Place</h3>");C.push('<form name="curate-form" id="curate-form" method="post">');C.push("<p>"+B.getName()+" was removed by a Walk Score user.</p>");C.push("<p>Click the button below to restore it.</p>");C.push('<div><label>Comments:</label> <span id="char-counter"></span></label><br />');C.push('<textarea name="comments" id="comments" style="width:90%;" rows="3" ></textarea></div>');C.push('<div id="facebook-user-login"></div>');C.push('<div><input id="curate-confirm" type="button" value="Restore Place" /> &nbsp; <input id="curate-cancel" type="button" value="Cancel" /></div>');C.push('<div id="curation-messaging"><p class="tight-bot"></p></div>');C.push("</form>");showDialog(C.join(""),"curate-place",true,this.x,this.y);this.updateFacebookLoginInfo();this.activeAmenity=B;var D=this;$("#curate-form").submit(bindCallback(this,this.saveRestoredPlace));$("#curate-confirm").click(bindCallback(this,this.saveRestoredPlace));$("#curate-cancel").click(hideDialog);$("#comments").keyup(function(){limitText($("#comments"),$("#char-counter"),DataCurator.COMMENT_MAX_LENGTH)});trackEvent("Curation","Show restore dialog",document.location.href)};DataCurator.prototype.saveRestoredPlace=function(){var A=this.fbConnector.getUser();if(!A){return }var B=$("#curate-form");var E=B.find("textarea").val();var C="";C+=urlifyParam("act","restore");C+=urlifyParam("&key",this.activeAmenity.getKey());C+=urlifyParam("&comment",B.find("textarea").val());C+=urlifyParam("&cat",this.activeAmenity.getCategory());C+=urlifyParam("&ws_url",document.location.href);C+=this.getFacebookParams(A);var D=this;this.submitData(C,function(F){D.onRestoreComplete(parseJson(F))});$("#curate-confirm").attr("disabled",true);$("#curation-messaging").children().removeClass("form-error-message").addClass("progress").html("Saving your change...")};DataCurator.prototype.onRestoreComplete=function(A){if(A&&A.report=="success"){hideDialog();this.app.restoreAmenity(this.activeAmenity);trackEvent("Curation","Restore amenity",document.location.href);this.activeAmenity=null}else{$("#curation-messaging").children().removeClass("progress").addClass("form-error-message").html("Couldn't save your change, try reloading this page.");$("#curate-confirm").attr("disabled",false)}};DataCurator.prototype.initEditPlace=function(B,C,D,A,E){this.activeAmenity=B;this.showAddOrEditPlace("Edit",C,B.getCategory(),D,A,E);trackEvent("Curation","Show edit dialog",document.location.href)};DataCurator.prototype.initAddPlace=function(C,B,D,A,E){this.activeAmenity=null;this.showAddOrEditPlace("Add",C,B,D,A,E);trackEvent("Curation","Show add dialog",document.location.href)};DataCurator.prototype.showAddOrEditPlace=function(F,J,B,E,M,K){this.geocoder=E;this.x=M+20;this.y=K-70;var I=[];I.push("<h3>"+F+" a Place</h3>");I.push('<form name="curate-form" id="curate-form" method="post">');I.push("<p><label>What type of place?</label><br />");I.push('<select name="category">');(function(){var N={};var O=0;_(J.list).chain().map(function(P){_(P.includes||[]).each(function(Q){N[Q.getName()]=P.getName()});return P}).map(function(Q){var P=Q.getName();var R=N[P];return[R||P,R?Q.getShortName():Q.includes?"Other":null,P]}).sort(function(Q,P){return(Q[0]<P[0]?-1:Q[0]>P[0]?1:"Other"==P[1]?-1:"Other"==Q[1]?1:Q[1]<P[1]?-1:Q[1]>P[1]?1:0)}).map(function(P){return[P[1]?(P[0]+": "+P[1]):P[0],P[2],P[0]]}).each(function(P){I.push('<option value="'+P[1]+'"'+((P[2]==B&&!O++)?" selected":"")+">"+P[0]+"</option>")})})();I.push("</select></p>");I.push('<div id="add-map"></div>');I.push("<p><label>Place Name <span>e.g. Irwin's Coffee Shop</span></label><br />");I.push('<input name="placename" type="text"></input></p>');I.push("<p><label>Address <span>e.g. 2123 N 40th St. Seattle, WA 98103</span></label><br />");I.push('<input name="address" id="add-address" type="text"></input></p>');I.push("<p><label>Phone Number <span>e.g. (206)555-5555</span></label><br />");I.push('<input name="phone" type="text"></input></p>');I.push("<p><label>Website <span>e.g. www.irwins.com</span></label><br />");I.push('<input name="site" type="text"></input></p>');I.push('<div><label>Comments:</label><br /> <span id="char-counter"></span>');I.push('<textarea name="comments" id="comments"></textarea></div>');I.push('<div id="facebook-user-login"></div>');I.push('<div><input id="curate-confirm" type="button" value="Submit" /> &nbsp; <input id="curate-cancel" type="button" value="Cancel" /></div>');I.push('<div id="curation-messaging"><p class="tight-bot"></p></div>');I.push("</form>");showDialog(I.join(""),"add-place",true,this.x,this.y);this.updateFacebookLoginInfo();var G=have_google?{mapTypeId:google.maps.MapTypeId.ROADMAP,mapTypeControl:false,streetViewControl:false,scrollwheel:false,panControl:false,zoomControl:false}:{};var C=have_google?{}:{mapTypeId:Microsoft.Maps.MapTypeId.road,showDashboard:false};this.geoData=new GeoData(undefined,new ws.LatLng(-7,-95));this.map=new AmenityMap(this);this.map.init($("#add-map"),this.geoData,{autoShowTransit:false,zoom:0,bingOptions:C,gmapOptions:G});var H=have_google?"mod_google_map":"mod_bing_map";this.map.enableModule(H);this.map.finalizeModules();this.map.activateModule(H);var D=this;$("#curate-form").submit(bindCallback(this,this.saveAddedPlace));$("#curate-confirm").click(bindCallback(this,this.saveAddedPlace));$("#curate-cancel").click(hideDialog);$("#add-address").change(bindCallback(this,this.geocodeAddAddress));$("#comments").keyup(function(){limitText($("#comments"),$("#char-counter"),DataCurator.COMMENT_MAX_LENGTH)});if(this.activeAmenity){var L=this.activeAmenity;var A=$("#curate-form");if("Local"==L.getDataSource()&&!L.userAddress){L.userAddress=_(["getStreetAddress","getCity","getRegion"]).map(function(N){return L[N]()}).join(" ")}_({category:B,placename:reversespecialchars(L.getName()),address:L.userAddress,phone:reversespecialchars(L.getPhoneNumber()),site:reversespecialchars(L.getUrl())}).each(function(O,N){A.find("[name="+N+"]").val(O)});this.geocodeAddAddress()}};DataCurator.prototype.geocodeAddAddress=function(){var A=$("#add-address").val();var B=new GeoData(A);this.geocoder.autoFillPartialGeoData(B,bindCallback(this,this.showGeocodeLocation))};DataCurator.prototype.showGeocodeLocation=function(A){if(this.addPlaceMarker){this.map.mod_do("removeOverlay")(this.addPlaceMarker)}this.icon||(this.icon=(new IconFactory()).makeBuildingIcon());if(A&&A.hasData()){this.addGeoData=A;$("#curation-messaging").children().html("");this.addPlaceMarker=new ws.Marker({position:A.getPreSnapLatLng(),icon:this.icon});this.map.mod_do("addOverlay")(this.addPlaceMarker);this.map.mod_do("goTo")(A.getPreSnapLatLng(),AmenityMap.DEFAULT_ZOOM)}else{$("#curation-messaging").children().addClass("form-error-message").html("Couldn't locate this address -- please try again.")}};DataCurator.prototype.saveAddedPlace=function(){var S=this.fbConnector.getUser();if(S){var B=$("#curate-form");var L=B.find("[name=category]").val();var T=B.find("[name=placename]").val();var E=B.find("[name=address]").val();var I=B.find("[name=phone]").val();var F=B.find("[name=site]").val();var A=B.find("textarea").val();var K=F.indexOf("://");if(F.length>0&&K==-1||K>8){F="http://"+F}if(!T){$("#curation-messaging").children().addClass("form-error-message").html("Please enter the name of the place to add.")}else{if(!E||!this.addGeoData||!this.addGeoData.hasData()){$("#curation-messaging").children().addClass("form-error-message").html("Couldn't locate this address -- please try again.")}else{if(F.length>0&&!isValidUrl(F)){$("#curation-messaging").children().addClass("form-error-message").html("Please correct the website address, or leave it blank.")}else{var O=this.addGeoData.getPreSnapLatLng();var Q=generateAmenityKey(T,O,"Curated");var H=O.lat();var R=O.lng();var D=this.addGeoData.getThoroughfare();var M=this.addGeoData.getCity();var C=this.addGeoData.getAdminArea();var G=this.addGeoData.getPostalCode();if(this.activeAmenity){if("Local"==this.activeAmenity.getDataSource()){this.activeAmenity.key="ws_local_"+this.activeAmenity.pid}Q=this.activeAmenity.key}var P="";P+=urlifyParam("key",Q);P+=urlifyParam("&cat",L);P+=urlifyParam("&name",T);P+=urlifyParam("&user_address",E);P+=urlifyParam("&address",D);P+=urlifyParam("&city",M);P+=urlifyParam("&region",C);P+=urlifyParam("&postal",G);P+=urlifyParam("&lat",H);P+=urlifyParam("&lng",R);P+=urlifyParam("&phone",I);P+=urlifyParam("&url",F);P+=urlifyParam("&ws_url",document.location.href);P+=urlifyParam("&comment",A);P+=this.getFacebookParams(S);var N=this;var J={category:L,key:Q,pid:(this.activeAmenity?this.activeAmenity.pid:""),lat:H,lng:R,url:F,name:T,user_address:E,address:D,city:M,region:C,postal:G,phone:I};if(this.activeAmenity&&this.activeAmenity.getDataSource()!="Local"){P+=urlifyParam("&act","edit");P+=urlifyParam("&old_key",this.activeAmenity.getKey());P+=urlifyParam("&old_cat",this.activeAmenity.getCategory())}else{P+=urlifyParam("&act","add")}this.submitData(P,function(U){N.onAdditionComplete(parseJson(U),J)});$("#curate-confirm").attr("disabled",true);$("#curation-messaging").children().removeClass("form-error-message").addClass("progress").html("Saving your change...")}}}}};DataCurator.prototype.onAdditionComplete=function(A,C){if(A&&A.report=="success"){hideDialog();if(this.activeAmenity){if(this.activeAmenity.getDataSource()=="Local"){C.local_source=this.activeAmenity}this.app.updateResult(C,"Curated",this.activeAmenity);trackEvent("Curation","Edit amenity",document.location.href);this.activeAmenity=null}else{var B=this.app.addNewResult(C,"Curated");trackEvent("Curation","Add amenity",document.location.href)}}else{message=(A.error)?A.error:"Couldn't save your change, try reloading this page.";$("#curation-messaging").children().removeClass("progress").addClass("form-error-message").html(message);$("#curate-confirm").attr("disabled",false)}};DataCurator.prototype.deleteAmenity=function(A){var B=this.fbConnector.getUser();if(!B){return }var C="";C+=urlifyParam("act","delete");C+=urlifyParam("&key",this.activeAmenity.getKey());C+=urlifyParam("&cat",this.activeAmenity.getCategory());C+=urlifyParam("&ws_url",document.location.href);C+=this.getFacebookParams(B);var D=this;this.submitData(C,function(E){A||D.onDeleteComplete(parseJson(E))});if(A){this.app.deleteAmenity(this.activeAmenity.getCategory(),this.activeAmenity.getKey())}$("#curate-confirm").attr("disabled",true);$("#curation-messaging").children().removeClass("form-error-message").addClass("progress").html("Saving your change...")};DataCurator.prototype.onDeleteComplete=function(A){if(A&&A.report=="success"){hideDialog();this.app.deleteAmenity(this.activeAmenity.getCategory(),this.activeAmenity.getKey());trackEvent("Curation","Remove amenity",document.location.href);this.activeAmenity=null}else{$("#curation-messaging").children().removeClass("progress").addClass("form-error-message").html("Couldn't save your change, try reloading this page.");$("#curate-confirm").attr("disabled",false)}};DataCurator.prototype.updateFacebookLoginInfo=function(){var A=this.fbConnector.getUser();if(A){this.OnReceiveFacebookInfo(A)}else{this.fbConnector.requestUserInfo(bindCallback(this,this.OnReceiveFacebookInfo))}};DataCurator.prototype.OnReceiveFacebookInfo=function(A){if(A){$("#facebook-user-login").html('<div class="facebook-icon"><p class="hint-text">Signed in as '+A.name+'.  <a class="dull-link" id="dialog-fb-logout">Sign out</a></p></div>');$("#curate-confirm").attr("disabled",false);this.fbConnector.registerSignOutLink("dialog-fb-logout",bindCallback(this,this.OnReceiveFacebookInfo))}else{$("#facebook-user-login").html('<a id="dialog-fb-login" class="dialog-fb-login"></a><div class="form-error-message">Sign in required to edit a place.</div>');$("#curate-confirm").attr("disabled",true);this.fbConnector.registerSignInLink("dialog-fb-login",bindCallback(this,this.OnReceiveFacebookInfo))}};DataCurator.prototype.updateUI=function(){if($("#curate-form").length){var A=($("#curate-form").find("input:radio[name=removeType]:checked").blur().val()=="other");$(".comments-required").css("display",((A)?"inline":"none"))}};DataCurator.prototype.submitData=function(B,A){var C=this;$.ajax({url:"/data/curate.php",type:"POST",data:B,success:A,error:A})};function FacebookConnector(){if(DEBUG_CURATION){dbug("FB init")}this.user=null;this.initialized=false;this.userCallback=null;this.loginInProgress=false;this.fbScriptLoadingStarted=false;var A=this;window.fbAsyncInit=function(){var B="http://"+window.location.host+"/channel.html";FB.init({appId:"133264856724753",status:true,cookie:true,xfbml:true,oath:true,channelUrl:B});if(window.appEvents){appEvents.fireEvent(null,"facebookScriptLoaded")}FB.UIServer.setActiveNode=function(D,C){FB.UIServer._active[D.id]=C};FB.UIServer.setLoadedNode=function(D,C){FB.UIServer._loadedNodes[D.id]=C};FB.getLoginStatus(function(C){A.handleSessionResponse(C)})};this.loadFacebook()}FacebookConnector.prototype.registerSignInLink=function(C,D){var B=this;var A=D;$("#"+C).bind("click",function(){if(FB&&!B.getUser()){B.loginInProgress=true;FB.login(function(E){B.handleSessionResponse(E,A)},{scope:"email"});trackEvent(ACTIVE_COMPONENT,"facebook permission requested")}})};FacebookConnector.prototype.registerSignOutLink=function(C,D){var B=this;var A=D;$("#"+C).bind("click",_(function(){var E=_(function(){B.user=null;A()}).max_attempts(1);_(E).delay(500);if(FB&&B.getUser()){FB.logout(function(F){B.handleSessionResponse(F,E)});trackEvent(ACTIVE_COMPONENT,"facebook logout")}}).bind(this))};FacebookConnector.prototype.getUser=function(){return this.user};FacebookConnector.prototype.requestUserInfo=function(A){if(A){if(this.initialized){A(this.user)}else{if(A){this.userCallback=A}}}};FacebookConnector.prototype.getUserLocation=function(){if(this.user&&this.user.location&&this.user.location.name){return this.user.location.name}return""};FacebookConnector.prototype.getUserWorkJson=function(){if(this.user&&this.user.work){return JSON.stringify(this.user.work)}return""};FacebookConnector.prototype.handleSessionResponse=function(B,E){this.initialized=true;if(B.status!=="connected"){if(DEBUG_CURATION){dbug("FB loaded - no user available")}this.user=null;if(E){E()}return }if(DEBUG_CURATION){dbug("FB loaded - got a user")}if(this.loginInProgress){trackEvent(ACTIVE_COMPONENT,"facebook permission granted");this.loginInProgress=false}var D=this;var C=(E)?E:null;var A=(this.userCallback)?this.userCallback:null;this.userCallback=null;FB.api("/me",function(F){if(F){D.user=F;if(DEBUG_CURATION){dbug("FB user retrieved: "+D.user.name,D.user.email)}}if(C){C(D.user)}if(A){A(D.user)}});return };FacebookConnector.prototype.loadFacebook=function(){if(!this.fbScriptLoadingStarted){var A=document.createElement("script");A.async=true;A.src=document.location.protocol+"//connect.facebook.net/en_US/all.js#appId=133264856724753&amp;xfbml=1";$("#fb-root").append(A);this.fbScriptLoadingStarted=true;return true}return false};function activateAptSearchBox(C){var C=(typeof (C)!="undefined")?C:false;(C)?setActiveText("#apt-search-input",C):setInputExampleText("#apt-search-input","Enter a neighborhood, city or place");var B=0,A=0;var D=new RentalsSearchBox().setInput($("#apt-search-input")).onUpdate(function(E){A++;$("#apt_search_hood").val(E.hood);$(".apt-search-form").submit()});$(".apt-search-form").submit(function(){if(B++){return }D.autoSelect();if(!A){trackEvent(ACTIVE_COMPONENT,"apt search",$("#apt-search-input").val())}$("#apt_search_street").val(urlifyAddress($("#apt-search-input").val()))})}function initFooterTweets(C){var C=C||"#city-footer .root-container";var B=function(D){tweets=[];_(D).each(function(E){tweets.push({text:E.text,user:E.user.screen_name,img:E.user.profile_image_url,datetime:E.created_at,top:rand(25)+20,right:rand(100)})});curTweet=0;tweetInterval=setInterval(function(){A()},3000);A();$("#home-tweet").css("display","block")};var A=function(){curTweet=(curTweet+1)%tweets.length;tweetData=tweets[curTweet];var G="";var F=tweetData.datetime.split(" ");var H=F[3].split(":");F=F.slice(1,3);G=F.join(" ");var D=H[0]%12;if(D==0){D=12}var E=(H[0]<12)?"am":"pm";G+=", "+D+":"+H[1]+E;var I=$("#home-tweet").css("top",tweetData.top).css("right",tweetData.right);I.find("img").attr("src",tweetData.img);I.find("img").attr("src",tweetData.img);I.find(".text").html(tweetData.text);I.find(".user a").attr("href","http://twitter.com/"+tweetData.user).html("&mdash;"+tweetData.user+"<span> "+G+"</span>")};$(C).append('<div id="home-tweet"><img src="" /><p class="text"></p><p class="user"><a target="_blank"></a></p><div></div></div>');jQuery.getJSON("http://api.twitter.com/1/favorites/walkscore.json?callback=?",function(D){B(D)})};
