function FlagComment(n,t){var i='{ "identifier":  "'+t+'" }';$.ajax({cache:!1,type:"POST",url:"/Comment/FlagComment/",data:i,contentType:"application/json",timeout:2e4,dataType:"json",success:function(){$("#"+n).html("<span>Flagged<\/span>")},error:function(){$("#"+n).html("Unavailable")}})}function PageComments(n){$(".pager").hide();$("#comment-list").html("");$("#comment-list").append("<div class='loading'><h2>Loading comments .... <\/h2><\/div>");$("#pg").val(n);$.ajax({cache:!1,type:"POST",url:"/Comment/Comments/",data:JSON.stringify({cId:$("#cId").val(),pageIndex:n,sortDir:$("#sortcomments").val()}),contentType:"application/json; charset=utf-8",dataType:"html",success:function(n){$("#comment-control").html(n)},error:function(){$("#comment-control").html("Unavailable")}});$.scrollTo("#comment-control")}function ReplyButton(n){$("#replydiv-"+n).toggle()}function SaveComment(){$("#txtcomment").val()!=""&&($(".your-comment").append("<div class='loading'><\/div>"),$.ajax({cache:!1,type:"POST",url:"/Comment/Comment",data:JSON.stringify({cId:$("#cId").val(),body:$("#txtcomment").val(),parentId:"",threadLevel:"",pageIndex:$("#pg").val(),contentTypeId:$("#cType").val(),contenturltitle:$("#cUrl").val()}),contentType:"application/json; charset=utf-8",dataType:"html",success:function(n){if(n!=""){var t=$(".number").html();$(".number").html(parseInt(t,10)+1);$(".loading").remove();$(".bad").remove();$("#txtcomment").val("");$(n).prependTo($("#comment-list")).show("slow")}else $(".loading").remove(),$(".bad").remove(),$(".your-comment").append("<p class='bad'>Inappropriate language please remove before trying to post again...<\/p>")},error:function(){return"Unavailable please refresh the page..."}}))}function ReplyComment2(n,t,i){$("#txtcomment-"+n).val()!=""&&($("#replydiv-").append("<div class='loading'><\/div>"),$.ajax({cache:!1,type:"POST",url:"/Comment/Comment",data:JSON.stringify({cId:$("#cId").val(),body:$("#txtcomment-"+n).val(),parentId:t,threadLevel:i,pageIndex:$("#pg").val(),contentTypeId:$("#cType").val(),contenturltitle:$("#cUrl").val()}),contentType:"application/json; charset=utf-8",dataType:"html",success:function(t){t!=""?($("#txtcomment-"+n).val(""),$(t).prependTo($("#comment-list")).show("slow")):($(".loading").remove(),$(".bad").remove(),$("#replydiv-"+n).append("<p class='bad'>Inappropriate language please remove before trying to post again...<\/p>"))},error:function(){return"Unavailable please refresh the page..."}}))}function ReplyComment(n,t,i){$("#txtcomment-"+n).val()!=""&&($("#replydiv-").append("<div class='loading'><\/div>"),$.ajax({cache:!1,type:"POST",url:"/Comment/Comment",data:JSON.stringify({cId:$("#cId").val(),body:$("#txtcomment-"+n).val(),parentId:t,threadLevel:i,pageIndex:$("#pg").val(),contentTypeId:$("#cType").val(),contenturltitle:$("#cUrl").val()}),contentType:"application/json; charset=utf-8",dataType:"html",success:function(t){if(t!=""){$("#comment-"+n).after(t);var i=$(".number").html();$(".number").html(parseInt(i,10)+1);$("#txtcomment-"+n).html();$("#replydiv-"+n).hide();$(".loading").remove();$(".bad").remove()}else $(".loading").remove(),$(".bad").remove(),$("#replydiv-"+n).append("<p class='bad'>Inappropriate language please remove before trying to post again...<\/p>")},error:function(){return"Unavailable please refresh the page..."}}))}function pageMethod(n,t,i,r,u){$.ajax({cache:!1,type:"POST",url:(u?u:window.location)+"/"+n,data:t?JSON.stringify(t):"{}",contentType:"application/json; charset=utf-8",dataType:"json",success:function(n){$("#comment-control").html(n)},error:function(){$("#comment-control").html("Unavailable")}})}function sortComments(){$("#comment-list").html("");$("#comment-list").append("<div class='loading'><h2>Loading comments .... <\/h2><\/div>");$.ajax({cache:!1,type:"POST",url:"/Comment/Comments/",data:JSON.stringify({cId:$("#cId").val(),pageIndex:1,sortDir:$("#sortcomments").val()}),contentType:"application/json; charset=utf-8",dataType:"html",success:function(n){$("#comment-control").html(n)},error:function(){$("#comment-control").html("Unavailable")}})}function isValidEmail(n){var t=new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);return t.test(n)}jQuery(document).ready(function(){function s(n){return n.indexOf("townhall.com")>-1?"http://"+n:"http://townhall.com"}function h(n){return n.replace(new RegExp("/d/$","i"))}var u=jQuery(".th-sharecounts"),n={Domain:document.domain,Url:u.data("url")||h(document.URL),Title:jQuery('meta[property="og:title"]').attr("content")||document.title},r=s(n.Domain),l=r,t={};jQuery.post(r+"/api/counts/articleview",n).done(function(r){t=r;c(t,u);jQuery(".sc-fb").hover(function(){jQuery(this).unbind("mouseenter mouseleave");jQuery.getJSON("http://graph.facebook.com/"+n.Url).done(function(r){var u=r.shares,e=0,o;t!=null&&(e=i(t.ShareCount,"Facebook"));u!==e&&(o={Url:n.Url,Domain:n.Domain,Title:n.Title,ShareCount:[{Type:"Facebook",Count:u,Css:"sc-fb"}]},f(o))})});jQuery(".sc-tw").hover(function(){jQuery(this).unbind("mouseenter mouseleave");jQuery.ajax({url:"http://cdn.api.twitter.com/1/urls/count.json?url="+n.Url,dataType:"jsonp"}).done(function(r){var u=0,e=r.count,o;t!=null&&(u=i(t.ShareCount,"Twitter"));e!==u&&(o={Url:n.Url,Domain:n.Domain,Title:n.Title,ShareCount:[{Type:"Twitter",Count:e,Css:"sc-tw"}]},f(o))})})});jQuery(".sc-fb").click(function(t){t.preventDefault();var i="http://www.facebook.com/sharer.php?u="+n.Url,r=window.screen.height/2-218,u=window.screen.width/2-313;window.open(i,"sharer","toolbar=0,status=0,width=626,height=436,top="+r+",left="+u)});jQuery(".sc-tw").click(function(t){t.preventDefault();var i=window.screen.height/2-218,r=window.screen.width/2-313,u="https://twitter.com/intent/tweet?text="+encodeURIComponent(n.Title)+"&url="+n.Url;window.open(u,"sharer","toolbar=0,status=0,width=626,height=436,top="+i+",left="+r)});var c=function(n,r){var u=0,h=0,f=0,o,s;n!=null&&(u=i(t.ShareCount,"Facebook")||0,h=i(t.ShareCount,"Twitter")||0,f=u+h,o=r.find(".sc-fb-count i"),s=r.find(".sc-counts span"),o.html(e(u,0,!1,!1)),s.html(e(f,0,!1,!1)),u>0&&o.parent().show(),f>1&&s.parent().show())},f=function(n){var t=r+"/api/counts/update";jQuery.post(t,n)},i=function(n,t){var i,r;if(n!=null)for(i=0;i<n.length;i++)if(r=n[i],r.Type===t)return r.Count},e=function(n,t,i,r){if(n=Number(n),r=r||!1,r!==!1)return o(n,t,i,r);var u;return u=n>=1e12?"T":n>=1e9?"B":n>=1e6?"M":n>=1e3?"K":"",o(n,t,i,u)},o=function(n,t,i,r){var u=0,f;switch(r){case"T":u=n/1e12;break;case"B":u=n/1e9;break;case"M":u=n/1e6;break;case"K":u=n/1e3;break;case"":u=n}return t!==!1&&(f=new RegExp("\\.\\d{"+(t+1)+",}$"),f.test(""+u)&&(u=u.toFixed(t))),i!==!1&&(u=Number(u).toFixed(i)),u+r}}),function(n){n.fn.feelings=function(t){function r(n){var t="themotion.";return t+n.replace(/[^a-z0-9]/gi,"")}function u(t,i){n.cookie(t,i,{expires:1,path:"/"})}function f(t){return n.cookie(t)===null?!0:!1}var i={};return n.extend(i,this.feelings.defaults,t),this.each(function(){var e=n(this),t=r(i.url);e.load("/mservices/widgets/feelingswidget",{url:i.url,version:i.version},function(){n(i.button).click(function(){var o=n(this),r=o.data("emotionid"),e=n(".feelings-thankyou");f(t)?n.post("/mservices/widgets/feelingswidgetupdate",{id:r,url:i.url},function(){var i=n("#"+r+"-lnk"),f=parseInt(i.html());i.html(f+1);u(t,r);e.css("display","block").html("Thank you for voting")}):e.css("display","block").html("You have already voted").hide().fadeIn("slow")})})})};n.fn.feelings.defaults={button:".feelings-btn-emotion",url:window.location.href,version:1}}(jQuery);$(document).ready(function(){var n=$("#cId").val(),t;$("#th-comments").on("click",".comment-alert a",function(){location.reload()});$("#th-comments").load("/comment/comments",{cId:n},function(){var n=$(".commentCount .number").html();$(".comment-count span").html(n)});$("#th-comments").on("click",".show-comments",function(n){var t=$(n.target);return t.parent().parent().next().toggle(),t.html(t.html()=="There are more comments on this thread. Click Here To See them All"?"Click here to hide extended comments":"There are More Comments on this Thread. Click Here To See them All"),!1});t=setInterval(function(){var i=$(".number").html();$.ajax({cache:!1,type:"POST",url:"/Comment/CommentCount/",data:JSON.stringify({cId:n,commentCountPage:i}),contentType:"application/json",timeout:2e4,dataType:"html",success:function(n){var t=n;t>0?($(".comment-alert").show(),$(".comment-refresh").html(t)):$(".comment-alert").hide()},error:function(){clearInterval(t);$(".comment-alert").html("Unavailable")}})},6e4)});$(function(){$("#float-actions-bar").affix({offset:{top:$("#float-actions-bar").offset().top}})});var thBaseUrl="http://townhall.com";window.location.href.indexOf("dev.")>-1&&(thBaseUrl="http://dev.townhall.com");jQuery(function(){CapturatorLoader()});CapturatorLoader=function(){jQuery(".capturator-main-container").each(function(){Capturator();Capturator.container=jQuery(this);Capturator.capturatorInfo.systemObjectId=Capturator.container.data("soid");Capturator.capturatorInfo.systemObjectType=Capturator.container.data("sot");Capturator.container.data("pos")!=undefined&&(Capturator.capturatorInfo.position=Capturator.container.data("pos"));Capturator.getCookie();Capturator.getMe(Capturator.container);Capturator.container.on("click","a.submit-capturator",function(n){Capturator.submitMe(n)})})};Capturator=function(){Capturator.getCookie=function(){var t=jQuery.cookie("th-cap-offer"),n;t!=undefined&&(n=jQuery.parseJSON(t),this.capturatorInfo.userId=n.userId,this.capturatorInfo.email=n.email,this.capturatorInfo.offersSeen=n.offersSeen)};Capturator.setCookie=function(){jQuery.cookie("th-cap-offer",JSON.stringify(this.capturatorInfo),{expires:365,path:"/"})};Capturator.getMe=function(n){var t=this;n.load(thBaseUrl+"/mservices/capturator/get",jQuery.postifyMe(t.capturatorInfo),function(i,r,u){var f,e;if(r!="error"&&u.status!=400){var s=n.find(".cap-offer-id").val(),o=t.capturatorInfo.offersSeen,h=!0;for(f=0;f<o.length;f++)o[f].offerId==s&&(h=!1,o[f].seenCount++);h&&(e=t.userOfferInfo,e.offerId=s,e.seenCount=1,t.capturatorInfo.offersSeen.push(e));t.setCookie(t.capturatorInfo);jQuery.get(thBaseUrl+"/mservices/kpi/action",{title:n.find(".cap-name").val(),url:t.capturatorInfo.url,act:"8",tlist:null})}})};Capturator.submitMe=function(n){var i=this,t=jQuery(n.currentTarget).parentsUntil(".capturator-main-container"),r=t.find(".email-address-capturator").val();isValidEmail(r)?jQuery.post(thBaseUrl+"/mservices/capturator/vote",t.serialize()).done(function(n){n.IsSuccess&&(i.capturatorInfo.userId=n.UserId,i.capturatorInfo.email=r,i.setCookie(),jQuery.get(thBaseUrl+"/mservices/kpi/action",{title:t.find(".cap-name").val(),url:i.capturatorInfo.url,act:"9",tlist:null}),t.find(".capturator-thankyou").show(),t.find(".capturator-form").hide(),t.find(".capturator-disclaimer").hide())}):alert("Please enter a valid email address")};Capturator.container="";Capturator.capturatorInfo={userId:0,email:"",domain:location.hostname,url:location.href,offersSeen:[],systemObjectId:0,systemObjectType:"",position:""};Capturator.userOfferInfo={offerId:0,seenCount:0};Capturator.position={bodyLarge:1,bodySmall:2,sidebar:3}};jQuery.postifyMe=function(n){var t={},i=function(n,r){var u,f;for(u in n){f=isFinite(u)?(r!=""?r:"")+"["+u+"]":(r!=""?r+".":"")+u;switch(typeof n[u]){case"number":case"string":case"boolean":t[f]=n[u];break;case"object":n[u].toUTCString?t[f]=n[u].toUTCString().replace("UTC","GMT"):i(n[u],f!=""?f:u)}}};return i(n,""),t}