﻿// JScript File

function getXmlValue(oNode,sTagName)
{
    try
    {
        return oNode.getElementsByTagName(sTagName)[0].childNodes[0].nodeValue;
    }
    catch(e)
    {
        alert(e.description);
        return "";
    }
}

function getXmlObject()
{
    var oXml;
    try 
    {
        oXml = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
          oXml = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
          oXml = null;
      }
    }
    if(!oXml && typeof XMLHttpRequest!="undefined")
    {
        oXml = new XMLHttpRequest();
    }
    if(!oXml)
    {
        alert("Sorry, your browser is not supported by our system. Please use Internet Explorer 6.0+ or Firefox 2.0");
    }
    return oXml;
}

function ajaxCall(sUrl,sRequest,fCallback)
{
    var oXml = getXmlObject();
    
    oXml.open("POST",sUrl,true);
    oXml.setRequestHeader("Method", "POST " + sUrl + " HTTP/1.1");
    oXml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    oXml.onreadystatechange = function()
    {
        if(oXml.readyState!=4) return;
        if(fCallback) fCallback(oXml.responseText);
    }
    oXml.send(sRequest);
}

function ajaxCallObject(sUrl,sRequest,fCallback)
{
    var oXml = getXmlObject();
    var oXmlReturn;
    
    oXml.open("POST",sUrl,true);
    oXml.setRequestHeader("Method", "POST " + sUrl + " HTTP/1.1");
    oXml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    oXml.onreadystatechange = function()
    {
        if(oXml.readyState!=4) return;
        if (typeof DOMParser != "undefined")
        {  
            var objDOMParser = new DOMParser();
            oXmlReturn = objDOMParser.parseFromString(oXml.responseText, "application/xml");
        } 
        else if (typeof ActiveXObject != "undefined" && typeof GetObject != "undefined")
        {
            try 
            {
                oXmlReturn = new ActiveXObject("Msxml2.XMLDOM");
            }
            catch(e)
            {
                try
                {
                    oXmlReturn = new ActiveXObject("Microsoft.XMLDOM");
                }
                catch(e)
                {
                    oXmlReturn = null;
                }
            }
            oXmlReturn.async="false";

            oXmlReturn.loadXML(oXml.responseText);
        }

        if(fCallback) fCallback(oXmlReturn);
    }
    oXml.send(sRequest);
}