/** XHConn - Simple XMLHTTP Interface - bfults@gmail.com - 2005-04-08        **
 ** Code licensed under Creative Commons Attribution-ShareAlike License      **
 ** http://creativecommons.org/licenses/by-sa/2.0/                           **/
function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

/*Dave's custom additions*/
//Connection variable for our ajax
var conn = new XHConn();

//Alert function for debugging
var alertMe = function (oXML) { alert(oXML.responseText); return true; };

//Empty function for doing nothing
var doNothing = function (oXML) { return true; };

//Makes an ajax call to 'file' with a string of get variables 'vars' and calls back to the function 'callback'
//Adds in a timestamp to the call to keep IE from cashing
function doAjax(file,vars,callback) {
	var d = new Date();
	var t = d.getUTCMilliseconds()+d.getUTCSeconds()+d.getUTCMinutes()+d.getUTCHours();
	conn.connect(file,"GET",vars+"&ignore="+t,callback);
	return true;
}

//Returns XML from a string
function getXMLString(oXML) {
	//Get response
	if(window.ActiveXObject) {
		var xmlResponse = new ActiveXObject("Microsoft.XMLDOM");
		xmlResponse.async = "false";
		xmlResponse.loadXML(oXML.responseText);
	}
	else {
		var xmlResponse = (new DOMParser()).parseFromString(oXML.responseText,"text/xml");
	}
	
	return xmlResponse;
}