$(document).ready(function(){

 
	// $("a.vote").click(function(){
	// the_id = $(this).attr('id');
	
	// if ($.cookies.get("vote" + the_id)) alert ("Вы уже голосовали");
	// else
	// {
	// $(this).parent().html("<img src='images/spinner.gif'/>");
	// $("span#votes_count"+the_id).fadeOut("fast");
		// $.ajax({
			// type: "POST",
			// data: "action=vote&id="+$(this).attr("id"),
			// url: "votes.php",
			// success: function(msg)
			// {
				// $("span#votes_count"+the_id).html(msg);
				// $("span#votes_count"+the_id).fadeIn();
				// $("span#vote_buttons"+the_id).remove();
				// $.cookies.set("vote" + the_id, 'voted', {hoursToLive: 24});
			// }
		// });
	// }
	// });
	
$("a.vote").click(function(){
	var server_id = $(this).attr('id');
	var answer = '';
	$("a.#"+server_id).parent().html("&nbsp;<img src='/images/spinner.gif'/>");
	$.ajax({
		type: 'GET',
		url: '/ajax/antibot.php',
		cache: false,
		dataType: 'script',
		async: false,
		success: function(result){
			var answer=prompt(result,'');
			$.ajax({
				type: 'POST',
				data: 'action=vote&id=' + server_id + '&ans=' + answer,
				url: "/votes.php",
				cache: false,
				dataType: 'script',
				async: true,
				success: function(result){
					$("span#votes_count"+server_id).fadeOut("fast");
					var votes = $('span#votes_count' + server_id).get(0);
					if (result == '1') {
						var my_num = votes.innerHTML;
						my_num++;
						votes.innerHTML = my_num;
						$("span#votes_count"+server_id).fadeIn();
						$("span#vote_buttons"+server_id).remove();
					}
					else if (result == '2') {
						alert('Вы не верно ответили на вопрос.');
						$("span#votes_count"+server_id).fadeIn();
						$("span#vote_buttons"+server_id).remove();
					}
					else if (result == '3') {
						alert('Вы уже голосовали сегодня.');
						$("span#votes_count"+server_id).fadeIn();
						$("span#vote_buttons"+server_id).remove();
					}
					else {
						alert('Ошибка голосования.');
					}
				}
			});
		}
	});
	return(true);
});
	
});	