// globale Instanciation de XMLHttpRequest
var xmlHttp = false;
// XMLHttpRequest-Instanciation
// ... pour Internet Explorer
try {
  xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
} 
catch(e) {
  try {
    xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
  } 
  catch(e) {
    xmlHttp  = false;
  }
}
// ... pour Mozilla, Opera & Safari
if (!xmlHttp  && typeof XMLHttpRequest != 'undefined')
  xmlHttp = new XMLHttpRequest();
loadData();
setInterval("loadData()",5000);
function loadData(){
  if(xmlHttp) {
    xmlHttp.open('GET', '../shoutbox/getdata.php', true);
    xmlHttp.onreadystatechange = function () {
      if (xmlHttp.readyState == 4)
        document.getElementById("informationsShoutbox").innerHTML = xmlHttp.responseText;
    };
    xmlHttp.send(null);
  }
}
function saveData(){
  if(xmlHttp) {
    xmlHttp.open('POST', '../shoutbox/setdata.php');
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.send('nom='+document.getElementById("texteNom").value+'&message='+document.getElementById("texteMessage").value);
  }
  document.getElementById("texteMessage").value = '';
  document.getElementById("texteMessage").focus();
}
