xmlhttps = Array();

function createXmlHttp(aIdentifier)
{
	xmlhttps[aIdentifier] = instantiateXmlHttp();
}

function getXmlHttp(aIdentifier)
{
	return xmlhttps[aIdentifier];
}

function removeXmlHttp(aIdentifier)
{
	delete(xmlhttps[aIdentifier]);
}

function instantiateXmlHttp()
{
	var getxmlhttp = false;
	if (window.XMLHttpRequest)
	{
		getxmlhttp = new XMLHttpRequest();
		if (getxmlhttp.overrideMimeType)
		{
			getxmlhttp.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject)
	{
		try
		{
			getxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				getxmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert('Warning. Could not create xmlhttp instance at getXmlHttp().');
				return null;
			}
		}
	}
	return getxmlhttp;
}

function normalizeResponseXml(aXmlResponse)
{
  // Firefox workaround, try-catch for ie.
  try
  {
  	aXmlResponse.normalize();
  }
  catch (aError) {}
  
  return aXmlResponse;
}

function decodeXmlResponse(aXmlResponse,aContentTag)
{
  var aReturn = "";
  
  aXmlResponse = normalizeResponseXml(aXmlResponse);
  
  aContent = aXmlResponse.getElementsByTagName(aContentTag);
  if (aContent.length > 0)
  {
  	try
  	{
    	aContent = aContent.item(0).firstChild.nodeValue;
    	aReturn  = unescape(aContent);
    }
    catch (e)
    {
    	aReturn = "";
    }
  }
  
  return aReturn;
}