// charge les informations de la page en AJAX
function ajaxLoadCarnet()
{
  //alert('ajaxLoadCarnet');
  //alert(url2006UsaLoadCarnet);
  var xhr = getXHR();
  xhr.onreadystatechange = function() { ajaxDisplayCarnet(xhr); };
  xhr.open('GET', url2006UsaLoadCarnet, true);
  xhr.send(null);
}

function ajaxDisplayCarnet(xhr)
{
  //alert('ajaxDisplayCarnet');
  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;
  
    var td_carnet = document.getElementById('carnet');

    var table = null;
    var border = null;
    var cellpadding = null;
    var cellspacing = null;
    //var class = null;
    var width = null;
    var tr = null;
    var td = null;
    var valign = null;
    var textNode = null;
    var b = null;
    var br = null;
    var img = null;
    var a = null;
    var href = null;
    
    table = document.createElement('table');

    border = document.createAttribute('border');
    border.nodeValue = 0;
    table.setAttributeNode(border);
    cellpadding = document.createAttribute('cellpadding');
    cellpadding.nodeValue = 0;
    table.setAttributeNode(cellpadding);
    cellspacing = document.createAttribute('cellspacing');
    cellspacing.nodeValue = 0;
    table.setAttributeNode(cellspacing);
    //class = document.createAttribute('class');
    //class.nodeValue = 'carnet';
    //table.setAttributeNode(class);

    //alert(items.length);
    for (var i = 0; i < items.length / 2; i++)
    {
      tr = document.createElement('tr');
      
      for (var j = i; j < items.length; j = j + items.length / 2)
      {
        td = document.createElement('td');
        //class = document.createAttribute('class');
        //class.nodeValue = 'carnet_etape';
        //td.setAttributeNode(class);

        b = document.createElement('b');
        textNode = document.createTextNode(items.item(j).childNodes.item(0).firstChild.nodeValue);
        b.appendChild(textNode);
        td.appendChild(b);
        
        br = document.createElement('br');
        td.appendChild(br);
        
        img = document.createElement('img');
        src = document.createAttribute('src');
        src.nodeValue = 'images/' + items.item(j).childNodes.item(1).firstChild.nodeValue;
        img.setAttributeNode(src);
        td.appendChild(img);
            
        br = document.createElement('br');
        td.appendChild(br);
        
        b = document.createElement('b');
        textNode = document.createTextNode(items.item(j).childNodes.item(2).firstChild.nodeValue);
        b.appendChild(textNode);
        td.appendChild(b);
        
        td.innerHTML += ' - ' + items.item(j).childNodes.item(3).firstChild.nodeValue.substring(0, 230) + ' ... ';
        
        a = document.createElement('a');
        href = document.createAttribute('href');
        href.nodeValue = 'etape.php?jour=' + (j+1) + '';
        a.setAttributeNode(href);
        textNode = document.createTextNode('(suite)');
        a.appendChild(textNode);
        td.appendChild(a);
        
        br = document.createElement('br');
        td.appendChild(br);

        img = document.createElement('img');
        src = document.createAttribute('src');
        src.nodeValue = 'images/carnet_barre1.gif';
        img.setAttributeNode(src);
        td.appendChild(img);
        
        br = document.createElement('br');
        td.appendChild(br);

        a = document.createElement('a');
        href = document.createAttribute('href');
        href.nodeValue = 'etape.php?jour=' + (j+1) + '&carte=n&videos=n';
        a.setAttributeNode(href);
        img = document.createElement('img');
        src = document.createAttribute('src');
        src.nodeValue = 'images/ico_carnet_small.gif';
        img.setAttributeNode(src);
        border = document.createAttribute('border');
        border.nodeValue = 0;
        img.setAttributeNode(border);
        a.appendChild(img);
        td.appendChild(a);
        
        textNode = document.createTextNode(' carnet ');
        td.appendChild(textNode);

        a = document.createElement('a');
        href = document.createAttribute('href');
        href.nodeValue = 'etape.php?jour=' + (j+1) + '&carte=n&videos=n';
        a.setAttributeNode(href);
        img = document.createElement('img');
        src = document.createAttribute('src');
        src.nodeValue = 'images/ico_photos_small.gif';
        img.setAttributeNode(src);
        border = document.createAttribute('border');
        border.nodeValue = 0;
        img.setAttributeNode(border);
        img.style.marginLeft = '5px';
        a.appendChild(img);
        td.appendChild(a);
        
        textNode = document.createTextNode(' ' + items.item(j).childNodes.item(4).firstChild.nodeValue + ' photo(s) ');
        td.appendChild(textNode);

        a = document.createElement('a');
        href = document.createAttribute('href');
        href.nodeValue = 'etape.php?jour=' + (j+1) + '&carte=n&videos=y';
        a.setAttributeNode(href);
        img = document.createElement('img');
        src = document.createAttribute('src');
        src.nodeValue = 'images/ico_videos_small.gif';
        img.setAttributeNode(src);
        border = document.createAttribute('border');
        border.nodeValue = 0;
        img.setAttributeNode(border);
        img.style.marginLeft = '5px';
        a.appendChild(img);
        td.appendChild(a);
        
        textNode = document.createTextNode(' ' + items.item(j).childNodes.item(5).firstChild.nodeValue + ' vidéo(s) ');
        td.appendChild(textNode);

        a = document.createElement('a');
        href = document.createAttribute('href');
        href.nodeValue = 'etape.php?jour=' + (j+1) + '&carte=n&video=n';
        a.setAttributeNode(href);
        img = document.createElement('img');
        src = document.createAttribute('src');
        src.nodeValue = 'images/ico_comment_small.gif';
        img.setAttributeNode(src);
        border = document.createAttribute('border');
        border.nodeValue = 0;
        img.setAttributeNode(border);
        img.style.marginLeft = '5px';
        a.appendChild(img);
        td.appendChild(a);
        
        textNode = document.createTextNode(' ' + items.item(j).childNodes.item(6).firstChild.nodeValue + ' commentaire(s) ');
        td.appendChild(textNode);

        a = document.createElement('a');
        href = document.createAttribute('href');
        href.nodeValue = 'etape.php?jour=' + (j+1) + '&carte=y&videos=n';
        a.setAttributeNode(href);
        img = document.createElement('img');
        src = document.createAttribute('src');
        src.nodeValue = 'images/ico_carte_small.gif';
        img.setAttributeNode(src);
        border = document.createAttribute('border');
        border.nodeValue = 0;
        img.setAttributeNode(border);
        img.style.marginLeft = '5px';
        a.appendChild(img);
        td.appendChild(a);
        
        textNode = document.createTextNode(' carte ');
        td.appendChild(textNode);

        img = document.createElement('img');
        src = document.createAttribute('src');
        src.nodeValue = 'images/carnet_barre2.gif';
        img.setAttributeNode(src);
        td.appendChild(img);

        tr.appendChild(td);
      }
      
      table.appendChild(tr);
    }
    
    td_carnet.appendChild(table);
  }
  else
  {
  }
}
