$(document).ready(function(){
    $(".poll_form").each(function(){
        $(this).after($("<div></div>").addClass("poll_result formsection"));});
    if($(".poll_answered")!="undefined" && $(".poll_answered").val()=="yes"){
        var form = $(".poll_answered").parent();
        $.ajax({
                url: form.attr("action"),
                async: false,
                data: {show_results:true, formId:$(".poll_answered").next("input").val()},
                type: "POST",
                success: function(data){
                    form.parent().hide();
                    form.parent().next(".poll_result").html(data).show();
                }
            });
    }
    $(".nostyle").click(function(){
        var form = $(this).parent("form");
        if (form.attr("action").indexOf("savepoll.php")>-1) {
            $.ajax({
                url: form.attr("action"),
                async: false,
                data: form.serialize(),
                type: "POST",
                success: function(data){
                    form.parent().hide();
                    form.parent().next(".poll_result").html(data).show();
                }
            });
            return false;
        }
    });
});

