// used to find the Automation server name
function getDomDocumentPrefix() {

  if (getDomDocumentPrefix.prefix) return getDomDocumentPrefix.prefix;
	
  var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
  var o;
  for (var i = 0; i < prefixes.length; i++) {
    try {
      // try to create the objects
      o = new ActiveXObject(prefixes[i] + ".DomDocument");
      return getDomDocumentPrefix.prefix = prefixes[i];
    }
    catch (ex) {};
  }

  throw new Error("Could not find an installed XML parser");

}

// XmlDocument create
function XmlDocument() {}

XmlDocument.create = function () {

  try {

    // DOM2
    if (document.implementation && document.implementation.createDocument) {

      var doc = document.implementation.createDocument("", "", null);
			
      // some versions of Moz do not support the readyState property
      // and the onreadystate event so we patch it!
      if (doc.readyState == null) {
        doc.readyState = 1;
        doc.addEventListener("load", function () {
          doc.readyState = 4;
          if (typeof doc.onreadystatechange == "function") doc.onreadystatechange();
        }, false);
      }
			
      return doc;

    }

    // Micro$oft
    if (window.ActiveXObject) return new ActiveXObject(getDomDocumentPrefix() + ".DomDocument");

  }

  catch (ex) {}

  throw new Error("Your browser does not support XmlDocument objects");

}

// Create the loadXML method and xml getter for Mozilla
if (window.DOMParser &&	window.XMLSerializer &&	window.Node && Node.prototype && Node.prototype.__defineGetter__) {

  // XMLDocument did not extend the Document interface in some versions
  // of Mozilla. Extend both!
  Document.prototype.loadXML = function (s) {
		
    // parse the string to a new doc	
    var doc2 = (new DOMParser()).parseFromString(s, "text/xml");
		
    // remove all initial children
    while (this.hasChildNodes()) this.removeChild(this.lastChild);
			
    // insert and import nodes
    for (var i = 0; i < doc2.childNodes.length; i++) {
      this.appendChild(this.importNode(doc2.childNodes[i], true));
    }
    this.readyState = 4
  }
	
  // XML getter	
  // This serializes the DOM tree to an XML String

  // XMLDocument did not extend the Document interface in some versions
  // of Mozilla. Extend both!
  Document.prototype.__defineGetter__("xml", function () {
    return (new XMLSerializer()).serializeToString(this);
  });

}


































function readFile(url)
{
  var req;
  if (document.all){
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else if (netscape){
    if (document.getElementById){
      req = new XMLHttpRequest();
    }
    else {
      req = new NS4HttpRequest();
    }
  }
  req.open("GET",url,false);
  req.send(null);
  return req.responseText;
}

function NS4HttpRequest()
{
  this.url = "";
  this.responseText = "";
}
NS4HttpRequest.prototype.open = function(method,url)
{
  this.url = url;
  this.method = method||get;
}
NS4HttpRequest.prototype.send = function()
{
  // thank you Mr. Pemberton
  if (this.url=="") return false;
  var line,buffer;
  this.responseText = "";
  buffer = new java.io.BufferedReader(new java.io.InputStreamReader(new java.net.URL(this.url).openStream()));
  while ((line = buffer.readLine())!=null) this.responseText+=line + "\n";
  if (buffer!=null) buffer.close();
  return true;
}
