function VM_Candles_onSubmit(){VM.Candles.submit()}var VM=VM||{};VM.Momentum={dataSent:!1,clientId:null,init:function(){var n=this;VM.Track.isTracking()&&VM.Track.withClientId(function(t){n.clientId=t});document.addEventListener("visibilitychange",function(){document.visiblityState==="hidden"&&n.sendData()});window.addEventListener("pagehide",function(){n.sendData()})},sendData:function(){var n,i;if(window.location.pathname.indexOf("/obituaries")!==0&&!this.dataSent){if(this.dataSent=!0,n=VM.$body.find(".details"),n.data("momentum")==="off")return;var r=n.find(".sc-s").last(),t=n.find("#comments-count"),u=performance.now().toFixed(0),f=VM.Scroll.maxHeight===0?0:Math.min(VM.Scroll.maxDepth/VM.Scroll.maxHeight,1);viewport=$(window).width()+"x"+$(window).height();t.length===0&&(t=n.find(".sc-c"));i="/sendmomentum?id="+n.data("id")+"&tag="+n.data("tag")+"&shares="+parseInt(r.text()||0,10)+"&comments="+parseInt(t.text()||0,10)+"&viewport="+viewport+"&clientId="+this.clientId+"&scroll="+f+"&time="+u;navigator.sendBeacon?navigator.sendBeacon(i):$.ajax(i,{method:"POST"})}},onLoaded:function(){var n=$("#site-momentum-items");n.find('[data-ga-value="'+VM.$body.find(".details").data("id")+'"]').remove();n.find(".lazyimg").lazyloader();n.find(".timeago").timeago()}};VM.Embeds={tweetEmbeds:[],instaEmbeds:[],facebookEmbeds:[],hasSpaces:!1,init:function(){var r,u,i,t,n;if(this.fbToken=VM.getFacebookApiSettings().access_token,r=$("#details-body").children("p"),r.length>0)for(u=0;u<r.length;u++)i=r[u],t=i.innerText||i.textContent,t.indexOf("https://twitter.com")===0||t.indexOf("https://x.com")===0?this.tweetEmbeds.push(this.processEmbed(i,t,"twitter")):t.indexOf("https://www.instagram.com")===0&&this.instaEmbeds.push(this.processEmbed(i,t,"instagram"));n=this;$(".embed-custom-wrapper").each(function(){var t=this.getAttribute("data-type"),i=this.getAttribute("data-url");if(t=="twitter")n.tweetEmbeds.push(n.processEmbed(this,i,"twitter"));else if(t=="instagram")n.instaEmbeds.push(n.processEmbed(this,i,"instagram"));else if(t=="facebook")n.facebookEmbeds.push(n.processEmbed(this,i,"facebook"));else if(t=="facebook-page")n.facebookEmbeds.push(n.processEmbed(this,i,"facebook-page"));else if(t==="spaces"){n.hasSpaces=!0;const t=new URL(i),r=t.host.split(".")[0];t.host="embed.spaces.ca";t.pathname=r+t.pathname;this.setAttribute("data-url",t);this.classList.add("spaces-embed")}});this.loadWidgets()},loadWidgets:function(){if(this.tweetEmbeds.length>0&&$.when.apply($,this.tweetEmbeds).done(function(){$.getScript("https://platform.twitter.com/widgets.js")}),this.instaEmbeds.length>0&&$.when.apply($,this.instaEmbeds).done(function(){$.getScript("https://platform.instagram.com/en_US/embeds.js")}),this.facebookEmbeds.length>0&&$.when.apply($,this.facebookEmbeds).done(function(){$.getScript("https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.2")}),this.hasSpaces){var n=document.createElement("script");n.src="https://embed.spaces.ca/js/embed.min.js?v=1";n.crossOrigin="anonymous";document.body.appendChild(n)}},processEmbed:function(n,t,i){var r="";return i=="twitter"?r="https://publish.twitter.com/oembed?url="+encodeURIComponent(t):i=="instagram"?r="https://graph.facebook.com/instagram_oembed?url="+encodeURIComponent(t)+"&access_token="+this.fbToken:i=="facebook"?r="https://graph.facebook.com/oembed_post?url="+encodeURIComponent(t)+"&access_token="+this.fbToken:i=="facebook-page"&&(r="https://graph.facebook.com/oembed_page?url="+encodeURIComponent(t)+"&access_token="+this.fbToken),$.ajax({cache:!1,url:r,jsonp:"callback",dataType:"jsonp"}).success(function(t){if(t)try{n.innerHTML=t.html}catch(i){}})}};VM.TTS={init:function(){$("#tts").on("click","a",this.onPlayArticle)},onPlayArticle:function(n){n.preventDefault();var t=$(this),i=$("<audio src='"+t.attr("href")+"' controls><\/audio>");t.parent().html(i);i.get(0).play();i.focus();VM.Track.onGaClick.call(t)}};$(function(){VM.Scroll.initStory();VM.Momentum.init();VM.Embeds.init();VM.TTS.init()});VM=VM||{};VM.Perspective={$perspectiveResultArea:null,$descriptionSubmitArea:null,$form:null,formSubmit:null,init:function(n,t,i,r){this.$perspectiveResultArea=n;this.$descriptionSubmitArea=t;this.$form=i;this.formSubmit=r},check:function(n,t){var i={comment:{text:n},languages:["en"],requestedAttributes:{TOXICITY:{},OBSCENE:{}}};$.ajax("https://commentanalyzer.googleapis.com/v1alpha1/comments:analyze?key=AIzaSyByrN2npmkT86GzSFVyv-gsB11JqE8vKak",{method:"POST",dataType:"json",contentType:!1,data:JSON.stringify(i)}).done(function(n){var i={toxicity:n.attributeScores.TOXICITY.summaryScore.value,obscenity:n.attributeScores.OBSCENE.summaryScore.value};t(i)}).fail(function(n,i,r){t({error:r})})},showMessage:function(n,t){var r=this.$perspectiveResultArea.find(".message").empty(),i=!1;return this.$form.find(".comment-form-score").val(n.toxicity),n.toxicity>=.75&&(i=!0,r.append("<p>Our filter has rejected your "+t+'. We aim to provide a space for thoughtful discussion. Perhaps consider rewording and submitting again. Please review our <a href="/community-guidelines">Community Guidelines<\/a>.<\/p>')),n.obscenity>=.75&&(i=!0,r.append("<p>It appears that your "+t+' contains one or more obscene words or phrases, which goes against our <a href="/community-guidelines">Community Guidelines<\/a>. You can modify your '+t+" and resubmit it, or you can submit it for manual review by our news desk.<\/p>")),i&&(this.$perspectiveResultArea.removeClass("hidden"),this.$descriptionSubmitArea.addClass("hidden"),this.$form.find("input").prop("disabled",!0)),i},onEdit:function(){var n=VM.Perspective;n.$perspectiveResultArea.addClass("hidden");n.$descriptionSubmitArea.removeClass("hidden");n.$form.find("input").prop("disabled",!1);VM.scrollTo(n.$form)},onPost:function(){var n=VM.Perspective;n.onEdit();n.formSubmit.call(null,n.$form)}};VM=VM||{};VM.Comments={isAuthenticated:!1,isMember:!1,membershipCommenting:!1,loginUrl:"/account/login?ReturnUrl=",registerUrl:"/account/register?ReturnUrl=",storageKey:"",$loader:null,modalEndpoint:null,modalLoaded:!1,$comments:null,$comment:null,maxCommentChars:0,charsLeftKey:"chars-left",$form:null,$description:null,$sort:null,$sorts:null,sort:null,startingSort:null,commentCount:0,$count:null,$parentId:null,$alert:null,$popup:null,$commentsShow:null,$commentsAdd:null,threaded:!1,hasFreeMembership:!1,$feedbackContainer:null,setUser:function(n){this.isMember=n.member||n.cms;this.isAuthenticated=n.id!==0},onFormLoaded:function(){if(VM.Comments.init(),VM.Comments.checkForUrlParam(),typeof VM.Comments.onCommentsLoadedCallback=="function")VM.Comments.onCommentsLoadedCallback(VM.Comments.commentCount)},onCountLoadedCallback:null,onCommentsLoadedCallback:null,preinit:function(){var n=this,t=encodeURIComponent(window.location.pathname);this.loginUrl+=t;this.registerUrl+=t;this.$loader=$("#comments-loader");this.threaded=this.$loader.hasClass("comments-threaded");this.storageKey="VM-comment_"+this.$loader.data("storagesuffix");this.modalEndpoint=this.$loader.data("modal-endpoint");this.membershipCommenting=this.$loader.data("membership-commenting");this.hasFreeMembership=this.$loader.data("free-membership");this.$sorts=$("#comments-sorts").on("click","a",this.onSort);this.$sort=$("#comments-sort");this.$count=$("#comments-count");this.$commentsShow=$("#comments-show").click(function(){n.showComments()});$.getJSON(this.$count.data("endpoint"),function(t){if(t&&(t.comments=t.comments||0,t.replies=t.replies||0,n.commentCount=t.comments,n.$count.text(t.comments+t.replies).removeClass("hidden").parent().addClass("rendered"),n.afterCountLoaded($("#comments")),typeof n.onCountLoadedCallback=="function"))n.onCountLoadedCallback(t.comments)});VM.Me.getUser(function(n){VM.Comments.setUser(n)});VM.Feedback&&VM.Feedback.commentingLoaded(this.$commentsShow.length===0)},init:function(){this.$sort.click(this.onSortToggle);this.sort=this.$sort.data("sort");this.startingSort=this.sort;this.$comments=$("#comments").on("click",".avatar-view",this.onProfileSummary).on("click",".comment-un",this.onProfileLinkClick).on("click",".comment-vote",this.onVote).on("click",".comment-replies",this.onGetReplies).on("click",".comments-more",this.onLoadComments).on("click",".comment-reply",this.onReply).on("click",".comment-report",this.onReport).on("click",".comment-edit",this.onEdit).on("click",".comment-pin",this.onPin).on("click",".comment-unpin",this.onUnpin).on("click",".comment-delete",this.onDelete);this.$form=$("#comment-form").on("click",".comment-cancel",this.onReplyCancel).submit(this.onSubmit).on("click",".comment-perspective-edit",VM.Perspective.onEdit).on("click",".comment-perspective-post",VM.Perspective.onPost);this.$commentsPost=$("#comments-post").removeClass("hidden").click(this.onComment);this.$commentsAdd=$("#comments-add").on("click",()=>VM.scrollTo(this.$form));this.$description=this.$form.find(".comment-form-desc").val(VM.Storage.getObj(this.storageKey)).on("keyup paste",this.onDescriptionChange);this.maxCommentChars=parseInt(this.$description.data("val-length-max"),10);this.$description.data(this.charsLeftKey,this.$form.find(".comment-desc-left").removeClass("hidden").find("span").text(this.maxCommentChars));$(document).click(VM.Comments.onDocClick);this.afterCompleteLoad();this.afterLoad(this.$comments);this.accountModalInit();$(window).click(this.closeAvatarSummary)},showForm:function(){this.membershipCommenting&&!this.isMember?($(".membership-required-container").removeClass("hidden"),$("#comments-disclaimer").addClass("hidden"),this.$form.addClass("hidden"),this.isAuthenticated&&($(".membership-required-warning").removeClass("hidden"),$(".membership-required-container .account-modal-trigger").text("Sign in with a different account"))):($(".membership-required-container").addClass("hidden"),$("#comment-form-container").removeClass("hidden"),this.$form.removeClass("hidden"),$("#comments-disclaimer").removeClass("hidden"))},accountModalInit:function(){if((!this.isAuthenticated||this.membershipCommenting)&&this.modalEndpoint&&!$("#account-modal").length){var n=$("<div><\/div>").appendTo($("body"));n.load(this.modalEndpoint,function(){VM.Comments.$alert&&VM.Comments.$alert.remove();VM.Comments.$form&&VM.Comments.$form.removeClass("hidden");VM.Comments.modalLoaded=!0;VM.Ajax.resetValidation(VM.Login.$form);VM.Ajax.resetValidation(VM.Register.$form);VM.Ajax.resetValidation(VM.Register.$confirmForm)})}},checkForUrlParam:function(){if(window.location.search){var n=window.location.search.substring(1).split("=");n.length===2&&(n[0]==="target"?VM.scrollTo($("#"+n[1])):n[0]==="message"&&n[1].toLowerCase()==="registered"&&(this.$description.val()?(VM.scrollTo(this.$form),VM.Ajax.toast("Your registration is complete. You may now leave a comment.","success",!0)):(VM.scrollTo(this.$comments),VM.Ajax.toast("Your registration is complete. You may now leave a comment or vote.","success",!0))))}},onAccountModalOpened:function(n){n.hasClass("comment-submit")&&VM.Storage.setObj(VM.Comments.storageKey,VM.Comments.$description.val())},onLoginSuccess:function(n,t){VM.Comments.authenticated(n,t)},onRegisteredSuccess:function(n,t){VM.Comments.authenticated(n,t)},onRegisteredPartialSuccess:function(n,t){t.hasClass("comment-submit")?VM.Ajax.toast("Your account requires review before you can comment. Don't worry, we've saved your comment for later submission.","warning"):VM.Ajax.toast("Your account requires review before you can reply or vote.","warning")},authenticated:function(n,t){var r,i;this.setUser(n);this.showForm();VM.$body.find(".account-modal-trigger").removeClass("account-modal-trigger");r=this.$comments.find(".comment[data-uid='"+n.id+"']");r.length&&(r.find(".comment-vote").prop("disabled",!0),r.find(".comment-report").remove());i="You are now signed in.";t.hasClass("comment-submit")?this.$form.valid()&&(this.$form.data("success-toast","Your comment has been added."),t.click()):t.hasClass("comment-reply")?(i="You are now signed in, and may now reply.",t.click()):t.hasClass("comment-report")?(i="You may now report that comment.",t.click()):t.hasClass("comment-vote")&&!t.prop("disabled")?(i=" Your vote has been added.",t.click()):t.hasClass("membership-signin-link")&&($(".membership-required-container").addClass("hidden"),$("#feedback-form-container").removeClass("hidden"));VM.Ajax.toast(i,"success")},afterCompleteLoad:function(){this.isAuthenticated=this.$comments.data("auth");this.showForm();this.$count.removeClass("hidden").parent().addClass("rendered");this.checkAuthenticated(this.$form,"comment","comment-form");VM.Ajax.resetValidation(this.$form)},afterLoad:function(n){if(n&&n.length>0){var t=VM.Comments;n.find(".timeago").timeago();n.hasClass("comment")||VM.Comments.loadAds();t.afterCountLoaded(n)}},afterCountLoaded:function(n){var t=VM.Comments,i,r;t.commentCount>3&&t.$commentsPost!=null&&!t.$commentsPost.hasClass("hidden")&&t.$sort.removeClass("hidden");t.$commentsAdd!=null&&t.$commentsAdd.toggleClass("hidden",!(t.commentCount>10&&t.$form.length));n&&n.length>0&&(i=0,r=0,n.hasClass("comment")?(i=n.find(".comment").length,r=parseInt(n.data("replies"),10)):(i=n.find(">.comment").length,r=t.commentCount),i<r&&n.find(".comments-more").removeClass("hidden"))},checkAuthenticated:function(n,t,i){if(this.isAuthenticated)return!0;var r=n[0].id==="comment-form",f=r?null:n.closest(".comment"),u=encodeURIComponent("?target="+(i||"comments"));return VM.Comments.modalLoaded?!1:(this.$alert&&this.$alert.remove(),this.$alert=$('<p class="alert alert-warning" style="clear:both">You must be signed in to '+t+'. Please <a href="'+this.loginUrl+u+'" class="alert-link account-modal-trigger">sign in<\/a> or <a href="'+this.registerUrl+u+'" class="alert-link account-modal-trigger">register<\/a>.<\/p>'),r?(this.$alert.insertAfter(this.$form),this.$form.addClass("hidden")):this.$alert.appendTo(f),!1)},onGetReplies:function(){var n=$(this).closest(".comment"),t=n.find(".comment-child"),i,r;if(t.length){t.remove();return}i=$(this);r=VM.Comments.$comments.data("endpoint").replace("Sort="+VM.Comments.startingSort,"Sort="+VM.Comments.sort)+"&ParentId="+n.data("id")+"&Count="+n.data("replies");VM.Comments.load(i,r,null,function(t){t='<div class="comment-child">'+t+"<\/div>";n.append(t);VM.Comments.afterLoad(n)})},onSortToggle:function(){VM.Comments.$sorts.toggleClass("hidden")},onSort:function(n){var t,i;n&&n.preventDefault();t=VM.Comments;t.sort=$(this).data("sort");$(this).addClass("sort-active").siblings().removeClass("sort-active");i=VM.Comments.$loader.data("endpoint").replace("Sort="+VM.Comments.startingSort,"Sort="+VM.Comments.sort);t.load(VM.Comments.$sort,i,null,function(n){var i=$(n).filter("#comments");t.$comments.html(i.html());t.afterCompleteLoad();t.afterLoad(VM.Comments.$comments)})},onDocClick:function(n){n.target.id!=="comments-sort"&&n.target.id!=="comments-sort-arrow"&&VM.Comments.$sorts.addClass("hidden")},onSubmit:function(n){n.preventDefault();var i=VM.Comments,t=$(this),r=t.find(".comment-form-type").val();r==="Comment"?(VM.Perspective.init(t.find(".comment-perspective"),t.find(".comment-submit-area"),t,i.doSubmit),VM.Perspective.check(i.$description.val(),function(n){VM.Perspective.showMessage(n,i.threaded?"comment":"feedback")||i.doSubmit(t)})):i.doSubmit(t)},doSubmit:function(n){var t=VM.Comments;if(n.valid()){var r=n.find(".comment-submit"),u=n.attr("action"),f=n.serialize(),i;VM.Comments.load(r,u,f,function(u){var p=n.find(".comment-form-parent"),w=n.find(".comment-form-type").val(),f,s,h,y;if(w==="Report")t.onReplyCancel.call(r),t.$comment.find(".comment-report").text("Reported").removeClass("comment-report").removeClass("btn-default").addClass("btn-warning"),t.$comment=null;else if(t.threaded){var c=p.val(),o=t.getModerationMessage(u,"comment","comments"),l=o.length>0,a="",e="",v="<p>"+t.$description.val().replace(/(?:\r\n|\r|\n)/g,"<br>")+"<\/p>";a=u.avatar?'<a class="avatar-current avatar-sm avatar" href="/account" title="Change your photo"><img alt="'+u.username+'" class="avatar-img" src="'+u.avatar+';w=45;h=45;mode=crop"><\/a>':'<a class="theme-bg avatar-current avatar-sm avatar" href="/account" title="Add your photo">'+u.initials+"<\/a>";e='<div id="c_'+u.id+'" class="comment clearfix" data-id="'+u.id+'" data-replies="0">'+a+'<div class="comment-body"><div class="thread-date"><b class="theme-colour comment-un">'+u.username+'<\/b> Just now<\/div><div class="comment-text">'+v+o+'<\/div><div class="comment-actions"><form action="/comments/delete/'+u.id+'" class="pull-right" method="post">'+u.af+'<button type="button" class="btn btn-default btn-ns btn-xs comment-delete" title="Delete your comment"><i class="ic ic-delete"><\/i><\/button><\/form><button type="button" class="btn btn-default btn-ns btn-xs pull-right comment-edit" title="Edit your comment"><i class="ic ic-edit"><\/i><\/button><\/div><\/div><\/div>';c?(f=$("#c_"+c),u.edited?(f.find(">.comment-body .comment-text").html(v).append(o),i=f):(s=f.find(".comment-child"),s.length?(i=t.addReply(e,s,!0),l||(h=f.data("replies")+1,y=f.find(".comment-replies"),f.data("replies",h),y.html(h+' Replies <i class="caret"><\/i>'))):i=$('<div class="comment-child">'+e+"<\/div>").appendTo(f)),t.onReplyCancel.call(r),t.$comment=null):i=t.addReply(e,t.$comments,!1);l?i.find(">.comment-body .comment-actions").remove():t.$count.text(parseInt(t.$count.text(),10)+1);VM.scrollTo(i)}else VM.Ajax.toast("Thank you for your feedback.","success");VM.Track.onGaClick.call(r);VM.Track.trackEvent("comment added",{category:"NTG user",label:r.data("ga-label")});t.$description.val("");VM.Storage.setObj(t.storageKey,"");t.$description.data(t.charsLeftKey).text(t.maxCommentChars);n.find(".comment-form-score").val(0);n.data("success-toast")&&(VM.Ajax.toast(n.data("success-toast"),"success"),n.data("success-toast",""))})}},getModerationMessage:function(n,t,i){if(n.status==="Moderation"){var r="",u=t===i?"is":"are";switch(n.moderation){case"ModerateUser":r="Your "+t+" has been flagged for moderation";break;case"ModerateNewUser":r="All "+i+" posted by new accounts "+u+" flagged for moderation";break;case"ModerateContent":r="All "+i+" related to this story "+u+" currently being moderated";break;case"ModerateSite":r="All "+i+" "+u+" currently being moderated";break;case"ModerateComment":r="Your "+t+" has been flagged for moderation based on its contents"}return'<p class="alert alert-warning">'+r+".<\/p>"}return""},addReply:function(n,t,i){return this.sort==="Oldest"||i?$(n).appendTo(t):$(n).prependTo(t)},onLoadComments:function(){var n=$(this),i,t=n.data("parent"),u=t?"Oldest":VM.Comments.sort,r=VM.Comments.$comments.data("endpoint").replace("Sort="+VM.Comments.startingSort,"Sort="+u)+"&lastId="+n.prev().data("id")+"&ParentId="+t+"&Count=";VM.Track.onGaClick.call(n);t?(i=n.closest(".comment"),r+=i.data("replies")):r+=VM.Comments.commentCount;VM.Comments.load(n,r,null,function(r){n.replaceWith(r);t?VM.Comments.afterLoad(i):VM.Comments.afterLoad(VM.Comments.$comments)})},load:function(n,t,i,r){n.addClass("loading").prop("disabled",!0);$.ajax(t,{method:i===null?"GET":"POST",data:i}).done(r).fail(function(n,t,i){VM.Ajax.toast(n.responseText||i,"danger",!1)}).always(function(){n.removeClass("loading").prop("disabled",!1)})},onComment:function(){VM.Comments.checkAuthenticated(VM.Comments.$form,"comment","comment-form");VM.scrollTo(VM.Comments.$form)},onReply:function(){VM.Comments.checkAuthenticated($(this),"reply")&&VM.Comments.changeState(this,"Comment","Add your reply","Post Reply")},onReport:function(){if(VM.Comments.checkAuthenticated($(this),"report this comment")){var n=$(this).closest(".comment").hasClass("comment-candle")?"candle":"comment";VM.Comments.changeState(this,"Report","Please explain why you're reporting this "+n,"Report")}},onEdit:function(){VM.Comments.changeState(this,"Comment","Update your comment","Update");var n=$(this).closest(".comment"),t=n.find(".comment-text").html().replace(/<\/p><p>/g,"\n\n").replace(/<p>/g,"").replace(/<\/p>/g,"").replace(/<br>/g,"\n");VM.Comments.$description.val(t);VM.Comments.$form.find(".comment-form-editid").val(n.data("id"))},onPin:function(){var n=$(this);VM.Comments.pin(n,!0,function(){n.addClass("hidden").next().removeClass("hidden")})},onUnpin:function(){var n=$(this);VM.Comments.pin(n,!1,function(){n.addClass("hidden").prev().removeClass("hidden")})},pin:function(n,t,i){n.addClass("loading").prop("disabled",!0);$.ajax(n.parent().data("endpoint"),{method:"POST",data:"pin="+t}).done(function(){i()}).fail(function(n,t,i){VM.Ajax.toast(n.responseText||i,"danger",!1)}).always(function(){n.removeClass("loading").prop("disabled",!1)})},onDelete:function(){if(confirm("Are you sure you want to delete this comment?")){var n=VM.Comments,i=$(this),t=i.closest("form"),r=t.attr("action"),u=t.serialize();VM.Comments.load(i,r,u,function(){var f=t.closest(".comment"),r=f.parent();if(r.hasClass("comment-child")){var u=r.parent(),i=u.data("replies")-1,e=u.find(".comment-replies");u.data("replies",i);i===0?(e.remove(),r.remove()):e.html(i+(i===1?" Reply ":" Replies ")+'<i class="caret"><\/i>')}else n.commentCount--;n.$count.text(parseInt(n.$count.text(),10)-1);f.remove()})}},onReplyCancel:function(){VM.Comments.changeState(null,"Comment","Add your comment","Post Comment")},changeState:function(n,t,i,r){var u,f=this.$form.find(".comment-assite");n!==null?(this.$comment=$(n).closest(".comment").addClass("comment-replying"),$(n).hasClass("comment-edit")?this.$form.insertAfter(this.$comment.find(">.comment-body .comment-actions")):this.$comment.append(this.$form),u=this.$comment.data("id")):(this.$comment.removeClass("comment-replying"),this.threaded?this.$form.insertAfter(this.$comments):$("#comment-form-container").append(this.$form),u=null);f.length&&f.toggleClass("hidden",r.toLowerCase()==="update");this.$description.val("").attr("placeholder",i);this.$description.data(this.charsLeftKey)[0].innerText=this.maxCommentChars;this.$form.find(".comment-form-editid").val("");this.$form.find("label.sr-only").text(i);this.$form.find(".comment-submit").text(r).toggleClass("btn-block",n!==null);this.$form.find(".comment-cancel").toggleClass("hidden",n===null);this.$form.find(".comment-form-parent").val(u);this.$form.find(".comment-form-type").val(t);n!==null&&this.$description.focus()},onVote:function(){var n=$(this);if(VM.Comments.checkAuthenticated(n,"vote")){var t=n.closest("form"),i=t.attr("action")+"&type="+n.val(),r=t.serialize();VM.Comments.load(n,i,r,function(i){if(i)i.action==="banned"?VM.Ajax.toast("Sorry, your account has been banned from commenting or voting.","danger",!1):(t.find(".comment-vote[value='Upvote'] span").text(i.upvotes),t.find(".comment-vote[value='Downvote'] span").text(i.downvotes),VM.Track.onGaClick.call(n));else{var r=JSON.parse(xhr.getResponseHeader("X-Responded-JSON"));r&&r.status===401&&alert("You need to sign in.")}})}},onDescriptionChange:function(){var n=$(this);n.data(VM.Comments.charsLeftKey)[0].innerText=VM.Comments.maxCommentChars-n.val().length},onProfileSummary:function(n){n.preventDefault();var t=$(this),i=!1;VM.Comments.$popup&&(i=VM.Comments.$popup.find(".avatar").attr("href")===t.attr("href"),VM.Comments.$popup.remove(),VM.Comments.$popup=null);i||(VM.Comments.$popup=$('<div class="popup popup-bubble avatar-popup" style="top:'+(t.offset().top+58)+"px;left: "+t.offset().left+'px"><\/div>').load(t.attr("href")+"/summary"),$("body").append(VM.Comments.$popup))},onProfileLinkClick:function(n){$(this).hasClass("comment-un-current")||(n.preventDefault(),$(this).closest(".comment-body").prev().click())},closeAvatarSummary:function(n){if(VM.Comments.$popup){var t=$(n.target);t.hasClass("avatar-img")||t.hasClass("avatar")||t.hasClass("comment-un")||(VM.Comments.$popup.remove(),VM.Comments.$popup=null)}},showComments:function(n){VM.Comments.load(VM.Comments.$commentsShow,VM.Comments.$loader.data("endpoint"),null,function(t){VM.Comments.$loader.html(t);VM.Comments.init();VM.Comments.$commentsShow.remove();typeof n=="function"&&n()})},loadAds:function(){var n=this.$comments.find(".slot-comments:not(.slot-loaded)");n.length&&n.each(function(){var n=this;n.classList.add("slot-loaded");VM.Slots.loadSlot(n,function(t){n.classList.contains("slot-show")||VM.Slots.refreshSlots([t])})})}};$(function(){VM.Comments.preinit()});VM=VM||{};VM.Candles={storageKey:"VM-candle-",$loader:null,$form:null,$name:null,$location:null,$descriptionSubmitArea:null,$perspectiveResultArea:null,hasRecaptcha:!1,recaptcha:null,contentId:null,onFormLoaded:function(){var n=$(this);n.data("expanded")&&n.removeClass("hide");VM.Candles.$loader=n;VM.Candles.init()},init:function(){this.$form=$("#candle-form").on("click",".comment-perspective-edit",VM.Perspective.onEdit).on("click",".comment-perspective-post",VM.Perspective.onPost).on("click",".candle-submit",this.onSubmit);this.storageKey+=this.$form.find("input[name='ContentId']").val();this.$name=this.$form.find(".comment-form-name");this.$location=this.$form.find(".comment-form-location");this.$descriptionSubmitArea=this.$form.find(".comment-submit-area");this.$perspectiveResultArea=this.$form.find(".comment-perspective");this.hasRecaptcha=this.$form.find("#candles-recaptcha").length>0;this.addButton();this.hasRecaptcha&&($(".candle-submit").prop("disabled",!0),typeof grecaptcha=="undefined"?$.getScript("https://www.google.com/recaptcha/api.js",function(n,t,i){i.status===200&&(VM.Candles.addRecaptcha(),$(".candle-submit").prop("disabled",!1))}):(VM.Candles.addRecaptcha(),$(".candle-submit").prop("disabled",!1)));VM.Ajax.resetValidation(this.$form)},addRecaptcha:function(){grecaptcha.ready(function(){VM.Candles.recaptcha=grecaptcha.render("candles-recaptcha")})},addButton:function(){var n=$("#comments-post").text("Add Condolences"),t=$('<li><button class="btn btn-primary btn-sm">Light Candle<\/button><\/li>').insertAfter(n.parent());t.click(function(){VM.Candles.$loader.removeClass("hide");VM.Comments.$commentsShow.length?VM.Comments.showComments(function(){VM.scrollTo($("#candles"))}):VM.scrollTo($("#candles"))})},onSubmit:function(n){n.preventDefault();var t=VM.Storage.getObj(VM.Candles.storageKey);VM.Candles.$form.validate();VM.Candles.$form.valid()&&!t?VM.Candles.hasRecaptcha?grecaptcha.execute(VM.Candles.recaptcha):VM.Candles.submit():(VM.Candles.hasRecaptcha&&grecaptcha.reset(VM.Candles.recaptcha),t&&!$("#candle-error").length&&VM.Candles.$form.prepend('<div id="candle-error" class="alert alert-danger">You have already added a candle.<\/div>'))},submit:function(){var n=VM.Candles;VM.Perspective.init(n.$perspectiveResultArea,n.$descriptionSubmitArea,n.$form,n.addCandle);VM.Perspective.check(n.$name.val()+", "+n.$location.val(),function(t){VM.Perspective.showMessage.call(n,t,"candle")||n.addCandle()})},addCandle:function(){var n=VM.Candles,t=n.$form.find(".candle-submit"),i=n.$form.attr("action"),r=n.$form.serialize();VM.Comments.load(t,i,r,function(i){VM.Track.onGaClick.call(t);VM.Track.trackEvent("candle added",{category:"NTG user",label:t.data("ga-label")});var r=VM.Comments.getModerationMessage(i,"candle","candles"),u=r.length>0,f='<div id="c_'+i.id+'" class="comment comment-candle clearfix" data-id="'+i.id+'"><span class="avatar avatar-sm avatar-candle" title="Candle"><i class="ic ic-candle"><\/i><\/span><div class="comment-body"><div class="thread-date"><b class="comment-un">'+n.$name.val()+'<\/b> Just now<\/div><div class="comment-text"><p>'+n.$location.val()+"<\/p>"+r+"<\/div><\/div><\/div>",e=VM.Comments.addReply(f,VM.Comments.$comments,!1);u||VM.Comments.$count.text(parseInt(VM.Comments.$count.text(),10)+1);VM.scrollTo(e);VM.Storage.setObj(VM.Candles.storageKey,"1");n.$name.val("");n.$location.val("");n.$form.find(".comment-form-score").val(0);VM.Candles.hasRecaptcha&&grecaptcha.reset(VM.Candles.recaptcha)})}}