// Fonction pour l'affichage des photos
function ajax(nom)
{
    var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { affiche_photo(xhr, nom); };
    
    //on appelle le fichier reponse.txt
    xhr.open("GET", "photo.xml", true);
    xhr.send(null);
}

function affiche_photo(xhr, nom)
{
    if (xhr.readyState==4) 
    {
    	var docXML= xhr.responseXML;
    	var items = docXML.getElementsByTagName(nom)
		var html = '';
		var source = '';
		var alt = '';
			for (i=0; i < items.length; i++)
			{	
				html += "<strong>" + items[i].getElementsByTagName("nom")[0].firstChild.nodeValue + "</strong><br/><br/><br/>";
				html += items[i].getElementsByTagName("tech")[0].firstChild.nodeValue + "<br/><br/><br/>";
				html += items[i].getElementsByTagName("dim")[0].firstChild.nodeValue;
				
				source += items[i].getElementsByTagName("src")[0].firstChild.nodeValue;
				alt += items[i].getElementsByTagName("alt")[0].firstChild.nodeValue;
			}
		document.getElementById('nomTech').innerHTML = html;
		document.getElementById('image').src = source;
		document.getElementById('image').alt = alt;
    }
}

// Fonction pour l'affichage du texte
function afficheTexte(id, what, classe)
{
	var xhr;
	if (window.XMLHttpRequest) xhr = new XMLHttpRequest();
	else if (window.ActiveXObject) xhr = new ActiveXObject('Microsoft.XMLHTTP');
	else
	{
		alert('JavaScript : votre navigateur ne supporte pas les objets XMLHttpRequest...');
		return;
	}
	var texte = xhr.open('GET','text.php?n='+what,true);
	xhr.onreadystatechange = function()
	{
		if (xhr.readyState == 4)
		{
			if (document.getElementById(id)) document.getElementById(id).innerHTML = xhr.responseText;
		}
	}
	xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	var data = escape(texte);
	xhr.send(data);
}


