function getXhr(){
					var xhr = null; 
	if(window.XMLHttpRequest) // Firefox et autres
	   xhr = new XMLHttpRequest(); 
	else if(window.ActiveXObject){ // Internet Explorer 
	   try {
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
	}
	else { // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	   xhr = false; 
	} 
	return xhr
}
//UP
function requestUp(callback, id, userID) {
	var xhr = getXhr();
	
	xhr.onreadystatechange = function(){
		// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
		if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			callback(xhr.responseText, id, userID);
		}
	};
	var up = encodeURIComponent('1');
	var commentID =encodeURIComponent(id)
	var usersID =encodeURIComponent(userID)
	xhr.open("GET", "data_rate.php?up=" + up +"&id=" + commentID +"&userID="+usersID, true);
	xhr.send(null);
	
}

function rateUp(sData, id) {
	var updateUp = document.getElementById("up"+id).innerHTML;
	document.getElementById("up"+id).innerHTML = parseInt(updateUp)+parseInt(sData);
	removeElement(id);
}
//DOWN
function requestDown(callback, id, userID) {
	var xhr = getXhr();
	
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			callback(xhr.responseText, id, userID);
		}
	};
	var down = encodeURIComponent('1');
	var commentID =encodeURIComponent(id)
	var usersID =encodeURIComponent(userID)
	xhr.open("GET", "data_rate.php?down=" + down+"&id=" + commentID+"&userID="+usersID, true);
	xhr.send(null);
}
function rateDown(sData, id) {
	var updateDown = document.getElementById("down"+id).innerHTML;
	document.getElementById("down"+id).innerHTML = parseInt(updateDown)-parseInt(sData);
	removeElement(id);
}

function removeElement(id){
	$('.'+id).remove();
}
//-->
function affich(commentID){
		$("#comment"+commentID).toggle();
}
function affichpost(postID){
		$("#post"+postID).toggle();
}
					
