function AddressControl(n){this.name=n;this.zipSelector="#"+this.name+"_ZipCode";this.zipUSRowSelector="#"+this.name+"_ZipUSRow";this.zipMirrorSelector="#"+this.name+"_ZipCodeMirror";this.countrySelector="#"+this.name+"_CountryId";this.stateZipSelector="#"+this.name+"_StateZip";this.citySelector="#"+this.name+"_City";this.stateSelector="#"+this.name+"_State";this.address1Selector="#"+this.name+"_Address1";this.stateZipIntSelector="#"+this.name+"_StateZipInt";this.alternateSelector="#"+this.name+"_AlternateAddress";this.cityList=[];this.alternates=[];addressControlInstances[n]=this;$(this.address1Selector).on("blur",function(){$(this).trigger("change")});$(this.citySelector).on("blur",function(){$(this).trigger("change")})}function sendAnalyticsData(n,t){function e(u){gtag("event","page_view",{page_title:document.title,page_location:n,election_date:t.election,parish_name:t.parish,client_ip_address:u,generation_time:i,login_type:r,race_id:t.raceId,team:"ERIN"})}function o(){var t=document.cookie.split(";"),n=t.filter(function(n){return n.includes("client_ip_address")})[0];return n!==null&&n!==undefined?n.replace("client_ip_address=","").trim():null}function s(n){document.cookie="client_ip_address="+n+"; secure;"}var i,r,u,f;if(typeof __analyticsSuppress!="undefined"&&__analyticsSuppress==!0){__analyticsSuppress=!1;return}if(window._gat&&window._gat._getTracker){setTimeout(sendAnalyticsData(n,t),1e3);return}i=null;typeof __pageGenerationTime!="undefined"&&(i=__pageGenerationTime);r=null;typeof __loginType!="undefined"&&(r=__loginType);typeof n=="object"&&(t=n,n=window.location.href);u=o();u===null?(f=$.ajax({method:"POST",url:"/GetClientIpAddress"}),f.done(function(n){s(n);var t=o();e(t)})):e(u)}var addressControlInstances=[];AddressControl.instance=function(n){return addressControlInstances[n]};AddressControl.prototype.selectors=["_Address1","_Address2","_City","_ZipCode","_PostCode","_State","_StateInternational","_ZipCodeMirror"];AddressControl.prototype.UNITED_STATES_ID=482;AddressControl.prototype.isUnitedStates=function(n){return n==this.UNITED_STATES_ID};AddressControl.prototype.setup=function(n){var t=this,i;$(this.zipSelector).on("change.GetStreets",function(){t.zipChanged()});$(this.countrySelector).on("change",function(){t.countrySelected($("#"+this.attributes.id.value+" option:selected").attr("value"))});$(this.address1Selector).autocomplete({source:function(n,i){$.ajax({url:"/Address/StreetLookup",type:"POST",dataType:"json",data:{searchText:n.term,zipCode:$(t.zipSelector).val()},success:function(n){i($.map(n,function(n){return{label:n,value:n}}))}})},minLength:3,autoFocus:!0,delay:200});$(this.citySelector).autocomplete({source:this.cityList,minLength:0,autoFocus:!0}).on("focus",function(){$(this).autocomplete("search")});n&&$("form").submit(function(){return t.checkForPOBox()});i=$(this.alternateSelector).val();i!=""&&this.useAddress(i)};AddressControl.prototype.countrySelected=function(n){var t=this,i;typeof n!="undefined"&&n!=null&&(t.isUnitedStates(n)?($(t.stateZipSelector).show(),$(t.zipUSRowSelector).show(),$(t.stateZipIntSelector).hide(),$(t.address1Selector).autocomplete("enable")):($(t.stateZipSelector).hide(),$(t.zipUSRowSelector).hide(),$(t.stateZipIntSelector).show(),$(t.address1Selector).autocomplete("disable")),i=$(this.countrySelector+" option:selected").attr("data-labels").split("|"),$("#"+t.name+"_CityLabel").html(i[0]),$("#"+t.name+"_StateInternationalLabel").html(i[1]),$("#"+t.name+"_PostCodeLabel").html(i[2]))};AddressControl.prototype.zipChanged=function(){$(this.zipMirrorSelector).val($(this.zipSelector).val()).trigger("change");$(this.zipSelector).val().trim().length==5&&this.getCities()};AddressControl.prototype.getCities=function(){var n=this;$(this.alternateSelector).val()==""&&$.ajax({type:"POST",url:"/Address/GetCities",data:"{'zipCode':'"+$(this.zipSelector).val()+"'}",contentType:"application/json; charset=utf-8",dataType:"json",success:function(t){for(var f,r,u,i;n.cityList.length>0;)n.cityList.pop();if(f=$("#"+n.name+"_IsRegistrationAddress").val()=="True",r="",t.length==0)$(n.citySelector).val(""),f||$(n.stateSelector).val("").trigger("change");else if(t.length==1)$(n.citySelector).val(t[0].CityName).trigger("change"),f||$(n.stateSelector).val(t[0].State).trigger("change");else if(t.length>1){for(i=0;i<=t.length-1;i++)n.cityList.push({label:t[i].CityName,value:t[i].CityName});if(!f){for(u=[],i=0;i<=t.length-1;i++)u.indexOf(t[i].State)==-1&&u.push(t[i].State);u.length==1?r=t[0].State:u.indexOf("LA")>-1&&(r="LA");$(n.stateSelector).val(r).trigger("change")}$(n.citySelector).val("");$(n.citySelector).autocomplete("option","source",n.cityList)}t.length&&(t[0].State=="LA"||r=="LA")?$(n.address1Selector).autocomplete("enable"):$(n.address1Selector).autocomplete("disable")}})};AddressControl.prototype.addAlternate=function(n,t){this.alternates[n]=t};AddressControl.prototype.useAddress=function(n){var u=this,r,t,i;if(typeof n=="undefined"&&(n=null),r=$(this.alternateSelector).val(),r==""||r in this.alternates||($.each(this.selectors,function(n,t){$("#"+r+t).off("change."+u.name)}),$("#"+r+"_CountryId").off("change."+u.name)),t=null,$(this.zipSelector).off("change.GetStreets"),n==null?(t={countryId:this.UNITED_STATES_ID,street1:"",street2:"",city:"",state:"",zip:""},i=null):n in this.alternates?(t=this.alternates[n],i="readonly"):(this.hookControl(n),i="readonly"),$(this.alternateSelector).val(n),t!=null&&($(this.countrySelector).val(t.countryId==null?this.UNITED_STATES_ID:t.countryId).trigger("change"),$("#"+this.name+"_Address1").val(t.street1).trigger("change"),$("#"+this.name+"_Address2").val(t.street2).trigger("change"),$("#"+this.name+"_City").val(t.city).trigger("change"),$("#"+this.name+"_State").val(t.state).trigger("change"),$("#"+this.name+"_StateInternational").val(t.state).trigger("change"),$("#"+this.name+"_ZipCode").val(t.zip).trigger("change"),$("#"+this.name+"_PostCode").val(t.zip).trigger("change"),$(this.zipMirrorSelector).val(t.zip)),n==null)$(this.zipSelector).on("change.GetStreets",function(){u.zipChanged()});i?($(this.countrySelector).css("background-color","#eee"),$(this.countrySelector+" option:not(:selected)").attr("disabled",!0)):($(this.countrySelector).css("background-color",""),$(this.countrySelector+" option").attr("disabled",!1));$("#"+this.name+"_Address1").attr("readonly",i);$("#"+this.name+"_Address2").attr("readonly",i);$("#"+this.name+"_City").attr("readonly",i);$("#"+this.name+"_State").attr("readonly",i);$("#"+this.name+"_StateInternational").attr("readonly",i);$("#"+this.name+"_ZipCode").attr("readonly",i);$("#"+this.name+"_PostCode").attr("readonly",i);$("#"+this.name+" .field-validation-error").empty();$("#"+this.name+" input.input-validation-error").removeClass("input-validation-error").addClass("valid")};AddressControl.prototype.hookControl=function(n){var t=this,i;i=$("#"+n+"_CountryId").length?$("#"+n+"_CountryId :selected").attr("value"):this.UNITED_STATES_ID;$(this.countrySelector).val(i).trigger("change");$("#"+n+"_CountryId").on("change."+t.name,function(){$("#"+t.name+"_CountryId").val($("#"+n+"_CountryId :selected").attr("value")).trigger("change")});$.each(t.selectors,function(i,r){var u=$("#"+n+r).val();$("#"+t.name+r).val(u);$("#"+n+r).on("change."+t.name,function(){$("#"+t.name+r).val($("#"+n+r).val()).trigger("change")})})};AddressControl.prototype.checkForPOBox=function(){return/\b[P|p]*(OST|ost)*\.*\s*[O|o|0]*(ffice|FFICE)*\.*\s*[B|b][O|o|0][X|x]\b/.test($(this.address1Selector).val())?confirm("It appears you have entered a post office box for your residence address, which is not acceptable. 'Residence Address' is the address where you live and are registering to vote. If you claim a homestead exemption, you must list the address of that residence. Enter the house or apartment number and street. If your address is rural, enter the Route and Box Number. If the address you entered is not a post office box, then click OK to proceed. Otherwise, click Cancel to enter a new residence address."):!0}