function loadLocations(){var o=$("#store-locate-block"),t=$("#loc-select-block"),r=t.find(".loc-select"),s=$("#submit"),e=$("#CompanyId"),n=$("#SuburbId"),h=$("#ReferredCompanyId"),i=$("#ReferredSuburbId"),u=$("#ReferredLocationId"),f;$("#submit").hide();n.empty().append('<option value="0">-Select-<\/option>').val("");n.next("span").html("-Select-");f=e.val();r.empty();$.ajax({url:"/account/get-locations-by-company",data:{companyId:f,isVanityUrl:$("#IsVanityUrl").val()}}).done(function(f){f.Success?($.each(f.Suburbs,function(t,r){var u=$("<option />").val(r.Value).text(r.Text);i.val()==r.Value&&u.attr("selected","selected");n.append(u)}),$.each(f.Locations,function(n,t){var i=$('<input type="radio" name="LocationId" id="location_'+t.Id+'" value="'+t.Id+'" />'),f,e;u.val()==t.Id&&i.attr("checked","checked");f=$('<input type="hidden" />');e=$('<label for="location_'+t.Id+'" class="isRadio '+(u.val()==t.Id?"isFocus isChecked":"")+'">'+t.Name+"<br />"+t.AddressString+"<\/label>");r.append(i,f,e)}),t.slideDown(500)):t.slideUp(500);i.val()!=""&&n.val(i.val()).change();$("#store-locate-block .loc-select").length==1&&$("#submit").show()})}$(document).ready(function(){var r=$("#store-locate-block"),t=$("#loc-select-block"),i=t.find(".loc-select"),h=$("#submit"),n=$("#CompanyId"),s=$("#SuburbId"),u=$("#ReferredCompanyId"),c=$("#ReferredSuburbId"),f=$("#ReferredLocationId"),e,o;r.hide();t.hide();$(".inp-block").each(function(){if($(this).data("required")==!0){var n=$(this).find("label"),t=n.html();$(n).html(t+" <span style='color:red'>*<\/span>")}});e=$("#CountryId").val();$(".img-wrap",".choose-channel-row").on("click",function(n){$(this).parent().trigger("click",n)});$(".loc-select").on("click","input:radio[name=LocationId]",function(){var n=$(".loc-select input:radio[name=LocationId]").val();n!=undefined&&($("#submit").show(),scrollToTrg($("#register-step2-buttons")))});$("input[name=ChannelId]",".choose-channel-row").on("change",function(){r.slideUp(500);t.slideUp(500);$("#submit").hide();n.empty().append('<option value="0">-Select-<\/option>').val();n.val($("#CompanyId option:first").val()).change();n.next("span").html("-Select-");i.empty().append('<option value="0">-Select-<\/option>').val("");i.val($("#SuburbId option:first").val()).change();i.next("span").html("-Select-");var f=$(this).val();$.ajax({url:"/account/get-channel-companies",data:{channelId:f,countryId:e,isVanityUrl:$("#IsVanityUrl").val()}}).done(function(t){var i,f;t.Success?(i=t.LocationName,i==null&&(i="Location"),f=$(".location-name"),f.text(i),$.each(t.Companies,function(t,i){var r=$("<option />").val(i.Value).text(i.Text);u.val()==i.Value&&r.attr("selected","selected");n.append(r)}),r.slideDown(500)):r.slideUp(500);u.val()!=""&&u.val()!=0&&n.val(u.val()).change()})});$("input[name=ChannelId]:checked",".choose-channel-row").trigger("change");$("input[name=LocationId]:checked",".loc-select").trigger("click");n.on("change",function(){loadLocations()});s.on("change",function(){$("#submit").hide();var u=n.val(),r=$(this).val();r=="0"?n.trigger("change"):(i.empty(),$.ajax({url:"/account/get-locations-by-postcode",data:{companyId:u,postcode:r,isVanityUrl:$("#IsVanityUrl").val()}}).done(function(n){n.Success?($.each(n.Locations,function(n,t){var r=$('<input type="radio" name="LocationId" id="location_'+t.Id+'" value="'+t.Id+'" />'),u,e;console.log(f.val()+"<>"+t.Id);f.val()==t.Id&&r.attr("checked","checked");u=$('<input type="hidden" />');e=$('<label for="location_'+t.Id+'" class="isRadio '+(f.val()==t.Id?"isFocus isChecked":"")+'">'+t.Name+"<br />"+t.AddressString+"<\/label>");i.append(r,u,e)}),t.slideDown(500),$("#ReferredCompanyId").val(""),$("#ReferredSuburbId").val(""),$("#ReferredLocationId").val("")):t.slideUp(500)}))});o=$("#AccessCode");o.on("keyup",function(){var n=$(this),t,i;n.removeClass("loading");t=n.closest(".form-row");t.removeClass("valid error");i=$("#access-code-name");i.hide();n.val().length>8&&(n.addClass("loading"),$.ajax({url:"/account/validate-access-code",data:{code:n.val()}}).done(function(r){r.Success?(t.removeClass("error").addClass("valid"),i.find(".inp-wrap p").text(r.DisplayName),i.slideDown(500)):t.removeClass("valid").addClass("error");n.removeClass("loading")}))})})