function voteComment(comment_id, rate) {
	var xmlHttpReq, url;
	
	xmlHttpReq = GetXmlHttpReqObject();
	
	url = "/comment_votes/vote.php?comment_id=" + comment_id + "&rate=" + rate;
	
	xmlHttpReq.onreadystatechange = function() {
		voteReqStateChange(xmlHttpReq, comment_id, rate);
	};
	
	xmlHttpReq.open("GET",url,true);
	xmlHttpReq.send(null);	
}

function voteReqStateChange(xmlHttpReq, comment_id, rate) {
	var xmlDoc, errorText, commentRateSum, commentRateObj, commentFooterObj;
	
	if (xmlHttpReq.readyState==4) {
		xmlDoc = xmlHttpReq.responseXML.getElementsByTagName("RESPONSE")[0];
		
		// Apskatīsimies vai gadījumā nav kāda kļūda
		errorDoc = xmlDoc.getElementsByTagName("ERROR_TEXT");
		
		if (errorDoc.length > 0) {
			errorText = errorDoc[0].childNodes[0].nodeValue;
			alert(errorText);
		}
		else {
			// Nav bijusi kļūda
			commentRateSum = xmlDoc.getElementsByTagName("COMMENT_RATE_SUM")[0].childNodes[0].nodeValue;
			commentRateObj = document.getElementById("comment_" + comment_id + "_rate_sum");
			//alert(commentRateObj);
			
			
			
			if (commentRateSum == 0) {
				commentRateObj.style.color = "grey";
			}
			else if (commentRateSum > 0) {
				commentRateSum = "+" + commentRateSum;
				commentRateObj.style.color = "green";
				
			}
			else if (commentRateSum < 0) {
				commentRateObj.style.color = "red";
			}
			
			commentRateObj.innerHTML = commentRateSum;
			//alert(commentRateSum);
			
			commentFooterObj = document.getElementById("comment_" + comment_id + "_footer");
			
			if (rate == 1) {
				commentFooterObj.innerHTML = "<img style='margin-right: 5px;' src='/images/plus.gif'><img src='/images/minus_grey.gif'>";
			}
			else {
				commentFooterObj.innerHTML = "<img style='margin-right: 5px;' src='/images/plus_grey.gif'><img src='/images/minus.gif'>";
			}
			
			
		}
					
	}
}