function displayMessage(n,t,i,r,u){n===undefined&&(window.console&&window.console.error("Message '"+i+"' contains an undefined type"),n=messageType.WARNING),this.type=n,this.text=i,this.hint=r,this.heading=t,this.image=u,(i===undefined||i==="")&&n===messageType.ERROR&&(this.text=messages.defaultErrorMessage,(t===undefined||t==="")&&(this.heading=messages.defaultErrorTitle))}function resetFormValidation(n){$.validator.unobtrusive.parse(n);var t=$(n).data("validator");t&&(t.settings.onkeyup=!1)}function resetLoginForm(){$("#loginModalBody").load("/Account/LoginModalBodyPartial",function(){$("#loginForm").submit(function(n){loginFormSubmit(this,n)})})}function resetRegisterForm(){$("#registerModalBody").load("/Account/RegisterModalBodyPartial",function(){$("#registerForm").submit(function(n){registerFormSubmit(this,n)})})}function loadAndShowLoginForm(){$("#loginParentDiv").load("/Account/LoginModalPartial",function(){$("#loginForm").submit(function(n){loginFormSubmit(this,n)}),resetFormValidation("#loginForm"),$("#loginModal").modal()})}function loadAndShowRegisterForm(){$("#registerParentDiv").load("/Account/RegisterModalPartial",function(){$("#registerForm").submit(function(n){registerFormSubmit(this,n)}),resetFormValidation("#registerForm");var u,r;r=document.createElement("script"),r.src="/Scripts/zxcvbn.js",r.type="text/javascript",r.async=!0,u=document.getElementsByTagName("script")[0],u.parentNode.insertBefore(r,u),$("#registerModal").modal()})}function zxcvbn_load_hook(){$("#registerPassword").keyup(function(){handlePasswordStrength(this,"register")}),$("#NewPassword").keyup(function(){handlePasswordStrength(this,"new")}),$("#Password").keyup(function(){handlePasswordStrength(this,"reset")}),$("#NewUser_Password").keyup(function(){handlePasswordStrength(this,"newprovider")})}function handlePasswordStrength(n,t){var r=zxcvbn($(n).attr("value")),i="";switch(r.score){case 0:i="Very weak",$("#"+t+"ParentPasswordScoreProgress").attr("class","progress progress-danger");break;case 1:i="Weak",$("#"+t+"ParentPasswordScoreProgress").attr("class","progress progress-danger");break;case 2:i="Ok",$("#"+t+"ParentPasswordScoreProgress").attr("class","progress progress-warning");break;case 3:i="Good",$("#"+t+"ParentPasswordScoreProgress").attr("class","progress progress-success");break;case 4:i="Strong",$("#"+t+"ParentPasswordScoreProgress").attr("class","progress progress-success")}$("#"+t+"PasswordScore").text("Password score: "+i),$("#"+t+"PasswordScoreProgress").css("width",((r.score+1)*20).toString()+"%"),$("#"+t+"PasswordScore").removeClass("hide")}function loginFormSubmit(n,t){t.preventDefault();var r=$(n),i=r.serialize();i=i.replace("RememberMe=true&RememberMe=false","RememberMe=true"),clearModalDialogErrors("login"),r.valid()&&$.ajax({type:"POST",url:"/api/AccountAPI/PostLogin",data:i,error:function(n,t,i){handleModalDialogErrors(n,t,i,"login")},success:function(n){var i,u,r,t;n!=null&&(n.Success?($("#loginmessage").text("Login successful"),u=$("#menuwrapper"),r=$("#MyToilets"),LoadWithoutCache("/Home/RightNavigationMenu","rightNav"),r.load("Account/LoginMini",function(){}),$("#loginModal").modal("hide"),t="",t=n.AccountType=="Admin"?"You can now do administration tasks.":n.AccountType=="Provider"?"To update your toilet information click on the 'Toilets I manage' button above.":"You can now save toilets, maps and trips to your My Toilets account.",messages.temporaryMessage([new displayMessage(messageType.SUCCESS,"You have successfully logged in.",t)],8e3),n.FirstLogin&&$("#crowdSourceParentDiv").load("/Account/CrowdSourceModalPartial",function(){$("#CrowdSourceModal").modal()}),typeof PostLogin=="function"&&PostLogin()):n.Message.indexOf("Unconfirmed user. ")>-1?($("#confirmSection").show(),$("#loginSection").hide(),i=n.Message.replace("Unconfirmed user. ",""),$("#Email").attr("value",i)):handleModalDialogErrorMessages(n,"login"))}})}function registerFormSubmit(n,t){t.preventDefault();var i=$(n);clearModalDialogErrors("register"),i.valid()&&$.ajax({type:"POST",url:"/api/AccountAPI/PostRegister",data:i.serialize(),error:function(n,t,i){handleModalDialogErrors(n,t,i,"register")},success:function(n){n.Success?($("#registerModal").modal("hide"),messages.stopWork([new displayMessage(messageType.SUCCESS,"Registered successfully","A confirmation email has been sent to you. Please check your email and click on the link to confirm your registration.")]),typeof PostRegister=="function"&&PostRegister()):handleModalDialogErrorMessages(n,"register")}})}function confirmEmail_registration(){var i=$($("#ConfirmEmailForm")),t=i.serialize(),n=$("#loginForm").serialize();n=n.substring(n.indexOf("&Login="),n.length),t=t+n,clearModalDialogErrors("ConfirmEmail"),i.valid()&&$.ajax({type:"POST",url:"/api/AccountAPI/PostConfirmEmail",data:t,error:function(n,t,i){handleModalDialogErrors(n,t,i,"ConfirmEmail")},success:function(n){n.Success?($("#loginModal").modal("hide"),messages.stopWork([new displayMessage(messageType.SUCCESS,"Confirmation sent","An email has been sent to your address "+$("#Email").attr("value")+". Note that your user name has also changed to "+$("#Email").attr("value")+". Use this to log into the site once you have confirmed your account.")])):handleModalDialogErrorMessages(n,"ConfirmEmail")}})}function LoadWithoutCache(n,t){return $.ajax({url:n,cache:!1,dataType:"html",error:function(n,i,r){var u=handleAjaxErrors(n,i,r,null);typeof partialLoadError=="function"&&partialLoadError(t,n,i,r,u)},success:function(n){return $("#"+t).html(n),typeof partialLoadCompleted=="function"&&partialLoadCompleted(t),!1}})}function createCookie(n,t,i){var r,u;i?(r=new Date,r.setTime(r.getTime()+i*864e5),u="; expires="+r.toGMTString()):u="",document.cookie=n+"="+t+u+"; path=/"}function getCookie(n){return document.cookie.length>0&&(c_start=document.cookie.indexOf(n+"="),c_start!=-1)?(c_start=c_start+n.length+1,c_end=document.cookie.indexOf(";",c_start),c_end==-1&&(c_end=document.cookie.length),unescape(document.cookie.substring(c_start,c_end))):""}function doActionFavourites(){$("#actionBarSave").attr("data-enabled")=="enabled"&&typeof myActionFavourites=="function"&&myActionFavourites()}function doActionPrint(){$("#actionBarPrint").attr("data-enabled")=="enabled"&&window.print()}function doActionGPS(){$("#actionBarGPS").attr("data-enabled")=="enabled"&&typeof myActionGPS=="function"&&myActionGPS()}function doActionEmail(){$("#actionBarEmail").attr("data-enabled")=="enabled"&&typeof myActionEmail=="function"&&myActionEmail()}function doActionFacebook(){$("#actionBarFacebook").attr("data-enabled")=="enabled"&&typeof myActionFacebook=="function"&&myActionFacebook()}function doActionTwitter(){$("#actionBarTwitter").attr("data-enabled")=="enabled"&&typeof myActionTwitter=="function"&&myActionTwitter()}function doActionGooglePlus(){$("#actionBarGoogle").attr("data-enabled")=="enabled"&&typeof myActionGooglePlus=="function"&&myActionGooglePlus()}function enabledActionSave(n){enableActionCommand("actionBarSave",n)}function enabledActionPrint(n){enableActionCommand("actionBarPrint",n)}function enabledActionGPS(n){enableActionCommand("actionBarGPS",n)}function enabledActionEmail(n){enableActionCommand("actionBarEmail",n)}function enabledActionFacebook(n){enableActionCommand("actionBarFacebook",n)}function enabledActionTwitter(n){enableActionCommand("actionBarTwitter",n)}function enabledActionGoogle(n){enableActionCommand("actionBarGoogle",n)}function enableActionCommand(n,t){$("#"+n).attr("data-enabled",t?"enabled":"disabled"),t?$("#"+n).children("i").removeClass("disabled"):$("#"+n).children("i").addClass("disabled")}function convertToGoogleLatLng(n){var t,i,o,r,u,f,s=!1,e=null;return r=n.split(","),r.length==2&&(u=r[0].replace("(",""),f=r[1].replace(")",""),isNaN(u)==!1&&(t=Number(u),isNaN(f)==!1&&(i=Number(f),t<-9&&t>-44&&i>112&&i<154&&(e=new google.maps.LatLng(t,i))))),e}function getSession(n){var t={},i=null;return Modernizr.sessionstorage&&typeof JSON=="object"&&(t=JSON.parse(sessionStorage.getItem(n)),t&&(i=t.value)),i}function setSession(n,t){Modernizr.sessionstorage&&typeof JSON=="object"&&sessionStorage.setItem(n,JSON.stringify({value:t}))}function removeSession(n){Modernizr.sessionstorage&&sessionStorage.removeItem(n)}function htmlEncode(n){return n?$("<div/>").text(n).html():""}function htmlDecode(n){return n?$("<div/>").html(n).text():""}function ToBoolean(n){var t=!1,i=typeof n;switch(i.toLowerCase()){case"string":(n.toLowerCase()=="true"||n.toLowerCase()=="yes")&&(t=!0);break;case"number":n>0&&(t=!0);break;case"boolean":t=n}return t}function handleAjaxErrors(n,t,i,r,u){var e=null,f;return n.status==603||n.statusText=="Unauthorized"?(loadAndShowLoginForm(),e="login loaded"):(r!=null?handleModalDialogErrors(n,t,i,r):u!=null?(f=n.statusText,f=="A required anti-forgery validation token was not found"&&(f="This site requires cookies to be enabled. Enable cookies in your browser and try again."),$(u).text(f)):messages.stopWork([new displayMessage(messageType.ERROR)]),e="error displayed"),e}function handleModalDialogErrors(n,t,i,r){var u=n.statusText;u=="A required anti-forgery validation token was not found"&&(u="This site requires cookies to be enabled. Enable cookies in your browser and try again."),$("#"+r+"ErrorMessage").text(u),$("#"+r+"ErrorMessageBlock").removeClass("hide")}function handleModalDialogErrorMessages(n,t){$("#"+t+"ErrorMessageBlock").removeClass("hide");var i=buildValidationErrorMessages(n);$("#"+t+"ErrorMessage").html(i)}function handleValidationMessages(n){var t=buildValidationErrorMessages(n);messages.stopWork([new displayMessage(messageType.ERROR,"",t)])}function buildValidationErrorMessages(n){var t="<ul>",i;if(n.ValidationErrors.length>0)for(i in n.ValidationErrors)t+="<li>"+n.ValidationErrors[i]+"<\/li>";else t+=n.Message!=""&&n.Message!=""?"<li>"+n.Message+"<\/li>":n.VMessage!=""&&n.VMessage!=""?"<li>"+n.VMessage+"<\/li>":"<li>Unknown error<\/li>";return t+="<\/ul>"}function clearModalDialogErrors(n){$("#"+n+"ErrorMessage").text(""),$("#"+n+"ErrorMessageBlock").addClass("hide")}function handleModalDialogSuccess(n,t){$("#"+t+"SuccessMessage").text(n),$("#"+t+"SuccessMessageBlock").removeClass("hide")}function iWantCrowdSource(){var n={},t=$("input[name='__RequestVerificationToken']").attr("value");n.__RequestVerificationToken=t,$.ajax({type:"POST",url:"/api/AccountAPI/AllowCrowdSource",data:n,error:function(n,t,i){handleModalDialogErrors(n,t,i,"CrowdSource")},success:function(n){n!=null&&(n.Success?$("#CrowdSourceModal").modal("hide"):handleModalDialogErrorMessages(n,"CrowdSource"))}})}function iDontWantCrowdSource(){$("#CrowdSourceModal").modal("hide")}var messages={defaultErrorMessage:"A system error has occurred. Please try again in a few minutes",defaultErrorTitle:"An error has occurred",findInstructionTitle:"Finding toilets",findInstruction:"Please enter a location, address or postcode to find toilets. Selecting from the icons above the map will display toilets with facilities that match your priorities.|Clicking on a toilet in the list shows more information about that toilet. You can enter a new place name or pan and zoom the map to display other toilets.|",noToiletsFoundTitle:"No toilets found",noToiletsFound:"There are no toilets at your selected location. Please enter a new location, address or postcode. You can also pan or zoom the map to find toilets nearby.",tooManyToilets:"There are too many toilets to display on the map.",toiletsClustered:"Toilets situated close together have been clustered. Click on the cluster icon or zoom in to see them.",toiletsClusteredImage:"/Images/m1.png",createInstruction:"Please enter an address for the toilet, then complete as much detail as possible. Your suggestion will be sent to the relevant provider for their confirmation.",editInstruction:"Click on the icons to turn them on and add any notes as needed. You must select at least one toilet type to save your suggestion.|If the icon is not in the correct position on the map, drag the icon to the right spot.",providerCreateInstruction:"Please enter an address for the toilet, then complete as much detail as possible. Your new toilet will be sent to admin for their confirmation.",providerEditInstruction:"Click on the icons to turn them on and add any notes as needed. You must select at least one toilet type to save your toilet.|If the icon is not in the correct position on the map, drag the icon to the right spot.",routeInstructionTitle:"Planning a trip",routeInstruction:"Please enter a place name or address for the start and destination of your journey.|You can add more destinations to go via as well.|The toilets listed for your journey will match your selections from the icons above the map where possible.",routeNotFound:"A suitable route could not be found.",routeNoToiletsFound:"There were no toilets found on this route.|Please try a different start or end location or <a href='/plan'>create a new route<\/a>.",routeNoMatchingToiletsFound:"No toilets matching your priorities were found on this route. <a href='#' onclick='return(showExtras(this));'>Look for other toilets<\/a>.",routeShowMore:"There are toilets that don't match your priorities and aren't displayed on the route. <a href='#messages' onclick='return(showExtras(this));'>Show these toilets<\/a>.",routeShowLess:"Some of the toilets listed below don't match your priorities but are displayed on the route. <a href='#messages' onclick='return(hideExtras(this));'>Hide these toilets<\/a>.",routeSaved:"The trip plan was successfully saved.",routeSaveInvalid:"A trip plan must be created before you can perform this action.",routeSaveInterferrence:"The trip plan parameters do not match the current plan. Recreate the plan and try again.",saveMap:"Map saved successfully.",saveToilet:"Toilet saved successfully.",MainMessageID:"messages"},messageType={INFO:0,SUCCESS:1,WARNING:2,ERROR:3,INSTRUCTION:4};messages.setMainMessageID=function(n){messages.MainMessageID=n},messages.resetMainMessageID=function(){messages.MainMessageID="messages"},messages.GetMainMessageBlock=function(){return $("#"+messages.MainMessageID)},displayMessage.prototype.escapeHTML=function(n,t){return $(n).text(t)[0].outerHTML},displayMessage.prototype.toHTML=function(){var n="",t=!1,i,r;this.image!==undefined&&this.image!==""&&(t=!0),t&&(n+='<div class="media"><img class="media-object pull-left" src="'+encodeURI(this.image)+'"><div class="media-body">'),this.heading!==undefined&&this.heading!==""&&(n+=this.escapeHTML("<h4><\/h4>",this.heading)),i=this.text.split("|");for(r in i)n+="<p>"+i[r]+"<\/p>";return this.hint!==undefined&&this.hint!==""&&(n+=this.escapeHTML('<p class="hint"><\/p>',this.hint)),t&&(n+="<\/div><\/div>"),n},messages.startWork=function(){$("#spinner").show()},messages.formatHTML=function(n,t){var f="",e="",u,r,i;for(u in n)r="",i=n[u],i.type!==undefined&&(i.type===messageType.ERROR?r=" alert-error":i.type===messageType.SUCCESS?r=" alert-success":(i.type===messageType.INFO||i.type===messageType.INSTRUCTION)&&(r=" alert-info")),t!==undefined&&t===!0&&(e="<button type='button' class='close' data-dismiss='alert'>&times;<\/button>"),f+='<div class="alert'+r+'">'+e+n[u].toHTML()+"<\/div>";return f},messages.temporaryMessage=function(n,t,i){$("#spinner").hide(),(t===undefined||t<=0)&&(t=5e3);var u=this.formatHTML(n,!0),f=!1,e=!1,r=$("#temporaryMessage");r.size()===0?($("#leftcolumn").prepend("<div id='temporaryMessage' style='display:none'>"+u+"<\/div>"),r=$("#temporaryMessage")):(f=!0,e=r.html()===u),e?r.clearQueue().delay(t).fadeOut(200,function(){$(this).remove()}):f?r.clearQueue().fadeOut(200,function(){$(this).html(u)}).fadeIn(200).delay(t).fadeOut(200,function(){$(this).remove()}):r.clearQueue().fadeIn(400).delay(t).fadeOut(200,function(){$(this).remove()}),i&&messages.GetMainMessageBlock().slideUp(200,function(){$(this).addClass("hide").html("")})},messages.stopWork=function(n){$("#spinner").hide();var i=!messages.GetMainMessageBlock().hasClass("hide"),t=this.formatHTML(n);messages.GetMainMessageBlock().html()!==t&&(t.length>0?i?messages.GetMainMessageBlock().slideUp(200,function(){$(this).html(t)}).delay(100).slideDown(200):messages.GetMainMessageBlock().html(t).removeClass("hide").slideDown(200):messages.GetMainMessageBlock().slideUp(200,function(){$(this).addClass("hide").html(t)}))},Sentry.init({dsn:"https://6df986d7bdc948a68bc4cb4e4382359f@sentry.io/1450105"}),$(function(){var r,u,f,n,t,i;$("#actionbar").fadeIn(),$(".loginLink").attr("href","#"),$(".loginLink").attr("onclick","loadAndShowLoginForm(); return false;"),$(".registerLink").attr("href","#"),$(".registerLink").attr("onclick","loadAndShowRegisterForm(); return false;"),r={},r.URL=window.location.pathname,u=encodeURIComponent(r.URL),$("#feedback").attr("href",$("#feedback").attr("href")+"?oldUrl="+u),$(".AddressBox").get(0)!=null&&(f={componentRestrictions:{country:"au"}},$(".AddressBox").each(function(){var n=new google.maps.places.Autocomplete(this,f)})),$("#content .static a#showall").click(function(){$("#content .static a#showall").text()=="Show all"?($("#content .static dl.dynamic dd").show(),$("#content .static a#showall").text("Hide all")):($("#content .static dl.dynamic dd").hide(),$("#content .static a#showall").text("Show all"))}),$("#content .static dl.dynamic dd").toggle(!1),$("#content .static dl.dynamic dt").click(function(){$(this).next("dd").slideToggle(100)}),$("form").each(function(){var n=$(this).data("validator");n&&(n.settings.onkeyup=!1)}),$("#RunningJS").attr("value",!0),location.hash&&location.hash!="#"&&$(location.hash).next("dd").show(),Modernizr.sessionstorage&&(n=sessionStorage.OneOffMessage,n!=undefined&&n!="none"&&(oneOffMessage=JSON.parse(n),messages.temporaryMessage([new displayMessage(messageType.SUCCESS,oneOffMessage.Heading,oneOffMessage.Message)],oneOffMessage.Time)),sessionStorage.OneOffMessage="none"),$("#isFirstLogin").attr("value")=="True"&&$("#crowdSourceParentDiv").load("/Account/CrowdSourceModalPartial",function(){$("#CrowdSourceModal").modal()}),t=$("#InitialFriendlyMessageHeader").attr("value"),i=$("#InitialFriendlyMessage").attr("value"),t!=undefined&&i!=undefined&&t+i!=""&&messages.temporaryMessage([new displayMessage(messageType.SUCCESS,t,i)],8e3),$("a#feedback").click(function(n){var t=screen.width/2-300,i=screen.height/2-200,r=$(this).attr("href");window.open(r,"feedback","scrollbars=1, width=680, height=580, left="+t+", top="+i),n.preventDefault()})}),$("#loginForm").submit(function(n){loginFormSubmit(this,n)}),$("#registerForm").submit(function(n){registerFormSubmit(this,n)}),$("#ConfirmEmailForm").submit(function(n){n.preventDefault();var r=$(this),i=r.serialize(),t=$("#loginForm").serialize();t=t.substring(t.indexOf("&Login="),t.length),i=i+t,clearModalDialogErrors("ConfirmEmail"),r.valid()&&$.ajax({type:"POST",url:"/api/AccountAPI/PostConfirmEmail",data:i,error:function(n,t,i){handleModalDialogErrors(n,t,i,"ConfirmEmail")},success:function(n){n.Success?($("#loginModal").modal("hide"),messages.stopWork([new displayMessage(messageType.SUCCESS,"Confirmation sent","An email has been sent to your address "+$("#Email").attr("value")+". Note that your user name has also changed to "+$("#Email").attr("value")+". Use this to log into the site once you have confirmed your account.")])):handleModalDialogErrorMessages(n,"ConfirmEmail")}})})