var xmlHttp = false;

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

// load data every two seconds
loadData();
setInterval("loadData()",2000);

// function of loading data
function loadData()
{
 if (xmlHttp) {
     xmlHttp.open('GET', 'getdata.php', true);
     xmlHttp.onreadystatechange = function () {
         if (xmlHttp.readyState == 4) {
             document.getElementById("asb_content").innerHTML = xmlHttp.responseText;
         }
     };
     xmlHttp.send(null);
 }
}

// function of saving data
function saveData()
{
if (xmlHttp) {
    xmlHttp.open('POST', 'setdata.php');
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.send('name='+document.frmshoutbox.txtname.value+'&message='+document.frmshoutbox.txtmessage.value);
}

// clear textfields and set them on focus
document.frmshoutbox.txtmessage.value = '';
document.frmshoutbox.txtmessage.focus();
}