﻿poll = function(content_id) {
    $.ajax({
        url: "/widget/poll/ajax_poll.ashx" + $.query,
        dataType: "html",        
        success: function(data) {            
            if (data.length > 0 && data != "0") {
                $(content_id).removeClass('hidden');
                $(content_id).html(data);

                $(content_id + " li input," + content_id + " .view-results").click(function(event) {
                    event.preventDefault();
                    poll_action($(".p" + $(this).attr("rel")), $(this).attr("id"), $(this).attr("rel"));
                });
            }            
        },
        error: function(xhr, ajaxOptions, thrownError) {
            //jQuery.facebox(xhr.responseText);
        }
    })
}

poll_action = function(obj, ans_id, poll_id) {
    $.ajax({
        url: "/widget/poll/ajax_poll.ashx" + $.query + "&val=1&ans=" + ans_id + "&pll=" + poll_id,        
        success: function(data, status) {
            if (data.length > 0 && data != "0") {
                $(obj).hide().html(data).fadeIn();
            }            
        },
        error: function(xhr, ajaxOptions, thrownError) {
            //jQuery.facebox(xhr.responseText);
        }
    })
}
