function VoteProcessResult(xmlhttp_obj, post_id, vote)
{
	var result;
	if (xmlhttp_obj.readyState==4)
	{
	//alert("downloaded");
		result = xmlhttp_obj.responseText;

		//if (result == '0')
		//{
		//   // do something
		//} else {

		cur_rating_span = document.getElementById('rating_span_' + post_id);
		if (cur_rating_span)
		{
			cur_rating_span.innerHTML = result;
		}
		//}
	}
}


function vote(post_id, vote)
{

	vote_form = document.getElementById('vote_form_' + post_id);
	voted_area = document.getElementById('voted_area2_' + post_id);
	vote_form.style.display = 'none';
	voted_area.style.display = 'inline';
	switch (vote)
	{
		case 1:
			voted_area.innerHTML = 'зачот';
			break;
		case -1:
			voted_area.innerHTML = 'КГ/АМ';
			break;
		case 0:
			voted_area.innerHTML = '?я чото п';
			break;
		default:
			voted_area.innerHTML = 'хуйня какая-то';
			break;
	}


	var xmlhttp_obj = new XMLHttpRequest();

    if (xmlhttp_obj)
	{
		xmlhttp_obj.onreadystatechange=function(){VoteProcessResult(xmlhttp_obj, post_id, vote);};
		xmlhttp_obj.open("GET", "/vote.php?post_id="+post_id+"&vote="+vote+"&dynamic=1",true);
		xmlhttp_obj.send(null);
 	}
}


function BorodaProcessResult(xmlhttp_obj, post_id, dbl)
{
	var result;
	if (xmlhttp_obj.readyState==4)
	{
		result = xmlhttp_obj.responseText;

		boroda_form = document.getElementById('boroda_form_' + post_id);
		boroda_voted = document.getElementById('boroda_voted_' + post_id);
		boroda_form.style.display = 'none';
		boroda_voted.style.display = 'inline';

		cur_boroda_span = document.getElementById('cur_boroda_span_' + post_id);
		if (cur_boroda_span)
		{
			cur_boroda_span.innerHTML = result;
		}
	}
}

function boroda(post_id, dbl)
{
	var xmlhttp_obj = new XMLHttpRequest();

    if (xmlhttp_obj)
	{
		xmlhttp_obj.onreadystatechange=function(){BorodaProcessResult(xmlhttp_obj, post_id, dbl);};
		xmlhttp_obj.open("GET", "/boroda.php?boroda_id="+post_id+"&double="+dbl+"&dynamic=1",true);
		xmlhttp_obj.send(null);
 	}
}
