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 submitPlan(n,t){var i=getFilterMask(),r=$("#SearchMask").attr("value");return $("#SearchMask").attr("value",i),$("#submitPlan").focus(),lastField="submitPlan",directionsDisplay.setMap(map),$("#ViaPoints").attr("value",""),originalRoute=!0,currentDirections=null,oldDirections=[],overrideScore=ToBoolean($("#ShowMore").attr("value")),originalViaAddress=$("#ViaAddress").attr("value"),postBackToServer==!1?(t.preventDefault(),calcRoute()):postBackToServer=!1,!0}function PostInitialiseMap(){var t,u,n,i,r,f;stepInfoWindow=new google.maps.InfoWindow,stepMarker=new google.maps.Marker({map:map,zIndex:1e3,visible:!1}),directionsDisplay=new google.maps.DirectionsRenderer({map:map,preserveViewPort:!1,draggable:!0,hideRouteList:!1,suppressInfoWindows:!0,polylineOptions:{strokeColor:"magenta",strokeOpacity:.5,strokeWeight:5}}),t=$("#MyTripID").val(),customList==!1&&directionsDisplay.setPanel($("div#directions-panel").get(0)),t!=""&&Number(t)>0?(u=window.location,n={},n.Link=u,n.Title="My trip",saveHref(n),firstLoadFromId=!0):firstLoadFromId=!1,originalRoute=!1,map.setOptions({scaleControl:!0}),typeof $("#googleAPI").get(0)=="object"&&$("#googleAPI").attr("src").indexOf("&v=3.13")>0?(i="https://maps.gstatic.com/mapfiles/markers2/icon_greenA.png",r="https://maps.gstatic.com/mapfiles/markers2/icon_greenB.png"):(i="https://maps.gstatic.com/mapfiles/markers2/marker_greenA.png",r="https://maps.gstatic.com/mapfiles/markers2/markerB.png"),startMarker=new google.maps.Marker({icon:i,draggable:!0,animation:"DROP"}),endMarker=new google.maps.Marker({icon:r,draggable:!0,animation:"DROP"}),debug=$("#debug").attr("value"),debug>1&&$("#diagControls").show(),f=ToBoolean($("#debug").attr("page-valid")),f?($("div#directions-panel").toggleClass("hide"),debug>1&&$("#diagnostics").toggleClass("hide"),calcRoute(),google.maps.event.addListener(directionsDisplay,"directions_changed",function(){changeDirections()}),google.maps.event.addListener(map,"rightclick",function(){mapRightClick()}),google.maps.event.addListener(map,"zoom_changed",function(){changeMapZoom()}),setUndoDisabled(!0)):showDefaultMap()}function getFilterMask(){var n=0,t=$("#smAccessible").data("selected"),i=$("#smUnisex").data("selected"),r=$("#smFemale").data("selected"),u=$("#smMale").data("selected"),f=$("#smDumpPoint").data("selected"),e=$("#smChangingPlaces").data("selected"),o=$("#smParkingAccessible").data("selected"),s=$("#smLHTransfer").data("selected"),h=$("#smRHTransfer").data("selected"),c=$("#smAdultChange").data("selected"),l=$("#smAmbulant").data("selected"),a=$("#smSharps").data("selected"),v=$("#smShowers").data("selected"),y=$("#smBaby").data("selected"),p=$("#smDisposable").data("selected"),w=$("#smDrink").data("selected"),b=$("#smMlak").data("selected"),k=$("#smOpen24").data("selected");return n=GenerateBSearchMask(t,i,r,u,f,e,null,o,y,a,v,p,w,null,b,null,null,l,s,h,c,k,null,null,null)}function calcRoute(n,t){var v,s=[],u=$("#StartAddress").attr("value").toString(),f=$("#EndAddress").attr("value").toString(),r=$("#ViaAddress").attr("value").toString(),e=$("#ViaPoints").attr("value").toString(),y,p,h,c,l,o,a,w;if(r==$("#ViaAddress").attr("placeholder")&&(r=""),y=$("#AvoidTollRoads").is(":checked"),p=$("#AvoidHighways").is(":checked"),travelMode=$("#TravelMode").attr("value"),n&&(u=n),t&&(f=t),h=convertToGoogleLatLng(u),h!=null?u=h:u.indexOf("Australia")<0&&(u+=", Australia"),c=convertToGoogleLatLng(f),c!=null?f=c:f.indexOf("Australia")<0&&(f+=", Australia"),l=convertToGoogleLatLng(r),l!=null?r=l:r.length>0&&(r.indexOf("Australia")<0&&(r+=", Australia"),e.length<1&&(e=r)),e.length>1)for(o=e.split("),("),i=0;i<o.length;i++)a=convertToGoogleLatLng(o[i]),a!=null?s.push({location:a,stopover:!1}):s.push({location:o[i],stopover:!1});w=ToBoolean($("#debug").attr("page-valid")),w&&(v={origin:u,destination:f,waypoints:s,travelMode:travelMode,optimizeWaypoints:!1,avoidTolls:y,avoidHighways:p,region:"Australia"},directionsService.route(v,function(n,t){t==google.maps.DirectionsStatus.OK?(directionsDisplay.setDirections(n),startMarker.setMap(null),endMarker.setMap(null),enabledActionSave(!0),enabledActionPrint(!0),enabledActionGPS(!0),enabledActionEmail(!0),enabledActionFacebook(!0),enabledActionTwitter(!0),enabledActionGoogle(!0)):(AreAddressesEmpty()==!1&&(okToReuseMap=!1,messages.stopWork([new displayMessage(messageType.WARNING,"",messages.routeNotFound)])),showDefaultMap(),enabledActionSave(!1),enabledActionPrint(!1),enabledActionGPS(!1),enabledActionEmail(!1),enabledActionFacebook(!1),enabledActionTwitter(!1),enabledActionGoogle(!1))}));return}function mapRightClick(){iconVisibility=!iconVisibility,markerVisibility(iconVisibility)}function changeMapZoom(){markerVisibility(iconVisibility)}function markerVisibility(n){var u=map.getZoom(),t,i,r;if(t=map,n!=null&&(iconVisibility==!0?($("#toggleIconsLink").text("Hide toilet icons"),t=map):($("#toggleIconsLink").text("Show toilet icons"),t=null)),markers)for(r in markers)i=markers[r],i.setMap(t)}function changeDirections(){currentDirections&&(oldDirections.push(currentDirections),originalRoute==!1&&$("#ViaAddress").attr("value",""),setUndoDisabled(!1)),currentDirections=directionsDisplay.getDirections(),currentDirections&&$("#showOverview").hasClass("hide")&&$("#showOverview").toggleClass("hide"),currentDirections.status==google.maps.DirectionsStatus.OK&&(currentDirections.routes[0].legs[0].steps.length>1||currentDirections.routes[0].legs[0].steps[0].path.length>1)?(showSteps(currentDirections),$("#PrintableMapTitle").text(getTripTitle(currentDirections))):(AreAddressesEmpty()==!1&&(okToReuseMap=!1,messages.stopWork([new displayMessage(messageType.WARNING,"",messages.routeNotFound)])),showDefaultMap()),originalRoute=!1;return}function getTripTitle(n){var r="",f="",e="",t="",t="",u=null,i="",o="",s="";return n==null?r="":(u=n.routes[0].legs[0],f=getLocationFromAddressString(u.start_address),e=getLocationFromAddressString(u.end_address),i=$("#ViaAddress").attr("value"),o=$("#ViaAddress").attr("placeholder"),s=$("#TravelMode option:selected").text(),i==o&&(i=""),t=getLocationFromAddressString(i),t.length>0&&(t=" via "+t),r=s+" from "+f+" to "+e+t),r}function AreAddressesEmpty(n,t){var i,r,u=$("#StartAddress").attr("placeholder").toString(),f=$("#EndAddress").attr("placeholder").toString();return i=n?n:$("#StartAddress").attr("value").toString(),r=t?t:$("#EndAddress").attr("value").toString(),(i==u||i.replace(/ /g,"")=="")&&(r==f||r.replace(/ /g,"")=="")?!0:!1}function overrideBootstrapListStyle(){$("table.adp-placemark tbody tr:eq(0) td:eq(0)").attr("style","width:10%"),$("table.adp-placemark").attr("style","width:100%"),$("table.adp-placemark tbody tr:eq(1) td:eq(0)").attr("style","width:10%"),$("table.adp-placemark").attr("style","width:100%"),$("table.adp-directions tbody tr").find("td:gt(0)").each(function(){var r=$(this).get(0).innerText,t,i,n;if(r.length>35){for(t=r.split(" "),i=!1,n=0;n<t.length;n++)if(t[n].length>27){i=!0;break}i&&$(this).attr("style","word-break: break-all; overflow: auto; overflow-wrap: break-word;")}})}function buildDirectionsList(n){var c="",t=n.routes[0].legs[0],b=t.start_address,k=t.end_address,l=n.routes[0].warnings,f="",a="",v="",y="",u="",p="",d="<div id='plan-legal' class='adp-legal plan-legal'>"+n.routes[0].copyrights+"<\/div>",r=0,o=0,e="",s,i;switch(t.steps[0].travel_mode){case"BICYCLING":e="Cycling ";break;case"WALKING":e="Walking ";break;default:e="Driving "}y="<div id='plan-summary' class='adp-summary plan-summary'>"+e+t.distance.text+" - about "+t.duration.text+"<\/div>";for(r in l)f=f+l[r]+" ";f.length>1&&(a="<div id='plan-warnings' class='alert alert-warning'>"+f+"<\/div>"),v="<div id='plan-start'><table class='adp-placemark plan-placemark'><tr><td><img src='"+startMarker.getIcon()+"'><\/td><td>"+b+"<\/td><\/tr><\/table><\/div>",p="<div id='plan-end'><table class='adp-placemark plan-placemark'><tr><td><img src='"+endMarker.getIcon()+"'><\/td><td>"+k+"<\/td><\/tr><\/table><\/div>",u="<div id='adp-directions'><table class='adp-directions plan-directions'><tbody>",s=t.steps.length,varlastStepIndex="0",s>0&&(lastStepIndex=(s-1).toString());for(r in t.steps){var w=t.steps[r],g=w.instructions,h="",nt=w.distance.text;o=o+1,h=r==lastStepIndex?"*"+r.toString():r.toString(),i="<tr jsinstance='"+h+"'><td><\/td><td class='adp-substep plan-substep'>"+o.toString()+".<\/td>",i=i+"<td class='adp-substep plan-substep'>"+g+"<\/td>",i=i+"<td class='adp-substep plan-substep'><div class='adp-distance plan-distance'>"+nt+"<\/div><\/td>",i=i+"<\/tr>",u=u+i}u=u+"<\/tbody><\/table><\/div>",c=a+v+y+u+p+d,$("div#directions-panel").get(0).innerHTML=c}function showSteps(n){var i=n.routes[0].legs[0],r=i.start_address,u=i.end_address,p=$("#ViaAddress").attr("value"),w=i.duration.value,b=i.distance.value,k=$("#TravelMode").attr("value"),d=n.routes[0].overview_polyline.points,f="",g="",l=!1,t,o,a,e,s,h,v,y,c;if(l=$("#chkShowAll").get(0).checked,customList&&buildDirectionsList(n),i.via_waypoints.length>0){for(t=0;t<i.via_waypoints.length;t++)o=i.via_waypoints[t],t==0?g=o:f+=",",f+="("+o.toUrlValue(6)+")";$("#ViaPoints").attr("value",f)}if(clearTimeout(timeoutID),timeoutID=setTimeout(overrideBootstrapListStyle,10),$("#StartAddress").attr("value",r),$("#EndAddress").attr("value",u),$("#StartAddress").attr("fullvalue",r),$("#EndAddress").attr("fullvalue",u),a=new google.maps.InfoWindow,e=[],debug=$("#debug").attr("value"),debug>1){for(t=0;t<stepMarkers.length;t++)stepMarkers[t].setMap(null);while(stepMarkers.length>0)stepMarkers.pop()}for(e.push(i.steps[0].start_point),t=0;t<i.steps.length;t++)e.push(i.steps[t].end_point),debug>1&&(s=new google.maps.Marker({position:i.steps[t].start_point,map:map}),attachInstructionText(s,i.steps[t].instructions,a),stepMarkers.push(s));var nt=google.maps.geometry.encoding.encodePath(e),tt=SausagePreProcessing(n),it=$("#smAccessible").data("selected"),rt=$("#smUnisex").data("selected"),ut=$("#smFemale").data("selected"),ft=$("#smMale").data("selected"),et=$("#smDumpPoint").data("selected"),ot=$("#smChangingPlaces").data("selected"),st=$("#smOpen24").data("selected"),ht=$("#smParkingAccessible").data("selected"),ct=$("#smLHTransfer").data("selected"),lt=$("#smRHTransfer").data("selected"),at=$("#smAdultChange").data("selected"),vt=$("#smAmbulant").data("selected"),yt=$("#smSharps").data("selected"),pt=$("#smShowers").data("selected"),wt=$("#smBaby").data("selected"),bt=$("#smDisposable").data("selected"),kt=$("#smDrink").data("selected"),dt=$("#smMlak").data("selected"),gt=$("#formRoute > input[name='__RequestVerificationToken']").attr("value");$("#__RequestVerificationToken").attr("value"),h=getScoreThreshold(overrideScore),v=ToBoolean($("#ShowMore").attr("value")),debug>0&&(y="<b>ShowSteps - b4 ajax call<\/b><\/br>ScoreThreshold =  "+h.toString()+"<br />overrideScore = "+overrideScore.toString()+"<br/>",$("#diagnostics").get(0).innerHTML=y),r.indexOf("Australia")>=0&&u.indexOf("Australia")>=0?(messages.startWork(),c=$.ajax({type:"POST",url:"/api/PlanAPI/PostToiletsEnRoute",data:{__RequestVerificationToken:gt,overviewPolyline:d,waypoints:f,stepPoints:nt,miniPolylines:tt,startFrom:r,endAt:u,viaAddress:p,travelMode:k,zoom:map.zoom,tripLength:b,tripTime:w,IncludeAccessible:it,IncludeUnisex:rt,IncludeFemale:ut,IncludeMale:ft,IncludeDumpPoint:et,IncludeChangingPlaces:ot,IsOpen24:st,IsParking:ht,IsLHTransfer:ct,IsRHTransfer:lt,IsAdultChange:at,IsAmbulant:vt,IsSharpsDisposal:yt,IsShowers:pt,IsBabyChange:wt,IsSanitaryDisposal:bt,IsDrinkingWater:kt,IsMLAKKey:dt,ShowMore:v,ShowAll:l,MinRequiredScore:h},dataType:"json",contentType:"application/x-www-form-urlencoded; charset=UTF-8"}),c.done(function(n){if(preSubmit){var t=$("#LinkNorthEastLat").attr("value"),i=$("#LinkNorthEastLon").attr("value"),r=$("#LinkSouthWestLat").attr("value"),u=$("#LinkSouthWestLon").attr("value");if(t!=null&&t!=""&&t!="0"){var f=new google.maps.LatLng(Number(r),Number(u)),e=new google.maps.LatLng(Number(t),Number(i)),o=new google.maps.LatLngBounds(f,e);map.fitBounds(o),map.setZoom(map.getZoom()+1)}}firstLoadFromId||(okToReuseMap=!1),firstLoadFromId=!1,handleToilets(n)}),c.fail(function(){okToReuseMap=!1,messages.stopWork([new displayMessage(messageType.ERROR)])})):(okToReuseMap=!1,messages.stopWork([new displayMessage(messageType.ERROR,"","One of the addresses provided is problematic - try using different addresses or shift the green markers a short distance on the map.")]),showDefaultMap())}function SausagePreProcessing(n){for(var i=[],b=n.routes[0].overview_path.length,f=n.routes[0].legs[0],it=f.steps.length,k=0,h=0,c,l,d,a,s,u,tt,p,r,w,e,o,t=0;t<b;t++)for(c=!1,l=n.routes[0].overview_path[t],r=k;r<it;r++){for(d=f.steps[r].path.length,u=h;u<d;u++)if(l.equals(f.steps[r].path[u])){(i[r]==null||i==undefined)&&(i[r]=[]),i[r].push(l),c=!0,k=r,h=u;break}if(c)break;h=0}for(a=0,t=0;t<f.steps.length;t++){var v=!1,y=!1,g=f.steps[t].path[0],nt=f.steps[t].path[f.steps[t].path.length-1];for((i[t]==null||i==undefined)&&(i[t]=[]),r=0;r<i[t].length;r++)if(i[t][r]==g&&(v=!0),i[t][r]==nt&&(y=!0),v&&y)break;if(!v){for(a++,s=[],s.push(g),u=0;u<i[t].length;u++)tt=i[t][u],s.push(tt);i[t]=s}y||(a++,i[t].push(nt))}for(t=0;t<i.length;t++)for(p=i[t],r=0;r<p.length;r++)w=p[r],i[t][r].hb=Number(Number(w.hb).toFixed(6)),i[t][r].ib=Number(Number(w.ib).toFixed(6));for(e="",o=[],t=0;t<i.length;t++)o[t]=google.maps.geometry.encoding.encodePath(i[t]),debug>1&&(e+="["+(t+1).toString()+"] "+i[t].length.toString()+" points, "+o[t].length.toString()+"\n ");return debug>1&&(e+="TotalMiniPolylineLength = "+JSON.stringify(o).length.toString()+" bytes \n ",e+="OverviewPathLength = "+b.toString()+" bytes \n ",window.console&&console.log(e)),o}function showExtras(){return overrideScore=!0,$("#ShowMore").attr("value",overrideScore.toString()),updateMap(),!1}function hideExtras(){return overrideScore=!1,$("#ShowMore").attr("value",overrideScore.toString()),updateMap(),!1}function showExtras_2(){return $("#showExtras").toggleClass("hide"),$("#hideExtras").toggleClass("hide"),overrideScore=!0,$("#ShowMore").attr("value",overrideScore.toString()),updateMap(),!1}function hideExtras_2(){return $("#showExtras").toggleClass("hide"),$("#hideExtras").toggleClass("hide"),overrideScore=!1,$("#ShowMore").attr("value",overrideScore.toString()),updateMap(),!1}function showExtras_1(){if($("#showExtras").toggleClass("hide"),$("#hideExtras").toggleClass("hide"),toiletArray)for(index in toiletArray){var n=toiletArray[index],i=n.S,t="#toiletRow"+n.ID;n.S<scoreThreshold&&($(t).show(),markers[n.ID].setVisible(!0))}return!1}function hideExtras_1(){if($("#showExtras").toggleClass("hide"),$("#hideExtras").toggleClass("hide"),toiletArray)for(index in toiletArray){var n=toiletArray[index],i=n.S,t="#toiletRow"+n.ID;n.S<scoreThreshold&&($(t).hide(),markers[n.ID].setVisible(!1))}return!1}function handleToilets(n){var o=0,e,u,r,f,t;if(toiletArray=n,markers){e=map.getBounds(),u={};for(i in n)r=n[i],t=r.ID,markers[t]?(markers[t].Toilet.StepNo=r.StepNo,markers[t].Toilet.SDist=r.SDist,u[t]=markers[t]):(u[t]=new google.maps.Marker({position:new google.maps.LatLng(r.LA,r.LO),map:map,title:r.T,ToiletID:t,Toilet:r,icon:GetMapPinImage(r,null),draggable:!1}),e.contains(new google.maps.LatLng(r.LA,r.LO))&&o++,google.maps.event.addListener(u[t],"mouseover",function(){markerMouseOver(this.ToiletID)}),google.maps.event.addListener(u[t],"mouseout",function(){markerMouseOut(this.ToiletID)}),google.maps.event.addListener(u[t],"click",function(){markerClick(this.ToiletID)}));for(i in markers)f=markers[i],t=f.ToiletID,u[t]||f.setMap(null);markers=u,markerVisibility(iconVisibility),renderAlerts(),clearTimeout(timeoutID),timeoutID=setTimeout(customiseList,100)}}function renderAlerts(){var t=toiletArray==null?0:toiletArray.length,s=t==0,h=getPriorityCount(),r=h>0,a,c=getIncludeCount(),l=c>10,u=getScoreThreshold(overrideScore),n=[],i="",o,f,e;debug>0&&(o=$("#diagnostics").get(0).innerHTML+"<b>renderAlerts<\/b><\/br>ScoreThreshold =  "+u.toString()+"<br />OverrideScore = "+overrideScore.toString()+"<br />ToiletCount = "+t.toString(),$("#diagnostics").get(0).innerHTML=o),f=t>0?missingMaskInfo(toiletArray[0].MM,"route"):"",e=t>0?searchMaskInfo(currentSearchMask(),toiletArray[0].MM,"route"):"There are no toilets with "+selectedPrioritiesList()+" on the route.",e.length>0?n.push(new displayMessage(messageType.SUCCESS,i,e)):i!==undefined&&i.length>0&&n.push(new displayMessage(messageType.INFO,i,"")),f.length>0&&n.push(new displayMessage(messageType.WARNING,"",f)),s?(n=[],u==1||u==4&&r?n.push(new displayMessage(messageType.WARNING,messages.noToiletsFoundTitle,messages.routeNoToiletsFound)):overrideScore?n.push(new displayMessage(messageType.WARNING,messages.noToiletsFoundTitle,messages.routeNoToiletsFound)):n.push(new displayMessage(messageType.SUCCESS,"",messages.routeNoMatchingToiletsFound))):(r||!r&&l)&&(overrideScore?n.push(new displayMessage(messageType.SUCCESS,"",messages.routeShowLess)):n.push(new displayMessage(messageType.SUCCESS,"",messages.routeShowMore))),messages.stopWork(n)}function getIncludeCount(){var t=$("#smAccessible").data("selected"),i=$("#smUnisex").data("selected"),r=$("#smFemale").data("selected"),u=$("#smMale").data("selected"),f=$("#smDumpPoint").data("selected"),e=$("#smChangingPlaces").data("selected"),n=0;return t&&(n+=11),i&&n++,r&&n++,u&&n++,f&&n++,e&&n++,n}function getPriorityCount(){var t=$("#smParkingAccessible").data("selected"),i=$("#smLHTransfer").data("selected"),r=$("#smRHTransfer").data("selected"),u=$("#smAdultChange").data("selected"),f=$("#smAmbulant").data("selected"),e=$("#smSharps").data("selected"),o=$("#smShowers").data("selected"),s=$("#smBaby").data("selected"),h=$("#smDisposable").data("selected"),c=$("#smDrink").data("selected"),l=$("#smMlak").data("selected"),a=$("#smOpen24").data("selected"),n=0;return t&&n++,i&&n++,r&&n++,u&&n++,f&&n++,e&&n++,o&&n++,s&&n++,h&&n++,c&&n++,l&&n++,a&&n++,n}function getScoreThreshold(n){var r=getIncludeCount(),i=getPriorityCount(),t=0;return t=r>10?i>0?n==!1?8:4:n==!1?4:1:i>0?n==!1?8:1:1}function currentSearchMask(){var n=$("#smAccessible").data("selected"),t=$("#smUnisex").data("selected"),i=$("#smFemale").data("selected"),r=$("#smMale").data("selected"),u=$("#smDumpPoint").data("selected"),f=$("#smChangingPlaces").data("selected"),e=$("#smParkingAccessible").data("selected"),o=$("#smLHTransfer").data("selected"),s=$("#smRHTransfer").data("selected"),h=$("#smAdultChange").data("selected"),c=$("#smAmbulant").data("selected"),l=$("#smSharps").data("selected"),a=$("#smShowers").data("selected"),v=$("#smBaby").data("selected"),y=$("#smDisposable").data("selected"),p=$("#smDrink").data("selected"),w=$("#smMlak").data("selected"),b=$("#smOpen24").data("selected");return GenerateBSearchMask(n,t,i,r,u,f,null,e,v,l,a,y,p,null,w,null,null,c,o,s,h,b,null,null,null)}function selectedPrioritiesList(){var t="",n=[],i="",p=$("#smAccessible").data("selected"),w=$("#smUnisex").data("selected"),b=$("#smFemale").data("selected"),k=$("#smMale").data("selected"),d=$("#smDumpPoint").data("selected"),g=$("#ChangingPlaces").data("selected"),r=$("#smParkingAccessible").data("selected"),u=$("#smLHTransfer").data("selected"),f=$("#smRHTransfer").data("selected"),e=$("#smAdultChange").data("selected"),o=$("#smAmbulant").data("selected"),s=$("#smSharps").data("selected"),h=$("#smShowers").data("selected"),c=$("#smBaby").data("selected"),l=$("#smDisposable").data("selected"),a=$("#smDrink").data("selected"),v=$("#smMlak").data("selected"),y=$("#smOpen24").data("selected");return r&&n.push("accessible parking"),u&&n.push("LH transfer"),f&&n.push("RH transfer"),e&&n.push("adult change"),o&&n.push("ambulant"),s&&n.push("sharps disposal"),h&&n.push("showers"),c&&n.push("baby change facilities"),l&&n.push("sanitary disposal"),a&&n.push("drinking water"),v&&n.push("MLAK keys"),y&&n.push("Open 24 hours"),n.length>0&&(i=n.pop()),t=n.join(", "),n.length>0?t+=" or "+i:t=i,t.length>0&&(t="with "+t),t}function markerMouseOverNonDestructive(n){HighlightToilet(n),lastToiletId!=null&&UnHighlightToilet(lastToiletId),lastToiletId=n}function markerClick(){}function customiseList(){for(var o=currentDirections.routes[0].legs[0].steps,u=o.length,s=u-1,e=0,v=0,y=0,n=0,i,n=0;n<u;n++)i=n,$("table.adp-directions tr:eq("+n.toString()+")").mouseenter(i,function(n){highlightListRow(n.data)}),$("table.adp-directions tr:eq("+n.toString()+")").mouseleave(i,function(n){unHighlightListRow(n.data)}),$("table.adp-directions tr:eq("+n.toString()+")").click(i,function(n){displayInstruction(n.data)});for($("table.adp-placemark tr:eq(0)").mouseenter(0,function(n){highlightEndPoint(n.data)}),$("table.adp-placemark tr:eq(0)").mouseleave(0,function(){stepMarker.setVisible(!1),clearTimeout(listTimeout)}),$("table.adp-placemark tr:eq(0)").click(0,function(n){displayEndPoint(n.data)}),$("table.adp-placemark tr:eq(1)").mouseenter(1,function(n){highlightEndPoint(n.data)}),$("table.adp-placemark tr:eq(1)").mouseleave(0,function(){stepMarker.setVisible(!1),clearTimeout(listTimeout)}),$("table.adp-placemark tr:eq(1)").click(1,function(n){displayEndPoint(n.data)}),toiletArray.reverse(),e=toiletArray.length,j=0;j<e;j++){var t=toiletArray[j],f=t.StepNo,p=t.S,h=t.ID,r="",c=BuildMiniToilet(t),l="class=''",a=2;r="<tr id='toiletRow"+h+"' "+l+"><td colspan='"+a.toString()+"'><td colspan='1'><ul class='toilet-list'>"+c+"<\/ul><\/td><td valign='top'>"+(t.SDist/1e3).toFixed(1)+" km <\/td><\/tr>",f<u?t.SDist<0?$(r).insertBefore("table.adp-directions tr:eq("+f+")"):$(r).insertAfter("table.adp-directions tr:eq("+f+")"):$(r).insertAfter("table.adp-directions tr:eq("+s+")")}$(".miniToiletItem").each(function(){var n=$(this).attr("data-toiletId");$(this).mouseenter(function(){minitoilet_mouseenter(n),clearTimeout(listTimeout),listTimeout=setTimeout(function(){listRowMapToiletHighlight(n)},listTimeoutValue)}),$(this).mouseleave(function(){listRowMapToiletUnHighlight(n)}),$(this).click(function(){})})}function listRowMapToiletHighlight(n){var t=markers[n].getPosition(),i=new google.maps.LatLngBounds(t,t),r=map.getZoom();iconVisibility==!1&&markers[n].setMap(map),r>16?map.panTo(t):map.panToBounds(i)}function listRowMapToiletUnHighlight(n){iconVisibility==!1&&(closeToiletInfo(),markers[n].setMap(null)),minitoilet_mouseleave(n),clearTimeout(listTimeout)}function displayInstruction(n){var i=n.toString(),t=currentDirections.routes[0].legs[0].steps[n],r=currentDirections.routes[0].legs[0].steps.length-1;stepInfoWindowDisplay(t.instructions,t.start_location),stepMarker.setPosition(t.start_location),stepMarker.setVisible(!0)}function displayEndPoint(n){var t="",i;n==0?(t=currentDirections.routes[0].legs[0].start_address,i=currentDirections.routes[0].legs[0].start_location):(t=currentDirections.routes[0].legs[0].end_address,i=currentDirections.routes[0].legs[0].end_location),stepInfoWindowDisplay(t,i)}function stepInfoWindowDisplay(n,t){supressInfoWindow||(closeToiletInfo(),toiletInfo=new google.maps.InfoWindow({content:n,position:t,disableAutoPan:!1,maxWidth:300}),toiletInfo.open(map))}function listRowMapHighlight(n){var r=n.toString(),t,i;currentDirections&&(t=currentDirections.routes[0].legs[0].steps[n],stepMarker.setPosition(t.start_location),stepMarker.setVisible(!0),i=new google.maps.LatLngBounds(t.start_location,t.start_location),map.panToBounds(i))}function highlightListRow(n){var t=n.toString(),i,r,u;currentDirections&&(i=currentDirections.routes[0].legs[0].steps[n],r=currentDirections.routes[0].legs[0].steps.length-1,stepMarker.setPosition(i.start_location),stepMarker.setVisible(!0),n==r&&(t="*"+t),u=2,$("table.adp-directions tr[jsinstance='"+t+"'] td:eq("+u.toString()+")").animate({backgroundColor:color2},500),clearTimeout(listTimeout),listTimeout=setTimeout(function(){listRowMapHighlight(n)},listTimeoutValue))}function unHighlightListRow(n){var t=n.toString(),i,r;clearTimeout(listTimeout),currentDirections&&(i=currentDirections.routes[0].legs[0].steps.length-1,stepMarker.setVisible(!1),t==i&&(t="*"+t),$("table.adp-directions tr[jsinstance='"+t+"'] td:eq(2)").removeClass("miniToiletHightlighted"),r=2,$("table.adp-directions tr[jsinstance='"+t+"'] td:eq("+r.toString()+")").animate({backgroundColor:"transparent"},500))}function highlightEndPoint(n){clearTimeout(listTimeout),listTimeout=setTimeout(function(){endPointMapHighlight(n)},listTimeoutValue)}function endPointMapHighlight(n){var i="",t,r;stepMarker.setVisible(!1),currentDirections&&(n==0?(i=currentDirections.routes[0].legs[0].start_address,t=currentDirections.routes[0].legs[0].start_location):(i=currentDirections.routes[0].legs[0].end_address,t=currentDirections.routes[0].legs[0].end_location),stepMarker.setPosition(t),stepMarker.setVisible(!0),r=new google.maps.LatLngBounds(t,t),map.panToBounds(r))}function undoClick(){return undo(),!1}function undo(){currentDirections=null;var n=oldDirections.pop();oldDirections.length||(setUndoDisabled(!0),$("#ViaAddress").attr("value",originalViaAddress),originalRoute=!0),n&&directionsDisplay.setDirections(n),renderAlerts()}function showOptionsClick(){var n=$("#ShowOptions").text(),t=$(".optional").hasClass("hide");return n=="Hide options"?$("#ShowOptions").text("Show options"):(n=="Show options"||t==!0)&&$("#ShowOptions").text("Hide options"),typeof setSession=="function"&&setSession("showOptions",t),$(".optional").each(function(){$(this).toggleClass("hide")}),!1}function toggleIconVisibilityClick(){return iconVisibility=!iconVisibility,markerVisibility(iconVisibility),!1}function showOverviewClick(){return showOverview(),!1}function showOverview(){var n,t;if(currentDirections!=null){n=currentDirections.routes[0].bounds,map.fitBounds(currentDirections.routes[0].bounds);for(t in markers)n.extend(markers[t].position);map.fitBounds(n)}}function attachInstructionText(n,t,i){google.maps.event.addListener(n,"click",function(){i.setContent(t),i.open(map,n)})}function moveStartMarker(n){$("#ViaAddress").attr("value",""),calcRoute(n.latLng.toUrlValue(),null)}function moveEndMarker(n){$("#ViaAddress").attr("value",""),calcRoute(null,n.latLng.toUrlValue())}function showDefaultMap(){var f=$("#StartPoint").attr("value"),e=$("#EndPoint").attr("value"),n,h,c;if(f&&e){var o=f.split(","),s=e.split(","),t=Number(o[0]),i=Number(o[1]),r=Number(s[0]),u=Number(s[1]),l=Math.min(t,r),a=Math.min(i,u),v=Math.max(t,r),y=Math.max(i,u),p=new google.maps.LatLng(t,i),w=new google.maps.LatLng(r,u),b=new google.maps.LatLng(l,a),k=new google.maps.LatLng(v,y);startMarker.getPosition()==null&&startMarker.setPosition(p),startMarker.setMap(map),endMarker.getPosition()==null&&endMarker.setPosition(w),endMarker.setMap(map),google.maps.event.addListener(startMarker,"dragend",function(n){moveStartMarker(n)}),google.maps.event.addListener(endMarker,"dragend",function(n){moveEndMarker(n)}),h=new google.maps.LatLngBounds(b,k),map.fitBounds(h)}else map.fitBounds(AustraliaBounds);if($("#PrintableMapTitle").text(getTripTitle(currentDirections)),currentDirections==null){n=customList?$("div#directions-panel").get(0):directionsDisplay.getPanel(),n&&(n.innerHTML="");for(c in markers)markers[c].setMap(null);markers={},directionsDisplay.setMap(null),$("#showOverview").hasClass("hide")==!1&&$("#showOverview").toggleClass("hide")}else customList&&buildDirectionsList(currentDirections);clearTimeout(timeoutID),timeoutID=setTimeout(overrideBootstrapListStyle,10)}function setUndoDisabled(n){n?$("#undo").hasClass("hide")==!1&&$("#undo").toggleClass("hide"):$("#undo").hasClass("hide")==!0&&$("#undo").toggleClass("hide");return}function updateMap(){var n=getFilterMask(),t=$("#SearchMask").attr("value"),i;$("#SearchMask").attr("value",n),t!=n&&(i=$.ajax({url:"/api/PlanAPI/UpdateSearchMask",type:"GET",data:{searchMask:n},dataType:"text"})),currentDirections&&(directionsDisplay.setDirections(currentDirections),oldDirections.pop(),oldDirections.length<1&&(setUndoDisabled(!0),originalRoute=!0))}function closeToiletInfo(){toiletInfo&&(toiletInfo.close(),toiletInfo=null)}function savePlan(){var n=localStorage.PlanSaveData,t=!0;localStorage.PlanSaveData=null,saveThePlan("/api/PlanAPI/SaveTripPlan",JSON.parse(n),t)}function savePlanFormSubmit(n,t){t.preventDefault();var s=$(n),u=$("#savePlanTitle").attr("value"),h=$("#StartAddress").attr("value"),c=$("#EndAddress").attr("value"),i=$("#ViaAddress").attr("value"),l=$("#ViaAddress").attr("placeholder"),a=$("#ViaPoints").attr("value"),v=$("#TravelMode").attr("value"),y=$("#AvoidTollRoads").is(":checked"),p=$("#AvoidHighways").is(":checked"),w=$("#smAccessible").data("selected"),b=$("#smUnisex").data("selected"),k=$("#smFemale").data("selected"),d=$("#smMale").data("selected"),g=$("#smDumpPoint").data("selected"),nt=$("#smChangingPlaces").data("selected"),tt=$("#smOpen24").data("selected"),it=$("#smParkingAccessible").data("selected"),rt=$("#smLHTransfer").data("selected"),ut=$("#smRHTransfer").data("selected"),ft=$("#smAdultChange").data("selected"),et=$("#smAmbulant").data("selected"),ot=$("#smSharps").data("selected"),st=$("#smShowers").data("selected"),ht=$("#smBaby").data("selected"),ct=$("#smDisposable").data("selected"),lt=$("#smDrink").data("selected"),at=$("#smMlak").data("selected"),vt=$("#ShowMore").attr("value").toLowerCase()=="true",yt=$("#savePlanForm > input[name='__RequestVerificationToken']").attr("value");$("#__RequestVerificationToken").attr("value");var pt=$("#EmailToAddress").attr("value"),wt=$("#SendViaEmail").attr("value"),bt=$("#SendViaFacebook").attr("value"),kt=$("#SendViaTwitter").attr("value"),dt=$("#SendViaGoogle").attr("value"),ni,f=!0;if($("#SaveToFavourites").length>0&&$("#SaveToFavourites").attr("type")=="checkbox"&&$("#SaveToFavourites").is(":checked")==!1&&(f=!1),i==l&&(i=""),s.valid()){var gt={title:u,startFrom:h,endAt:c,viaAddress:i,wayPoints:a,travelMode:v,avoidTollroads:y,avoidHighways:p,IncludeAccessible:w,IncludeUnisex:b,IncludeFemale:k,IncludeMale:d,IncludeDumpPoint:g,IncludeChangingPlaces:nt,IsOpen24:tt,IsParking:it,IsLHTransfer:rt,IsRHTransfer:ut,IsAdultChange:ft,IsAmbulant:et,IsSharpsDisposal:ot,IsShowers:st,IsBabyChange:ht,IsSanitaryDisposal:ct,IsDrinkingWater:lt,IsMLAKKey:at,Private:f,ShowMore:vt},e={__RequestVerificationToken:yt,EmailToAddress:pt,SendViaEmail:wt,SendViaFacebook:bt,SendViaTwitter:kt,SendViaGoogle:dt,Title:u,TripPlan:gt},ti=1,r,o=$("#SaveToFavourites").attr("value");r=o=="true"||o=="True"?"/api/PlanAPI/SaveTripPlan":"/api/PlanAPI/SendTripPlan",Modernizr.localstorage&&(localStorage.PlanSaveData=JSON.stringify(e)),saveThePlan(r,e,!1)}}function saveThePlan(n,t,i){var r=$.ajax({type:"POST",url:n,data:t,dataType:"json",contentType:"application/x-www-form-urlencoded; charset=UTF-8"});r.success(function(n){n.Success&&(Modernizr.localstorage&&(localStorage.PlanSaveData=null),i&&($("#StartAddress").attr("value",t.TripPlan.startFrom),$("#EndAddress").attr("value",t.TripPlan.endAt),$("#ViaAddress").attr("value",t.TripPlan.viaAddress),$("#ViaPoints").attr("value",t.TripPlan.wayPoints),$("#TravelMode").attr("value",t.TripPlan.travelMode),$("#AvoidTollRoads").prop("checked",t.TripPlan.avoidTollroads),$("#AvoidHighways").prop("checked",t.TripPlan.avoidHighways),$("#formRoute").submit()))}),r.done(function(n){handleSavePlanPostOp(n)}),r.error(function(n,t,r){handleSavePlanError(n,t,r,i)})}function sendEmail(){$("#mailToLink").get(0).click()}function onMiniToiletLinkClick(n){var f=$($("#linkForm")),y=$("#savePlanTitle").attr("value"),e=$("#StartAddress").attr("value"),o=$("#EndAddress").attr("value"),t=$("#ViaAddress").attr("value"),s=$("#ViaAddress").attr("placeholder"),h=$("#ViaPoints").attr("value"),c=$("#TravelMode").attr("value"),l=$("#AvoidTollRoads").is(":checked"),a=$("#AvoidHighways").is(":checked"),v=$("#ShowMore").attr("value");t==s&&(t=""),$("#LinkStartAddress").attr("value",e),$("#LinkEndAddress").attr("value",o),$("#LinkViaAddress").attr("value",t),$("#LinkViaPoints").attr("value",h),$("#LinkTravelMode").attr("value",c),$("#LinkAvoidTollRoads").attr("value",l),$("#LinkAvoidHighways").attr("value",a),$("#navToID").attr("value",n);var i=map.getBounds(),r=i.getNorthEast(),u=i.getSouthWest();$("#LinkNorthEastLat").attr("value",r.lat()),$("#LinkNorthEastLon").attr("value",r.lng()),$("#LinkSouthWestLat").attr("value",u.lat()),$("#LinkSouthWestLon").attr("value",u.lng()),$("#linkForm").attr("action","/Toilet/Index"),setSession("showMore",v),f.submit()}function handleSavePlanPostOp(n){n.Success?(saveType!="Facebook"&&saveType!="Twitter"&&saveType!="Google"&&(saveType!="Email"||$("#SaveToFavourites").is(":checked"))&&(n.Message?messages.temporaryMessage([new displayMessage(messageType.SUCCESS,n.Message,"")]):messages.temporaryMessage([new displayMessage(messageType.SUCCESS,messages.routeSaved,"")])),closeSavePlanForm()):n.Message=="Unauthorized"?(tryingToSave=!0,$("#SavePlanModal").modal("hide"),loadAndShowLoginForm()):handleModalDialogErrorMessages(n,"SavePlan")}function handleSavePlanError(n,t,i,r){r?i!="Unauthorized"&&handleAjaxErrors(n,t,i):handleAjaxErrors(n,t,i,"SavePlan")=="login loaded"&&(tryingToSave=!0,$("#SavePlanModal").modal("hide"))}function closeSavePlanForm(){$("#SavePlanModal").modal("hide")}function myActionFavourites(){saveType="Save",getSaveDialog()}function showSavePlanModal(n){if(currentDirections&&currentDirections.status==google.maps.DirectionsStatus.OK&&(currentDirections.routes[0].legs[0].steps.length>1||currentDirections.routes[0].legs[0].steps[0].path.length>1)){var t=currentDirections.routes[0].legs[0],i=getLocationFromAddressString(t.start_address),r=getLocationFromAddressString(t.end_address),u=i+" to "+r;t.start_address==$("#StartAddress").attr("value")&&t.end_address==$("#EndAddress").attr("value")&&t.steps[0].travel_mode==$("#TravelMode").attr("value")?(tryingToSave==!1&&$("#savePlanTitle").attr("value",u),$("#mdValSummary ul li").text(""),$("#mdValSummary ul li").attr("style","display: none"),n?$("#SavePlanModal").modal():$("#savePlanForm").submit()):messages.temporaryMessage([new displayMessage(messageType.Warning,messages.routeSaveInterferrence,"")],4e3)}else messages.temporaryMessage([new displayMessage(messageType.WARNING,messages.routeSaveInvalid,"")],4e3)}function getLocationFromAddressString(n){var t,i,r;return t=n.replace(", Australia"," ").replace(" WA ","_STATE_").replace(" NT ","_STATE_").replace(" SA ","_STATE_").replace(" QLD ","_STATE_").replace(" NSW ","_STATE_").replace(" ACT ","_STATE_").replace(" VIC ","_STATE_").replace(" TAS ","_STATE_"),i=t.split("_STATE_"),r=i[0]}function PostLogin(){return tryingToSave?(showSavePlanModal(!1),tryingToSave=!1,!1):!1}function myActionGPS(){var t="",n=[],i;if($("#GPS_FromPage").attr("value","Plan"),markers)for(i in markers)n.push(markers[i].ToiletID);if(currentDirections==null){messages.temporaryMessage([new displayMessage(messageType.WARNING,"",messages.routeSaveInvalid)],4e3);return}n.length>0?($("#GPS_Alert").get(0).innerHTML="",$("#downloadGPSSubmit").removeClass("hide"),t=n.toString(),$("#GPS_HRToiletIDs").attr("value",t)):($("#GPS_Alert").get(0).innerHTML="<div class='alert alert-warning'><h4>A trip plan that locates some toilets needs to be created prior to exporting to your GPS device.<\/h4><\/div>",$("#downloadGPSSubmit").addClass("hide")),$("#DownloadGPSModal").modal()}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:"/Plan/SavePlanPartial/"+saveType,cache:!1,dataType:"html",success:function(n){$("#savePlanParent").html(n),$("#savePlanForm").submit(function(n){n.preventDefault(),savePlanFormSubmit(this,n)}),resetFormValidation("#savePlanForm");var t=$("#SavePlanModal");t!=null&&t.length==1&&(saveType!="Facebook"&&saveType!="Twitter"&&saveType!="Google"&&saveType!="Email"?showSavePlanModal(!0):showSavePlanModal(!1))},error:function(){messages.temporaryMessage([new displayMessage(messageType.ERROR)],2e3)}})}function buildSaveData(){var e="My trip",h=$("#StartAddress").attr("value"),c=$("#EndAddress").attr("value"),u=$("#ViaAddress").attr("value"),l=$("#ViaAddress").attr("placeholder"),a=$("#ViaPoints").attr("value"),v=$("#TravelMode").attr("value"),y=$("#AvoidTollRoads").is(":checked"),p=$("#AvoidHighways").is(":checked"),w=$("#smAccessible").data("selected"),b=$("#smUnisex").data("selected"),k=$("#smFemale").data("selected"),d=$("#smMale").data("selected"),g=$("#smDumpPoint").data("selected"),nt=$("#smChangingPlaces").data("selected"),tt=$("#smOpen24").data("selected"),it=$("#smParkingAccessible").data("selected"),rt=$("#smLHTransfer").data("selected"),ut=$("#smRHTransfer").data("selected"),ft=$("#smAdultChange").data("selected"),et=$("#smAmbulant").data("selected"),ot=$("#smSharps").data("selected"),st=$("#smShowers").data("selected"),ht=$("#smBaby").data("selected"),ct=$("#smDisposable").data("selected"),lt=$("#smDrink").data("selected"),at=$("#smMlak").data("selected"),vt=$("#ShowMore").attr("value").toLowerCase()=="true",yt=$("input[name='__RequestVerificationToken']").attr("value"),pt="notset@hs.com.au",n=!1,t=!1,i=!1,r=!1,wt,o,s,f;switch(saveType){case"Facebook":n=!1,t=!0,r=!1,i=!1;break;case"Email":n=!0,t=!1,r=!1,i=!1;break;case"Google":n=!1,t=!1,r=!0,i=!1;break;case"Twitter":n=!1,t=!1,r=!1,i=!0}return wt=!1,o=!1,u==l&&(u=""),s={title:e,startFrom:h,endAt:c,viaAddress:u,wayPoints:a,travelMode:v,avoidTollroads:y,avoidHighways:p,IncludeAccessible:w,IncludeUnisex:b,IncludeFemale:k,IncludeMale:d,IncludeDumpPoint:g,IncludeChangingPlaces:nt,IsOpen24:tt,IsParking:it,IsLHTransfer:rt,IsRHTransfer:ut,IsAdultChange:ft,IsAmbulant:et,IsSharpsDisposal:ot,IsShowers:st,IsBabyChange:ht,IsSanitaryDisposal:ct,IsDrinkingWater:lt,IsMLAKKey:at,Private:o,ShowMore:vt},f={__RequestVerificationToken:yt,EmailToAddress:pt,SendViaEmail:n,SendViaFacebook:t,SendViaTwitter:i,SendViaGoogle:r,Title:e,TripPlan:s},Modernizr.localstorage&&(localStorage.PlanSaveData=JSON.stringify(f)),f}function buildReSaveData(){var f=$("input[name='__RequestVerificationToken']").attr("value"),n=!1,t=!1,i=!1,r=!1,e,u;switch(saveType){case"Facebook":n=!1,t=!0,r=!1,i=!1;break;case"Email":n=!0,t=!1,r=!1,i=!1;break;case"Google":n=!1,t=!1,r=!0,i=!1;break;case"Twitter":n=!1,t=!1,r=!1,i=!0}return e=!1,u={__RequestVerificationToken:f,SendViaEmail:n,SendViaFacebook:t,SendViaTwitter:i,SendViaGoogle:r},u}function saveMapSimple(){var u=buildSaveData(),t="",i="",r=!1,n;return $.ajax({type:"POST",url:"/api/PlanAPI/SendTripPlan",data:u,async:!1,success:function(n){n.Success?(Modernizr.localstorage&&(localStorage.PlanSaveData=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/PlanAPI/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%20trip&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 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(){}var MarkerIconDefinitions,timingMessage,lastToiletId,color,color2;(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);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 directionsDisplay,currentDirections=null,oldDirections=[],directionsService,debug=0,stepInfoWindow,stepMarker,startMarker,endMarker,originalRoute,okToReuseMap=!1,firstLoadFromId=!1,overrideScore=!1,iconVisibility=!0,toiletArray=[],timeoutID,listTimeout,listTimeoutValue=1e3,stepMarkers=[],tryingToSave=!1,postBackToServer=!1,saveType="Save",preSubmit=!0,lastField="",originalViaAddress="",autoCompleteOptions,autoCompleteObject,customList=!0;$(function(){$("#submitPlan").attr("value","Route"),directionsService=new google.maps.DirectionsService,AreAddressesEmpty()?messages.stopWork([new displayMessage(messageType.INSTRUCTION,messages.routeInstructionTitle,messages.routeInstruction)],!1):messages.stopWork(),getSession("showMore")==null?overrideScore=ToBoolean($("#ShowMore").attr("value")):(overrideScore=ToBoolean(getSession("showMore")),removeSession("showMore"));var n=getSession("showOptions");n!=null&&n==!0&&showOptionsClick(),$("#StartAddress").focus(function(){return lastField!="StartAddress"?(setTimeout(function(){$("#StartAddress").select(),lastField="StartAddress"},100),!1):!0}),$("#EndAddress").focus(function(){return lastField!="EndAddress"?(setTimeout(function(){$("#EndAddress").select(),lastField="EndAddress"},100),!1):!0}),$("#ViaAddress").focus(function(){var n=!0;return(autoCompleteOptions=null,autoCompleteOptions={componentRestrictions:{country:"au"}},autoCompleteObject=null,autoCompleteObject=new google.maps.places.Autocomplete(this,autoCompleteOptions),lastField!="ViaAddress"&&$("#ViaAddress").attr("value")!=""&&$("#ViaAddress").attr("value")!=$("#ViaAddress").attr("placeholder"))?(setTimeout(function(){$("#ViaAddress").select(),lastField="ViaAddress"},100),!1):!0})}),$("#formRoute").submit(function(n){preSubmit=!1,submitPlan(this,n)}),$("#showOptions").toggleClass("hide"),showOptionsClick(),$(function(){Modernizr.localstorage&&localStorage.PlanSaveData!=undefined&&localStorage.PlanSaveData!=null&&localStorage.PlanSaveData!="null"&&savePlan()}),$("#savePlanForm").submit(function(n){savePlanFormSubmit(this,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"