function clearAllMessages(){findByNameMessage.html("");manualLocationMessage.html("")}function warningTextBlock(n){return messageTextBlock(n,"warning")}function errorTextBlock(n){return messageTextBlock(n,"error")}function successTextBlock(n){return messageTextBlock(n,"success")}function infoTextBlock(n){return messageTextBlock(n,"info")}function failureTextBlock(n){return messageTextBlock(n,"failure")}function successCallout(n){return messageCallout(n,"success")}function failureCallout(n){return messageCallout(n,"alert")}function messageTextBlock(n,t){return'<div class="small '+t+'-text">'+n+"<\/div>"}function messageCallout(n,t){return'<div data-closable class="callout '+t+'"><button class="close-button" data-close aria-label="Close alert" type="button"><span aria-hidden="true">×<\/span><\/button>'+n+"<\/div>"}function setupGeolocation(){navigator.geolocation?(accessLocation.show(),manualLocator.hide()):showManualLocation(!1)}function showManualLocation(n){manualLocator.show();findByAddressInput.focus();n===!0?manualLocationMessage.html(failureTextBlock("We couldn't properly determine your location.")):manualLocationMessage.html("")}function showManualPosition(n){myLat=n.lat();myLng=n.lng();showPositionAndLoadNearest("searchnear")}function showAutoPosition(n){var t=n.coords;myLat=t.latitude;myLng=t.longitude;showPositionAndLoadNearest("near")}function showPositionAndLoadNearest(n){mapLoader.show();scrollToMap();setUpAllMapStuff();var t=$.get(window.urlNearest,{lat:myLat,lng:myLng});loadCenters(t,n);locationLoader.hide()}function positionError(n){switch(n.code){case 0:showManualLocation(!0);break;case 1:showManualLocation(!0);break;case 2:showManualLocation(!0);break;case 3:showManualLocation(!0)}}function initializeMap(){mapLoader.show();window.google.maps.visualRefresh=!0;var n=document.getElementById("map_canvas"),t={mapTypeId:window.google.maps.MapTypeId.G_NORMAL_MAP,zoom:4};window.map=new window.google.maps.Map(n,t);window.bounds=new window.google.maps.LatLngBounds;window.infowindow=new window.google.maps.InfoWindow({pixelOffset:new window.google.maps.Size(0,12)});window.google.maps.event.addListener(window.map,"idle",function(){mapLoader.fadeOut(800)});window.google.maps.event.addListener(window.infowindow,"domready",function(){var i=$(".gm-style-iw"),n,t,r;i.addClass("listing");n=i.prev();n.children(":nth-child(2)").css({display:"none"});n.children(":nth-child(4)").css({display:"none"});n.children(":nth-child(3)").find("div").children().css({"box-shadow":"#999999 0px 1px 6px","z-index":"1"});t=i.next();t.css({height:"28px",width:"28px",opacity:"1",right:"20px",top:"0",border:"7px solid #444770","border-radius":"13px","box-shadow":"0 0 5px #3990B9"});r=t.next();r.css({right:"20px",top:"0",height:"28px",width:"28px"});t.mouseout(function(){$(this).css({opacity:"1"})})});window.gmarkers=[]}function findByName(){findByNameMessage.html("");var n=findByNameInput.val().length;n>2?(mapLoader.show(),findByNameLoader.show(),getLocations("byname",null),findByNameLoader.hide()):findByNameMessage.html(warningTextBlock("Please enter at least 3 letters."))}function setUpAllMapStuff(){initializeMap();setMapCenterToUS();clearOtherCountryAnchors();removeBackToTopLinks()}function getLocations(n,t){scrollToMap();setUpAllMapStuff();switch(n){case"state":loadStateCenters(t);break;case"country":loadCountryCenters(t);break;case"byname":loadCentersByName();break;default:loadAllCenters()}}function loadAllCenters(){var n=$.get(window.urlMapPointsAll);loadCenters(n,"world")}function loadStateCenters(n){if(n!==null&&n!=="0"){var t=$.get(window.urlMapPointsState,{geozoneId:n});loadCenters(t,"state")}}function loadCountryCenters(n){if(n!==null&&n!=="0"){var t=$.get(window.urlMapPointsCountry,{countryId:n});loadCenters(t,"country")}}function loadCentersByName(){var n=$.get(window.urlFindByName,{q:findByNameInput.val()});loadCenters(n,"query")}function loadCenters(n,t){var i;n!==null&&(n.success(function(n){var r,u;if(n.length>0){switch(t){case"country":i=n[0].CountryName;break;case"state":i=n[0].StateName;break;default:i=t}LoadMapAndLists(n);(t==="near"||t==="searchnear")&&(r="Your Location",t==="searchnear"&&(r="Your Search"),u='<div class="infoWindow"><div class="infoWindowInner"><h4>'+r+"<\/h4><\/div><\/div>",placeMarkerAndInfoWindow({Latitude:myLat,Longitude:myLng,InfoWindowContent:u}),map.setCenter(window.bounds.getCenter()),map.fitBounds(window.bounds),openMe(0,!1));setSummary(n,i)}else{hideAllCountryLists();clearAllStateLists();setMapCenterToUS();summaryCallout.html(failureCallout('We could not find any location names that matched your query. Please try again. <a href="/LGBTCenters">See all member locations.<\/a>'));listLoader.hide();return}}),n.error(function(){alert("Failed to retrieve country map points.")}))}function LoadMapAndLists(n){var t,u;hideAllCountryLists();clearAllStateLists();var i="",e="",f,r,o=n[0].CountrySeoName;for(listLoader.show(),t=0;t<n.length;t++)f=n[t].StateSeoName,r=n[t].CountrySeoName,u=n[t].CountryId,placeMarkerAndInfoWindow(n[t]),r!==e&&($("#country-"+u).show(),r!==o&&(appendOtherCountryAnchor(u,n[t].CountryName),appendBackToTopAnchor(u))),f!==i?(appendNewState(n[t]),equalizeStateList(i)):appendListItem(n[t]),i=f,e=r;equalizeStateList(i);map.setCenter(window.bounds.getCenter());map.fitBounds(window.bounds);map.zoom>smallDataZoom&&n.length<smallDataCount&&map.setZoom(smallDataZoom);n.length===1&&window.google.maps.event.trigger(gmarkers[0],"click");listLoader.hide()}function placeMarkerAndInfoWindow(n){var t,i;n.Index!==-1&&(n.Icon!==undefined?(i={url:n.Icon,size:new window.google.maps.Size(24,32),origin:new window.google.maps.Point(0,0),anchor:new window.google.maps.Point(10,32)},t=new window.google.maps.Marker({position:new window.google.maps.LatLng(n.Latitude,n.Longitude),map:map,icon:i})):t=new window.google.maps.Marker({position:new window.google.maps.LatLng(n.Latitude,n.Longitude),map:map}),window.gmarkers.push(t),window.bounds.extend(t.position),window.google.maps.event.addListener(t,"click",function(t){return function(){infowindow.setContent(n.InfoWindowContent);infowindow.open(map,t)}}(t)))}function openMe(n,t){window.google.maps.event.trigger(gmarkers[n],"click");t&&scrollToMap()}function scrollToMap(){var n=$(".nav-wrapper").innerHeight();$("html, body").animate({scrollTop:mapTop.offset().top-n},"slow")}function setMapCenterToUS(){map.setZoom(4);map.setCenter(new window.google.maps.LatLng(usLat,usLon))}function equalizeStateList(n){var t=new Foundation.Equalizer($("#state-list-"+n));$(t).foundation()}function clearAllStateLists(){$(".country-list").html("")}function hideAllCountryLists(){$(".countryLists").hide()}function showAllCountryLists(){$(".countryLists").show()}function clearOtherCountryAnchors(){otherCountryAnchors.html("")}function removeBackToTopLinks(){$("a[href='#page-top']").remove()}function appendNewState(n){$("#location-list-"+n.CountrySeoName).append($('<h3 class="state-name">'+n.StateName+'<\/h3 ><div id="state-list-'+n.StateSeoName+'" class="row small-up-1 medium-up-3 state-list" data-equalize-by-row="true"/>'));appendListItem(n)}function appendListItem(n){var t="",i='<a class="button tiny" href="'+n.DetailLink+'">listing<\/a>';n.Index!==-1?t='<a class="button tiny" href="javascript: openMe('+n.Index+',true);">map<\/a>&nbsp;':i='<a class="button tiny full" href="'+n.DetailLink+'">listing<\/a>';$("#state-list-"+n.StateSeoName).append($('<div class="column"/>').html('<div class="item" data-equalizer-watch="state-list-'+n.StateName+'">'+n.ListContent+'<\/div><div class="button-wrap">'+t+i+"<\/div><\/div>"))}function setSummary(n,t){var i,r,u;if(t==="near"||t==="searchnear"){i="you";t==="searchnear"&&(i="your search");summaryCallout.html(successCallout("These are the "+n.length+' CenterLink Member locations near <a title="click to see your location" href="javascript:openMe('+n.length+',false)">'+i+"<\/a>"));return}n.length===1?(isare="is",locationlocations="location"):(isare="are",locationlocations="locations");u='<a title="click to see all of our member locations" href="/LGBTCenters">See all member locations<\/a>';t==="world"?(r=" around the world",u=""):r=t==="query"?" that matched your query":" in "+t;summaryCallout.html(successCallout("There "+isare+" "+n.length+" CenterLink Member "+locationlocations+r+". "+u))}function appendOtherCountryAnchor(n,t){otherCountryAnchors.append('<a class="button small secondary" href="#country-'+n+'-list">Go to '+t+" listings<\/a> ")}function appendBackToTopAnchor(n){var t=$("#country-"+n+" h2").html();$("#country-"+n+" h2").html(t+" <a class='button tiny secondary' href='#page-top'>Back To Top<\/a>")}jQuery.validator&&jQuery.validator.setDefaults({ignore:[]});var gmarkers=[],map,locations,bounds,infowindow,geocoder,usLat=42.877742,usLon=-97.380979,myLat,myLng,mapTop=$("#map_wrap"),countryId=$("#CountryId").val(),stateId=$("#StateId").val(),accessLocation=$("#AccessLocation"),accessRadio=$("input[name=locator]"),locationLoader=$("#LocationLoader"),manualLocator=$("#ManualLocation"),findByAddressInput=$("#findAddress"),findByAddressButton=$("#btnFindAddress"),manualLocationMessage=$("#ManualLocationMessage"),mapLoader=$(".MapLoader"),stateLoader=$("#StateLoader"),countryLoader=$("#CountryLoader"),listLoader=$("#ListLoader"),summaryCallout=$("#Summary"),isare="are",locationlocations="locations",otherCountryAnchors=$("#OtherCountryAnchors"),findByNameMessage=$("#FindByNameMessage"),findByNameInput=$("#LocationName"),findByNameButton=$("#btnByName"),findByNameLoader=$("#ByNameLoader"),smallDataZoom=6,smallDataCount=4;$(function(){function i(){if(n.width()!==t){$("#map_canvas").width($("#map_wrap").width());gmarkers.length>0?(map.setCenter(bounds.getCenter()),map.fitBounds(bounds),map.zoom>smallDataZoom&&gmarkers.length<smallDataCount&&map.setZoom(smallDataZoom)):setMapCenterToUS();var i=new Foundation.Equalizer($(".location-list"));$(i).foundation();t=n.width()}}$(document).ajaxComplete(function(){$.validator.unobtrusive.parse(document);window.setSmoothScrolling()});var n=$(window),t=n.width();window.google.maps.event.addDomListener(window,"resize",function(){window.google.maps.event.trigger(map,"resize");i()});$("#Countries").change(function(){countryLoader.show();mapLoader.show();var n=$(this).val();n==="0"?getLocations("all",null):getLocations("country",n);countryLoader.hide()});$("#States").change(function(){mapLoader.show();stateLoader.show();var n=$(this).val();n==="0"?getLocations("all",null):getLocations("state",n);stateLoader.hide()});findByNameButton.click(function(n){n.preventDefault();findByName()});findByNameInput.keypress(function(n){n.which===13&&(n.preventDefault(),findByName())});accessRadio.click(function(){var t=$("input[name=locator]:checked").val(),n;t==="user"?(locationLoader.show(),manualLocator.hide(),n={enableHighAccuracy:!0,timeout:2e4,maximumAge:2e3},navigator.geolocation.getCurrentPosition(showAutoPosition,positionError,n)):showManualLocation(!1)});findByAddressInput.keypress(function(){event.which===13&&(event.preventDefault(),findByAddressButton.click())});findByAddressButton.click(function(n){n.preventDefault();var t=findByAddressInput.val(),i=t.length;i>3?(geocoder=new window.google.maps.Geocoder,geocoder.geocode({address:t},function(n,t){if(t==="OK"){var i=n[0].geometry.location;showManualPosition(i)}else alert("Geocode was not successful for the following reason: "+t)})):manualLocationMessage.html(warningTextBlock("Please enter at least 3 letters."))});setupGeolocation();countryId>0?getLocations("country",countryId):stateId>0?getLocations("state",stateId):getLocations("all",null)})