 
//var id_globale=0;
var hauteur=0;
function get_result(id,obj,chemin)
{
	
    sendData('GET',chemin + 'favoris_ajax.php','id='+id);
	hauteur=findPos(obj);
	
}
//fonction pour retirer un favoris 
function retirer_favoris(id,obj,chemin)
{
	var div_file = document.getElementById('zoom'+id+'_1');
    sendData('GET',chemin + 'retire_favoris_ajax.php','id='+id);
	hauteur=findPos(obj);
	div_file.style.display='none';
	
}
function get_points(id,obj)
{
	sendData('GET','getUserPoints.php','id='+id);
	hauteur=findPos(obj);
}
function display_fiche(infos)
{
	document.getElementById('fiche').style.display="block";
	document.getElementById('fiche').style.top=(hauteur-200)+"px";
	document.getElementById('fiche').innerHTML='<a href="#" onclick="javascript:hide_fiche();return false;">fermer la fenêtre</a><br>'+infos;
}
function hide_fiche()
{
	document.getElementById('fiche').style.display="none";
}
function findPos(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop
		}
	}
	return curtop;
} 
function getHTTPObject()
{
	var xmlhttp = false;
	if(window.XMLHttpRequest) // Firefox et autres
		xmlhttp = new XMLHttpRequest(); 
	else if(window.ActiveXObject){ // Internet Explorer 
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
	} else { // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	   xmlhttp = false; 
	}
 
	if (xmlhttp)
	{
		/* on définit ce qui doit se passer quand la page répondra */
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState == 4) /* 4 : état "complete" */
			{
				if (xmlhttp.status == 200) /* 200 : code HTTP pour OK */
				{
					/*
					Traitement de la réponse.
					Ici on affiche la réponse dans une boîte de dialogue.
					*/
					alert(xmlhttp.responseText);
					display_fiche(xmlhttp.responseText);
				}
			}
		}
	}
	return xmlhttp;
}

function sendData(method, url, data)
{
	var xmlhttp = getHTTPObject();

    if (!xmlhttp)
    {
        return false;
    }
 
    if(method == "GET")
    {
		if(data == 'null')
		{
			xmlhttp.open("GET", url, true); //ouverture asynchrone
		}
		else
		{
			xmlhttp.open("GET", url+"?"+data, true);
		}
		
		xmlhttp.send(null);

    }
    else if(method == "POST")
    {
		xmlhttp.open("POST", url, true); //ouverture asynchrone
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.send(data);
    }
    
	return true;

}
