/*------------------------------------------------------------------------------
 * JavaScript zXml Library
 * Version 1.0
 * by Nicholas C. Zakas, http://www.nczonline.net/
 * Copyright (c) 2004-2005 Nicholas C. Zakas. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *------------------------------------------------------------------------------
 */  

/**
 * Legacy zXml settings for backwards compatibility.
 */
var zXml = {
    useActiveX /*:Boolean*/ : (typeof ActiveXObject != "undefined"),
    useDom /*:Boolean*/: document.implementation && document.implementation.createDocument,
    useXmlHttp /*:Boolean*/: (typeof XMLHttpRequest != "undefined"),
    
    settings : {

        /**
		 * Does this browser support native XMLHttpRequest?
		 */
		hasXmlHttp /*:Boolean*/: (typeof XMLHttpRequest != "undefined"),
		
		/**
		 * Does this browser support ActiveX controls?
		 */
		hasActiveX /*:Boolean*/: (typeof ActiveXObject != "undefined"),
		
		/**
		 * Does this browser support native DOM creation?
		 */
		hasXmlDom /*:Boolean*/: (document.implementation && document.implementation.hasFeature("XML", "1.0")),
		
		/**
		 * Does this browser support DOM LoadSave?
		 */
		hasDomLS /*:Boolean*/: (document.implementation && document.implementation.hasFeature("LS", "3.0")),
		
		/**
		 * Does this browser support DOM LoadSave?
		 */
		hasDomLSAsync /*:Boolean*/: (document.implementation && document.implementation.hasFeature("LS-Async", "3.0")),
		
		/**
		 * Does this browser support a native DOMParser?
		 */
		hasDomParser /*:Boolean*/: (typeof DOMParser != "undefined"),
		
		/**
		 * Does this browser support a native XMLSerializer?
		 */
		hasXmlSerializer /*:Boolean*/: (typeof XMLSerializer != "undefined"),
		
		/**
		 * Does this browser have an XSLTProcessor?
		 */
		hasXSLTProcessor /*:Boolean*/: (typeof XSLTProcessor != "undefined")
    }
}

zXml.ARR_XMLHTTP_VERS = ["MSXML2.XmlHttp.6.0", "MSXML2.XmlHttp.3.0"];

zXml.ARR_DOM_VERS = ["MSXML2.DOMDocument.6.0", "MSXML2.DOMDocument.3.0"];
 
/**
 * Static class for handling XMLHttp creation.
 * @class
 * @scope public
 */                     
function zXmlHttp() {
}

/**
 * Creates an XMLHttp object.
 * @static
 * @scope public
 * @return An XMLHttp object.
 */
zXmlHttp.createRequest = function ()/*:XMLHttp*/ {

    if (zXml.settings.hasXmlHttp) {
        return new XMLHttpRequest();
    } else if (zXml.settings.hasActiveX) {
        if (!zXml.XMLHTTP_VER) {
            for (var i=0; i < zXml.ARR_XMLHTTP_VERS.length; i++) {
                try {
                    new ActiveXObject(zXml.ARR_XMLHTTP_VERS[i]);
                    zXml.XMLHTTP_VER = zXml.ARR_XMLHTTP_VERS[i];
                    break;
                } catch (oError) {                
                }
            }
        }
        
        if (zXml.XMLHTTP_VER) {
            return new ActiveXObject(zXml.XMLHTTP_VER);
        } else {
            throw new Error("Could not create XML HTTP Request.");
        }
    } else {
        throw new Error("Your browser doesn't support an XML HTTP Request.");
    }
}

/**
 * Indicates if XMLHttp is available.
 * @static
 * @scope public
 * @return True if XMLHttp is available, false if not.
 */
zXmlHttp.isSupported = function ()/*:Boolean*/ {
    return zXml.settings.hasXmlHttp || zXml.settings.hasActiveX;
}


/**
 * Static class for handling XML DOM creation.
 * @class
 * @scope public
 */
function zXmlDom() {

}

/**
 * Creates an XML DOM document.
 * @static
 * @scope public
 * @return An XML DOM document.
 */

