
	Stenstrom.NET.Web.Xml.HttpRequest	= function() {
	
	// inherit the System.Navigator class properties and methods 
		Stenstrom.NET.Web.Navigator.call(this);
	
		
	// TODO : remove the properties and methods that this class does not require
		delete Stenstrom.NET.Web.Xml.HttpRequest.SetCookie;
		delete Stenstrom.NET.Web.Xml.HttpRequest.GetCookie;
		delete Stenstrom.NET.Web.Xml.HttpRequest.ClearCookie;
		delete Stenstrom.NET.Web.Xml.HttpRequest.ClearAllCookies;
		delete Stenstrom.NET.Web.Xml.HttpRequest.QueryString;
		
	// create the prototype so that this class may be inherited 
		Stenstrom.NET.Web.Xml.HttpRequest.prototype				= new Stenstrom.NET.System.Object();
		Stenstrom.NET.Web.Xml.HttpRequest.prototype.constructor	= Stenstrom.NET.Web.Xml.HttpRequest;
		
	// static properties - defined as public but not intended for public consumption
		this.Type			= "Stenstrom.NET.Web.Xml.HttpRequest";
		
		Xml_HttpRequest_Initialize(this);
	}
	function Xml_HttpRequest_Initialize(obj){
		
	// go through the different types of Request objects until one is found that works for the host browser.
		var progIdList	= [ "Msxml2.XMLHTTP.6.0",  "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP" ];
	// Properties
		obj.RequestVersion	= null;
		obj.Request			= null;
		
		(function(){
		
			var factory	= null;
			var version	= "Un-Supported";
			
		// MSIE
			if(obj.ActiveXSupport && obj.ActiveXEnabled()){
		
				for(var i=0; i<progIdList.length; i++){
				
					try {
						
						factory = new ActiveXObject( progIdList[i] );
						version	= progIdList[i];
						break;
					}
					catch(err) { continue;}
				}
			}
			else
		// MOZILLA
			{
				factory = new XMLHttpRequest();
				version = "XMLHttpRequest";
			}
			
			obj.RequestVersion	= version;
			obj.Request			= factory;
		
		})()
		
	// functions
		obj.GetText			= function(sURL){
		
			if(this.Request == null)
				return;
				
			this.Request.open("GET", sURL, false);
			this.Request.send(null);
			
			if(this.Request.status != 200){
			
				var err = new Error("An HTTP "+ this.Request.status +" error occured while retrieving the file : "+ sURL);
				throw err;
			}
			else{
				return this.Request.responseText		
			}
			
		}
	
	}

	Stenstrom.NET.Web.Xml.DOMDocument	= function(sXML, bIsFreeThreaded){
	
	// inherit the System.Xml.HttpRequest class properties and methods 
		Stenstrom.NET.Web.Xml.HttpRequest.call(this);
		
	// TODO : remove the properties and methods that this class does not require
		
	// create the prototype so that this class may be inherited 
		Stenstrom.NET.Web.Xml.DOMDocument.prototype				= new Stenstrom.NET.System.Object();
		Stenstrom.NET.Web.Xml.DOMDocument.prototype.constructor	= Stenstrom.NET.Web.Xml.DOMDocument;
		
	// static properties - defined as public but not intended for public consumption
		this.Type			 = "Stenstrom.NET.Web.Xml.DOMDocument";
		this.bIsFreeThreaded = (bIsFreeThreaded == null)? false : bIsFreeThreaded;
		
		Xml_DOMDocument_Initialize(this, bIsFreeThreaded);
		
	// after the object has been initialized ... load the content if provided.
		if(sXML != null && typeof(sXML) != "undefined")
			this.LoadXML( sXML );
	}
	function Xml_DOMDocument_Initialize(obj, bIsFreeThreaded){
	
	// properties
		obj.SelectionLanguage	= "XPath";
		obj.DocumentElement	= null;
		obj.Xml				= "";
		obj.Dom;
		obj.DomVersion;
		
	// initlize the obj.Dom
		(function(){
		
		// will contain list of available ProgId's
			var progIdList;			
			
			if(obj.ActiveXSupport && obj.ActiveXEnabled()){
			// generate arrays of possible ProgIDs 
				if(!obj.bIsFreeThreaded){
					progIdList = ["MSXML2.DOMDocument.6.0","MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument", "Microsoft.XMLDOM"];}
				else{
					progIdList = ["MSXML2.FreeThreadedDOMDocument.6.0", "MSXML2.FreeThreadedDOMDocument.5.0", "MSXML2.FreeThreadedDOMDocument.4.0", "MSXML2.FreeThreadedDOMDocument.3.0", "MSXML2.FreeThreadedDOMDocument", "MSXML.FreeThreadedDOMDocument", "Microsoft.FreeThreadedXMLDOM"];}
			
				var factory	= null;
				var version	= "Un-Supported";
				
			// go through each ProgID until one is found that is compatible
				for(var i=0; i<progIdList.length; i++)
				{
					try{
						
						factory 		= new ActiveXObject( progIdList[i] );
						factory.setProperty("SelectionLanguage", obj.SelectionLanguage);
						factory.async	= false;
						version			= progIdList[i];
						break;
					}
					catch(err) { continue;}
				}
				
				obj.Dom			= factory;
				obj.DomVersion	= version;
			}
			else if(obj.ActiveXSupport && !obj.ActiveXEnabled()){
				alert("ActiveX must be enabled");
			}
			else if(!obj.ActiveXSupport){
			
				obj.Dom 		= new DOMParser();	
				obj.DomVersion	= "DOMParser";
			}
		})();
		
	// methods 
		obj.LoadXML				= function(sXML){
			
		var xmlText;
						
		// Is a reference to an xml DataIsland element
			if(typeof(sXML) == "object" && sXML.tagName.toLowerCase() == "xml"){
			
			// does the DataIsland have a SRC defined?
				if(sXML.getAttributeNode("src") != null)
				{
					var src = sXML.getAttribute("src");
					xmlText = this.GetText(src);
				}
				else
				{
					if(this.IsMSIE)
						xmlText = sXML.documentElement.xml;
					else
						xmlText = sXML.innerHTML;
				}
			}
			else if(typeof(sXML) == "string"){
			
				var isXmlString	= ( sXML.indexOf("<") != -1 )? true : false;
				var isDataIsland	= ( !isXmlString && (document.getElementById( sXML ) != null && document.getElementById( sXML ).tagName.toLowerCase() == "xml") )? true : false;
				var isFilePath	= ( !isXmlString && !isDataIsland )? true : false;
				
				if(isXmlString)
					xmlText	= sXML;
				else if(isFilePath){
					try{ xmlText = this.GetText(sXML); } 
					catch(err){ 
					
						var errMsg  = "ERROR Retrieving XML : Could not load XML Src.\n\n ";
							errMsg += "The file, '"+ sXML +"' was unable to be loaded. Verify that the file exists.";
						var err = new Error(errMsg);
						throw err;
					}
				}
				else if(isDataIsland){
					var dataIsland	= document.getElementById( sXML );
					
				// does the DataIsland have a SRC defined?
					if(dataIsland.getAttributeNode("src") != null)
					{
						var src = dataIsland.getAttribute("src");
						xmlText = this.GetText(src);
					}
					else
					{
						if(this.IsMSIE){
							if(dataIsland.documentElement == null){
								
								var errMsg	= "ERROR Loading XML: Unable to initialize DOMDocument\n\n";
									errMsg += "Verify that the xml Data Island Source contains only valid XML";
								
								var err = new Error(errMsg);
								throw(err);
							}
							else{
							
								xmlText = dataIsland.documentElement.xml;
							}
						}
						else{
							xmlText = dataIsland.innerHTML;
						}
					}
				}
				else{
				
					var errMsg	= ""
						errMsg += "ERROR Retrieving XML : Invalid XmlDOM source.\n\n XmlDOM Source must be ... \n";
						errMsg += "1. A reference to, or the ID of, a valid Xml Data Island ( ie. an <xml> element) \n";
						errMsg += "2. Path to a valid XML document.\n";
						errMsg += "3. A valid XML String";
					var err = new Error(errMsg);
					throw err;
				}
			}
			else{
			
				var errMsg	= ""
						errMsg += "ERROR Retrieving XML : Invalid XmlDOM source.\n\n XmlDOM Source must be ... \n";
					errMsg += "1. A reference to, or the ID of, a valid Xml Data Island ( ie. an <xml> element) \n";
					errMsg += "2. Path to a valid XML document.\n";
					errMsg += "3. A valid XML String";
				var err = new Error(errMsg);
				throw err;
			}
			
		// strip away any characters which precede the first Element in the document.
			xmlText 	= xmlText.substring(xmlText.indexOf("<"));
			
		// MSIE
			if(this.ActiveXSupport){
				if(!this.Dom.loadXML(xmlText)){
					
					var errMsg	= "PARSER ERROR: Unable to initialize DOMDocument\n\n";
						errMsg += "Verify that the xml Source contains only valid XML";
					
					var err = new Error(errMsg);
					throw(err);
				}
				
				this.DocumentElement = this.Dom.documentElement;
				this.Xml			 = this.DocumentElement.xml;
			}
		// MOZILLA
			else{
					this.Dom = this.Dom.parseFromString(xmlText, "text/xml");
					this.DocumentElement = this.Dom.documentElement;
					this.Xml			 = (new XMLSerializer()).serializeToString( this.DocumentElement );
					
					if(this.DocumentElement.nodeName == "parsererror"){
					
						var errMsg	= "PARSER ERROR: Unable to initialize DOMDocument\n\n";
							errMsg += "Verify that the xml Source contains only valid XML";
						
						var err = new Error(errMsg);
						throw(err);
					}
			}
		
		}
		obj.GetOuterXml			= function(){
						
		// MSIE
			if(this.ActiveXSupport){
			
				this.Xml			 = this.DocumentElement.xml;
				return( this.Xml);
			}
		// MOZILLA
			else{
				this.Xml			 = (new XMLSerializer()).serializeToString( this.DocumentElement );
				return(this.Xml);
			}
		}
		obj.SelectSingleNode	= function(sXPath){
		
			var singleNode	= null;
			
		// MSIE
	        if(this.IsMSIE){
			
	            singleNode = this.DocumentElement.selectSingleNode(sXPath);
	        }
		// MOZILLA
	        else{
			
	            var xPathResult = this.Dom.evaluate(sXPath, this.Dom, null, FIRST_ORDERED_NODE_TYPE, null);
	            singleNode 	 = xPathResult.singleNodeValue
	        }   
			
			return(singleNode);
		}
		obj.SelectNodes			= function(sXPath){
			
			var nodeArray	= new Array();
			
			// MSIE
			if(this.IsMSIE){
            
				var nodeList = this.Dom.documentElement.selectNodes(sXPath);

				for(var i=0; i<nodeList.length; i++){
                
					nodeArray.push( nodeList[i] );
				}
			}
			else
			// MOZILLA
			{
				var xPathResult 	= this.Dom.evaluate(sXPath, this.Dom, null, ORDERED_NODE_ITERATOR_TYPE, null);				
				var node			= xPathResult.iterateNext();

				while(node){
                
					nodeArray.push( node );
					node = xPathResult.iterateNext();
				}
			}
			
			return(nodeArray);		
		}
        obj.CreateElement      	= function(sElementName){
         
                return( this.Dom.createElement(sElementName) );
        }
		obj.CreateCDATASection	= function( sText ){
		
			return( this.Dom.createCDATASection( sText ) );
		}
        obj.CreateTextNode		= function(sText){
			return( this.Dom.createTextNode( sText ) );
		}
		
	};
	

/*	METHOD 	: Transform(XmlDOMDocument) *********************************************
		PARAM	: XmlDOMDocument :  Stenstrom.NET.Web.Xml.DOMDocument : The Xml to be 
				  transformed.
		REMARKS	: This function only works if THIS document represents the XSLT. You then 
				  pass in the XML you want to apply this transformation to.
		RETURNS : String ... 
		obj.Transform			= function(XmlDOMDocument){
		
			if(obj.ActiveXSupport && !obj.bIsFreeThreaded){
				alert("DomDocument MUST be Free Threaded to transform");
			}
			
		// MSIE
			if(this.ActiveXSupport){
				if(!obj.bIsFreeThreaded){
					alert("Object cannot be transformed unless the XSLT is a FreeThreaded DOM.");
					return null;
				}
				else{
					var progIdList 		= ["MSXML2.XSLTemplate.6.0","MSXML2.XSLTemplate.5.0","MSXML2.XSLTemplate.4.0","MSXML2.XSLTemplate.3.0","MSXML2.XSLTemplate","MSXML2.XSLTemplate"];
					var xslTemplate		= null;
					var xslProcessor	= null;
				
				// go through each ProgID until one is found that is compatible
					for(var i=0; i<progIdList.length; i++){
						try{
							
							xslTemplate 		= new ActiveXObject( progIdList[i] );
							break;
						}
						catch(err) { continue;}
					}
					
					xslTemplate.stylesheet	= this.Dom;
					xslProcessor			= xslTemplate.createProcessor();
					xslProcessor.input		= XmlDOMDocument.Dom;
					
					return( xslProcessor.output );
				}
			}
		// MOZILLA
			else{
				var xsltProcessor	= new XSLTProcessor();
					xsltProcessor.importStylesheet(this.Dom);
				var docFragment		= document.implementation.createDocument("", "test", null);
				var resultDocument 	= xsltProcessor.transformToFragment(XmlDOMDocument.Dom, docFragment);
				return( (new XMLSerializer()).serializeToString( resultDocument.documentElement ) );				
			}
			
		}
		
	*/
		