function comments(){var f=false;function j(n){$("#comment-form-auth_code").val(n.auth_code);$("#comment-form-idcaptcha").val(n.id);$("#comment-captcha-image").html('<img src="'+n.url+'" align="top"/>')}function c(){if(f===true){return}f=true;$.post("/captchas/get_captcha",j)}function d(r){var p,q,n,o;$("#comment-form-facebook-id").val(r.id);p=$("#comment-form-name");p.hide();n=r.name;p.val(n);q=$("#comment-userbox");p=$("#comment-profile-link");p.html(n);p.attr("href",r.link);o=$("#comment-profile-pic");o.attr("href",r.link);o.html('<img src="http://graph.facebook.com/'+r.id+'/picture" alt="'+n+'" title="'+n+'" />');q.show();$("#comment-post-to-wall").show()}function g(){FB.getLoginStatus(function(n){if(n.status==="connected"){$("#comments_fb_login").hide();FB.api("/me",d)}else{if(n.status==="not_authorized"){$("#comments_fb_login").show();$("#fb-welcome").hide()}else{$("#comments_fb_login").show();$("#fb-welcome").hide()}}})}function l(){var o=document.getElementById("comment-form-comment"),p=document.getElementById("comment-count"),q=3000,n=q-o.value.length;if(n<=0){o.value=o.value.substr(0,q);n=0}p.innerHTML=n;c()}function h(){$("#comment-status-sending").hide();$("#comment-status-error").show()}function b(p,o){if(!window.fbApiInitDone){return}if(o===undefined){o=false}function n(q){function r(s){b(p,true)}if(!o&&q.error&&q.error.type==="OAuthException"){FB.login(r,{scope:"publish_stream"})}}FB.api("/me/feed","POST",p,n)}function i(n){$("#comment-status-sending").hide();switch(n.status){case"success":$("#comment-status-success").show();$("#comment-form-name").val("");$("#subject").val("");$("#comment-form-comment").val("");$("#comment-form-captchas").val("");if(n.post_to_wall){b({link:n.link,picture:n.picture,message:n.subject,name:n.name,description:n.comment})}break;case"wrong_captchas":$("#comment-status-wrong_captchas").show();c();break;case"subject_needed":$("#comment-status-subject_needed").show();break;default:alert("Unknown error:"+n.status)}}function e(){var q,r,p,n,s=document.getElementById("comment-form");n=$(s).serialize();if(window.fbApiInitDone){p=FB.getAuthResponse();if(p){n=n+"&signed_request="+p.signedRequest}}$.ajax({type:"POST",url:"comment_form.json",data:n,success:i,error:h,dataType:"json"});f=false;function o(t){return true}$("#comment-status span").hide();$("#comment-status-sending").show();$("#comment-status").show()}function k(r){var s,q,o,n,p;n=r.name;o="fb_uid_"+r.id;p=$(".comment-facebook-author.fb_uid_"+r.id);if(r.link===undefined){p.html(n)}else{p.html('<a href="'+r.link+'">'+n+"</a>")}}function a(u){var t,r,o,q,p,s={},n=$(".comment-facebook-author");n.each(function(v){p=this.attr("class").split(" ");for(o=0;o<p.length;o+=1){if(p[o].substr(0,7)==="fb_uid_"){s[p[o].substr(7)]=true;break}}});for(q in s){if(s.hasOwnProperty(q)){FB.api("/"+q,k)}}}function m(){g();a()}if(window.fbApiInitDone){m()}else{$(document).bind("fbApiInitDone",m)}return{post_form:e,update_user:g,handle_comment_keyup:l,maybe_load_captcha:c}}comments=comments();
