var ns = (navigator.appName.indexOf("Netscape") != -1);
var ie = (navigator.appName.indexOf("Microsoft Internet Explorer") != -1);
var httpreq=false;
var debug=false;

function ajaxResponse() {
  switch(httpreq.readyState){
    case 0: ajaxDebug("attempting to retrieve data..."); break;
    case 1: ajaxDebug("loading data..."); break;
    case 2: ajaxDebug("loading complete. Preparing data for use"); break;
    case 3: ajaxDebug("data almost done"); break;
    case 4: 
      ajaxDebug("calling response function " + responseFunc);
      if (httpreq.status>=200 && httpreq.status<=299) {
        //eval(responseFunc);
        eval(responseFunc);
      } else if(httpreq.status == 404){
         ajaxDebug("No resource found: " + httpreq.statusText);
      } else {
         ajaxDebug("There was a problem retrieving the XML data:" + httpreq.statusText);
      }
      break;
    default: 
      ajaxDebug("return state '" + httpreq.readyState + "'");
      break;
  }
}

function ajaxRequest(url) {
  d = new Date();
  //url = url + (url.indexOf('?')==-1 ? '?':'&') + 'hash='+d.getFullYear()+'/'+(d.getMonth()+1)+'/'+d.getDate()+' '+d.getHours()+':'+d.getMinutes()+':'+d.getSeconds();
  ajaxDebug("in ajaxRequest('" + url + "')")
  
  // create a free global httpreq socket
  httpreq = new XMLHttpRequest();
	httpreq.onreadystatechange = ajaxResponse;
	httpreq.open("GET", url );
	httpreq.send(null);
}

function ajaxDebug(debugstring) {
  node = document.getElementById("debug")
  if (debug && node) {
    d = new Date();
    zeitpunkt = d.getDate() + '.' + (d.getMonth()+1) + '.' + d.getFullYear() + ' ' + 
                d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds()
    
    node.innerHTML = zeitpunkt + ' - ' + debugstring + '<br />' + node.innerHTML
  }
}
