//================================================
//xml functions
//Splendid Ltd. 2006 http://www.howsplendid.com
//================================================
//Example use:
//getXMLfile("sample.xml","GET",null,httpXMLCallBack);
//function httpXMLCallBack(httpXML){
//  var nodeParent;
//  nodeParent = httpXML.responseXML;
//  alert(nodeParent);
//}
//
//================================================

        //getXMLfile - load an xml file from a remote source
        //sURL - url of xml data source
        //sMethod - POST or GET
        //sData - null for GET
        function getXMLfile(sURL,sMethod,sData,hCallBack){
            httpXML = createXMLHTTPObj();
            if (httpXML){
                httpXML.onreadystatechange = function(){
                    updatehttpXMLStatus(httpXML,hCallBack)
                }
                //load xml(method,url,async)
                httpXML.open(sMethod, sURL, true)
                httpXML.send(sData)
            }
        }
        //handle status update of current xml load
        //after success runs callback, other events are currently ignored
        function updatehttpXMLStatus(httpXML,hCallBack){ 
            // 0 Object is not initialized
            // 1 Loading object is loading data
            // 2 Loaded object has loaded data
            // 3 Data from object can be worked with
            // 4 Object completely initialized
            if (httpXML.readyState == 4){ //if request of file completed
                if (httpXML.status==200){
                    //alert(httpXML.responseText);
                    hCallBack(httpXML);
                }                
            }
        }
        //create an XMLHTTP object for this browser            
        function createXMLHTTPObj(){
            var httprequest=null;
            if (window.XMLHttpRequest){ 
                //non IE - xml obj
                httprequest=new XMLHttpRequest();
                if (httprequest.overrideMimeType){
                    httprequest.overrideMimeType('text/xml')
                }
            } else if (window.ActiveXObject){ 
                //IE - two possible versions of xml obj
                try {
                    httprequest=new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e){
                    try{
                        httprequest=new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    catch (e){
                        return null;
                    }
                }
            }
            return httprequest;
        }