function nodata(sDiv) {
  document.getElementById(sDiv).innerHTML = "<p class=\"style5\">A problem was encountered while loading the page.<br /><br />Please retry the operation by pressing Refresh in your browser.<br /><br />If this problem persists, please contact the database administrator.<br /><br /></p>";
}

function nopage(sDiv) {
  document.getElementById(sDiv).innerHTML = "<p class=\"style5\">A problem was encountered while loading the page.<br /><br />Please retry the operation by pressing Refresh in your browser.<br /><br />If this problem persists, please contact the database administrator.<br /><br /></p>";
}

function loading(sDiv) {
  document.getElementById(sDiv).innerHTML = "<p class=\"style5\">Loading ... one moment please</p>";
}

function getFormValues(fobj) {
  var aParams = new Array();
  for (var i = 0; i < fobj.elements.length; i++) {
    switch(fobj.elements[i].type) {
      case "textarea":
      case "hidden":
      case "checkbox":
      case "password":
      case "text":
        aParams.push(escape(fobj.elements[i].name) + "=" + escape(fobj.elements[i].value));
        break;
    }
  }
  return aParams.join("&");
}

function get_data(sDest, sDiv) {
//alert(sDest);
  var oZxml = zXmlHttp.createRequest();
  oZxml.open("GET", sDest, true);
  var timerID = setTimeout("nopage(" + sDiv + ")", 15000); // set a 15 second timer just in case we don't get the data back
  var delayID = setTimeout("loading(" + sDiv + ")", 3000); // set a 3 second timer just in case we don't get the data back quickly
    oZxml.onreadystatechange = function() {
    if (oZxml.readyState == 4) {
      //response received
      clearTimeout(timerID);
      clearTimeout(delayID);
      if (oZxml.status == 200) {
        //got data
        //alert(oZxml.responseText);
        document.getElementById(sDiv).innerHTML = oZxml.responseText;
      } else {
        //error occurred
        nopage(sDiv);
      }
    }
  }
  oZxml.send(null);
}

function post_data(sBody, sDest, sDiv) {
  var oZxml = zXmlHttp.createRequest();
  oZxml.open("POST", sDest, true);
  oZxml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  var timerID = setTimeout("nodata(" + sDiv + ")", 15000); // set a 15 second timer just in case we don't get the data back
  oZxml.onreadystatechange = function() {
    if (oZxml.readyState == 4) {
      //response received
      clearTimeout(timerID);
      if (oZxml.status == 200) {
        //alert(oZxml.responseText);
        if (oZxml.responseText == "Accepted") {
          loadpage("main");
          showuser();
        } else {
          if (oZxml.responseText == "Change") {
            loadpage("alter");
            showuser();
          } else {
            document.getElementById(sDiv).innerHTML = oZxml.responseText;
            chng(sDiv, '');
          }
        }
      } else {
        //error occurred
        nodata(sDiv);
      }
    }
  }
  oZxml.send(sBody);
}

function loaddata(intMth) {
    get_data("events.php?m=" + intMth + "&data=true", "content");
}

