var WSLApp=WSL.EnsureNamespace("WSL.App"),WSLeComments;WSLApp.ResponsiveElements=function(){var n,t,i=function(){n=$("#divMobileSearch");t=$("#navPanel")},r=function(n){$("#navigationList").appendTo(n)},u=function(i){n&&(i?t.panel("open"):t.panel("close"))},f=function(i){t&&(i?n.show():n.hide())};return{init:i,appendNavigation:r,displayMobileSearch:u,displayNavPanel:f}}();WSLApp.MediaQueryBreakPoints={xsmall:1,small:2,medium:3,large:4,xlarge:5};WSLApp.JSMediaQueries=function(){var s=250,r,t="small",i="",n="",u,f,e,h=function(){n=$("#headerNavigationFooter");externalContentHeader=n.find("#headerElements");externalContentNav=n.find("#navigationLinks");externalContentFooter=n.find("#footer");u=$("#headerElements");f=$("#navPanel");e=$("#footer");externalContentHeader.appendTo(u);externalContentNav.appendTo(f);externalContentFooter.appendTo(e);WSLApp.ResponsiveElements.init()},c=function(){clearTimeout(r);r=setTimeout(o,s)},l=function(){var n=window.getComputedStyle(document.getElementById("mediaquery"),":after").getPropertyValue("content");return n==null&&(n=window.getComputedStyle(document.getElementById("mediaquery"),"").getPropertyValue("font-family")),n.replace(/"/g,"")},o=function(n){WSL.Logger.log("window.screen.width="+window.screen.width);WSL.Logger.log("lastMediaQuery="+t);WSL.Logger.log("lastPage="+i);WSL.Logger.log("currentPage="+n);var r=l();(r!=t||i!=n)&&(t=r,a(r));i=n},a=function(n){try{WSL.Logger.log("breakpoint="+n);WSL.Logger.log("WSLApp.MediaQueryBreakPoints[breakpoint]="+WSLApp.MediaQueryBreakPoints[n]);var t="#navPanel";WSLApp.MediaQueryBreakPoints[n]>=WSLApp.MediaQueryBreakPoints.xsmall;WSLApp.MediaQueryBreakPoints[n]>=WSLApp.MediaQueryBreakPoints.small;WSLApp.MediaQueryBreakPoints[n]>=WSLApp.MediaQueryBreakPoints.medium;WSLApp.MediaQueryBreakPoints[n]>=WSLApp.MediaQueryBreakPoints.large&&(WSLApp.ResponsiveElements.displayMobileSearch(!1),WSLApp.ResponsiveElements.displayNavPanel(!1),t="#desktopNavigation");WSLApp.MediaQueryBreakPoints[n]>=WSLApp.MediaQueryBreakPoints.xlarge;WSLApp.ResponsiveElements.appendNavigation(t)}catch(i){WSL.Logger.log("Error in processMediaQuery="+i.message)}};return{init:h,onResize:c,apply:o}}();window.addEventListener?window.addEventListener("resize",WSLApp.JSMediaQueries.onResize):window.attachEvent&&window.attachEvent("onresize",WSLApp.JSMediaQueries.onResize);window.getComputedStyle||(window.getComputedStyle=function(n){return this.el=n,this.getPropertyValue=function(t){var i=/(\-([a-z]){1})/g;return t=="float"&&(t="styleFloat"),i.test(t)&&(t=t.replace(i,function(){return arguments[2].toUpperCase()})),n.currentStyle[t]?n.currentStyle[t]:null},this});WSLApp.Search=function(){var i=function(){if(!WSL.Logger)throw"WSLApp.Search requires WSL.Logger";if(!SubmitWebsiteSearch)throw"WSLApp.Search requires WSL.Utilities SubmitWebsiteSearch";}(),n=function(n,t){$(n).click(function(){$(t).slideToggle("fast")})},t=function(n,t){$(n).bind("keyup",function(n){(n.which&&n.which==13||n.keyCode&&n.keyCode==13)&&$(t).click()});$(t).click(function(){SubmitWebsiteSearch($(n).val())})};return{initializeControls:t,initializeContainer:n}}();WSLeComments=WSL.EnsureNamespace("WSL.eComments");WSLeComments.Constants=function(){return{CCRadioHide:"CCRadioHide"}}();WSLeComments.TextArea=function(){var t=function(){var n=$("#FormSubmitButton")[0],t=$(".ui-input-btn");t.addClass("disabled");n.disabled=!0},n=function(n,i,r){var u=r-$(n).val().length;u<0?(u=0,t()):WSLeComments.Form.enableSubmit();$(i).text(u)},i=function(t,i,r){$(t).on("input",function(){$(t).val($(t).val().replace(/([\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2694-\u2697]|\uD83E[\uDD10-\uDD5D])/g,""));n(t,i,r)});n(t,i,r)};return{charactersRemaining:i}}();WSLeComments.BillLookUp=function(){var n=function(){return $("#BillNumber").val()};return{billNumberFromTextBox:n}}();WSLApp.Analytics=function(){var n=function(n,t){ga("send","event",n,t,shortBillId,{hitCallback:function(){shortBillId=$("#shortBillId").text()}})};return{trackGoogleUIEvent:n}}();WSLeComments.Form=function(){var n=function(){var n,t;WSLApp.Analytics.trackGoogleUIEvent("ButtonClick","BillCommentFormSubmit");n=$("#FormSubmitButton");n.prop("disabled","disabled").val("Sending...").button("refresh");t=n.closest("form");t.submit()},t=function(){var t=$("#FormSubmitButton"),n;!WSLeComments.TextArea.charactersRemaining<=0&&(n=$(".ui-input-btn"),n.removeClass("disabled"),t.removeProp("disabled").val("Send Comment").button("refresh"))};return{submit:n,enableSubmit:t}}();WSLeComments.ValidateDistrict=function(){var i=function(n){$("#HiddenDistrict").val(n.District);$("#HiddenAddressIsValidated").val(!0);$("#HiddenAddressIsValidated").valid();WSLeComments.ClientActions.clearValidationBorders();WSL.Logger.log("HiddenDistrict value: "+n.District);WSLeComments.ClientActions.showOrHideResponseRequested(n.District);var t=$("#PrimaryResponseMember_District").val();WSL.Logger.log("PrimaryResponseMemberDistrict: "+t);$("#DistrictLabel").removeClass("notFoundAddressColor");$("#mayContinueMessage").removeClass("notFoundAddressColor");$("#mayContinueMessage").removeClass("validationred");$("#mayContinueMessageContainer").hide();n.District&&n.District!=0?u(t,n):(n.District=0,r(t,n));$("#ValidateAddressButton").removeClass("ui-btn-active")},r=function(n,i){WSL.Logger.log("Validation fails");$("#DistrictLabel").html(i.UnableToValidateMessage).addClass("notFoundAddressColor");$("#mayContinueMessageContainer").show();n==null||n==""?($('[type="submit"]').button("disable").button("refresh"),$("#MemberRoutingSection").empty(),$("#mayContinueMessage").html("Comments may only be sent from a verified address.").addClass("notFoundAddressColor")):n>=0&&(WSLeComments.ClientActions.showOrHideSecondaryMembers(),i.State!="WA"?($("#mayContinueMessage").html("A valid Washington state address is required to send a message to legislators.").addClass("validationred"),$('[type="submit"]').button("disable").button("refresh")):(ClientStorage.set(WSLeComments.Constants.CCRadioHide,"Hide"),t(i.District,n,$("#PrimaryResponseMember_Position").val()),$('[type="submit"]').button("enable").button("refresh")))},u=function(n,i){if(WSL.Logger.log("Validation succeeds"),$('[type="submit"]').button("enable").button("refresh"),ClientStorage.set(WSLeComments.Constants.CCRadioHide,"CCRadioHide"),$("#Address_Street").val(i.Street),$("#Address_City").val(i.City),$("#Address_State").val(i.State),$("#Address_Zip").val(i.Zip),n==null||n=="")$('[type="submit"]').button("enable").button("refresh"),$("#DistrictLabel").html("The address entered is in <strong>District "+i.District+"<\/strong>"),WSLeComments.ClientActions.populateMemberRouting();else{WSLeComments.ClientActions.showOrHideSecondaryMembers($("#SecondaryResponseRequested_True").is(":checked"));var r=e(i.District);WSL.Logger.log("isUserInSelectedDistrict: "+r);r==!0?$("#DistrictLabel").html("The address entered is in <strong>District "+i.District+"<\/strong>"):(ClientStorage.set(WSLeComments.Constants.CCRadioHide,"Hide"),t(i.District,n,$("#PrimaryResponseMember_Position").val()),f(i.District))}},t=function(n,t,i){WSL.Logger.log("User is out of district, get new view to give them some options.");$.ajax({url:WSLeComments.Url.resolve("~/OutOfDistrict/"+n+"/"+t+"/"+i),data:{},datatype:"json",traditional:!0,async:!0,success:function(n){$("#DistrictLabel").html(n).enhanceWithin()},error:function(n){onError(n)}})},f=function(n){WSL.Logger.log("show user their district legislators.");$.ajax({url:WSLeComments.Url.resolve("~/DistrictMembers/"+n),data:{},datatype:"json",traditional:!0,async:!0,success:function(n){$("#DistrictLegislators").html(n).enhanceWithin()},error:function(n){onError(n)}})},e=function(n){WSL.Logger.log("validatedDistrict "+n);var t=$("#PrimaryResponseMember_District").val();return WSL.Logger.log("primaryResponseMemberDistrict "+t),n==t?!0:!1},n=function(){var n=!0;return $("#Address_Street").valid()||(n=!1),$("#Address_City").valid()||(n=!1),$("#Address_State").valid()||(n=!1),$("#Address_Zip").valid()||(n=!1),n},o=function(t){if(!n())return WSL.Logger.log("address failed client validation..."),!1;$("#DistrictLegislators").html("");$("#DistrictLabel").html("");$("#mayContinueMessage").html("");$(t).html("Validating...")},s=function(t){WSL.Logger.log("Ajax call failed.");WSL.Logger.log("addressIsValid value: "+n);n()&&$(t).html("There was an error communicating with the server, please check your entry and try again.")};return{addressIsValid:n,populateValidatedResults:i,beginAddressValidation:o,showErrorMessage:s}}();WSLeComments.ClientActions=function(){String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var n=function(n,t,i,r){var u=WSLeComments.Url.resolve("~/custom302route/"+n+"/"+t+"/"+i+"/"+r);$.ajax(u,{type:"GET",async:!0})},t=function(n){$(n).html("Loading...")},i=function(){$("#EditBillButton").removeClass("ui-btn-active");$("#dynamicPosition").html("<span class='validationred'>*<\/span>")},r=function(){$("#EditBillButton").removeClass("ui-btn-active");$("#BriefDescription").html("There was an error communicating with the server, please check your entry and try again.")},u=function(n){if(!n||n.length==0)return n;WSL.Logger.log("Formatting address part: '"+n+"'");n=n.trim().replace(/[^A-Za-z0-9\-\# ]/g,"");for(var t=n.charAt(n.length-1);n.length>0&&"-#".indexOf(t)>-1;)WSL.Logger.log("Last character is invalid - strip it"),n=n.slice(0,n.length-1),t=n.trim().charAt(n.length-1);return n=encodeURIComponent(n),WSL.Logger.log("Formatting complete, output: '"+n+"'"),n},f=function(n,t){WSL.Logger.log("IsConstituent radio changed, setting value - "+n+" and Id - "+t);$("#HiddenIsPossibleConstituent").val(t)},e=function(n){var u=n.numberOfInvalids(),f=u+" validation errors.",t,r,i;for(WSL.Logger.log(f),t=0;t<n.errorList.length;t++)r=n.errorList[t].element.id,i=$("#"+r),i.is(":visible")&&i.parent().addClass("generalValidationBorder")},o=function(){setTimeout(function(){$.each($(".generalValidationBorder").children("input"),function(n,t){var i=$(t);i.valid()&&i.parent(".generalValidationBorder").removeClass("generalValidationBorder")})},10)},s=function(){WSL.Logger.log("Member Routing YES- fire ajax call");var n=$("#HiddenDistrict").val();$("#FormSubmitButton").prop("disabled",!0);WSL.Logger.log("District: "+n);$.ajax({url:WSLeComments.Url.resolve("~/MemberRouting/"+n),data:{},datatype:"json",traditional:!0,async:!0,success:function(n){$("#MemberRoutingSection").html(n).enhanceWithin();$("#FormSubmitButton").prop("disabled",!1)},error:function(n){onError(n);$("#FormSubmitButton").prop("disabled",!1)}})},h=function(){WSL.Logger.log("rr YES- fire ajax call");var n=$("#HiddenDistrict").val();$("#FormSubmitButton").prop("disabled",!0);WSL.Logger.log("District: "+n);$.ajax({url:WSLeComments.Url.resolve("~/ResponseRequested/"+n),data:{},datatype:"json",traditional:!0,async:!0,success:function(n){$("#MemberResponse").html(n).enhanceWithin();$("#FormSubmitButton").prop("disabled",!1)},error:function(n){onError(n);$("#FormSubmitButton").prop("disabled",!1)}})},c=function(n){$(n).removeClass("generalValidationBorder")},l=function(n){WSL.Logger.log("inside showOrHideResponseRequested,District: "+n);n===null||n===""?(WSL.Logger.log("inside district is null or district is ''"),$("#ResponseRequested_EmailForm").hide()):n==0?(WSL.Logger.log("ResponseRequested district = 0, checking the false box for them"),$("#ResponseRequested").hide()):($("#ResponseRequested").show(),$("#ResponseRequested_EmailForm").show())},a=function(n){n?($("#MemberResponse_EmailForm").show(),$("#MemberResponse").show()):($("#MemberResponse_EmailForm").hide(),$("#MemberResponse").hide())};return{showLoadingMessage:t,formValidationPainter:e,clearValidationBorders:o,clearValidationBorder:c,showOrHideResponseRequested:l,showOrHideSecondaryMembers:a,setSelectedConstituentValue:f,validateBillNumberSuccess:i,populateMemberResponse:h,populateMemberRouting:s,formatUserInput:u,call302errorRoute:n,validateBillNumberFail:r}}();$(document).on("mobileinit",function(){WSL.Logger.on();$.mobile.ajaxEnabled=!1});$(document).on("pagebeforeshow","[data-role=page]",function(){$("#pageContent").removeClass("ui-body-a");ClientStorage.set(WSLeComments.Constants.CCRadioHide,"CCRadioHide");WSLApp.JSMediaQueries.init();WSLApp.JSMediaQueries.apply();WSLApp.Search.initializeControls("#bannerSearchInput","#bannerSubmitSearchBtn");WSLApp.Search.initializeControls("#mobileSearchInput","#mobileSubmitSearchBtn");WSLApp.Search.initializeContainer("#searchPanel","#divMobileSearch")});$(document).on("pagecontainershow",function(){if($.contains(document.documentElement,$("#mainForm")[0])){WSL.Logger.log("we are on a form page");WSLeComments.ClientActions.clearValidationBorders();var n=$("#Comment").attr("maxLength");WSLeComments.TextArea.charactersRemaining("#Comment","#charactersRemaining",n);$("input[id$=Email]").bind("contextmenu cut copy paste",function(n){n.preventDefault()});$("input[id$=ConfirmEmail]").bind("contextmenu cut copy paste",function(n){n.preventDefault()});$(".AddressField").bind("paste keypress",function(){$("#HiddenAddressIsValidated").val(!1);$("#DistrictLabel").empty();$("#HiddenDistrict").val("")});$("input").blur(function(){WSLeComments.ClientActions.clearValidationBorders()});$("#mainForm").bind("invalid-form.validate",function(n,t){WSLeComments.ClientActions.formValidationPainter(t);WSLeComments.Form.enableSubmit()});WSLeComments.ClientActions.showOrHideResponseRequested($("#HiddenDistrict").val());WSLeComments.ClientActions.showOrHideSecondaryMembers($("#ResponseRequested_True").is(":checked"));$("#mayContinueMessageContainer").hide()}});$(document).on("click",".alternateMember",function(){var n=$(this),t=n.prop("href");n.prop("href",t+"?"+$("input:visible,textarea:visible","#mainForm").serialize())});$(document).on("click","#PrintConfirmationButton",function(){window.print()});$(document).on("click",".userInteractionButton",function(){$(this).removeClass("ui-btn-active")});$(".play_navigation").on("click","a",function(n){console.log("this is the click");n.preventDefault()});$(document).on("click","#EditBillButton",function(){if(WSL.Logger.log("EditBillButton clicked"),!$("#BillNumber").valid())return!1;WSLeComments.ClientActions.showLoadingMessage($("#BriefDescription"));var n=WSLeComments.ClientActions.formatUserInput($("#BillNumber").val()),t=WSLeComments.Url.resolve("~/GetBriefDescriptionForBill/"+n);WSL.Logger.log("find bill "+n);$.ajax(t,{type:"GET",datatype:"json",traditional:!0,async:!0}).fail(function(){WSLeComments.ClientActions.validateBillNumberFail()}).success(function(n){$("#BriefDescription").html(n);$("#IsInitiative").val(!1);$("#InitiativeNumber").val("");WSLeComments.ClientActions.validateBillNumberSuccess()})});$(document).on("click","#EditInitiativeButton",function(){if(WSL.Logger.log("EditInitiativeButton clicked"),!$("#InitiativeNumber").valid())return!1;WSLeComments.ClientActions.showLoadingMessage($("#BriefDescription"));var n=WSLeComments.ClientActions.formatUserInput($("#InitiativeNumber").val()),t=WSLeComments.Url.resolve("~/GetBriefDescriptionForInitiative/"+n);WSL.Logger.log("find bill "+n);$.ajax(t,{type:"GET",datatype:"json",traditional:!0,async:!0}).fail(function(){WSLeComments.ClientActions.validateBillNumberFail()}).success(function(n){$("#BriefDescription").html(n);$("#IsInitiative").val(!0);$("#BillNumber").val("");WSLeComments.ClientActions.validateBillNumberSuccess()})});$(document).on("click","#ValidateAddressButton",function(n){var f;if(WSL.Logger.log("ValidateAddressButton clicked"),!WSLeComments.ValidateDistrict.addressIsValid())return WSL.Logger.log("address failed client validation..."),n.stopImmediatePropagation(),n.preventDefault(),!1;$("#DistrictLegislators").html("");$("#mayContinueMessage").html("");$("#DistrictLabel").html("Validating...");var t=WSLeComments.ClientActions.formatUserInput($("#Address_Street").val()),i=WSLeComments.ClientActions.formatUserInput($("#Address_City").val()),r=WSLeComments.ClientActions.formatUserInput($("#Address_State").val()),u=WSLeComments.ClientActions.formatUserInput($("#Address_Zip").val());if(!t||t.length===0||!i||i.length===0||!r||r.length===0||!u||u.length===0)return WSL.Logger.log("address failed client validation..."),$("#DistrictLabel").html("Street, City, State and Zip are all required for address validation."),n.stopImmediatePropagation(),n.preventDefault(),!1;f=WSLeComments.Url.resolve("~/ValidateTheAddressJSON/"+t+"/"+i+"/"+r+"/"+u);WSL.Logger.log("validate address "+t+" "+i+" "+r+" "+u);$.ajax(f,{type:"GET",datatype:"json",traditional:!0,async:!0,statusCode:{302:function(){WSLeComments.ClientActions.call302errorRoute(t,i,r,u)}}}).fail(function(){WSLeComments.ValidateDistrict.showErrorMessage($("#DistrictLabel"))}).success(function(n){WSLeComments.ValidateDistrict.populateValidatedResults(n)})});$(document).on("change","input[name='IsPossibleConstituent']",function(){var n=$(this).val();WSL.Logger.log("IsPossibleConstituent changed to: "+n);n==="True"?(ClientStorage.set(WSLeComments.Constants.CCRadioHide,""),WSLeComments.ClientActions.showOrHideSecondaryMembers($("#ResponseRequested_True").is(":checked"))):n==="False"&&(ClientStorage.set(WSLeComments.Constants.CCRadioHide,"Hide"),WSLeComments.ClientActions.showOrHideSecondaryMembers(!1),$("#SecondaryResponseRequested_False").prop("checked",!0).checkboxradio("refresh"),$("#SecondaryResponseRequested_True").prop("checked",!1).checkboxradio("refresh"))});$(document).on("change","#RRControlGroupEmailForm input[name='ResponseRequested']",function(){var n=$(this).val();WSL.Logger.log("ResponseRequested_EmailForm changed to: "+n);n==="True"&&ClientStorage.get(WSLeComments.Constants.CCRadioHide)!=="Hide"?$("#MemberResponse_EmailForm").show():n==="False"&&$("#MemberResponse_EmailForm").hide()});$(document).on("change","#RRControlGroupCommentForm input[name='ResponseRequested']",function(){var n=$(this).val();WSL.Logger.log("ResponseRequested changed to: "+n);n==="True"?($("#MemberResponse").show().html("Loading..."),WSLeComments.ClientActions.populateMemberResponse()):n==="False"&&$("#MemberResponse").hide()})