function MarkerClusterer(n,t,i){var r,u;this.extend(MarkerClusterer,google.maps.OverlayView),this.map_=n,this.markers_=[],this.clusters_=[],this.styles_=[],this.ready_=!1,r=i||{},this.sizes=r.sizes||[53,56,66,78,90],this.gridSize_=r.gridSize||60,this.minClusterSize_=r.minimumClusterSize||2,this.maxZoom_=r.maxZoom||null,this.styles_=r.styles||[],this.imagePath_=r.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_,this.imageExtension_=r.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_,this.zoomOnClick_=!0,r.zoomOnClick!=undefined&&(this.zoomOnClick_=r.zoomOnClick),this.averageCenter_=!1,r.averageCenter!=undefined&&(this.averageCenter_=r.averageCenter),this.setupStyles_(),this.setMap(n),this.prevZoom_=this.map_.getZoom(),u=this,google.maps.event.addListener(this.map_,"zoom_changed",function(){var n=u.map_.getZoom();u.prevZoom_!=n&&(u.prevZoom_=n,u.resetViewport())}),google.maps.event.addListener(this.map_,"idle",function(){u.redraw()}),this.clusterOnClick=null,t&&t.length&&this.addMarkers(t,!1)}function Cluster(n){this.markerClusterer_=n,this.map_=n.getMap(),this.gridSize_=n.getGridSize(),this.minClusterSize_=n.getMinClusterSize(),this.averageCenter_=n.isAverageCenter(),this.center_=null,this.markers_=[],this.bounds_=null,this.clusterIcon_=new ClusterIcon(this,n.getStyles(),n.getGridSize())}function ClusterIcon(n,t,i){n.getMarkerClusterer().extend(ClusterIcon,google.maps.OverlayView),this.styles_=t,this.padding_=i||0,this.cluster_=n,this.center_=null,this.map_=n.getMap(),this.div_=null,this.sums_=null,this.visible_=!1,this.setMap(this.map_)}function GenerateBSearchMask(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt,it,rt){var ut=0;return ut=ut|xISMALE,ut=ut|xISACCESSIBLEMALE,ut=ut|xISFEMALE,ut=ut|xISACCESSIBLEFEMALE,ut=ut|xISUNISEX,ut=ut|xISACCESSIBLEUNISEX,n||(ut=ut&~xISACCESSIBLEMALE,ut=ut&~xISACCESSIBLEFEMALE,ut=ut&~xISACCESSIBLEUNISEX),t||(ut=ut&~xISUNISEX),i||(ut=ut&~xISFEMALE),r||(ut=ut&~xISMALE),u&&(ut=ut|xISDUMPPOINT),f&&(ut=ut|xISCHANGINGPLACES),e!=null&&e&&(ut=ut|xISPARKING),o!=null&&o&&(ut=ut|xISPARKINGACCESSIBLE),s!=null&&s&&(ut=ut|xISBABYCHANGE),h!=null&&h&&(ut=ut|xISSHARPSDISPOSAL),c!=null&&c&&(ut=ut|xISSHOWERS),l!=null&&l&&(ut=ut|xISSANITARYDISPOSAL),a!=null&&a&&(ut=ut|xISDRINKINGWATER),v!=null&&v&&(ut=ut|xISKEYREQUIRED),y!=null&&y&&(ut=ut|xISMLAKKEY),p!=null&&p&&(ut=ut|xISPAYMENTREQUIRED),w!=null&&w&&(ut=ut|xISACCESSLIMITED),b!=null&&b&&(ut=ut|xISAMBULANT),k!=null&&k&&(ut=ut|xISLHTRANSFER),d!=null&&d&&(ut=ut|xISRHTRANSFER),g!=null&&g&&(ut=ut|xISADULTCHANGE),nt!=null&&nt&&(ut=ut|xISOPENALLHOURS),tt!=null&&tt&&(ut=ut|xISOPENDAYLIGHTHOURS),it!=null&&it&&(ut=ut|xISCLOSED),rt!=null&&rt&&(ut=ut|xISOPENINGHOURSVARIABLE),ut}function GetWithSelectedPrioritiesText(n,t){var i="";return i=CheckMissingMaskFlag(n,xISPARKING,"parking",i,t),i=CheckMissingMaskFlag(n,xISPARKINGACCESSIBLE,"accessible parking",i,t),i=CheckMissingMaskFlag(n,xISLHTRANSFER,"LH transfer",i,t),i=CheckMissingMaskFlag(n,xISRHTRANSFER,"RH transfer",i,t),i=CheckMissingMaskFlag(n,xISADULTCHANGE,"adult change",i,t),i=CheckMissingMaskFlag(n,xISAMBULANT,"ambulant",i,t),i=CheckMissingMaskFlag(n,xISBABYCHANGE,"baby change facilities",i,t),i=CheckMissingMaskFlag(n,xISSHARPSDISPOSAL,"sharps disposal",i,t),i=CheckMissingMaskFlag(n,xISSHOWERS,"showers",i,t),i=CheckMissingMaskFlag(n,xISSANITARYDISPOSAL,"sanitary disposal",i,t),i=CheckMissingMaskFlag(n,xISDRINKINGWATER,"drinking water",i,t),i=CheckMissingMaskFlag(n,xISMLAKKEY,"MLAK keys",i,t),i=CheckMissingMaskFlag(n,xISOPENALLHOURS,"Open 24 hours",i,t),i=CheckMissingMaskFlag(n,xISDUMPPOINT,"caravan dumpoints",i,t),i=CheckMissingMaskFlag(n,xISCHANGINGPLACES,"Changing Places",i,t),i!=""&&(i=" with "+i),i}function CheckMissingMaskFlag(n,t,i,r,u){var e=", ",f=" or ";return u==null?HasFlag(n,t)&&(r!=null&&r!=""&&(r=r.replace(f,e),r=r+f),r+=i):(f=" and ",HasFlag(u,t)&&!HasFlag(n,t)&&(r!=null&&r!=""&&(r=r.replace(f,e),r=r+f),r+=i)),r}function HasFlag(n,t){return(n&t)==t}function missingMaskInfo(n,t){var i="",r=t===undefined?"map":t;return n>0&&(i=GetWithSelectedPrioritiesText(n)),i!==""?"There are no toilets"+GetWithSelectedPrioritiesText(n)+" on the "+r+".":""}function searchMaskInfo(n,t,i){var r="",u=i===undefined?"map":i;return n>0&&(r=GetWithSelectedPrioritiesText(t,n)),r!==""?"There are toilets"+r+" on the "+u+".":""}function showNoResultsError(n){n!==undefined&&n.length>0&&messages.temporaryMessage([new displayMessage(messageType.ERROR,n,"No results could be found for your search. Please ensure that your search text is spelt correctly and try again.")])}function clientSearch(){var n,t,r,i;canSearch()&&(n="",Modernizr.geolocation&&navigator.geolocation.getCurrentPosition(showPosition,showError),n=usingGeolocation?$("#GeoSearch").attr("value"):$("#ClientSearch").attr("value"),(n=="Enter a location, address, ..."||n=="Use your current location to find toilets.")&&(n=""),t="",t=n.indexOf(" Australia")==-1?n+" Australia":n,addressSearched=t,r=new google.maps.Geocoder,i=usingGeolocation&&n==""?{location:geoLatLng}:{address:t,region:"au"},r.geocode(i,function(i,r){var u,f,e,o,s;switch(r){case google.maps.GeocoderStatus.OK:u=-1;for(f in i){for(e in i[f].address_components)if(i[f].address_components[e].short_name=="AU"){u=f;break}if(u>-1)break}if(u==-1)showNoResultsError(n);else{o=i[u].geometry.viewport,s=i[u].geometry.location,preSearchSetup(),$("#GeoSearch").attr("value",i[u].formatted_address),$("#ClientSearch").attr("value",i[u].formatted_address),Modernizr.sessionstorage&&(sessionStorage.FormattedAddress=i[u].formatted_address),$("#ReadOnlyClientSearch").attr("value",i[u].formatted_address),handleSearchResultBoth(o,s),finishSearch(i[u].geometry.location,t),lastResultBounds=i[u].geometry.viewport;break}case google.maps.GeocoderStatus.ERROR:messages.temporaryMessage([new displayMessage(messageType.ERROR,"","There was a problem contacting the Google servers.")]);break;case google.maps.GeocoderStatus.INVALID_REQUEST:messages.temporaryMessage([new displayMessage(messageType.ERROR,"","The request was invalid.")]);break;case google.maps.GeocoderStatus.OVER_QUERY_LIMIT:messages.temporaryMessage([new displayMessage(messageType.ERROR,"","There was a problem geocoding the address, please wait a short time before refreshing, scrolling or zooming the map.")]);break;case google.maps.GeocoderStatus.REQUEST_DENIED:messages.temporaryMessage([new displayMessage(messageType.ERROR,"","The attempt to geocode the address has been denied by Google.","The request may succeed if you try again.")]);break;case google.maps.GeocoderStatus.UNKNOWN_ERROR:messages.temporaryMessage([new displayMessage(messageType.ERROR,"","A geocoding request could not be processed due to a server error.","The request may succeed if you try again.")]);break;case google.maps.GeocoderStatus.ZERO_RESULTS:getMapFromSearch(n)}}))}function getMapFromSearch(n){$.ajax({dataType:"json",url:"/api/MapAPI/GetMapFromSearch",data:{search:n},success:function(t){if(t.swlt!=0&&t.swln!=0&&t.nelt!=0&&t.neln!=0){var i=new google.maps.LatLng(t.swlt,t.swln),r=new google.maps.LatLng(t.nelt,t.neln),u=new google.maps.LatLngBounds(i,r);handleSearchResults(u)}else showNoResultsError(n)},error:function(){messages.stopWork([new displayMessage(messageType.ERROR)])}})}function ProcessSideList(n,t){var f=new Date,u="",r;for(i in n)r="",ProcessSideList_OkToAdd(n[i])&&(r=BuildMiniToilet(n[i]),ProcessSideList_AdditionalWork(n[i].ID,r),u+=r,anyToiletsShown=!0,toiletsShown++);$(t).text(""),$(t).append(u),recordTiming("Process side list for "+t,f)}function PostInitialiseMap(){var u=$("#ClientSearch").attr("value"),f=$("#NorthEastLat").attr("value"),s=$("#NorthEastLon").attr("value"),h=$("#SouthWestLat").attr("value"),c=$("#SouthWestLon").attr("value"),n=$("#Lat").attr("value"),l=$("#Lon").attr("value"),a=$("#Zoom").attr("value"),v=$("#ShowMore").attr("value"),e=$("#MapID").val(),o,t,i;if(e!=""&&Number(e)?(o=window.location,t={},t.Link=o,t.Title=u==""?"My map":u,saveHref(t),firstLoadFromId=!0):firstLoadFromId=!1,areaId=null,map.fitBounds(AustraliaBounds),$("#smOpen24").hide(),addressSearched=$.trim(u),Modernizr.sessionstorage&&(sessionStorage.FormattedAddress=addressSearched),isFirstRun=!1,showingFailedToilets=v=="True",showingFailedToilets?($("#hideFailedList").show(),$("#showFailedList").hide(),$("#failedToiletList").show()):($("#hideFailedList").hide(),$("#showFailedList").show(),$("#failedToiletList").hide()),PostInitialiseMap_PreSearch(),i=!1,(addressSearched=="Australia"||addressSearched==null||addressSearched==""||addressSearched.indexOf("Enter a ")>-1)&&(i=!0),f!=null&&f!=""){var y=new google.maps.LatLng(Number(h),Number(c)),p=new google.maps.LatLng(Number(f),Number(s)),r=new google.maps.LatLngBounds(y,p);if(AreBoundsEqual(r,AustraliaBounds))i=!0;else{myFavouriteMapFirstLoad=!0,myFavouriteMapBounds=r,handleSearchResultSimple(r),lastResultBounds=r;return}}n!=null&&n!=""&&n!=0&&handleSearchResultCentre(new google.maps.LatLng(Number(n),Number(l)),Number(a)),i?(isFirstRun=!0,messages.stopWork([new displayMessage(messageType.INSTRUCTION,messages.findInstructionTitle,messages.findInstruction)],!1),addressSearched!="Australia"&&addressSearched.indexOf("Enter a ")==-1&&showNoResultsError(addressSearched),Modernizr.geolocation&&navigator.geolocation.getCurrentPosition(showPosition,showError),lastResultBounds=AustraliaBounds):clientSearch()}function showPosition(n){var i=n.coords.latitude,r=n.coords.longitude,t=new google.maps.LatLng(i,r);t!=null?(usingGeolocation=!0,geoLatLng=t,$("#ClientSearch").hide(),$("#GeoSearch").show()):($("#ClientSearch").show(),$("#GeoSearch").hide())}function showError(n){usingGeolocation=!1,geoLatLng=null,$("#ClientSearch").show(),$("#GeoSearch").hide();switch(n.code){}}function mapFromBounds(n,t,i,r){var f=new google.maps.LatLng(n,t),e=new google.maps.LatLng(i,r),u=new google.maps.LatLngBounds(f,e);handleSearchResultSimple(u),lastResultBounds=u}function mapFromArea(n,t,i,r,u){areaId=n;var e=new google.maps.LatLng(t,i),o=new google.maps.LatLng(r,u),f=new google.maps.LatLngBounds(e,o);handleSearchResultSimple(f),lastResultBounds=f}function showFailedToiletList(){$("#failedToiletList").show(),$("#showFailedList").hide(),$("#hideFailedList").show(),showingFailedToilets=!0,okToReuseMap=!1,hiddenToiletCount=0,toiletCount>0&&handleToiletData(successToilets,failedToilets)}function hideFailedToiletList(){$("#failedToiletList").hide(),$("#showFailedList").show(),$("#hideFailedList").hide(),showingFailedToilets=!1,okToReuseMap=!1,hiddenToiletCount=failedToilets.length,clearToiletMarkers(),toiletCount>0&&handleToiletData(successToilets,failedToilets),$("#failedToiletList").text("")}function buildSaveData(){var r=$("#smAccessible").data("selected"),u=$("#smUnisex").data("selected"),f=$("#smFemale").data("selected"),e=$("#smMale").data("selected"),o=$("#smDumpPoint").data("selected"),s=$("#smChangingPlaces").data("selected"),h=$("#smParkingAccessible").data("selected"),c=$("#smLHTransfer").data("selected"),l=$("#smRHTransfer").data("selected"),a=$("#smAdultChange").data("selected"),v=$("#smAmbulant").data("selected"),y=$("#smSharps").data("selected"),p=$("#smShowers").data("selected"),w=$("#smBaby").data("selected"),b=$("#smDisposable").data("selected"),k=$("#smDrink").data("selected"),d=$("#smMlak").data("selected"),g=GenerateBSearchMask(r,u,f,e,o,s,null,h,w,y,p,b,k,null,d,null,null,v,c,l,a,null,null,null,null),nt=map.getCenter().lat(),tt=map.getCenter().lng(),it=map.getZoom(),t="",n;t=usingGeolocation?$("#GeoSearch").attr("value"):$("#ClientSearch").attr("value"),(t=="Enter a location, address, ..."||t=="Use your current location to find toilets.")&&(t="");var rt=map.getBounds().getNorthEast().lat(),ut=map.getBounds().getNorthEast().lng(),ft=map.getBounds().getSouthWest().lat(),et=map.getBounds().getSouthWest().lng(),i=t;(t==null||t=="")&&(i="Empty search"),n={},n.__RequestVerificationToken=$("input[name='__RequestVerificationToken']").attr("value"),n["Map.Latitude"]=nt,n["Map.Longitude"]=tt,n["Map.Zoom"]=it,n["Map.NorthBound"]=rt,n["Map.EastBound"]=ut,n["Map.SouthBound"]=ft,n["Map.WestBound"]=et,n["Map.SearchMask"]=g,n["Map.SearchText"]=t,n["Map.ShowMore"]=showingFailedToilets,n.Title=i,n.SaveToFavourites=!1,n.EmailToAddress="notset@hs.com.au";switch(saveType){case"Facebook":n.SendViaEmail=!1,n.SendViaFacebook=!0,n.SendViaGoogle=!1,n.SendViaTwitter=!1;break;case"Email":n.SendViaEmail=!0,n.SendViaFacebook=!1,n.SendViaGoogle=!1,n.SendViaTwitter=!1;break;case"Google":n.SendViaEmail=!1,n.SendViaFacebook=!1,n.SendViaGoogle=!0,n.SendViaTwitter=!1;break;case"Twitter":n.SendViaEmail=!1,n.SendViaFacebook=!1,n.SendViaGoogle=!1,n.SendViaTwitter=!0}return n}function BuildReSaveData(){var n={};n.__RequestVerificationToken=$("input[name='__RequestVerificationToken']").attr("value");switch(saveType){case"Facebook":n.SendViaEmail=!1,n.SendViaFacebook=!0,n.SendViaGoogle=!1,n.SendViaTwitter=!1;break;case"Email":n.SendViaEmail=!0,n.SendViaFacebook=!1,n.SendViaGoogle=!1,n.SendViaTwitter=!1;break;case"Google":n.SendViaEmail=!1,n.SendViaFacebook=!1,n.SendViaGoogle=!0,n.SendViaTwitter=!1;break;case"Twitter":n.SendViaEmail=!1,n.SendViaFacebook=!1,n.SendViaGoogle=!1,n.SendViaTwitter=!0}return n}function saveMapSimple(){var u=buildSaveData(),t="",i="",r=!1,n;return $.ajax({type:"POST",url:"/api/MapAPI/PostMap",data:u,async:!1,success:function(n){n.Success?(Modernizr.localstorage&&(localStorage.FindSaveData=null),r=!0,t=n.Link,i=n.Title):handleValidationMessages(n)},error:function(n,t,i){handleAjaxErrors(n,t,i)}}),n={},n.Success=r,n.Link=t,n.Title=i,n}function reSaveMapSimple(){var i=BuildReSaveData(),t=!1,n;return $.ajax({type:"POST",url:"/api/MapAPI/IncrementShareCount",data:i,async:!1,success:function(n){n.Success?t=!0:handleValidationMessages(n)},error:function(n,t,i){handleAjaxErrors(n,t,i)}}),n={},n.Success=t,n}function saveHref(n){var i="mailto:?to=&subject=View%20my%20map&body="+encodeURIComponent(n.Link)+"%0D%0A",r="https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(n.Link),u="https://twitter.com/intent/tweet?url="+encodeURIComponent(n.Link)+"&text="+encodeURIComponent(n.Title),f="https://plus.google.com/share?url="+encodeURIComponent(n.Link),t;switch(saveType){case"Email":t=i;break;case"Facebook":t=r;break;case"Twitter":t=u;break;case"Google":t=f}return $("#mailToLink").attr("href",i),$("#actionBarEmail").attr("href",i),$("#actionBarFacebook").attr("href",r),$("#actionBarTwitter").attr("href",u),$("#actionBarGoogle").attr("href",f),okToReuseMap=!0,t}function myActionFavourites(){saveType="Save",getSaveDialog()}function myActionEmail(){var n,t;saveType="Email",okToReuseMap?(reSaveMapSimple(),$("#mailToLink").get(0).click()):(n=saveMapSimple(),n.Success&&(saveHref(n),t=setTimeout(function(){sendEmail()},100)))}function myActionFacebook(){var n,i,t;saveType="Facebook",n="",i=!0,okToReuseMap?(reSaveMapSimple(),n=$("#actionBarFacebook").attr("href")):(t=saveMapSimple(),i=t.Success,t.Success&&(n=saveHref(t))),i&&window.open(n,"facebook_share_dialog","width=626,height=436")}function myActionTwitter(){var n,i,t;saveType="Twitter",n="",i=!0,okToReuseMap?(reSaveMapSimple(),n=$("#actionBarTwitter").attr("href")):(t=saveMapSimple(),i=t.Success,t.Success&&(n=saveHref(t))),i&&window.open(n,"twitter_dialog","width=626,height=436")}function myActionGooglePlus(){var n,i,t;saveType="Google",n="",i=!0,okToReuseMap?(reSaveMapSimple(),n=$("#actionBarGoogle").attr("href")):(t=saveMapSimple(),i=t.Success,t.Success&&(n=saveHref(t))),i&&window.open(n,"google_dialog","width=626,height=436")}function getSaveDialog(){$.ajax({url:"/Find/SaveMapPartial/"+saveType,cache:!1,dataType:"html",success:function(n){$("#saveMapParent").html(n),$("#saveMapForm").submit(function(n){n.preventDefault(),saveMapFormSubmit(this,n)}),resetFormValidation("#saveMapForm");var t=$("#SaveMapModal");t!=null&&t.length==1&&(saveType!="Facebook"&&saveType!="Twitter"&&saveType!="Google"&&saveType!="Email"?showSaveMapModal(!0):showSaveMapModal(!1))},error:function(){messages.temporaryMessage([new displayMessage(messageType.ERROR)],2e3)}})}function myActionPrint(){window.print()}function cancelSave(){$("#SaveMapModal").modal("hide")}function showSaveMapModal(n){var r=$("#smAccessible").data("selected"),u=$("#smUnisex").data("selected"),f=$("#smFemale").data("selected"),e=$("#smMale").data("selected"),o=$("#smDumpPoint").data("selected"),s=$("#smChangingPlaces").data("selected"),h=$("#smLHTransfer").data("selected"),c=$("#smRHTransfer").data("selected"),l=$("#smAdultChange").data("selected"),a=$("#smAmbulant").data("selected"),v=$("#smParkingAccessible").data("selected"),y=$("#smSharps").data("selected"),p=$("#smShowers").data("selected"),w=$("#smBaby").data("selected"),b=$("#smDisposable").data("selected"),k=$("#smDrink").data("selected"),d=$("#smMlak").data("selected"),g=GenerateBSearchMask(r,u,f,e,o,s,null,v,w,y,p,b,k,null,d,null,null,a,h,c,l,null,null,null,null),nt=map.getCenter().lat(),tt=map.getCenter().lng(),it=map.getZoom(),t="",i;t=usingGeolocation?$("#GeoSearch").attr("value"):$("#ClientSearch").attr("value"),(t=="Enter a location, address, ..."||t=="Use your current location to find toilets.")&&(t="");var rt=map.getBounds().getNorthEast().lat(),ut=map.getBounds().getNorthEast().lng(),ft=map.getBounds().getSouthWest().lat(),et=map.getBounds().getSouthWest().lng();$("#saveMapLatitude").attr("value",nt),$("#saveMapLongitude").attr("value",tt),$("#saveMapZoom").attr("value",it),$("#saveMapSearchText").attr("value",t),$("#saveMapSearchMask").attr("value",g),$("#saveMapShowMore").attr("value",showingFailedToilets.toString()),$("#saveMapNorthBound").attr("value",rt),$("#saveMapEastBound").attr("value",ut),$("#saveMapSouthBound").attr("value",ft),$("#saveMapWestBound").attr("value",et),clearModalDialogErrors("SaveMap"),i=$("#ClientSearch").attr("value"),n||i!=null&&i!=""||(i="Empty search"),$("#saveTitle").attr("value",i),n?$("#SaveMapModal").modal():$("#saveMapForm").submit()}function saveMapFormSubmit(n,t){var u;t.preventDefault();var i=$(n),r=i.serialize(),f=i.serializeObject();r=r.replace("SaveToFavourites=true&SaveToFavourites=false","SaveToFavourites=true"),clearModalDialogErrors("SaveMap"),u=!1,Modernizr.localstorage&&(localStorage.FindSaveData=JSON.stringify(f)),i.valid()&&saveTheMap(r,u)}function saveMap(){var n=localStorage.FindSaveData,t=!0;localStorage.FindSaveData=null,saveTheMap(JSON.parse(n),t)}function saveTheMap(n,t){$.ajax({type:"POST",url:"/api/MapAPI/PostMap",data:n,error:function(n,i,r){t?r!="Unauthorized"&&handleAjaxErrors(n,i,r):handleAjaxErrors(n,i,r,"SaveMap")=="login loaded"&&(wantingToSave=!0,$("#SaveMapModal").modal("hide"))},success:function(i){if(i.Success){if(Modernizr.localstorage&&(localStorage.FindSaveData=null),$("#SaveMapModal").modal("hide"),updateMap(),saveType!="Facebook"&&saveType!="Twitter"&&saveType!="Google"&&(saveType!="Email"||$("#SaveToFavourites").is(":checked"))&&messages.temporaryMessage([new displayMessage(messageType.SUCCESS,"",messages.saveMap)],8e3),t){var r=new google.maps.LatLng(n["Map.NorthBound"],n["Map.EastBound"]),u=new google.maps.LatLng(n["Map.SouthBound"],n["Map.WestBound"]),f=new google.maps.LatLngBounds(u,r);$("#ClientSearch").attr("value",n.Title),$("#GeoSearch").attr("value",n.Title),map!=null&&ensureBoundsAreBestFit(f)}}else i.Message=="Unauthorized"?t||(wantingToSave=!0,$("#SaveMapModal").modal("hide"),loadAndShowLoginForm()):handleModalDialogErrorMessages(i,"SaveMap")}})}function sendEmail(){$("#mailToLink").get(0).click()}function sendShare(n,t,i){$("#"+i).attr("href",n),$("#"+i).attr("onclick","window.open('"+n+"', '"+t+"', 'width=626,height=436'); return false;"),$("#"+i).click();var r=setTimeout(function(){$("#"+i).attr("onclick",$("#"+i).attr("data-defaultAction"))},250)}function PostLogin(){var n="";wantingToSave&&(n=$("#saveMapTitle").attr("value")),$.ajax({url:"/Find/SaveMapPartial/"+saveType,cache:!1,dataType:"html",success:function(t){return $("#saveMapParent").html(t),$("#saveMapForm").submit(function(n){saveMapFormSubmit(this,n)}),wantingToSave&&(showSaveMapModal(!0),$("#saveTitle").attr("value",n),$("#saveMapForm").submit(),wantingToSave=!1),!1},error:function(){messages.temporaryMessage([new displayMessage(messageType.ERROR)],2e3)}})}function myActionGPS(){var r="",t=[],i,u=map.getBounds(),n;if($("#GPS_FromPage").attr("value","Find"),successToilets)for(i in successToilets)n=successToilets[i],u.contains(new google.maps.LatLng(n.LA,n.LO))&&t.push(successToilets[i].ID);if(failedToilets&&showingFailedToilets)for(i in failedToilets)n=failedToilets[i],u.contains(new google.maps.LatLng(n.LA,n.LO))&&t.push(n.ID);if(t.length>0)r=t.toString(),window.console&&console.log(t.length.toString()+" loos - "+r),$("#GPS_Alert").get(0).innerHTML="",$("#downloadGPSSubmit").removeClass("hide"),$("#GPS_HRToiletIDs").attr("value",r);else{areaClusterer!=null&&areaClusterer.getTotalMarkers()>0?messages.temporaryMessage([new displayMessage(messageType.WARNING,"","There are too many toilets, try zooming the map in or refine your search.")],4e3):messages.temporaryMessage([new displayMessage(messageType.WARNING,"","There are no toilets listed to export")],4e3);return}$("#DownloadGPSModal").modal()}function onMiniToiletLinkClick(n){$("#navToID").attr("value",n);var t="";return Modernizr.geolocation&&navigator.geolocation.getCurrentPosition(showPosition,showError),t=usingGeolocation?$("#GeoSearch").attr("value"):$("#ClientSearch").attr("value"),(t=="Enter a location, address, ..."||t=="Use your current location to find toilets.")&&(t=""),$("#HiddenSearch").attr("value",t),typeof writeAdditionalFields=="function"&&writeAdditionalFields(),$("#linkForm").attr("action","/Toilet/Index"),$($("#linkForm")).submit(),!1}function BuildToiletSideIcon(n,t){var i=$("#toilet-icon-template").clone().html();return i.replace(/{{tooltip}}/g,n).replace("{{icon}}",t)}function BuildToiletIconList(n){var t="";(HasFlag(n.SM,xISACCESSIBLEMALE)||HasFlag(n.SM,xISACCESSIBLEFEMALE)||HasFlag(n.SM,xISACCESSIBLEUNISEX))&&(t+=BuildToiletSideIcon("Accessible","wheelchair")),HasFlag(n.SM,xISUNISEX)&&(t+=BuildToiletSideIcon("Unisex","mf")),HasFlag(n.SM,xISMALE)&&(t+=BuildToiletSideIcon("Male","m")),HasFlag(n.SM,xISFEMALE)&&(t+=BuildToiletSideIcon("Female","f")),HasFlag(n.SM,xISACCESSIBLEUNISEX)&&(t+=BuildToiletSideIcon("Accessible Unisex","mfa")),HasFlag(n.SM,xISACCESSIBLEMALE)&&(t+=BuildToiletSideIcon("Accessible Male","ma")),HasFlag(n.SM,xISACCESSIBLEFEMALE)&&(t+=BuildToiletSideIcon("Accessible Female","fa")),HasFlag(n.SM,xISDUMPPOINT)&&(t+=BuildToiletSideIcon("Dump point","dumppoint")),HasFlag(n.SM,xISPARKING)&&(t+=BuildToiletSideIcon("Parking","parking")),HasFlag(n.SM,xISPARKINGACCESSIBLE)&&(t+=BuildToiletSideIcon("Parking accessible","parkingacc")),HasFlag(n.SM,xISLHTRANSFER)&&(t+=BuildToiletSideIcon("LH Transfer","transfer_lh")),HasFlag(n.SM,xISRHTRANSFER)&&(t+=BuildToiletSideIcon("RH Transfer","transfer_rh")),HasFlag(n.SM,xISADULTCHANGE)&&(t+=BuildToiletSideIcon("Adult change","adultchange")),HasFlag(n.SM,xISCHANGINGPLACES)&&(t+=BuildToiletSideIcon("Changing Places accredited facility","changingplaces")),HasFlag(n.SM,xISAMBULANT)&&(t+=BuildToiletSideIcon("Ambulant","ambulant"));switch(n.F){case"Bus station":t+=BuildToiletSideIcon(n.F,"bus");break;case"Caravan park":t+=BuildToiletSideIcon(n.F,"caravan");break;case"Camping ground":t+=BuildToiletSideIcon(n.F,"camp");break;case"Car park":t+=BuildToiletSideIcon(n.F,"motor");break;case"Train station":t+=BuildToiletSideIcon(n.F,"train");break;case"Service station":t+=BuildToiletSideIcon(n.F,"fuel");break;case"Park or reserve":t+=BuildToiletSideIcon(n.F,"park");break;case"Airport":t+=BuildToiletSideIcon(n.F,"plane");break;case"Sporting facility":t+=BuildToiletSideIcon(n.F,"sport");break;case"Food outlet":t+=BuildToiletSideIcon(n.F,"food");break;case"Shopping centre":t+=BuildToiletSideIcon(n.F,"shop")}return HasFlag(n.SM,xISPAYMENTREQUIRED)&&(t+=BuildToiletSideIcon("Payment required","payment")),HasFlag(n.SM,xISKEYREQUIRED)&&(t+=BuildToiletSideIcon("Key required","key")),HasFlag(n.SM,xISMLAKKEY)&&(t+=BuildToiletSideIcon("MLAK key","mlak")),HasFlag(n.SM,xISACCESSLIMITED)&&(t+=BuildToiletSideIcon("Access limited","lock")),HasFlag(n.SM,xISSHOWERS)&&(t+=BuildToiletSideIcon("Showers","shower")),HasFlag(n.SM,xISBABYCHANGE)&&(t+=BuildToiletSideIcon("Baby change","babychange")),HasFlag(n.SM,xISDRINKINGWATER)&&(t+=BuildToiletSideIcon("Drinking water","water")),HasFlag(n.SM,xISSHARPSDISPOSAL)&&(t+=BuildToiletSideIcon("Sharps disposal","syringe")),HasFlag(n.SM,xISSANITARYDISPOSAL)&&(t+=BuildToiletSideIcon("Sanitary disposal","disposal")),t}function BuildMiniToilet(n){var r=$("#toilet-mini-template").clone().html(),t="",i;return t=n.O==null?"unknown":n.O,i=r.replace("{{title}}",n.T).replace(/{{toiletId}}/g,n.ID).replace("{{score}}",n.S).replace("{{icons}}",BuildToiletIconList(n)).replace("{{address1}}",n.A1).replace("{{open}}",t).replace("{{mapicon}}",GetMapImageName(n)).replace("{{locality}}",(n.A1==null||n.A1==""?"":", ")+n.L)}function BuildMarkerImage(n,t){var i=0,r=0,u=0,f=0,e=0,o=0,h,c,l,s,a;return MarkerIconDefinitions[n]==null?(h=$("."+n).css("background-position"),h==undefined?(c=$("."+n).css("background-position-x"),l=$("."+n).css("background-position-y"),e=Number(c.match("[0-9]+")[0]),o=Number(l.match("[0-9]+")[0])):(s=$("."+n).css("background-position").match(/[0-9]+/g),e=Number(s[0]),o=Number(s[1])),i=Number($("."+n).css("width").match("[0-9]+")[0]),r=Number($("."+n).css("height").match("[0-9]+")[0]),t=="centre"?(u=Math.floor(i/2),f=Math.floor(r/2)):t=="bottomthird"?(u=Math.floor(i/3),f=r):(u=n.indexOf("-pin")>0?13:Math.floor(i/2),f=r),MarkerIconDefinitions[n]={x:e,y:o,width:i,height:r,pinX:u,pinY:f}):(i=MarkerIconDefinitions[n].width,r=MarkerIconDefinitions[n].height,e=MarkerIconDefinitions[n].x,o=MarkerIconDefinitions[n].y,u=MarkerIconDefinitions[n].pinX,f=MarkerIconDefinitions[n].pinY),a=new google.maps.MarkerImage("/Images/toiletmap-icons.png?v=2",new google.maps.Size(i,r),new google.maps.Point(e,o),new google.maps.Point(u,f))}function GetMapPinImage(n){var r,i=GetMapImageName(n);return images[i]==null&&(images[i]=BuildMarkerImage(i+"-pin")),r=images[i]}function GetHightlightedMapPinImage(n){var r,i=GetMapImageName(n)+"-pin-highlight";return images[i]==null&&(images[i]=BuildMarkerImage(i)),r=images[i]}function GetMapImageName(n){var t;return t=HasFlag(n.SM,xISDUMPPOINT)?"dumppoint":HasFlag(n.SM,xISACCESSIBLEMALE)&&HasFlag(n.SM,xISACCESSIBLEFEMALE)||HasFlag(n.SM,xISACCESSIBLEUNISEX)?"mfa":HasFlag(n.SM,xISUNISEX)?"mf":HasFlag(n.SM,xISMALE)&&HasFlag(n.SM,xISFEMALE)?"mf":HasFlag(n.SM,xISACCESSIBLEFEMALE)?"fa":HasFlag(n.SM,xISFEMALE)?"f":HasFlag(n.SM,xISACCESSIBLEMALE)?"ma":HasFlag(n.SM,xISMALE)?"m":"mf"}function AreBoundsEqual(n,t){var i=!1;return i=n==null&&t==null?!0:n==null||t==null?!1:n.getSouthWest().lat()==t.getSouthWest().lat()&&n.getSouthWest().lng()==t.getSouthWest().lng()&&n.getNorthEast().lat()==t.getNorthEast().lat()&&n.getNorthEast().lng()==t.getNorthEast().lng()}function recordTiming(n,t){var i=new Date,r=i.getTime()-t.getTime();buildTimingMessage(n,r,t)}function accumulateTime(n,t){var i=new Date,r=i.getTime()-n.getTime();return t+=r}function buildTimingMessage(n,t,i){timingMessage+="\n"+n+" took "+t+" milliseconds to run. "+(i==null?"":"Started-"+formatTime(i))}function formatTime(n){var u="",f=0,i=0,r=0,t=0,e;return f=n.getHours(),i=n.getMinutes(),i<10&&(i="0"+i),r=n.getSeconds(),r<10&&(r="0"+r),t=n.getMilliseconds(),t<10&&(e="00"+t),t<100&&(e="0"+t),u=f+":"+i+":"+r+":"+t}function ToiletMiniClick(n){typeof onToiletMiniClick=="function"&&onToiletMiniClick(n)}function onToiletMiniClick(n){markerClick(n)}function ensureBoundsAreBestFit(n){var i=!0,t=map.getBounds(),r=n.getNorthEast().lng()-n.getSouthWest().lng(),u=n.getSouthWest().lat()-n.getNorthEast().lat(),f=t.getNorthEast().lng()-t.getSouthWest().lng(),e=t.getSouthWest().lat()-t.getNorthEast().lat();return r<=f/2*1.01&&u*-1<=e/-2*1.01&&(map.setZoom(map.getZoom()+1),i=!1),i}function PreInitialiseMap(){$("#filterbar div div a").each(function(){$(this).data("selected",!$(this).children("i").hasClass("disabled"))}),$("#filterbar div div a").click(function(){$(this).children("i").toggleClass("disabled"),$(this).data("selected",!$(this).children("i").hasClass("disabled")),clearTimeout(updateCallTimeout),updateCallTimeout=setTimeout(function(){updateMap()},800)})}function InitialiseMap(){var o,n,f;if($("div#map-canvas").length>0){var i=$("#staticMap"),t=$("#map-canvas"),r=$("#filterbar"),u=$("#actionbar"),e=$("#GoogleClientID").attr("value");i!=null&&i.remove(),t!=null&&(t.height($(window).height()-300),t.toggleClass("hide")),r!=null&&r.toggleClass("hide"),u!=null&&u.toggleClass("hide"),o=new google.maps.LatLng(-26.5,133),supressInfoWindow=!1,n=getSession("mapType"),n==null&&(n=google.maps.MapTypeId.ROADMAP),f={minZoom:3,client:e,mapTypeId:n,gestureHandling:"greedy"},map=new google.maps.Map($("div#map-canvas").get(0),f),typeof PostInitialiseMap=="function"?PostInitialiseMap():map.fitBounds(AustraliaBounds),google.maps.event.addListener(map,"dragend",function(){toiletInfo&&(toiletInfo.close(),toiletInfo=null)}),google.maps.event.addListener(map,"maptypeid_changed",function(){var n=map.getMapTypeId();setSession("mapType",n)})}}function highlightMarker(n){var i=$("#toilet"+n).attr("data-mapicon"),t,r;i!=null&&i!=""&&(t=i+"-pin-highlight",images[t]==null&&(images[t]=BuildMarkerImage(t)),r=images[t],markers[n].setIcon(r),markers[n].setZIndex(500))}function unHighlightMarker(n){var i=$("#toilet"+n).attr("data-mapicon"),t,r;i!=null&&i!=""&&(t=i+"-pin",images[t]==null&&(images[t]=BuildMarkerImage(t)),r=images[t],markers[n].setIcon(r),markers[n].setZIndex(1))}function HighlightToilet(n){jQuery("#toilet"+n).animate({backgroundColor:color2},100),highlightMarker(n)}function UnHighlightToilet(n){unHighlightMarker(n),$("#toilet"+n).removeClass("miniToiletHightlighted"),$("#toilet"+n).animate({backgroundColor:"transparent"},100)}function minitoilet_mouseenter(n){HighlightToilet(n),lastToiletId!=null&&lastToiletId!=n&&UnHighlightToilet(lastToiletId),lastToiletId=n}function minitoilet_mouseleave(n){UnHighlightToilet(n)}function markerMouseOver(n){HighlightToilet(n),lastToiletId!=null&&lastToiletId!=n&&UnHighlightToilet(lastToiletId),lastToiletId=n}function markerClick(n){calloutDisplayTimeout&&(clearTimeout(calloutDisplayTimeout),calloutDisplayTimeout=null),calloutDisplayTimeout=setTimeout(function(){buildToiletCallout(n)},500)}function buildToiletCallout(n){if(calloutDisplayTimeout&&(clearTimeout(calloutDisplayTimeout),calloutDisplayTimeout=null),toiletInfo&&(toiletInfo.close(),toiletInfo=null),!supressInfoWindow){var t=$("#list ul li#toilet"+n).clone();t==undefined?(window.console&&console.log("Delaying callout display by 200ms"),calloutDisplayTimeout=setTimeout(function(){buildToiletCallout(n)},200)):(toiletInfo=new google.maps.InfoWindow({content:toiletCalloutContent(t),disableAutoPan:!1,maxWidth:300}),toiletInfo.toiletId=n,toiletInfo.open(map,markers[n]))}}function toiletCalloutContent(n){return $(n).find("img").each(function(){$(this).attr("src",$(this).attr("src").replace(".png",".small.png"))}),$(n).children("a").append("<br/><p>Click to see details<\/p>"),'<div class="callout">'+$(n).html()+"<\/div>"}function markerMouseOut(){}function canSearch(){return $("#ClientSearch").length>0&&map!=null}function preSearchSetup(){marker!=null&&marker.setMap(null),overlay!=null&&overlay.setMap(null),$("#failedToiletList").hide(),$("#showFailedList").show(),$("#hideFailedList").hide(),showingFailedToilets=!1}function handleSearchResultBoth(n,t){n!=null?handleSearchResult(n):handleSearchResultCentre(t)}function handleSearchResult(n){myFavouriteMapFirstLoad=!0,myFavouriteMapBounds=n,map.fitBounds(n),(lastResultBounds==null||lastResultBounds.getSouthWest().lat()==n.getSouthWest().lat()&&lastResultBounds.getSouthWest().lng()==n.getSouthWest().lng()&&lastResultBounds.getNorthEast().lat()==n.getNorthEast().lat()&&lastResultBounds.getNorthEast().lng()==n.getNorthEast().lng())&&updateMap(),typeof FinishedFittingMap=="function"&&FinishedFittingMap(map,n)}function handleSearchResultSimple(n){myFavouriteMapFirstLoad=!0,myFavouriteMapBounds=n,map.fitBounds(n),typeof FinishedFittingMap=="function"&&FinishedFittingMap(map,n)}function handleSearchResultCentre(n,t){(t==0||t==null)&&(t=map.getZoom()),map.setOptions({zoom:t,center:n})}function finishSearch(n,t){typeof FinishedAddressSearch=="function"&&FinishedAddressSearch(map,n,t)}function updateMap(){var f=!1,e,h,u,c;if(isFirstRun&&(f=!0,isFirstRun=!1,lastZoom=map.getZoom()),doingAClusterClick&&(doingAClusterClick=!1,lastZoom==map.getZoom())){map.setZoom(lastZoom+1);return}if(!myFavouriteMapFirstLoad||(myFavouriteMapFirstLoad=!1,ensureBoundsAreBestFit(myFavouriteMapBounds))){var t=map.getBounds().getSouthWest(),r=map.getBounds().getNorthEast(),l={gridSize:100,maxZoom:14,minimumClusterSize:5,imagePath:"/images/m",sizes:[50,60,70,80,100]};clusterer==null&&(clusterer=new MarkerClusterer(map,[],l),clusterer.setClusterOnClick(function(){OnClusterClick()})),e={gridSize:75,minimumClusterSize:1,imagePath:"/images/m",sizes:[50,60,70,80,100]},areaClusterer==null&&(areaClusterer=new MarkerClusterer(map,[],e),areaClusterer.setClusterOnClick(function(){OnClusterClick()})),$("#lfsErrors").hide();var o=$("#smAccessible").data("selected"),a=$("#smUnisex").data("selected"),v=$("#smFemale").data("selected"),y=$("#smMale").data("selected"),p=$("#smDumpPoint").data("selected"),w=$("#smChangingPlaces").data("selected"),b=$("#smLHTransfer").data("selected"),k=$("#smRHTransfer").data("selected"),d=$("#smAdultChange").data("selected"),g=$("#smAmbulant").data("selected"),nt=$("#smParkingAccessible").data("selected"),tt=$("#smSharps").data("selected"),it=$("#smShowers").data("selected"),rt=$("#smBaby").data("selected"),ut=$("#smDisposable").data("selected"),ft=$("#smDrink").data("selected"),et=$("#smMlak").data("selected"),ot=$("#smOpen24").data("selected"),n=GenerateBSearchMask(o,a,v,y,p,w,null,nt,rt,tt,it,ut,ft,null,et,null,null,g,b,k,d,ot,null,null,null),s=map.getZoom();(lastZoom!=s||n!=lastSearchMask)&&clearAllMarkers(),lastZoom=s,lastSearchMask=n,h=new Date,u=o!=null?{areaId:areaId,swLat:t.lat(),swLon:t.lng(),neLat:r.lat(),neLon:r.lng(),zoom:map.getZoom(),address:addressSearched,searchmask:n,clientTime:h.toUTCString()}:{swLat:t.lat(),swLon:t.lng(),neLat:r.lat(),neLon:r.lng(),address:addressSearched},timingMessage="",runStart=new Date,c=new Date,$.ajax({dataType:"json",url:"/api/MapAPI/GetMapDetails",data:u,success:function(t){var u,r;if(toiletCount=t.R.length+t.F.length,hiddenToiletCount=0,toiletsShown=0,anyToiletsShown=!1,firstLoadFromId||(okToReuseMap=!1),firstLoadFromId=!1,typeof ClearTimingMessages=="function"&&ClearTimingMessages(),recordTiming("getting data from server",c),u=[],Modernizr.sessionstorage&&(sessionStorage.SearchMask=n&~xISOPENALLHOURS,sessionStorage.MissingMask=t.M),toiletCount>0?(t.R.length==0?(lastResultWasFullFail=!0,$("#failedToiletList").show(),$("#failedToiletsHeading").hide()):(lastResultWasFullFail&&(showingFailedToilets||(clearAllMarkers(),$("#failedToiletList").hide(),$("#failedToiletsHeading").show())),lastResultWasFullFail=!1),handleToiletData(t.R,t.F,n,t.M),clearAreaMarkers(),enabledActionGPS(!0)):(t.A.length?f||messages.stopWork([new displayMessage(messageType.SUCCESS,"",messages.tooManyToilets),new displayMessage(messageType.WARNING,"",messages.toiletsClustered,"",messages.toiletsClusteredImage)]):messages.stopWork([new displayMessage(messageType.WARNING,messages.noToiletsFoundTitle,messages.noToiletsFound)]),$("#failedToiletsHeading").hide(),$("#mainToiletList").text(""),$("#failedToiletList").text(""),clearToiletMarkers(),successToilets=null,failedToilets=null,enabledActionGPS(!1)),t.A.length>0&&typeof AddTimingMessage=="function"&&AddTimingMessage("Area count: "+t.A.length),ProcessAreaList(t.A),t.TS.length>0)for(i in t.TS)r=t.TS[i],timingMessage+="<br/>"+r},error:function(){okToReuseMap=!1,messages.stopWork([new displayMessage(messageType.ERROR)])}}).always(function(){recordTiming("Full run",runStart),typeof AddTimingMessage=="function"&&AddTimingMessage(timingMessage)}),typeof FinishedUpdatingMap=="function"&&FinishedUpdatingMap(map)}}function handleToiletData(n,t,r,u){var b=new Date,s=[],f=[],v,y,h,c,p,w,o;toiletsShown=0,successToilets=n,failedToilets=t,typeof AddTimingMessage=="function"&&AddTimingMessage("Toilet count: "+toiletCount),Modernizr.sessionstorage&&(r=sessionStorage.SearchMask,u=sessionStorage.MissingMask);var l=missingMaskInfo(u,"map"),a=searchMaskInfo(r,u,"map"),e="";if(Modernizr.sessionstorage&&(e=sessionStorage.FormattedAddress),a.length>0?f.push(new displayMessage(messageType.SUCCESS,e,a)):e!==undefined&&e.length>0&&f.push(new displayMessage(messageType.INFO,e,"")),l.length>0&&f.push(new displayMessage(messageType.WARNING,"",l)),toiletCount>20?(isCurrentlyClustered||clearToiletMarkers(),isCurrentlyClustered=!0):isCurrentlyClustered=!1,ProcessMarkers(successToilets,s),failedToilets.length>0?(lastResultWasFullFail||$("#failedToiletsHeading").show(),showingFailedToilets||lastResultWasFullFail?ProcessMarkers(failedToilets,s):hiddenToiletCount=failedToilets.length):$("#failedToiletsHeading").hide(),toiletCount>20)v=new Date,addMarkersToClusterer(clusterer,s),recordTiming("cluster.addMarkers",v);else{clusterer.clearMarkers(),y=new Date;for(i in markers)h=markers[i],h.getMap()==null&&h.setMap(map);recordTiming("add markers to map",y)}if(ProcessSideList(successToilets,"#mainToiletList"),showingFailedToilets||lastResultWasFullFail?ProcessSideList(failedToilets,"#failedToiletList"):$("#failedToiletList").text(""),toiletsShown<toiletCount-hiddenToiletCount){c=!1,p=map.getBounds();for(w in clusterer.clusters_)o=clusterer.clusters_[w],o.markers_.length>=5&&o.getMap()!=null,o.markers_.length>=5&&p.contains(o.center_)&&(c=!0);c&&f.push(new displayMessage(messageType.WARNING,messages.toiletsClusteredTitle,messages.toiletsClustered,"",messages.toiletsClusteredImage))}$(".miniToiletItem").each(function(){var n=$(this).attr("data-toiletId");$(this).mouseenter(function(){minitoilet_mouseenter(n)}),$(this).mouseleave(function(){minitoilet_mouseleave(n)})}),messages.stopWork(f),recordTiming("handleToiletData",b)}function ProcessMarkers(n,t){var p=new Date,c,u,l,a,r,v,y,f=0,e=0,o=0,s=0,h=0,w;for(i in n)w="",c=new Date,u=GetMapPinImage(n[i],images),f=accumulateTime(c,f),l=new Date,u==null&&(u=BuildMarkerImage("mf-pin")),e=accumulateTime(l,e),a=new Date,markers[n[i].ID]==null&&(r=new google.maps.Marker({position:new google.maps.LatLng(n[i].LA,n[i].LO),title:n[i].T,code:n[i].ID,description:n[i].T,icon:u,clickable:!0}),o=accumulateTime(a,o),markers[n[i].ID]=r,t.push(r),v=new Date,google.maps.event.addListener(r,"mouseover",function(){markerMouseOver(this.code)}),google.maps.event.addListener(r,"mouseout",function(){markerMouseOut(this.code)}),google.maps.event.addListener(r,"click",function(){markerClick(this.code)}),s=accumulateTime(v,s)),y=new Date,h=accumulateTime(y,h);buildTimingMessage("Total GetMapPinImage time",f,null),buildTimingMessage("Total BuildMarkerImage time",e,null),buildTimingMessage("Total build marker time",o,null),buildTimingMessage("Total add event time",s,null),buildTimingMessage("Total newToilets.push time",h,null),recordTiming("Process markers",p)}function ProcessAreaList(n){var c=new Date,p="",l=BuildMarkerImage("crosshair","centre"),t,w,f,e,r=0,u=0,o=[],s,h;areaMarkers=[],clearAreaMarkers();for(i in n)if(f=new Date,s={},areaMarkers[n[i].ID]==null){var a=new google.maps.LatLng(n[i].B.swlt,n[i].B.swln),v=new google.maps.LatLng(n[i].B.nelt,n[i].B.neln),b=new google.maps.LatLngBounds(a,v),y=!0;y&&(t=new google.maps.Marker({position:new google.maps.LatLng(n[i].LA,n[i].LO),title:n[i].T,code:n[i].ID,description:n[i].T,icon:l}),t.toiletCount=n[i].TC,t.toiletBounds=new google.maps.LatLngBounds(new google.maps.LatLng(n[i].B.swlt,n[i].B.swln),new google.maps.LatLng(n[i].B.nelt,n[i].B.neln)),r=accumulateTime(f,r),o.push(t),areaMarkers[n[i].ID]=t,s[n[i].ID]=t)}if(e=new Date,n.length>0){areaClusterer.setCalculator(function(n,t){var i=0,u=0,r;for(k in n)cm=n[k],(cm.ignore!=!0||n.length==1)&&(u+=cm.toiletCount);for(r=u;r!==0;)r=parseInt(r/10,10),i++;return i=Math.min(i,t),{text:u,index:i}}),addMarkersToClusterer(areaClusterer,o);for(i in areaClusterer.clusters_)h=areaClusterer.clusters_[i],h.getBounds=function(){for(var t=new google.maps.LatLngBounds(this.center_,this.center_),r=this.getMarkers(),i,n=0;i=r[n];n++)t.union(i.toiletBounds);return t}}u=accumulateTime(e,u),$("#areaList").text(""),buildTimingMessage("Total area BuildMarkerImage time",r,null),buildTimingMessage("Total areaCluster calculation time",u,null),recordTiming("Process areas ",c)}function BuildArea(n){var t=$("#area-template").clone().html();return t.replace("{{title}}",n.T).replace(/{{areaId}}/g,n.ID).replace(/{{swLat}}/g,n.B.swlt).replace(/{{swLon}}/g,n.B.swln).replace(/{{neLat}}/g,n.B.nelt).replace(/{{neLon}}/g,n.B.neln)}function ProcessSideList_OkToAdd(n){var t=!1,i=markers[n.ID];return i.getMap()!=null&&(t=!0),t}function ProcessSideList_AdditionalWork(n,t){if(toiletInfo&&toiletInfo.toiletId==n){var i=$(t).clone();i.html()!=undefined&&toiletInfo.setContent(toiletCalloutContent(i))}}function PostInitialiseMap_PreSearch(){google.maps.event.addListener(map,"idle",function(){clearTimeout(timeout),timeout=setTimeout("updateMap()",100)})}function addMarkersToClusterer(n,t){n.addMarkers(t);return}function clearAllMarkers(){clusterer.clearMarkers(),areaClusterer.clearMarkers();for(i in markers){var n=markers[i];n.setMap(null)}toiletInfo&&(toiletInfo.close(),toiletInfo=null),markers={},areaMarkers={}}function clearAreaMarkers(){areaClusterer.clearMarkers(),areaMarkers={}}function clearToiletMarkers(){clusterer.clearMarkers();for(i in markers){var n=markers[i];n.setMap(null)}toiletInfo&&(toiletInfo.close(),toiletInfo=null),markers={}}function OnClusterClick(){doingAClusterClick=!0,calloutUpdateMap&&(clearTimeout(calloutUpdateMap),calloutUpdateMap=null);var n=map.getBounds();calloutUpdateMap=setTimeout(function(){AreBoundsEqual(n,map.getBounds())&&(lastZoom=map.getZoom(),map.setZoom(lastZoom+1))},100)}function writeAdditionalFields(){var n=map.getBounds(),t=n.getNorthEast(),i=n.getSouthWest();$("#NorthEastLat").attr("value",t.lat()),$("#NorthEastLon").attr("value",t.lng()),$("#SouthWestLat").attr("value",i.lat()),$("#SouthWestLon").attr("value",i.lng()),$("#Lat").attr("value",map.getCenter().lat()),$("#Lon").attr("value",map.getCenter().lng()),$("#Zoom").attr("value",map.getZoom()),$("#ShowMore").attr("value",showingFailedToilets)}var isFirstRun,timeout,areaId,firstLoadFromId,MarkerIconDefinitions,timingMessage,lastToiletId,color,color2,calloutUpdateMap;(function(n,t){function e(n,t,i){var r=s[t.type]||{};return n==null?i||!t.def?null:t.def:(n=r.floor?~~n:parseFloat(n),isNaN(n))?t.def:r.mod?(n+r.mod)%r.mod:0>n?0:r.max<n?r.max:n}function l(t){var e=i(),o=e._rgba=[];return(t=t.toLowerCase(),r(y,function(n,i){var r,s=i.re.exec(t),h=s&&i.parse(s),f=i.space||"rgba";if(h)return r=e[f](h),e[u[f].cache]=r[u[f].cache],o=e._rgba=r._rgba,!1}),o.length)?(o.join()==="0,0,0,0"&&n.extend(o,f.transparent),e):f[t]}function o(n,t,i){return(i=(i+1)%1,i*6<1)?n+(t-n)*i*6:i*2<1?t:i*3<2?n+(t-n)*(2/3-i)*6:n}var a="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",v=/^([\-+])=\s*(\d+\.?\d*)/,y=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(n){return[n[1],n[2],n[3],n[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(n){return[n[1]*2.55,n[2]*2.55,n[3]*2.55,n[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(n){return[parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(n){return[parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(n){return[n[1],n[2]/100,n[3]/100,n[4]]}}],i=n.Color=function(t,i,r,u){return new n.Color.fn.parse(t,i,r,u)},u={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},s={byte:{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},h=i.support={},c=n("<p>")[0],f,r=n.each;c.style.cssText="background-color:rgba(1,1,1,.5)",h.rgba=c.style.backgroundColor.indexOf("rgba")>-1,r(u,function(n,t){t.cache="_"+n,t.props.alpha={idx:3,type:"percent",def:1}}),i.fn=n.extend(i.prototype,{parse:function(o,s,h,c){if(o===t)return this._rgba=[null,null,null,null],this;(o.jquery||o.nodeType)&&(o=n(o).css(s),s=t);var a=this,v=n.type(o),y=this._rgba=[];return(s!==t&&(o=[o,s,h,c],v="array"),v==="string")?this.parse(l(o)||f._default):v==="array"?(r(u.rgba.props,function(n,t){y[t.idx]=e(o[t.idx],t)}),this):v==="object"?(o instanceof i?r(u,function(n,t){o[t.cache]&&(a[t.cache]=o[t.cache].slice())}):r(u,function(t,i){var u=i.cache;r(i.props,function(n,t){if(!a[u]&&i.to){if(n==="alpha"||o[n]==null)return;a[u]=i.to(a._rgba)}a[u][t.idx]=e(o[n],t,!0)}),a[u]&&n.inArray(null,a[u].slice(0,3))<0&&(a[u][3]=1,i.from&&(a._rgba=i.from(a[u])))}),this):void 0},is:function(n){var e=i(n),t=!0,f=this;return r(u,function(n,i){var o,u=e[i.cache];return u&&(o=f[i.cache]||i.to&&i.to(f._rgba)||[],r(i.props,function(n,i){if(u[i.idx]!=null)return t=u[i.idx]===o[i.idx]})),t}),t},_space:function(){var n=[],t=this;return r(u,function(i,r){t[r.cache]&&n.push(i)}),n.pop()},transition:function(n,t){var f=i(n),c=f._space(),o=u[c],l=this.alpha()===0?i("transparent"):this,a=l[o.cache]||o.to(l._rgba),h=a.slice();return f=f[o.cache],r(o.props,function(n,i){var c=i.idx,r=a[c],u=f[c],o=s[i.type]||{};u!==null&&(r===null?h[c]=u:(o.mod&&(u-r>o.mod/2?r+=o.mod:r-u>o.mod/2&&(r-=o.mod)),h[c]=e((u-r)*t+r,i)))}),this[c](h)},blend:function(t){if(this._rgba[3]===1)return this;var r=this._rgba.slice(),u=r.pop(),f=i(t)._rgba;return i(n.map(r,function(n,t){return(1-u)*f[t]+u*n}))},toRgbaString:function(){var i="rgba(",t=n.map(this._rgba,function(n,t){return n==null?t>2?1:0:n});return t[3]===1&&(t.pop(),i="rgb("),i+t.join()+")"},toHslaString:function(){var i="hsla(",t=n.map(this.hsla(),function(n,t){return n==null&&(n=t>2?1:0),t&&t<3&&(n=Math.round(n*100)+"%"),n});return t[3]===1&&(t.pop(),i="hsl("),i+t.join()+")"},toHexString:function(t){var i=this._rgba.slice(),r=i.pop();return t&&i.push(~~(r*255)),"#"+n.map(i,function(n){return n=(n||0).toString(16),n.length===1?"0"+n:n}).join("")},toString:function(){return this._rgba[3]===0?"transparent":this.toRgbaString()}}),i.fn.parse.prototype=i.fn,u.hsla.to=function(n){if(n[0]==null||n[1]==null||n[2]==null)return[null,null,null,n[3]];var i=n[0]/255,r=n[1]/255,e=n[2]/255,c=n[3],u=Math.max(i,r,e),s=Math.min(i,r,e),t=u-s,h=u+s,l=h*.5,f,o;return f=s===u?0:i===u?60*(r-e)/t+360:r===u?60*(e-i)/t+120:60*(i-r)/t+240,o=t===0?0:l<=.5?t/h:t/(2-h),[Math.round(f)%360,o,l,c==null?1:c]},u.hsla.from=function(n){if(n[0]==null||n[1]==null||n[2]==null)return[null,null,null,n[3]];var r=n[0]/360,u=n[1],t=n[2],e=n[3],i=t<=.5?t*(1+u):t+u-t*u,f=2*t-i;return[Math.round(o(f,i,r+1/3)*255),Math.round(o(f,i,r)*255),Math.round(o(f,i,r-1/3)*255),e]},r(u,function(u,f){var s=f.props,o=f.cache,h=f.to,c=f.from;i.fn[u]=function(u){if(h&&!this[o]&&(this[o]=h(this._rgba)),u===t)return this[o].slice();var l,a=n.type(u),v=a==="array"||a==="object"?u:arguments,f=this[o].slice();return r(s,function(n,t){var i=v[a==="object"?n:t.idx];i==null&&(i=f[t.idx]),f[t.idx]=e(i,t)}),c?(l=i(c(f)),l[o]=f,l):i(f)},r(s,function(t,r){i.fn[t]||(i.fn[t]=function(i){var f=n.type(i),h=t==="alpha"?this._hsla?"hsla":"rgba":u,o=this[h](),s=o[r.idx],e;return f==="undefined"?s:(f==="function"&&(i=i.call(this,s),f=n.type(i)),i==null&&r.empty)?this:(f==="string"&&(e=v.exec(i),e&&(i=s+parseFloat(e[2])*(e[1]==="+"?1:-1))),o[r.idx]=i,this[h](o))})})}),i.hook=function(t){var u=t.split(" ");r(u,function(t,r){n.cssHooks[r]={set:function(t,u){var o,f,e="";if(u!=="transparent"&&(n.type(u)!=="string"||(o=l(u)))){if(u=i(o||u),!h.rgba&&u._rgba[3]!==1){for(f=r==="backgroundColor"?t.parentNode:t;(e===""||e==="transparent")&&f&&f.style;)try{e=n.css(f,"backgroundColor"),f=f.parentNode}catch(s){}u=u.blend(e&&e!=="transparent"?e:"_default")}u=u.toRgbaString()}try{t.style[r]=u}catch(s){}}},n.fx.step[r]=function(t){t.colorInit||(t.start=i(t.elem,r),t.end=i(t.end),t.colorInit=!0),n.cssHooks[r].set(t.elem,t.start.transition(t.end,t.pos))}})},i.hook(a),n.cssHooks.borderColor={expand:function(n){var t={};return r(["Top","Right","Bottom","Left"],function(i,r){t["border"+r+"Color"]=n}),t}},f=n.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}})(jQuery),MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/images/m",MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_="png",MarkerClusterer.prototype.extend=function(n,t){return function(n){for(var t in n.prototype)this.prototype[t]=n.prototype[t];return this}.apply(n,[t])},MarkerClusterer.prototype.onAdd=function(){this.setReady_(!0)},MarkerClusterer.prototype.draw=function(){},MarkerClusterer.prototype.setupStyles_=function(){if(!this.styles_.length)for(var n=0,t;t=this.sizes[n];n++)this.styles_.push({url:this.imagePath_+(n+1)+"."+this.imageExtension_,height:t,width:t})},MarkerClusterer.prototype.fitMapToMarkers=function(){for(var r=this.getMarkers(),t=new google.maps.LatLngBounds,i,n=0;i=r[n];n++)t.extend(i.getPosition());this.map_.fitBounds(t)},MarkerClusterer.prototype.setStyles=function(n){this.styles_=n},MarkerClusterer.prototype.getStyles=function(){return this.styles_},MarkerClusterer.prototype.isZoomOnClick=function(){return this.zoomOnClick_},MarkerClusterer.prototype.isAverageCenter=function(){return this.averageCenter_},MarkerClusterer.prototype.getMarkers=function(){return this.markers_},MarkerClusterer.prototype.getTotalMarkers=function(){return this.markers_.length},MarkerClusterer.prototype.setMaxZoom=function(n){this.maxZoom_=n},MarkerClusterer.prototype.getMaxZoom=function(){return this.maxZoom_},MarkerClusterer.prototype.calculator_=function(n,t){for(var i=0,u=n.length,r=u;r!==0;)r=parseInt(r/10,10),i++;return i=Math.min(i,t),{text:u,index:i}},MarkerClusterer.prototype.setCalculator=function(n){this.calculator_=n},MarkerClusterer.prototype.getCalculator=function(){return this.calculator_},MarkerClusterer.prototype.setClusterOnClick=function(n){this.clusterOnClick=n},MarkerClusterer.prototype.getClusterOnClick=function(){return this.clusterOnClick},MarkerClusterer.prototype.addMarkers=function(n,t){for(var i=0,r;r=n[i];i++)this.pushMarkerTo_(r);t||this.redraw()},MarkerClusterer.prototype.pushMarkerTo_=function(n){if(n.isAdded=!1,n.draggable){var t=this;google.maps.event.addListener(n,"dragend",function(){n.isAdded=!1,t.repaint()})}this.markers_.push(n)},MarkerClusterer.prototype.addMarker=function(n,t){this.pushMarkerTo_(n),t||this.redraw()},MarkerClusterer.prototype.removeMarker_=function(n){var t=-1,i,r;if(this.markers_.indexOf)t=this.markers_.indexOf(n);else for(i=0;r=this.markers_[i];i++)if(r==n){t=i;break}return t==-1?!1:(n.setMap(null),this.markers_.splice(t,1),!0)},MarkerClusterer.prototype.removeMarker=function(n,t){var i=this.removeMarker_(n);return!t&&i?(this.resetViewport(),this.redraw(),!0):!1},MarkerClusterer.prototype.removeMarkers=function(n,t){for(var i=!1,u,f,r=0;u=n[r];r++)f=this.removeMarker_(u),i=i||f;if(!t&&i)return this.resetViewport(),this.redraw(),!0},MarkerClusterer.prototype.setReady_=function(n){this.ready_||(this.ready_=n,this.createClusters_())},MarkerClusterer.prototype.getTotalClusters=function(){return this.clusters_.length},MarkerClusterer.prototype.getMap=function(){return this.map_},MarkerClusterer.prototype.setMap=function(n){this.map_=n},MarkerClusterer.prototype.getGridSize=function(){return this.gridSize_},MarkerClusterer.prototype.setGridSize=function(n){this.gridSize_=n},MarkerClusterer.prototype.getMinClusterSize=function(){return this.minClusterSize_},MarkerClusterer.prototype.setMinClusterSize=function(n){this.minClusterSize_=n},MarkerClusterer.prototype.getExtendedBounds=function(n){var t=this.getProjection(),e=new google.maps.LatLng(n.getNorthEast().lat(),n.getNorthEast().lng()),o=new google.maps.LatLng(n.getSouthWest().lat(),n.getSouthWest().lng()),r=t.fromLatLngToDivPixel(e),i,u,f;return r.x+=this.gridSize_,r.y-=this.gridSize_,i=t.fromLatLngToDivPixel(o),i.x-=this.gridSize_,i.y+=this.gridSize_,u=t.fromDivPixelToLatLng(r),f=t.fromDivPixelToLatLng(i),n.extend(u),n.extend(f),n},MarkerClusterer.prototype.isMarkerInBounds_=function(n,t){return t.contains(n.getPosition())},MarkerClusterer.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers_=[]},MarkerClusterer.prototype.resetViewport=function(n){for(var r,i,t=0;r=this.clusters_[t];t++)r.remove();for(t=0;i=this.markers_[t];t++)i.isAdded=!1,n&&i.setMap(null);this.clusters_=[]},MarkerClusterer.prototype.repaint=function(){var n=this.clusters_.slice();this.clusters_.length=0,this.resetViewport(),this.redraw(),window.setTimeout(function(){for(var t=0,i;i=n[t];t++)i.remove()},0)},MarkerClusterer.prototype.redraw=function(){this.createClusters_()},MarkerClusterer.prototype.distanceBetweenPoints_=function(n,t){if(!n||!t)return 0;var f=6371,i=(t.lat()-n.lat())*Math.PI/180,r=(t.lng()-n.lng())*Math.PI/180,u=Math.sin(i/2)*Math.sin(i/2)+Math.cos(n.lat()*Math.PI/180)*Math.cos(t.lat()*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2),e=2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u));return f*e},MarkerClusterer.prototype.addToClosestCluster_=function(n){for(var e=4e4,i=null,o=n.getPosition(),u,f,t,r=0;t=this.clusters_[r];r++)u=t.getCenter(),u&&(f=this.distanceBetweenPoints_(u,n.getPosition()),f<e&&(e=f,i=t));i&&i.isMarkerInClusterBounds(n)?i.addMarker(n):(t=new Cluster(this),t.addMarker(n),this.clusters_.push(t))},MarkerClusterer.prototype.createClusters_=function(){var i,r,t,n;if(this.ready_)for(i=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),this.map_.getBounds().getNorthEast()),r=this.getExtendedBounds(i),t=0;n=this.markers_[t];t++)!n.isAdded&&this.isMarkerInBounds_(n,r)&&this.addToClosestCluster_(n)},Cluster.prototype.isMarkerAlreadyAdded=function(n){if(this.markers_.indexOf)return this.markers_.indexOf(n)!=-1;for(var t=0,i;i=this.markers_[t];t++)if(i==n)return!0;return!1},Cluster.prototype.addMarker=function(n){var t,r;if(this.isMarkerAlreadyAdded(n))return!1;if(this.center_){if(this.averageCenter_){var i=this.markers_.length+1,u=(this.center_.lat()*(i-1)+n.getPosition().lat())/i,f=(this.center_.lng()*(i-1)+n.getPosition().lng())/i;this.center_=new google.maps.LatLng(u,f),this.calculateBounds_()}}else this.center_=n.getPosition(),this.calculateBounds_();if(n.isAdded=!0,this.markers_.push(n),t=this.markers_.length,t<this.minClusterSize_&&n.getMap()!=this.map_&&n.setMap(this.map_),t==this.minClusterSize_)for(r=0;r<t;r++)this.markers_[r].setMap(null);return t>=this.minClusterSize_&&n.setMap(null),this.updateIcon(),!0},Cluster.prototype.getMarkerClusterer=function(){return this.markerClusterer_},Cluster.prototype.getBounds=function(){for(var t=new google.maps.LatLngBounds(this.center_,this.center_),r=this.getMarkers(),i,n=0;i=r[n];n++)t.extend(i.getPosition());return t},Cluster.prototype.remove=function(){this.clusterIcon_.remove(),this.markers_.length=0,delete this.markers_},Cluster.prototype.getSize=function(){return this.markers_.length},Cluster.prototype.getMarkers=function(){return this.markers_},Cluster.prototype.getCenter=function(){return this.center_},Cluster.prototype.calculateBounds_=function(){var n=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(n)},Cluster.prototype.isMarkerInClusterBounds=function(n){return this.bounds_.contains(n.getPosition())},Cluster.prototype.getMap=function(){return this.map_},Cluster.prototype.updateIcon=function(){var f=this.map_.getZoom(),t=this.markerClusterer_.getMaxZoom(),n,i,r,u;if(t&&f>t){for(n=0;i=this.markers_[n];n++)i.setMap(this.map_);return}if(this.markers_.length<this.minClusterSize_){this.clusterIcon_.hide();return}r=this.markerClusterer_.getStyles().length,u=this.markerClusterer_.getCalculator()(this.markers_,r),this.clusterIcon_.setCenter(this.center_),this.clusterIcon_.setSums(u),this.clusterIcon_.show()},ClusterIcon.prototype.triggerClusterClick=function(){var n=this.cluster_.getMarkerClusterer();google.maps.event.trigger(n,"clusterclick",this.cluster_),n.getClusterOnClick()!=null&&n.clusterOnClick(this.cluster_),n.isZoomOnClick()&&this.map_.fitBounds(this.cluster_.getBounds())},ClusterIcon.prototype.onAdd=function(){var i,t,n,r,u;this.div_=document.createElement("DIV"),this.visible_&&(i=this.getPosFromLatLng_(this.center_),t=document.createElement("img"),$(t).attr("src",this.url_),this.div_.style.cssText=this.createCss(i),n=document.createElement("p"),$(n).css("position","absolute"),$(n).css("top","1px"),$(n).css("left","0px"),$(n).css("width","100%"),n.innerHTML=this.sums_.text,this.div_.appendChild(t),this.div_.appendChild(n)),r=this.getPanes(),r.overlayMouseTarget.appendChild(this.div_),u=this,google.maps.event.addDomListener(this.div_,"click",function(){u.triggerClusterClick()})},ClusterIcon.prototype.getPosFromLatLng_=function(n){var t=this.getProjection().fromLatLngToDivPixel(n);return t.x-=parseInt(this.width_/2,10),t.y-=parseInt(this.height_/2,10),t},ClusterIcon.prototype.draw=function(){if(this.visible_){var n=this.getPosFromLatLng_(this.center_);this.div_.style.top=n.y+"px",this.div_.style.left=n.x+"px"}},ClusterIcon.prototype.hide=function(){this.div_&&(this.div_.style.display="none"),this.visible_=!1},ClusterIcon.prototype.show=function(){if(this.div_){var n=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(n),this.div_.style.display=""}this.visible_=!0},ClusterIcon.prototype.remove=function(){this.setMap(null)},ClusterIcon.prototype.onRemove=function(){this.div_&&this.div_.parentNode&&(this.hide(),this.div_.parentNode.removeChild(this.div_),this.div_=null)},ClusterIcon.prototype.setSums=function(n){this.sums_=n,this.text_=n.text,this.index_=n.index,this.div_&&(this.div_.innerHTML=n.text),this.useStyle()},ClusterIcon.prototype.useStyle=function(){var t=Math.max(0,this.sums_.index-1),n;t=Math.min(this.styles_.length-1,t),n=this.styles_[t],this.url_=n.url,this.height_=n.height,this.width_=n.width,this.textColor_=n.textColor,this.anchor_=n.anchor,this.textSize_=n.textSize,this.backgroundPosition_=n.backgroundPosition},ClusterIcon.prototype.setCenter=function(n){this.center_=n},ClusterIcon.prototype.createCss=function(n){var t=[],i,r;return typeof this.anchor_=="object"?(typeof this.anchor_[0]=="number"&&this.anchor_[0]>0&&this.anchor_[0]<this.height_?t.push("height:"+(this.height_-this.anchor_[0])+"px; padding-top:"+this.anchor_[0]+"px;"):t.push("height:"+this.height_+"px; line-height:"+this.height_+"px;"),typeof this.anchor_[1]=="number"&&this.anchor_[1]>0&&this.anchor_[1]<this.width_?t.push("width:"+(this.width_-this.anchor_[1])+"px; padding-left:"+this.anchor_[1]+"px;"):t.push("width:"+this.width_+"px; text-align:center;")):t.push("height:"+this.height_+"px; line-height:"+this.height_+"px; width:"+this.width_+"px; text-align:center;"),i=this.textColor_?this.textColor_:"black",r=this.textSize_?this.textSize_:11,t.push("cursor:pointer; top:"+n.y+"px; left:"+n.x+"px; color:"+i+"; position:absolute; font-size:"+r+"px; font-family:Arial,sans-serif; font-weight:bold"),t.join("")},window.MarkerClusterer=MarkerClusterer,MarkerClusterer.prototype.addMarker=MarkerClusterer.prototype.addMarker,MarkerClusterer.prototype.addMarkers=MarkerClusterer.prototype.addMarkers,MarkerClusterer.prototype.clearMarkers=MarkerClusterer.prototype.clearMarkers,MarkerClusterer.prototype.fitMapToMarkers=MarkerClusterer.prototype.fitMapToMarkers,MarkerClusterer.prototype.getCalculator=MarkerClusterer.prototype.getCalculator,MarkerClusterer.prototype.getGridSize=MarkerClusterer.prototype.getGridSize,MarkerClusterer.prototype.getExtendedBounds=MarkerClusterer.prototype.getExtendedBounds,MarkerClusterer.prototype.getMap=MarkerClusterer.prototype.getMap,MarkerClusterer.prototype.getMarkers=MarkerClusterer.prototype.getMarkers,MarkerClusterer.prototype.getMaxZoom=MarkerClusterer.prototype.getMaxZoom,MarkerClusterer.prototype.getStyles=MarkerClusterer.prototype.getStyles,MarkerClusterer.prototype.getTotalClusters=MarkerClusterer.prototype.getTotalClusters,MarkerClusterer.prototype.getTotalMarkers=MarkerClusterer.prototype.getTotalMarkers,MarkerClusterer.prototype.redraw=MarkerClusterer.prototype.redraw,MarkerClusterer.prototype.removeMarker=MarkerClusterer.prototype.removeMarker,MarkerClusterer.prototype.removeMarkers=MarkerClusterer.prototype.removeMarkers,MarkerClusterer.prototype.resetViewport=MarkerClusterer.prototype.resetViewport,MarkerClusterer.prototype.repaint=MarkerClusterer.prototype.repaint,MarkerClusterer.prototype.setCalculator=MarkerClusterer.prototype.setCalculator,MarkerClusterer.prototype.setGridSize=MarkerClusterer.prototype.setGridSize,MarkerClusterer.prototype.setMaxZoom=MarkerClusterer.prototype.setMaxZoom,MarkerClusterer.prototype.onAdd=MarkerClusterer.prototype.onAdd,MarkerClusterer.prototype.draw=MarkerClusterer.prototype.draw,Cluster.prototype.getCenter=Cluster.prototype.getCenter,Cluster.prototype.getSize=Cluster.prototype.getSize,Cluster.prototype.getMarkers=Cluster.prototype.getMarkers,ClusterIcon.prototype.onAdd=ClusterIcon.prototype.onAdd,ClusterIcon.prototype.draw=ClusterIcon.prototype.draw,ClusterIcon.prototype.onRemove=ClusterIcon.prototype.onRemove;var xISMALE=1,xISACCESSIBLEMALE=2,xISFEMALE=4,xISACCESSIBLEFEMALE=8,xISUNISEX=16,xISACCESSIBLEUNISEX=32,xISDUMPPOINT=64,xISPARKING=128,xISPARKINGACCESSIBLE=256,xISBABYCHANGE=512,xISSHARPSDISPOSAL=1024,xISSHOWERS=2048,xISSANITARYDISPOSAL=4096,xISDRINKINGWATER=8192,xISKEYREQUIRED=16384,xISMLAKKEY=32768,xISPAYMENTREQUIRED=65536,xISACCESSLIMITED=131072,xISOPENALLHOURS=262144,xISOPENDAYLIGHTHOURS=524288,xISCLOSED=1048576,xISOPENINGHOURSVARIABLE=2097152,xISAMBULANT=4194304,xISLHTRANSFER=8388608,xISRHTRANSFER=16777216,xISADULTCHANGE=33554432,xISCHANGINGPLACES=67108864;var addressSearched,marker,overlay,image,lastResultBounds,successToilets,failedToilets,showingFailedToilets=!1,toiletCount=0,hiddenToiletCount=0,anyToiletsShown=!1,toiletsShown=0,runStart,clusterer,areaMarkers={},areaClusterer,lastSearchMask=0,lastZoom=0,isCurrentlyClustered=!1,lastResultWasFullFail=!1,doingAClusterClick=!1,myFavouriteMapFirstLoad=!1,myFavouriteMapBounds,usingGeolocation=!1,geoLatLng,wantingToSave=!1,saveType="Save",lastField="",okToReuseMap=!1;$("#findSearchForm").submit(function(n){n.preventDefault(),lastField="findSearchForm",clientSearch()}),$("#multiAddressForm").submit(function(n){n.preventDefault()}),$("#saveMapForm").submit(function(n){saveMapFormSubmit(this,n)}),$(function(){Modernizr.localstorage&&localStorage.FindSaveData!=undefined&&localStorage.FindSaveData!=null&&localStorage.FindSaveData!="null"&&saveMap(),$("#ClientSearch").focus(function(){return lastField!="ClientSearch"?(setTimeout(function(){$("#ClientSearch").select(),lastField="ClientSearch"},100),!1):!0}),$("#GeoSearch").focus(function(){return lastField!="GeoSearch"?(setTimeout(function(){$("GeoSearch").select(),lastField="GeoSearch"},100),!1):!0})}),$.fn.serializeObject=function(){var n={},t=this.serializeArray();return $.each(t,function(){n[this.name]!==undefined?(n[this.name].push||(n[this.name]=[n[this.name]]),n[this.name].push(this.value||"")):n[this.name]=this.value||""}),n};var map,markers={},mapImage,toiletInfo,images={},toilets={},updateCallTimeout,AustraliaBounds,calloutDisplayTimeout,supressInfoWindow,startMapTime;$(function(){startMapTime=+new Date,PreInitialiseMap(),AustraliaBounds=new google.maps.LatLngBounds(new google.maps.LatLng(-43.658327,112.9239721),new google.maps.LatLng(-9.2268057,153.6386738)),InitialiseMap()}),MarkerIconDefinitions=[],timingMessage="",color="#54DCFF",color2="#E0F8FE"