(function(n,t,i,r){"use strict";t(function(){t(r).ready(function(){t.Comments=function(i,r){var f={orderAscending:!0},u=this,e=function(){u.options=t.extend({},f,r);u.container=i;u.loaded=!1;u.bindForm()},o=function(){var i=t(".js_CommentLike");i.on("click",function(){var r=t(this),i=r.parents(".comment"),u=t(".js_CommentLikeResponse",i),e=t(".js_CommentLikeCount",i),f=t(".js_CommentLikeText",i),o=parseInt(r.data("comment-id"));return t.ajax("/comments/like",{data:{commentId:o},type:"POST"}).done(function(t){t.success?(e.text(t.count),parseInt(t.count)===1?f.text("Like"):f.text("Likes")):u.html(n.noticeDanger(t.message))}).error(function(){u.html(n.noticeDanger("1There was a problem liking this comment, please refresh and try again."))}),!1})},s=function(){var i=t(".js_CommentReportAbuse"),n=2e3;i.on("click",function(){var e=t(this),h=e.parents(".comment"),i=t(".js_CommentReportAbuseContainer",h),c=parseInt(e.data("comment-id")),r=t("<textarea>").attr("maxLength",n).addClass("form-control").css("margin-bottom","5px"),o=t("<button>").addClass("btn btn-primary").attr("type","button").text("Report Comment").css("margin-right","5px"),s=t("<button>").addClass("btn btn-default btn-sm").attr("type","button").text("Cancel").css("margin-right","5px"),f=t("<span>");f.html(" "+n+" characters remaining");i.html(r).append(o).append(s).append(f);o.on("click",function(){u.postAbuseComment(c,r.val(),i)});s.on("click",function(){i.empty()});r.on("keyup",function(){var i=n-t(this).val().length;f.html(" "+i+" characters remaining")});return!1})},h=function(){var n=t(".js_CommentSort");n.on("change",function(){var n=t(this);return u.options.orderAscending=n.val()==="asc",u.load(),!1})},c=function(){s();o();h()};u.load=function(i){n.ajaxLoader(u.container);var r=u.container.data("id"),f=u.container.data("comment-type");t.ajax("/comments/feed/?id="+r+"&type="+f+"&orderAscending="+u.options.orderAscending,{type:"GET"}).done(function(n){var r=t(n).css("opacity",0);u.container.html(r);c();r.animate({opacity:1},function(){i&&i()})}).error(function(){u.container.html(n.noticeDanger("Comments could not be loaded"))})};u.attach=function(){u.loaded||n.isElementInViewport(u.container)&&(u.loaded=!0,u.load())};u.bindForm=function(){var i=t(".js_CommentForm"),r=t(".js_CommentFormNoticeContainer"),f=t(".js_CommentFormLoader");if(typeof i!="undefined"&&i!=null){t("#Body",i).on("keyup",function(){var n=2e3-t(this).val().length;t("#textCount",i).html(n+" characters remaining")});i.on("submit",function(){if(i.valid()){var e=i.serialize(),o=i.attr("action"),s=t("input:checkbox[name='Notify']",i).is(":checked");i.hide();f.show();t.ajax(o,{data:e,type:"POST"}).done(function(f){f.success?(r.html(n.noticeSuccess(f.message)),i[0].reset(),s&&t("input:checkbox[name='Notify']",i).prop("checked",!0),u.load(function(){var n=t(".comment",u.container).last();t("html, body").animate({scrollTop:n.offset().top},1e3)})):r.html(n.noticeDanger(f.message))}).error(function(t,i){var u="";u=t.status===0?"Not connect.\n Verify Network.":t.status===404?"Requested page not found. [404]":t.status===500?"Could not submit your comment, please remove any html tags":i==="parsererror"?"Requested JSON parse failed.":i==="timeout"?"Time out error.":i==="abort"?"Ajax request aborted.":"There was a problem submitting your comment, please refresh and try again";r.html(n.noticeDanger(u))}).always(function(){f.hide();i.show()})}return!1})}};u.postAbuseComment=function(i,r,u){t.ajax("/comments/report",{data:{commentId:i,abuseCommentText:r},type:"POST"}).done(function(t){t.success?u.html(n.noticeSuccess("Your report has been received and will be reviewed by a member of our team")):u.html(n.noticeDanger(t.message))}).error(function(){u.html(n.noticeDanger("3There was a problem reporting this comment, please try again"))})};e()};n.comments=new t.Comments(t(".comment-feed-container"));typeof n.comments.container!="undefined"&&n.comments.container!=null&&t(i).waitForImages(function(){t(i).on("DOMContentLoaded load resize scroll",n.comments.attach)})})})})(window.framework=window.framework||{},window.jQuery,window,document)