$(function() {
    $("#commentloader").hide();
    $("#captchaloader").hide();
    $("#commentsubmit").click(function()
    {
        $("#geenreacties").hide();
        $(".error").fadeOut();
        var dataString = $("#comment").serialize();
        $("#commentloader").fadeIn();
        $.ajax({
            type: "POST",
            url: "/_nieuws/plaatscomment.php",
            data: dataString,
            cache: false,
            success: function(html){
                $("ul#update").append(html);
                $("ul#update li:last").fadeIn("slow");
                $("#commentloader").hide();
                $(".loader").hide();
                $(".ajax-fc-container").captcha({formId: "comment"});
            }
        });
        return false;
    });
    $(".reply").hide();
    $("#reagerenform").hide();
    $("#comment input, #comment textarea").focus(function() { $(".reply").html(" "); });
    $("#reageerknop").hide();
    $(".loader").hide();
    $("#reageerknop").click(function() {
        $(".reply").hide();
        $(".reply").html(" ");
        $(".ajax-fc-container").captcha({formId: "comment"});
        $("#reageerknop").hide();
        $("#comment").fadeIn();
    });

});

function reageer(id) {
    form = $("#reagerenform").html();
    $("#comment").hide();
    $(".reply").hide();
    $("#reageerknop").fadeIn();
    $(".reply").html(" ");
    $("#reply_"+id).html(form);
    $("#reply_"+id+" .submit").append("<input type=\"hidden\" name=\"reply\" value=\""+id+"\" /><div class=\"clearboth\"></div>");
    $("#reply_"+id+" .ajax-fc-container").captcha({formId: "reply_"+id});
    $("#reply_"+id).fadeIn();


    return false;
}

function submitReply(id) {
    var dataString = $("#reply_"+id).serialize();
    $(".error").fadeOut();
    $(".error").remove();
    $("#loader_"+id).fadeIn();
    $.ajax({
        type: "POST",
        url: "/_nieuws/plaatscomment.php",
        data: dataString,
        cache: false,
        success: function(html){
            $("ul#update_"+id).append(html);
            $("ul#update_"+id+" li:last").fadeIn("slow");
            $("#loader_"+id+" ").hide();
            $(".ajax-fc-container").captcha({formId: "comment"});
            if($(".error").length == 0) {
                $(".reply").hide(" ");
                $(".reply").html(" ");
            }
        }
    });
    return false;
}


