SK.Comments={View:{hideForms:function(){$("#reply-comment").hide().appendTo($("#invisible_section"))},showForm:function(b){SK.Comments.View.hideError();if(b=="comment-0"){}else{$("#reply-comment").show().appendTo($("#"+b+" > .comment_form_target"));if($("#reply-comment").attr("action")==""){var a=$("#reply-comment").attr("rel")}else{var a=$("#reply-comment").attr("action")}$("#reply-comment").attr("action",a.replace(/\/\//,"/"+b.split("-")[1]+"/"));$("#reply-comment").removeAttr("rel")}},showSpinner:function(a){SK.Comments.spinner.prependTo($("#"+a)).show()},hideSpinner:function(){SK.Comments.spinner.appendTo($("#invisible_section")).hide()},displayError:function(b,a){$("#"+b+" > .comment_form_target .error").html(a).show()},hideError:function(){$(".comment_form_target .error").hide()},addChild:function(b,a){if($("#"+b+" > ol.comments").length==0){$("#"+b).append('<ol class="comments"></ol>')}$("#"+b+" > ol.comments").prepend(a);$("#"+b+" > ol.comments > .comment:first > .footer .reply_comment_link").click(stopAnd(SK.Comments.Controller.handleReplyClick))},getElements:function(){SK.Comments.spinner=$("#comment_spinner");SK.Comments.newCommentForm=$("#new-comment");SK.Comments.newCommentLink=$("#new-comment_link")},form:function(a){if(a=="comment-0"){return $("#new-comment")}else{return $("#reply-comment")}}},Controller:{handleReplyClick:function(a){a.preventDefault();var b=$(a.target).parents(".comment").attr("id");SK.Comments.View.showForm(b);$("#reply_comment_content").val("")},handleSuccessFor:function(a){return function(b){if(b.status=="ok"){SK.Comments.View.addChild(a,b.body);SK.Comments.View.hideSpinner();SK.Comments.View.hideError()}else{SK.Comments.View.displayError(a,b.message);SK.Comments.View.hideSpinner()}}},handleErrorFor:function(a){return function(b){SK.Comments.View.displayError(a,"Sorry, there was an unknown error.");SK.Comments.View.hideSpinner()}},handleSubmitForm:function(a){var b;if(a.target.id=="new-comment"){b="comment-0"}else{b=a.target.parentNode.parentNode.id}SK.Comments.Controller.submitForm(b);if(b="comment-0"){$("#new_comment_content").val("");$("#rating").val("");if(SK.rating!=undefined){SK.rating.setRating(null)}}},submitForm:function(b){SK.Comments.View.hideForms();SK.Comments.View.showSpinner(b);var a=SK.Comments.View.form(b);$.ajax({type:"POST",url:a.attr("action"),data:a.serialize(),success:(SK.Comments.Controller.handleSuccessFor(b)),error:(SK.Comments.Controller.handleErrorFor(b)),dataType:"json"})}},init:function(){$(document).ready(function(){SK.Comments.View.hideForms();SK.Comments.View.getElements();$(".reply_comment_link").click(handleLoggedInLink(SK.Comments.Controller.handleReplyClick));$("#cancel_reply_comment_link").click(stopAnd(SK.Comments.View.hideForms));$("#new-comment").submit(stopAnd(SK.Comments.Controller.handleSubmitForm));$("#reply-comment").submit(stopAnd(SK.Comments.Controller.handleSubmitForm))})}};SK.Comments.init();