function loadComments()
{
    var videoId = $("#video_id").val();
    var comment = $("#comment").val();

    if(comment =="")
    {
        alert("Please Enter A Comment.");
        return;
    }
    $("#comment_area").html('<img src="/comment_system/img/ajax-loader.gif" border="0" alt="wait"/>');
    $.ajax({
        type: "POST",
        cache: false,
        url : "comment_system/episode_comments_results.php",
        data: "video_id="+videoId+"&comment="+comment,
        success : function (data) {
            if(data=="")
            {
                alert("broken");
                return;
            }

            $("#comment_area").html(data);
            $("#comment").val("");
        }
    });
}
function loadCommentsReply(reply_id)
{
    var videoId = $("#video_id").val();
    var member_link = $("#member_link").html();
    var comment = member_link + "      " + $("#reply").val();

    if(comment =="")
    {
        alert("Please Enter A Comment.");
        return;
    }

    if($("#reply").val().length >500)
    {
        alert("You have over 500 characters.");
        return;
    }
    $("#comment_area").html('<img src="/comment_system/img/ajax-loader.gif" border="0" alt="wait"/>');
    $.ajax({
        type: "POST",
        cache: false,
        url : "comment_system/episode_comments_results.php",
        data: "video_id="+videoId+"&comment="+comment,
        success : function (data) {
            if(data=="")
            {
                alert("broken");
                return;
            }
            
            $('html, body').animate({
            scrollTop: $("#comment").offset().top
            }, 200);

            $("#comment_area").html(data);
            tooltip();
            $("#comment").val("");
        }
    });
}
function replyComment(member_id, comment_id)
{
    $("#reply_area"+comment_id).html('<img src="/comment_system/img/ajax-loader.gif" border="0" alt="wait"/>');
    $.ajax({
        type: "POST",
        cache: false,
        url : "comment_system/reply_comment.php",
        data: "member_id="+member_id + "&comment_id="+comment_id,
        success : function (data) {
            if(data=="")
            {
                alert("broken");
                return;
            }

            $("#reply_area"+comment_id).html(data);
            $('html, body').animate({
                scrollTop: $("#comment_set"+comment_id).offset().top
            }, 200);
$("#reply").focus();
        }
    });
}

function enterLikeCount(comment_id, member_id)
{
    var videoId = $("#video_id").val();
    $("#comment_set"+comment_id).html('<img src="/comment_system/img/ajax-loader.gif" border="0" alt="wait"/>');
    $.ajax({
        type: "POST",
        cache: false,
        url : "comment_system/episode_like_count.php",
        data: "comment_id="+comment_id+"&member_id="+member_id + "&video_id=" + videoId,
        success : function (data) {
            if(data=="")
            {
                alert("broken");
                return;
            }

            $("#comment_area").html(data);
            $("#tooltip").remove();
            tooltip();
        }
    });
}

function deleteComment(delId)
{
    var delete_it = confirm("Are you sure you want to delete this comment?");

    if(delete_it)
    {
        $("#comment_set"+delId).html('<img src="/comment_system/img/ajax-loader.gif" border="0" alt="wait"/>');
        var videoId = $("#video_id").val();
        $.ajax({
            type: "POST",
            cache: false,
            url : "comment_system/delete_comment.php",
            data: "del_id="+delId + "&video_id=" + videoId,
            success : function (data) {
                if(data=="")
                {
                    alert("broken");
                    return;
                }

                $("#comment_area").html(data);
                $("#tooltip").remove();
                tooltip();
            }
        });
    }
}

function deleteReportedComment(delId)
{
    var delete_it = confirm("Are you sure you want to delete this comment?");

    if(delete_it)
    {
        var videoId = $("#video_id").val();
        $.ajax({
            type: "POST",
            cache: false,
            url : "comment_system/delete_comment.php",
            data: "del_id="+delId + "&video_id=" + videoId,
            success : function (data) {
                if(data=="")
                {
                    alert("broken");
                    return;
                }
                $("#reported_comment").html("Comment Deleted."+data);
            }
        });
    }
}

function reportComment(comment_id)
{
    var report_it = confirm("Are you sure you want to report this comment?");

    if(report_it)
    {
        $.ajax({
            type: "POST",
            cache: false,
            url : "comment_system/report_comment.php",
            data: "comment_id="+comment_id,
            success : function (data) {
                if(data=="")
                {
                    alert("This comment has been reported.");
                    return;
                }
            }
        });
    }
}
