
<!--

var commandCue = Array() ;
var loader = 'LOADING';

//Grab a URL, without using the queueing service
//Use this if you want to wait for a response
function xmlhttpGetWithLoader(url) {
   document.getElementById(divname).innerHTML = loader;
   xmlhttpGet(url);
}

//Grab a URL, without using the queueing service
//Use this if you want to wait for a response
function xmlhttpGet(url) {
  var statusDisplay ;

  var xmlHttpReq = false;
  var self = this;

  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) {
        return self.xmlHttpReq.responseText ;
  }

}

//An internal function, do not use
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('');
}

//The main timer, do not use
function ajaxCallBack(divname, responseText) {
  var statusDisplay ;

  document.getElementById(divname).innerHTML = responseText;
  setTimeout("postCue()", 10) ;
}


//The main ajax call, will cue the ajax call up and execute this and
//all following requests in order
function cueXMLHTTPPost(divname, url) {
  var cuecount = commandCue.length ;

  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) ;
  }
}

//The main ajax call, will cue the ajax call up and execute this and
//all following requests in order
function cueXMLHTTPPostWithLoader(divname, url) {
  document.getElementById(divname).innerHTML = loader;
  var cuecount = commandCue.length ;

  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']) ;
  }
}


// ############################################
// function just to replace the div straight - no cueing - nothing
// ############################################
function replaceDivWithURL(divname, url) {
	if (divname != "mytestGRID")
	  {	
	  		
		  document.getElementById(divname).innerHTML = '<div align="center"><img src="images/fat2.gif" /></div>'
	  }
  var http = false;

  if(navigator.appName == "Microsoft Internet Explorer") {
    http = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
    http = new XMLHttpRequest();
  } 

  http.open("GET", url, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
		
	  if (divname == 'mytestGRID')
	  {
		  document.getElementById(divname).innerHTML = document.getElementById(divname).innerHTML + http.responseText;
	  }
	  else
	  {
		  if (divname != 'twitterDIV')
		  {
		  document.getElementById(divname).innerHTML = http.responseText;
		  }
		  else
		  {
			 //SPLIT CALL BY THE [JS] TAG
			splitme = http.responseText.split('[JS]');
			//PUT IN HTML
			document.getElementById(divname).innerHTML = splitme[0];
			
			//PASS SCRIPT BLOCK INTO THE CURRENT PAGE
			var myVal = document.createElement('SCRIPT');
			myVal.type = 'text/javascript';
			myVal.text = splitme[1];
			document.body.appendChild(myVal);
		  }
	  }
	  //DAVES ADDITION SO THAT IF THE DIV IS CALLED 'mytestnew' THEN THE LYTEBOX ITEMS ARE UPDATED
	  //THIS IS USED WHEN AJAX IS USED TO GET BACK HTML CONTAINS LYTEBAX CALLS
	  if (divname == 'mytestnew')
	  {
	  LyteBox.prototype.updateLyteboxItems();
	  }
    }
  }

  http.send(null);
}
