var _canPost=false;$(document).ready(function(){$("#btnPost, #btnSearch").buttonify();$("#q").keypress(function(a){if(a.keyCode==13){a.preventDefault();goSearch()}});$("#btnSearch").click(function(a){a.preventDefault();goSearch()});$("#btnPost").click(function(a){a.preventDefault();if(_canPost){post()}});$("[remove]").live("click",function(){remove($(this).attr("remove"))});$("[reply]").click(function(){replyToPost($(this).attr("reply"))});$("#switch-search, #switch-post").click(function(){switchInputs($(this).attr("id").substr(7))})});function init(a,b){_canPost=a>1;if(a==0){$("#divPost").html("<div style='text-align: center; font-size: 14px;'>Please <a href='/login?redirect=/support/community'>login</a> to post</div>")}else{if(a==1){$("#divPost").html("<div style='text-align: center; font-size: 14px;'>Demo users can't post.</div>")}else{if(a==2){}else{if(a==3){$("#divPost").html("<div style='text-align: center; font-size: 14px;'>Please confirm your account.</div>")}}}}$("#q").val(b);switchInputs("search")}function switchInputs(a){if(a=="post"){$("#divSearch").hide();$("#divPost").show();$("#switch-post").addClass("community-tab-selected");$("#switch-search").removeClass("community-tab-selected")}else{$("#divSearch").show();$("#divPost").hide();$("#switch-post").removeClass("community-tab-selected");$("#switch-search").addClass("community-tab-selected")}}function goSearch(){window.location.href="?q="+$("#q").val()}function post(){var a=$("#txtPost");if(a.val()!=""){a.attr("disabled",true);$.buttonify.wait("btnPost","Posting");$.ajax({type:"POST",url:"/handlers/community.ashx",data:{action:"post",post:encodeURIComponent(a.val())},dataType:"json",success:function(b){if(b.successful){addDiv(b);$("#txtPost").val("")}else{var c="We're unable to post this. Please try again later";if(b.error){c=b.error}alert(c)}if(b.errorcode==1){$("#btnPost").buttonify.disable("btnPost","Post");$("#txtPost").val("")}else{$.buttonify.enable("btnPost");a.attr("disabled",false)}},error:function(){a.attr("disabled",false);$.buttonify.enable("btnPost");alert("An error has occured. Please try again")}})}else{}}function remove(a){if(confirm("Are you sure you want to remove this post?")){$.ajax({type:"POST",url:"/handlers/community.ashx",data:{action:"remove",id:a},dataType:"json",success:function(b){if(b.successful){$("#post_"+a).slideUp(300)}else{}},error:function(){}})}}function replyToPost(a){$("#txtPost").val($("#txtPost").val()+"@"+a+" ").focus();switchInputs("post")}function addDiv(a){$("#posts").prepend("<div id='post_"+a.id+"' class='community_ownpost community_main' style='display: none;'><div class='community_post'><img src='http://www.gravatar.com/avatar/"+a.gravatar+"?d=http://www.appfigures.com/images/pixel.gif&s=35' align='right' style='margin-left: 10px;'><b>"+a.name+"</b> "+$("#txtPost").val()+"</div><div class='community_date'><span class='remove-post' remove='"+a.id+"'>Remove</span> | "+a.timestamp+"</div><div class='community_div'></div></div>");$("#post_"+a.id).slideDown(350)};
