function rate(mode,topic_id,current_rate,user_rate,all_rates,all_votes) {

	file = "http://www.reason.pl/topics_rate_functions/tr_rate.php";
	for(x=1; x<=5; x++) { if( document.getElementById('rate'+x).checked ) { new_user_rate = x; break; } }
	rate_data = "mode="+mode+"&topic_id="+topic_id+"&old_user_rate="+user_rate+"&new_user_rate="+new_user_rate+"&current_rate="+current_rate+"&all_rates="+all_rates+"&all_votes="+all_votes;

	if(window.XMLHttpRequest) 
		{ xhr_object = new XMLHttpRequest(); }
	else if(window.ActiveXObject)
		{ xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); }
	xhr_object.open("POST", file, false); 
    	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
	xhr_object.setRequestHeader("Content-length", rate_data.length);
	xhr_object.send(rate_data); 
	if(xhr_object.readyState == 4) { 
		rate_data = xhr_object.responseText.split('<rate>');

		document.getElementById('user_rate').innerHTML = rate_data[0];
		document.getElementById('current_rate').innerHTML = rate_data[1];
		document.getElementById('all_votes').innerHTML = rate_data[2];
	}
	else { return(false); }
} 
