// charge les informations de l'étape courante en AJAX
function ajaxLoadIndex()
{
  //alert('ajaxLoadIndex');
  //alert(url2007JaponLoadIndex);
  var xhr = getXHR();
  xhr.onreadystatechange = function() { ajaxDisplayIndex(xhr); };
  xhr.open('GET', url2007JaponLoadIndex, true);
  xhr.send(null);
}

// affiche les informations de l'étape courante en AJAX
function ajaxDisplayIndex(xhr)
{
  //alert('ajaxDisplayIndex');
  if(xhr.readyState == 4 && xhr.status == 200) // le serveur est disponible && la lecture du fichier XML a bien été effectuée
  {
    var docXML = xhr.responseXML.documentElement;
    var items = docXML.childNodes;
    //alert(items.length);
    if (items.length == 5)
    {
      var id_etape = '';
      if (items.item(2).firstChild)
        id_etape = items.item(2).firstChild.nodeValue;
      //alert(id_etape);

      var nodeXML = items.item(0);
      var td = document.getElementById('carte_japon');
      td.style.backgroundImage = 'url(' + nodeXML.firstChild.nodeValue + ')';
      //alert(td.style.backgroundImage);

      var innerHTML = "";
      var nodeXML = items.item(1);
      var td = document.getElementById('photo_etape');
      if (id_etape != '')
      {
        innerHTML += '<a href="etape.php?id_etape=';
        innerHTML += id_etape;
        innerHTML += '"><img src="';
        innerHTML += nodeXML.firstChild.nodeValue;
        innerHTML += '" width="250" height="191" border="0" /></a>';
      }
      else
      {
        innerHTML += '<img src="';
        innerHTML += nodeXML.firstChild.nodeValue;
        innerHTML += '" width="250" height="191" border="0" />';
      }
      td.innerHTML = innerHTML;

      var nodeXML = items.item(3);
      var td = document.getElementById('titre_etape');
      if (id_etape != '')
      {
        td.innerHTML = nodeXML.firstChild.nodeValue;
      }

      var nodeXML = items.item(4);
      var td = document.getElementById('resume_etape');
      if (id_etape != '')
      {
        td.innerHTML = nodeXML.firstChild.nodeValue;
      }

      var innerHTML = "";
      var td = document.getElementById('lien_etape');
      if (id_etape != '')
      {
        innerHTML += '<a href="carnet.php?id_etape=';
        innerHTML += id_etape;
        innerHTML += '">Lire la suite ...</a>';
      }
      td.innerHTML = innerHTML;
    }
  }
}
