var xmlHttp;
function doRequest() {
  xmlHttp = GetXmlHttpObject();
  if (xmlHttp == null) {
    alert ("Browser does not support HTTP Request");
    return;
  }
  var url = "/guestbook/showcomments.php";
  xmlHttp.onreadystatechange = stateChanged;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}//end doRequest()

function stateChanged() {
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
    document.getElementById("gbdiv").innerHTML = xmlHttp.responseText;
  }
}//end stateChanged()

function GetXmlHttpObject() {
  var objXMLHttp = null;
  if (window.XMLHttpRequest) {
    objXMLHttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
    objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  return objXMLHttp;
}//end GetXmlHttpObject()
function addcomment()
{
  window.open('/guestbook/addcomment.php', 'addcomment', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=430,height=510');
}
function reloadcomments()
{
  setTimeout("doRequest()",1000);
}
function makeDoubleDelegate(function1, function2) {
  return function() {
    if (function1)
      function1();
    if (function2)
      function2();
  }
}

window.onload = makeDoubleDelegate(window.onload, doRequest );
