function bindPostCommentHandler(url) {
    $('#comment_form form input.submit-preview').remove();
    $('#comment_form form').submit(function() {
        $.ajax({
            type: "POST",
            data: $('#comment_form form').serialize(),
            url: url,
            cache: false,
            dataType: "html",
            success: function(html, textStatus) {
                $('#comment_form form').replaceWith('<strong>Thank you for your comment.</strong>');
                bindPostCommentHandler(url);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $('#comment_form form').replaceWith('Your comment was unable to be posted at this time. We apologise for the inconvenience.');
            }
        });
        return false;
    });
}

function saveToMyGames(url) {
 $.ajax({
            type: "GET",
            url: url, 
            cache: false,
            dataType: "html",
            success: function(html, textStatus) {
                $('#add_fav').replaceWith('<strong>Saved to your games.</strong>');
                bindPostCommentHandler(url);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $('#add_fav').replaceWith('Error occured, please try again later');
            }
         });
        return false;
}
