function setDefault(p, v) {
  if (typeof p == "undefined")
    return v
  return p
}

var uXml = {
    useActiveX: (typeof ActiveXObject != "undefined"),
    useDom: document.implementation && document.implementation.createDocument,
    useXmlHttp: (typeof XMLHttpRequest != "undefined")
}

uXml.ARR_XMLHTTP_VERS = ["MSXML2.XmlHttp.6.0","MSXML2.XmlHttp.3.0"]

function uXmlHttp() {}

uXmlHttp.createRequest = function () {
  if(uXml.useXmlHttp) {
      return new XMLHttpRequest()
  } else if(uXml.useActiveX) {
      if(!uXml.XMLHTTP_VER) {
          for(var i=0; i < uXml.ARR_XMLHTTP_VERS.length; i++) {
              try {
                  new ActiveXObject(uXml.ARR_XMLHTTP_VERS[i])
                  uXml.XMLHTTP_VER = uXml.ARR_XMLHTTP_VERS[i]
                  break
              } catch (oError) {}
          }
      }
      if (uXml.XMLHTTP_VER) {
          return new ActiveXObject(uXml.XMLHTTP_VER)
      } else {
          throw new Error("Could not create XML HTTP Request.")
      }
  } else {
      throw new Error("Your browser doesn't support an XML HTTP Request.")
  }
}

uXmlHttp.isSupported = function () {
    return uXml.useXmlHttp || uXml.useActiveX
}