var commandCue = Array() ;

function xmlhttpPostNow(divname, url) {
  var statusDisplay ;

  var xmlHttpReq = false;
  var self = this;
  var tempString ;

  if (window.XMLHttpRequest) {
    // Mozilla/Safari
    self.xmlHttpReq = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
    // IE
    self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  }

  var requestURL = url ;

  self.xmlHttpReq.open('POST', requestURL, false);
  self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  self.xmlHttpReq.send('');
       if (self.xmlHttpReq.readyState == 4) {
	 document.getElementById(divname).innerHTML = self.xmlHttpReq.responseText ;
       }
}

function xmlhttpPost(divname, url) {
  var statusDisplay ;

  var xmlHttpReq = false;
  var self = this;
  var tempString ;

  if (window.XMLHttpRequest) {
    // Mozilla/Safari
    self.xmlHttpReq = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
    // IE
    self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  }

  var requestURL = url ;

  self.xmlHttpReq.open('POST', requestURL, true);
  self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  self.xmlHttpReq.onreadystatechange =

     function() {
       var responseText = "" ;
       if (self.xmlHttpReq.readyState == 4) {
         responseText = self.xmlHttpReq.responseText ;
         ajaxCallBack(divname, responseText) ;
       }
     }

  self.xmlHttpReq.send('');
}

function ajaxCallBack(divname, responseText) {
  var statusDisplay ;

  document.getElementById(divname).innerHTML = responseText;
  setTimeout("postCue()", 10) ;
}


function cueXMLHTTPPost(divname, url) {
  var cuecount = commandCue.length ;
//alert(cuecount) ;

  var commandArray = Array()
  commandArray['divname'] = divname ;
  commandArray['url'] = url ;

  commandCue[cuecount] = commandArray ;

  if (cuecount ==0) {
    // because the cue was empty, kick the cue in to action
    setTimeout("postCue()", 10) ;
  }
}

function postCue() {
  var cuecount = commandCue.length ;
  if (cuecount > 0) {
     var command = commandCue.shift() ;
     xmlhttpPost(command['divname'], command['url']) ;
  }
}
