/**
 * xh_Request.js - basic XMLHttpRequest object
 *
 * @version 10 Jun 2005
 * @author  Joseph Oster, wingo.com, Copyright (c) 2005-2006
 */

function xh_newRequest() {
  // CONSTRUCTOR for basic XMLHttpRequest object 'xh_Request'
  // NOTE: DO _NOT_ USE 'new xh_newRequest()'!

  // instantiate an XMLHttpRequest object; different for IE vs. Mozilla
  // try IE first - source: http://jibbering.com/2002/4/httprequest.html
  var xmlhttp=false;
  /*@cc_on @*/
  /*@if (@_jscript_version >= 5)
  // JScript gives us Conditional compilation, we can cope with old IE versions.
  // and security blocked creation of the objects.
   try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
    try {
     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
     xmlhttp = false;
    }
   }
  @end @*/

  if (!xmlhttp && (typeof XMLHttpRequest != 'undefined')) xmlhttp = new XMLHttpRequest(); // Mozilla
  return xmlhttp;
  }

function xh_statusMsg(state) {
  var msg = state;
  switch (state) {
    case 0: {msg = "Uninitialized"; break;}
    case 1: {msg = "Loading..."; break;}
    case 2: {msg = "Loaded"; break;}
    case 3: {msg = "Interactive"; break;}
    case 4: {msg = "Complete"; break;}
    }
  return msg;
  }


/*********** BEGIN: generic code for handling XML/DOM nodes ***********/
function xdGetNode(atNode, nodeName) {
  // returns XML DOM node of first 'nodeName' child of 'atNode' (typically unique!)
  return atNode.getElementsByTagName(nodeName)[0];
  }

function xdNodeVal(atNode) {
  // returns 'nodeValue' of 'atNode'
  return atNode ? atNode.firstChild.nodeValue : '';
  }

function xdGetNodeVal(atNode, nodeName) {
  // returns 'nodeValue' of first 'nodeName' child of 'atNode' (typically unique!)
  return xdNodeVal(xdGetNode(atNode, nodeName));
  }

function xdGetNodeAttr(atNode, attrName) {
  return atNode.getAttribute(attrName);
  }
/*********** END: generic code for handling XML documents ***********/
