var commentType=null;function show(e,a,f,g,j,h){g=parseInt(g);commentType=j;$("#message_"+g).html("");if(g!=0){$("#message_reason_"+g).html("")}display("div_",g);var i=$("#loggedin_"+g);var b=$("#barred_"+g);if(e!=""){if((f&4)==4){i.show();b.hide()}else{i.hide();b.show()}}else{i.show();b.hide()}var k=$("#share_"+g);var d=$("#postFb_"+g);var l=$("#postTwitter_"+g);var c=$("#postComment_"+g+" > span");if(j=="post"){k.show();d.prop("checked",true);l.prop("checked",true);c.html("Post Comment");if(h){location.hash="#comment_"+g}if(e!=""&&a==""){$("#screenNameFieldSet_"+g).show()}}else{if(j=="reply"){$("#emailFieldSet_"+g).hide();$("#captchaTextFieldSet_"+g).hide();$("#captchaImgFieldSet_"+g).hide();k.show();d.prop("checked",true);l.prop("checked",true);c.html("Post Comment");if(e!=""&&a==""){$("#screenNameFieldSet_"+g).show()}}else{if(j=="abuse"){i.show();k.hide();d.prop("checked",false);l.prop("checked",false);c.html("Report");$("#screenNameFieldSet_"+g).hide();var n="Thank you for reporting abuse.";var m=$("#p_"+g);if(e!=""){m.html(n)}else{m.html(n+" We require you to enter the below verification code and your working email address - not for publication, but for verification.");$("#emailFieldSet_"+g).show();$("#captchaTextFieldSet_"+g).show();$("#captchaImgFieldSet_"+g).show()}}}}return false}function hide(c,a){var b=$("#"+c+a).hide();commentType=null}function validateCommentsForm(f,a,g,c,i,e,k){if(i!=0){$("#message_reason_"+i).html("")}var l=$("#message_"+i);l.html("");var d=$("#replyForm_"+i+" #comment");var h=d.val();if(h==""||h=="Start typing your comments here.."){l.html("Please enter your comments.");return false}if(commentType=="reply"){if(a==""){postComment(e,k,g,c,d,i,$("#"+form.id+" #screenName").val())}else{postComment(e,k,g,c,d,i)}}else{if(commentType=="abuse"){var b=$("#replyForm_"+i+" #emailId").val();var j=$("#replyForm_"+i+" #captcha").val();if(f==""){if(b==""||!validateEmail(b)){l.html("Invalid Email Address! Please re-enter.");return false}if(j==""){l.html("Please enter the Verification code. By entering this code, you help TennisEarth.com prevent spam and fake abuse reportings.");return false}}reportAbuse(i,(b?b:""),(j?j:""),d)}}return false}function postComment(e,h,f,d,g,c,b){var i=null;if(c&&c!=0){i=$("#message_"+c);$("#message_reason_"+c).html("")}else{i=$("#message_0")}i.html("");if(g.val()==""||g.val()=="Start typing your comments here.."){i.html("Please enter your comments.");return false}if(isLoggedIn()){if(b!=undefined&&(b==""||!validateScreenName(b))){i.html("Your Screen Name is invalid.");return false}var a="/ajax/addComment.htm?commentableId="+f+"&commentableType="+d+"&screenName="+(b?b:"")+"&comment="+encodeURIComponent(g.val())+"&parentCommentId="+(c?c:"")+"&postFb="+e+"&postTwitter="+h;$.get(a,function(j){g.val("");if(c){hide("div_",c)}else{hide("div_",0)}i.html("Thank you for your comments. They will appear once reviewed.");readJSONResponse(j);return false})}else{return $(".requireLogin:first").attr("href",location.href.replace(/(#.*)?$/,"?comment="+encodeURIComponent(g.val())+"&parentCommentId="+(c?c:"")+"&postFb="+e+"&postTwitter="+h)).click()}return false}function readJSONResponse(data){if(data==null||data.length==0){return}var json=eval("("+data+")");if(json.fbSuccess==null||json.fbSuccess=="false"){FB.ui({method:"feed",name:"TennisEarth Comments",caption:"TennisEarth Comment",description:"",message:json.fbComment+json.fbLink},function(response){if(response&&response.post_id){}else{}if(json.twitterSuccess==null||json.twitterSuccess=="false"){postToTwitter(json)}})}if(json.fbSuccess!=null&&json.fbSuccess=="true"&&(json.twitterSuccess==null||json.twitterSuccess=="false")){postToTwitter(json)}}function postToTwitter(a){$("#tweetBox").html("");twttr.anywhere(function(b){b("#tweetBox").tweetBox({label:"Share your comment on Twitter",defaultContent:a.twitterComment+a.twitterLink,onTweet:function(){$("#tweetBoxParent").hide()}})});$("#tweetBoxParent").show()}function openTwitterWindow(a){window.open("http://www.pageresource.com/jscript/jex5.htm","_blank")}function rateComment(a,b){$.get("/ajax/rateComment.htm?commentId="+a+"&type="+b,function(c){$("#span_"+a+"_"+b).html("("+c+")");return false})}function setStatus(d,b,a){var g=$("#message_"+d);if(g){g.html("")}var e=$("#message_reason_"+d);e.html("");if(b==a){hide("div_reason_",d);e.html("The comment has been Published.");return false}var f;if(a==0){f=$("#reasonForm_"+d+" #reason").val();if(f==""){e.html("Please enter a reason for rejection.");return false}}var c="/ajax/setCommentStatus.htm?commentId="+d+"&status="+a+(a==0?"&reason="+encodeURIComponent(f):"");$.get(c,function(i){hide("div_reason_",d);$("#status_"+d).val(a);$("#reasonForm_"+d+" #status").val(a);checkStatus(d,a);var h="The comment has been successfully";if(a==0){e.html(h+" Rejected.")}else{if(a==2){e.html(h+" Published.")}}});return false}function openRejectBox(d,b,a){var c=$("#message_reason_"+b);if(a==0){c.html("The comment has been Rejected.")}else{var e=$("#message_"+b);if(e){e.html("")}c.html("");display(d,b)}}function reportAbuse(d,c,b,a){$("#message_reason_"+d).html("");var e=$("#message_"+d);url="/ajax/reportCommentAbuse.htm?commentId="+d+"&emailId="+encodeURIComponent(c)+"&captcha="+encodeURIComponent(b)+"&abuseDesc="+encodeURIComponent(a.val());$.getJSON(url,function(f){e.html(f.message);if(f.error=="false"){hide("div_",d);a.val("");$("#share_"+d).show();$("#postFb_"+d).prop("checked",true);$("#postTwitter_"+d).prop("checked",true);$("#postComment_"+d).html("Post Comment")}return false})}function getCommentsLoginDestination(a){return location.href.replace(/(#.*)?$/,"#comment_"+a)+"?type="+(commentType!=null?commentType:"")}function submitFilters(c,e,d,b){var a;$("#viewForm input[name=viewType]").each(function(){if($("#"+this.id).is(":checked")){a=this.value}});location.href=TE_HOME+"/comments/getUserComments.htm?viewType="+a+(b!=null&&(b!=""||b==0||b=="0")?"&status="+b:"")+(e?"&commentableId="+e:"")+(d?"&commentableType="+d:"")+(c?"&isAdmin="+c:"")}function checkStatus(b,a){if(a==0){$("#review_reject_"+b).attr("checked",true)}if(a==2){$("#review_publish_"+b).attr("checked",true)}}function paginationComments(a,e,g,f,d,b){var c="/comments/getComments.htm?pageN="+e+"&view=ajax&nav="+g+"&commentableId="+f+"&commentableType="+d+"&isAdmin="+b;$.get(c,function(h){$("#"+a).html(h)})}function paginationFullCommentsByTime(g,i,a,f,c,e,d,h){var b="/comments/getUserComments.htm?pageN="+i+"&view=ajax&nav="+a+"&commentableId="+f+"&viewType="+e+"&status="+d+"&commentableType="+c+"&isAdmin="+h;$.get(b,function(j){$("#"+g).html(j)})};
