var formAt=0;

function comment(commentId) {
	if(formAt!=0) {
		document.getElementById("addCommentDiv"+formAt).innerHTML="";
	}
	formAt=commentId;


	document.getElementById('comment_parent_id').value=commentId;

	document.getElementById("addCommentDiv"+commentId).innerHTML=document.getElementById("addCommentFormDiv").innerHTML;

}

function ratePost(postid, rating, scriptUrl) {
	var url="";
	url = url + "&postid=" + postid + "&rating=" + rating;
	var xmlhttp = (typeof(XMLHttpRequest) != "undefined") ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
	xmlhttp.open("POST", scriptUrl, true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", url.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.onreadystatechange=function() {	if (xmlhttp.readyState==4) {
		if(document.getElementById('rateButtonsContainer')!=null) {
			if(xmlhttp.responseText=="nologin") document.getElementById('rateButtonsContainer').innerHTML = "Вы не залогинены!";
			else if(xmlhttp.responseText=="history") document.getElementById('rateButtonsContainer').innerHTML = "Вы уже голосовали!";
			else {
				document.getElementById('rateButtonsContainer').innerHTML = "Спасибо!";
				document.getElementById('ratingNum' + postid).innerHTML = xmlhttp.responseText;
				document.getElementById('ratingCount' + postid).innerHTML = parseInt(document.getElementById('ratingCount' + postid).innerHTML, 10)+1
			}
		}
	}}
	xmlhttp.send(url);
}