function loadXHR(){
	var xhr=null;
    if(window.XMLHttpRequest){ 
        xhr = new XMLHttpRequest();
    }
    else if(window.ActiveXObject){
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }	
	return xhr;
}

function ajax_disclaimer(Xml){
    xhr = loadXHR();
    xhr.onreadystatechange = function() {};
    xhr.open('GET', Xml, true);
    xhr.send(null);
}

function ajax_return_value(Xml, Destination){
    xhr = loadXHR();
    xhr.onreadystatechange = function() { ajax_return_value_RSP(xhr, Xml, Destination); };
    xhr.open('GET', Xml, true);
    xhr.send(null);
}

function ajax_return_value_RSP(xhr, Xml, Destination){
	if (xhr.readyState==4){
		var docXML = xhr.responseXML;
		var value_returned = docXML.getElementsByTagName('value')[0].firstChild.nodeValue;
		document.getElementById(Destination).innerHTML = value_returned;
	}
}

function ajax_return_alert(Xml){
    xhr = loadXHR();
    xhr.onreadystatechange = function() { ajax_return_alert_RSP(xhr, Xml); };
    xhr.open('GET', Xml, true);
    xhr.send(null);
}

function ajax_return_alert_RSP(xhr, Xml){
	if (xhr.readyState==4){
		var docXML = xhr.responseXML;
		var value_returned = docXML.getElementsByTagName('value')[0].firstChild.nodeValue;
		alert(value_returned);
	}
}

function ajax_execonly(Xml){
    xhr = loadXHR();
    xhr.open('GET', Xml + "&ms=" + new Date().getTime(), false);
	xhr.setRequestHeader("Cache-Control","no-cache");
    xhr.send(null);
}

function ajax_vote(Xml, BoxId){
    xhr = loadXHR();
    xhr.onreadystatechange = function() { ajax_vote_RSP(xhr, Xml, BoxId); };
    xhr.open('GET', Xml, true);
    xhr.send(null);
}

function ajax_vote_RSP(xhr, Xml, BoxId){
	if (xhr.readyState==4){
		var docXML = xhr.responseXML;
		
		var alert_returned = docXML.getElementsByTagName('alert')[0].firstChild.nodeValue;
		var new_nb_votes = docXML.getElementsByTagName('new_nb_votes')[0].firstChild.nodeValue;

		alert(alert_returned);
		document.getElementById('nb_votes_'+BoxId).innerHTML = new_nb_votes;
		
		new Effect.toggle('box_vote_'+BoxId,'BLIND'); 
		new Effect.toggle('box_infos_'+BoxId,'BLIND');
		return false;
	}
}
