// globale Instanz von XMLHttpRequest
var xmlHttp = false;


// XMLHttpRequest-Instanz erstellen
// ... für Internet Explorer
try {
    xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    try {
        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
        xmlHttp  = false;
    }
}
// ... für Mozilla, Opera und Safari
if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
}

// aktuelle Daten laden
// loadDatakom();

// alle 5 Sekunden neue Daten holen
// setInterval("loadData()",5000);

function loadDatakom()
{
 if (xmlHttp) {
     xmlHttp.open('GET', 'getdata.php', true);
     xmlHttp.onreadystatechange = function () {
         if (xmlHttp.readyState == 4) {
             document.getElementById("kommentar_content").innerHTML = xmlHttp.responseText;
         }
     };
     xmlHttp.send(null);
 }
}

function saveDatakom()
{
if (xmlHttp) {
    xmlHttp.open('POST', 'setdata.php');
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.send('name='+encodeURIComponent(document.frmkommentar.name.value) + '&email=' + encodeURIComponent(document.frmkommentar.email.value) + '&nachricht=' + encodeURIComponent(document.frmkommentar.nachricht.value) + '&artikelid=' + encodeURIComponent(document.frmkommentar.artikelid.value)+ '&homepage=' + encodeURIComponent(document.frmkommentar.homepage.value));
//    loadDatakom();
    document.getElementById("kommentar_senden").innerHTML = '<p>Ihr Kommentar wurde eingetragen!</p>';
}

// Message-Eingabefelder leeren und Focus setzen
//document.frmshoutbox.txtmessage.value = '';
//document.frmshoutbox.txtmessage.focus();

}
