$(document).ready(function() { 
    $("#comment_complete").hide();
    $("#embed_comment_form").hide();
    $("#become_friend_link").hide();
});

function show_embed_comment_form() {
    $('#embed_link').hide();
    $('#embed_comment_form').show();
}

function show_become_friend_link() {
    //$('#embed_link').hide();
    alert("To post an embed comment,\n you need to be signed in and a friend of this user");
    //$('#become_friend_link').show();
}

function submit_embed_comment(profile_user_id, body) {
    $.post("/users/embed_comment",
    { body: body, profile_user_id: profile_user_id },
    function(data) {
     if (data == "LOGINREQUIRED") alert("Login is required.");
     else if (data == "INVALIDINPUT") alert("You should enter only embeded code supplied by supported sites");
     else {
              $("#comment_complete").show();
              $("#embed_comment_form").hide();
          }
    });
}

function delete_embed_comment(comment_id, comment_link)
{
	if (confirm('Are you sure you want to delete the comment?'))
        {
                $.post("/users/delete_embed_comment",
                { comment_id: comment_id },
                function(data) {
                    if (data == "LOGINREQUIRED") alert("Login is required.");
                    else if (data == "INVALIDPRODUCTID") alert("Invalid comment ID.");
                    else if (data == "DOESNTEXIST") alert("Comment doesnt exist.");
                    else if (data == "DOESNTBELONGTOYOU") alert("Comment doesnt belong to you.");
                    else { 
                        $(comment_link.parentNode).fadeOut("slow");
                        alert('Comment deleted successfully.')
                    }
                }
                );
        } return false;
}