function showAnswerForm(obj) {
    obj.children(".answer-edit-btn").hide();
    obj.children(".add-answer-form").show();
}

function showAnswerEditForm(obj) {
    obj.children("p, h4").hide();
    obj.children(".add-answer-form").show();
}

function hideAnswerForm(obj) {
    obj.children(".add-answer-form").hide();
    obj.children(".answer-edit-btn").show();
}

function hideAnswerEditForm(obj) {
    obj.children(".add-answer-form").hide();
    obj.children("p, h4").show();
}

function submitAnswerForm(obj) {
    if (obj.children("p").children("textarea").val() == "") {
        obj.children(".error").show();
    } else {
        obj.children(".error").hide();
        obj.submit();
    }
}

$(document).ready(function(){
    $(".add-answer-btn").click(function(){
        showAnswerForm($(this).parent().parent());
        return false;
    });

    $(".edit-answer-btn").click(function(){
        showAnswerEditForm($(this).parent().parent());
        return false;
    });
});