var wp_poll_loading_image_object;
function wp_poll_get_results(results) {
  Effect.Fade(wp_poll_loading_image_object);
}

function wp_poll_submit_poll(form) {
  voted = $('is_already_voted');
  if (voted.value == '1') {
    if (!confirm("あなたは既に投票しています。以前の投票を無効にして新たに投票しなおしますか?")) {
      return false;
    }
  }
  voted.setAttribute('value', '1');
  var id;
  if (r = form.id.match(/_([0-9]+)$/)) {
    id = r[1];
    img_id = 'loading_image_' + id;
    wp_poll_loading_image_object = $(img_id);
    wp_poll_loading_image_object.style.visibility = "visible";
    Effect.Appear(wp_poll_loading_image_object);
  }
  // ajax.post("index.php?ajax=true&user=true", wp_poll_get_results, ajax.serialize(form));
  new Ajax.Request(
    "index.php",
    {
      "metod": "get",
      "parameters": Form.serialize(form) + "&ajax=true&user=true",
      onComplete: wp_poll_get_results,
      onSuccess: function (results) {
        var f = $$('form.vote_submit');
        for (var i = 0; i < f.length; i++) {
          // f[i].style.display = 'none';
          // Effect.SwitchOff(f[i]);
          Effect.Puff(f[i]);
        }
        Effect.Appear('thanks_message_' + id);
        wp_poll_get_results(results);
      },
      onFailure: wp_poll_get_results,
      onException: wp_poll_get_results
    }
  );
  return false;
}
