﻿// global request
var req;
var browserType = "IE";



function loadXMLDoc(url, onChange) {
	try
	{
		req = getRequest();
		if (req)
		{
			req.onreadystatechange = onChange;
			req.open("GET", url, true);
			req.send(null);		
		}
	}
	catch(e)
	{
		throw e;
	}
}

function loadXMLDocSync(url) {
	try
	{
		req = getRequest();
		if (req)
		{
		    if (browserType == "Other")
		    {
			    req.open("GET", "\"" + url + "\"", false);
		    }
		    else
		    {
		        req.open("GET", url, false);
		    }
			req.send(null);		
		}
	}
	catch(e)
	{
		throw e;
	}
}

function getRequest()
{
  try {
    request = new XMLHttpRequest();
    browserType = "Other";
  } catch (trymicrosoft) {
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
      browserType = "IE";
    } catch (othermicrosoft) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
        browserType = "IE";
      } catch (failed) {
        request = false;
      }
    }
  }
  return request;
}

function IsElement(node)
{
  var boolVal = true;
  if (browserType == "IE")
        boolVal  = (node.nodeTypeString == "element") 
  return boolVal;
}

function getNodeText(node)
{
    if (browserType == "IE")
    {
        return node.text;
    }
    else
    {
        return node.textContent;
    }
}
