function VM_Candles_onSubmit(n){VM.Register&&VM.Register.submitClicked?(VM.Register.$form.find(".g-recaptcha-response").val(n),VM.Register.submit(),VM.Register.submitClicked=!1):VM.Candles.submit()}var VM;(function(n){function i(n,t){for(var i=window,r=(n||"").split(".");i&&r.length;)i=i[r.shift()];return typeof i=="function"?i:(t.push(n),Function.constructor.apply(null,t))}function u(n){return n==="GET"||n==="POST"}function o(n,t){u(t)||n.setRequestHeader("X-HTTP-Method-Override",t)}function s(t,i,r){var u;r.indexOf("application/x-javascript")===-1&&(u=(t.getAttribute("data-ajax-mode")||"").toUpperCase(),n(t.getAttribute("data-ajax-update")).each(function(t,r){var f;switch(u){case"BEFORE":f=r.firstChild;n("<div />").html(i).contents().each(function(){r.insertBefore(this,f)});break;case"AFTER":n("<div />").html(i).contents().each(function(){r.appendChild(this)});break;case"REPLACE-WITH":n(r).replaceWith(i);break;default:n(r).html(i)}}))}function f(t,r){var e,h,f,c;(e=t.getAttribute("data-ajax-confirm"),!e||window.confirm(e))&&(h=n(t.getAttribute("data-ajax-loading")),c=parseInt(t.getAttribute("data-ajax-loading-duration"),10)||0,n.extend(r,{type:t.getAttribute("data-ajax-method")||undefined,url:t.getAttribute("data-ajax-url")||undefined,cache:!!t.getAttribute("data-ajax-cache"),beforeSend:function(n){var r;return o(n,f),r=i(t.getAttribute("data-ajax-begin"),["xhr"]).apply(t,arguments),r!==!1&&h.show(c),r},complete:function(){h.hide(c);i(t.getAttribute("data-ajax-complete"),["xhr","status"]).apply(t,arguments)},success:function(n,r,u){s(t,n,u.getResponseHeader("Content-Type")||"text/html");i(t.getAttribute("data-ajax-success"),["data","status","xhr"]).apply(t,arguments)},error:function(){i(t.getAttribute("data-ajax-failure"),["xhr","status","error"]).apply(t,arguments)}}),r.data.push({name:"X-Requested-With",value:"XMLHttpRequest"}),f=r.type.toUpperCase(),u(f)||(r.type="POST",r.data.push({name:"X-HTTP-Method-Override",value:f})),n.ajax(r))}function h(t){var i=n(t).data(e);return!i||!i.validate||i.validate()}var t="unobtrusiveAjaxClick",r="unobtrusiveAjaxClickTarget",e="unobtrusiveValidation";n(document).on("click","a[data-ajax=true]",function(n){n.preventDefault();f(this,{url:this.href,type:"GET",data:[]})});n(document).on("click","form[data-ajax=true] input[type=image]",function(i){var r=i.target.name,u=n(i.target),f=n(u.parents("form")[0]),e=u.offset();f.data(t,[{name:r+".x",value:Math.round(i.pageX-e.left)},{name:r+".y",value:Math.round(i.pageY-e.top)}]);setTimeout(function(){f.removeData(t)},0)});n(document).on("click","form[data-ajax=true] :submit",function(i){var f=i.currentTarget.name,e=n(i.target),u=n(e.parents("form")[0]);u.data(t,f?[{name:f,value:i.currentTarget.value}]:[]);u.data(r,e);setTimeout(function(){u.removeData(t);u.removeData(r)},0)});n(document).on("submit","form[data-ajax=true]",function(i){var e=n(this).data(t)||[],u=n(this).data(r),o=u&&u.hasClass("cancel");(i.preventDefault(),o||h(this))&&f(this,{url:this.action,type:this.method||"GET",data:e.concat(n(this).serializeArray())})})})(jQuery);VM=VM||{};VM.Reactions={init:function(){var n=VM.$body.find(".reactions");if(n.length){n.find(".react-view").removeClass("hidden").on("click",this.onShowReactions);n.find(".js-react").prop("disabled",!1).on("click",this.onReact).hover(this.onHover);VM.Storage.hasStorage()&&$.ajax(n.first().data("af"),{method:"POST"}).done(function(t){n.each(function(){var n=$(this);n.append(t);VM.Reactions.activate(n)})})}},activate:function(n){var t=localStorage.getItem(this.getStorageKey(n));t?n.find(".js-react").addClass("reacted").filter("[value='"+t+"']").addClass("yours").attr("title","Your choice"):n.data("can-react",!0)},onReact:function(n){n.preventDefault();var i=$(this).addClass("loading").prop("disabled",!0),r=i.attr("value"),t=i.closest("form");t.data("can-react")&&$.ajax(t.attr("action")+"&type="+t.data("type")+"&subtype="+r,{method:"POST",data:t.serialize()}).done(function(n){VM.Reactions.showReactions(t,n.Reactions,!1);switch(n.Result){case 0:if(localStorage.setItem(VM.Reactions.getStorageKey(t),r),i.addClass("reacted").addClass("yours"),i.parent().siblings().find("button").addClass("reacted"),t.data("event-type")==="Importance"){var u=i.parent().index()+1;VM.Reactions.trackReaction(t,u.toString())}else VM.Reactions.trackReaction(t,r);t.data("can-react",!1);break;case 1:VM.Reactions.errorMessage(t,"There was a problem adding your reaction.");break;case 2:t.data("can-react",!1);VM.Reactions.errorMessage(t,"It looks like you've already added your reaction.");break;case 3:t.data("can-react",!1);VM.Reactions.errorMessage(t,"You've already added your reaction.")}VM.Reactions.showRelated(t,r)}).fail(function(){alert("There was a problem adding your reaction.")}).always(function(){i.removeClass("loading").prop("disabled",!1)})},onHover:function(){var n=$(this);n.hasClass("reacted")||$(this).toggleClass("hovered").parent().prevAll().children().toggleClass("hovered")},getStorageKey:function(n){return"VM_"+n.data("type")+"_"+n.data("id")},onShowReactions:function(n){n.preventDefault();var t=$(this).closest("form");$.ajax(t.data("results"),{method:"GET"}).done(function(n){VM.Reactions.showReactions(t,n,!0)}).fail(function(){alert("Sorry, the results are currently unavailable.")})},showReactions:function(n,t,i){var u,f,h,c;if(t!==null){var r=0,o=0,s=0,e=null;for(u in t)t.hasOwnProperty(u)&&(f=t[u],i&&f>o&&(o=f,e=u),r+=f);h=n.find(".js-react").each(function(n){var i=$(this),u=0,l=n+1,f=t[i.attr("value")],e;f&&r>0&&(u=f/r,e=f*l,s+=e);var o=(u*100).toFixed(0)+"%",h=i.find(".react-label"),c=h.next("b");c.length?c.text(o):h.after("<b>"+o+"<\/b>");i.find(".theme-bg").css("opacity",u)});c=Math.round(s/r);h.lt(c).addClass("selected");i&&e&&this.showRelated(n,e)}},showRelated:function(n,t){n.data("shown-related")||$.ajax(n.data("items").replace("=0","="+t),{method:"GET"}).done(function(i){if(n.data("shown-related",!0),i.length>50){var u=n.data("type")==="importance"?"Here are recent stories that are important:":"Here are other recent stories that make people feel "+t.toLowerCase()+":",r=$('<div class="react-related"><h3 class="theme-colour">'+u+"<\/h3>"+i+"<\/div>");r.find(".section-tr-bordered").last().removeClass("section-tr-bordered");n.append(r);VM.setup()}}).fail(function(){})},errorMessage:function(n,t){var i=n.find(".alert-warning");i.length?i.text(t):n.find(".nav").after('<p class="alert alert-warning">'+t+"<\/p>")},trackReaction:function(n,t){var i={};i.eventCategory=n.data("event-type");i.eventAction=t;i.eventLabel=n.data("title");VM.Track.trackEvent(i)}};VM.Momentum={id:null,tag:null,shareCount:0,commentCount:0,counters:0,countersRendered:0,dataSent:!1,init:function(){var n=VM.$body.find(".details"),i=n.find(".sc-s").last(),t=n.find("#comments-count");this.id=n.data("id");this.tag=n.data("tag");t.length===0&&(t=n.find(".sc-c"));i.length&&(this.counters++,this.watchCount(i,i.closest(".sc"),this.setShareCount));t.length&&(this.counters++,this.watchCount(t,t.parent(),this.setCommentsCount))},setShareCount:function(n){VM.Momentum.shareCount=n},setCommentsCount:function(n){VM.Momentum.commentCount=n},watchCount:function(n,t,i){var r=this,u=0,f=window.setInterval(function(){u++;t.hasClass("rendered")&&(clearInterval(f),i(parseInt(n.text(),10)),r.countersRendered++,r.countersRendered===r.counters&&r.sendData());u===100&&clearInterval(f)},50)},sendData:function(n,t,i,r){if(!this.dataSent){this.dataSent=!0;var u=$(window).width()+"x"+$(window).height();$.ajax("/sendmomentum?id="+(n||this.id)+"&tag="+(t||this.tag)+"&shares="+(i||this.shareCount||0)+"&comments="+(r||this.commentCount||0)+"&viewport="+u,{method:"POST"})}}};VM.Embeds={tweetEmbeds:null,instaEmbeds:null,init:function(){var e,i,r,t,n,u,f;if(this.tweetEmbeds=[],this.instaEmbeds=[],this.facebookEmbeds=[],e=$("#details-body").children("p"),e.length>0)for(n=0;n<e.length;n++)i=e[n],r=i.innerText||i.textContent,r.indexOf("https://twitter.com")===0?this.tweetEmbeds.push(this.processEmbed(i,r,"twitter")):r.indexOf("https://www.instagram.com")===0&&this.instaEmbeds.push(this.processEmbed(i,r,"instagram"));if(t=$(".embed-custom-wrapper"),t.length>0)for(n=0;n<t.length;n++)u=$(t[n]).data("type"),f=$(t[n]).data("url"),u=="twitter"?this.tweetEmbeds.push(this.processEmbed(t[n],f,"twitter")):u=="instagram"?this.instaEmbeds.push(this.processEmbed(t[n],f,"instagram")):u=="facebook"?this.facebookEmbeds.push(this.processEmbed(t[n],f,"facebook")):u=="facebook-page"&&this.facebookEmbeds.push(this.processEmbed(t[n],f,"facebook-page"));this.loadWidgets()},loadWidgets:function(){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")})},processEmbed:function(n,t,i){var u=VM.getFacebookApiKey(),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="+u:i=="facebook"?r="https://graph.facebook.com/oembed_post?url="+encodeURIComponent(t)+"&access_token="+u:i=="facebook-page"&&(r="https://graph.facebook.com/oembed_page?url="+encodeURIComponent(t)+"&access_token="+u),$.ajax({cache:!1,url:r,jsonp:"callback",dataType:"jsonp"}).success(function(t){if(t)try{n.innerHTML=t.html}catch(i){}})}};$(function(){VM.Scroll.setIsStory();VM.Reactions.init();VM.Momentum.init();VM.Embeds.init()});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,$charsLeft:null,$form:null,$description:null,$descriptionSubmitArea:null,$perspectiveResultArea:null,$sort:null,$sorts:null,sort:null,startingSort:null,count:0,$count:null,$parentId:null,$alert:null,$popup:null,$commentsShow:null,onFormLoaded:function(){VM.Comments.init();VM.Comments.checkForUrlParam()},preinit:function(){var n=this,t=encodeURIComponent(window.location.pathname);this.loginUrl+=t;this.registerUrl+=t;this.$loader=$("#comments-loader");this.storageKey="VM-comment_"+this.$loader.data("storagesuffix");this.modalEndpoint=this.$loader.data("modal-endpoint");this.membershipCommenting=this.$loader.data("membership-commenting")==="True";this.$sorts=$("#comments-sorts").on("click","a",this.onSort);this.$count=$("#comments-count");this.$commentsShow=$("#comments-show").click(function(){n.showComments()});this.$commentsShow.length&&$.getJSON(this.$commentsShow.data("count-endpoint"),function(t){t&&(n.count=t.count,n.$count.text(n.count).removeClass("hidden").parent().addClass("rendered"))});VM.Me.getUser(function(n){VM.Comments.isMember=n.member||n.cms})},init:function(){this.$sort=$("#comments-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",this.onPerspectiveEdit).on("click",".comment-perspective-post",this.onPerspectivePost);$("#comments-post").removeClass("hidden").click(this.onComment);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.$charsLeft=this.$form.find(".comment-desc-left").removeClass("hidden").find("span").text(this.maxCommentChars);this.$descriptionSubmitArea=this.$form.find(".comment-submit-area");this.$perspectiveResultArea=this.$form.find(".comment-perspective");$(document).click(VM.Comments.onDocClick);this.afterCompleteLoad();this.afterLoad(this.$comments);this.accountModalInit();$(window).click(this.closeAvatarSummary)},showForm:function(){this.membershipCommenting&&!this.isMember?this.isAuthenticated&&($("#membership-commenting-warning").removeClass("hidden"),$("#membership-commenting-container .account-modal-trigger").text("Sign in with a different account")):($("#comment-form-container").removeClass("hidden"),$("#comments-disclaimer").removeClass("hidden"))},accountModalInit:function(){if((!this.isAuthenticated||this.membershipCommenting)&&this.modalEndpoint){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.isAuthenticated=!0;this.isMember=n.member;this.showForm();this.$loader.find(".account-modal-trigger").not("#membership-commenting-container .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());VM.Ajax.toast(i,"success")},afterCompleteLoad:function(){this.isAuthenticated=this.$comments.data("auth");this.showForm();this.count=parseInt(this.$comments.data("count"),10);this.$count.text(this.count).removeClass("hidden").parent().addClass("rendered");this.count>3&&this.$sort.removeClass("hidden");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();existingCount=0;count=0;n.hasClass("comment")?(existingCount=n.find(".comment").length,count=parseInt(n.data("replies"),10)):(existingCount=n.find(">.comment").length,count=t.count);existingCount<count&&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 t=VM.Comments,i=t.$form.find(".comment-form-type").val();i==="Comment"?t.checkPerspective(VM.Comments.$description.val(),function(n){t.showPerspectiveMessage(n)||t.doSubmit()}):t.doSubmit()},doSubmit:function(){var n=VM.Comments;if(n.$form.valid()){var t=n.$form.find(".comment-submit"),i=n.$form.attr("action"),r=n.$form.serialize();VM.Comments.load(t,i,r,function(i){var y=n.$form.find(".comment-form-parent"),p=n.$form.find(".comment-form-type").val(),r,s,h,v;if(p==="Report")n.onReplyCancel.call(t),n.$comment.find(".comment-report").text("Reported").removeClass("comment-report").removeClass("btn-default").addClass("btn-warning"),n.$comment=null;else{VM.Track.onGaClick.call(t);VM.Track.trackEvent({eventCategory:"NTG user",eventAction:"comment added",eventLabel:t.data("ga-label")});var c=y.val(),e=n.getModerationMessage(i,"comment","comments"),o=e.length>0,l="",f="",u,a="<p>"+n.$description.val().replace(/(?:\r\n|\r|\n)/g,"<br>")+"<\/p>";l=i.avatar?'<a class="avatar-current avatar-sm avatar" href="/account" title="Change your photo"><img alt="'+i.username+'" class="avatar-img" src="'+i.avatar+';w=45;h=45;mode=crop"><\/a>':'<a class="theme-bg avatar-current avatar-sm avatar" href="/account" title="Add your photo">'+i.initials+"<\/a>";f='<div id="c_'+i.id+'" class="comment clearfix" data-id="'+i.id+'" data-replies="0">'+l+'<div class="comment-body"><div class="thread-date"><b class="theme-colour comment-un">'+i.username+'<\/b> Just now<\/div><div class="comment-text">'+a+e+'<\/div><div class="comment-actions"><form action="/comments/delete/'+i.id+'" class="pull-right" method="post">'+i.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?(r=$("#c_"+c),i.edited?(r.find(">.comment-body .comment-text").html(a).append(e),u=r):(s=r.find(".comment-child"),s.length?(u=n.addReply(f,s,!0),o||(h=r.data("replies")+1,v=r.find(".comment-replies"),r.data("replies",h),v.html(h+' Replies <i class="caret"><\/i>'))):u=$('<div class="comment-child">'+f+"<\/div>").appendTo(r)),n.onReplyCancel.call(t),n.$comment=null):(u=n.addReply(f,n.$comments,!1),o||n.$count.text(parseInt(n.$count.text(),10)+1));o&&u.find(">.comment-body .comment-actions").remove();VM.scrollTo(u)}n.$description.val("");VM.Storage.setObj(n.storageKey,"");n.$charsLeft.text(n.maxCommentChars);n.$form.find(".comment-form-score").val(0);n.$form.data("success-toast")&&(VM.Ajax.toast(n.$form.data("success-toast"),"success"),n.$form.data("success-toast",""))})}},getModerationMessage:function(n,t,i){if(n.status==="Moderation"){var r="";switch(n.moderation){case"ModerateUser":r="Your "+t+" has been flagged for moderation";break;case"ModerateNewUser":r="All "+i+" posted by new accounts are flagged for moderation";break;case"ModerateContent":r="All "+i+" related to this story are currently being moderated";break;case"ModerateSite":r="All "+i+" are 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+". You will receive an email notification if your "+t+" is <i>not<\/i> approved.<\/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.count;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){alert(n.responseText||i)}).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){alert(n.responseText||i)}).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.$count.text(parseInt(n.$count.text(),10)-1),n.count--;f.remove()})}},onReplyCancel:function(){VM.Comments.changeState(null,"Comment","Add your comment","Post Comment")},changeState:function(n,t,i,r){var u;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.$form.insertAfter(this.$comments),u=null);this.$description.val("").attr("placeholder",i);this.$form.find(".comment-form-editid").val("");this.$form.find("label.sr-only").text(i);this.$form.find(".comment-submit").text(r);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)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(){VM.Comments.$charsLeft[0].innerText=VM.Comments.maxCommentChars-this.value.length},checkPerspective: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})})},showPerspectiveMessage:function(n){var i=this.$perspectiveResultArea.find(".message").empty(),t=!1;return VM.Comments.$form.find(".comment-form-score").val(n.toxicity),n.toxicity>=.75&&(t=!0,i.append('<p>Our filter has rejected your comment. We aim to provide a space for thoughtful discussion. Perhaps consider rewording and submitting again. Please remember our <a href="/community-guidelines">Community Guidelines<\/a> when commenting.<\/p>')),n.obscenity>=.75&&(t=!0,i.append('<p>It appears that your comment contains one or more obscene words or phrases, which goes against our <a href="/community-guidelines">Community Guidelines<\/a>. You can modify your comment and resubmit it, or you can submit it for manual review by our news desk.<\/p>')),t&&(this.$perspectiveResultArea.removeClass("hidden"),this.$descriptionSubmitArea.addClass("hidden"),this.$form.find("input").prop("disabled",!0)),t},onPerspectivePost:function(){VM.Comments.perspectivePost()},onPerspectiveEdit:function(){VM.Comments.perspectiveEdit()},perspectiveEdit:function(){this.$perspectiveResultArea.addClass("hidden");this.$descriptionSubmitArea.removeClass("hidden");this.$form.find("input").prop("disabled",!1);VM.scrollTo(this.$form)},perspectivePost:function(){VM.Comments.perspectiveEdit.call(this);this.doSubmit()},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()})}};$(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,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",function(){VM.Comments.perspectiveEdit.call(VM.Candles)}).on("click",".comment-perspective-post",function(){VM.Comments.perspectivePost.call(VM.Candles)}).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(".g-recaptcha").length>0;this.addButton();VM.Ajax.resetValidation(this.$form)},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.submit():(VM.Candles.hasRecaptcha&&grecaptcha.reset(),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(){VM.Comments.checkPerspective(VM.Candles.$name.val()+", "+VM.Candles.$location.val(),function(n){VM.Comments.showPerspectiveMessage.call(VM.Candles,n)||VM.Candles.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({eventCategory:"NTG user",eventAction:"candle added",eventLabel: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()})}}