var idthis={answers_start:0,answers_limit:10,answers_stop:false,identified:false,apikey:"8d3b165318535b969b1282bde9aaf179",load:function(identified){if(identified){idthis.identified=true;idthis.loadAnswers("/api/recent_answers_wins/")}else{idthis.photos.load("/api/recent_photos_user/",{user:idthis.username});idthis.loadAnswers("/api/recent_answers_user/")}},loadAnswers:function(api){opts={apikey:idthis.apikey,start:idthis.answers_start,limit:idthis.answers_limit};if(!idthis.identified){opts.user=idthis.username}$.getJSON(api,opts,idthis.showAnswers)},userDetails:function(user){window.location="/user/"+user.username+"/"},showAnswers:function(data){$("#answers").empty();if(data.length){$.each(data,function(){var score=this["upvote"]-this["downvote"];var scoremsg=(score==1)?"1 vote":score+" votes";var id="answer"+this["id"];var aid=this["id"];var ans=$("#answer").clone();ans.attr("id",id);ans.appendTo($("#answers"));$("#"+id+" .answerscore").html(scoremsg);$("#"+id+" .answerscore").attr("id","score"+aid);$("#"+id+" .answerscore").attr("score",score);$("#"+id+" .answerbody").html(this["answer"]);$("#"+id+" .answerphoto").html('<a href="/id/'+this["photo"]["id"]+'/"><img src="http://static.idthis.org/'+this["photo"]["small"]+'"></a>');$("#"+id+" .answercomments").html(this["comments"]+" comment"+((this["comments"]!=1)?"s":""));if(idthis.identified){var user=this["user"];if(user.username=="anonymous"){$("#"+id+" .answeruser").html(this["user"]["username"]);$("#"+id+" .answeruser").css("color","#494949")}else{$("#"+id+" .answeruser").html(this["user"]["username"]+" ("+this["user"]["wins"]+")");$("#"+id+" .answeruser").css("cursor","pointer");$("#"+id+" .answeruser").bind("click",function(){idthis.userDetails(user)})}}if(this["winner"]){$("#"+id+" .answerwin").show()}ans.show()});if(data.length<idthis.answers_limit){idthis.answers_stop=true;$("#aforward").hide()}}else{idthis.answers_stop=true;$("#aforward").hide();if(idthis.answers_start==0){$("#answers").html("<h2>no answers.</h2>")}}},refreshAnswers:function(forward){if(forward&&idthis.answers_stop){return}if(forward){idthis.answers_start+=idthis.answers_limit}else{idthis.answers_start-=idthis.answers_limit}if(idthis.answers_start<0){idthis.answers_start=0}if(idthis.answers_start>0){$("#aback").show()}else{$("#aback").hide();$("#aforward").show();idthis.answers_stop=false}window.location.hash="answerstop";idthis.load(idthis.identified)}};