/*	File		:	jsXMLlib.js
**	Author		:	Dr. Clue	( A.K.A. Ian A. Storms)
**	Description	:	A singular XML class that handles both DOM
**			and HTTP access of XML data.
*/
oDCxmllib={};
/*	Function	:	DCxmlCreate()
**	Parameters	:	N/A
**	Returns		:	Browser XML object
**	Description	:	Since the XML parser object we need is accessed
**				via different methods by the various browsers,
**				I use a little object sniffing to determine
**				if the object is aquired by IE's
**				ActiveObject("Microsoft.XMLDOM") approach, or
**				the more common approach used by other browsers
**				document.implementation.createDocument("","",null)
**				
**				Since it is an object sniffer , it should hold up
**				well as browser evolve and rebrand themselves,
*/
function	DCxmlCreateDOM()
	{
	oXmlDoc=null
	if(typeof ActiveXObject=='function')
		{
		oXmlDoc		=new ActiveXObject("Microsoft.XMLDOM");
		oXmlDoc.async	="false";
		} else if(typeof document.implementation.createDocument=='function')
		{
		oXmlDoc=self.document.implementation.createDocument("","",null);
		oXmlDoc.bNS=true;
		}
	return oXmlDoc;
	}
/*	Function	:	DCxmlCreateHTTP()
**	Parameters	:	N/A
**	Returns		:	oXmlDoc
**	Description	:	Creates a cross browser XMLHTTP object
*/
function	DCxmlCreateHTTP()
	{
	oXmlDoc=null;
	if(typeof window.XMLHttpRequest=='object')
		{	oXmlDoc		=new window.XMLHttpRequest();
			oXmlDoc.bNS	=true		;
		} else	if(typeof ActiveXObject=='function')
			{
			oXmlDoc		=new ActiveXObject("Microsoft.XMLHTTP");
			} else if(typeof XMLHttpRequest=='function')
				{
				oXmlDoc= new XMLHttpRequest()
				}
	return oXmlDoc;
	}
/*	Function	:	DCxmlFind()
**	Parameters	:	szField
**				szValue
**	Returns		:	-1	-Not Found
**				>-1	-indexOffset of matching result
**	Description	:	Simply searchs for an element containing the value
*/
function	DCxmlFind(szField,szValue)
	{
	aS=this.xmlDoc.getElementsByTagName(szField)
	for(x=0;x<aS.length;x++)
		{
		if(aS[x].firstChild.nodeValue==szValue)return (this.iRecno=x)
		}
	return (this.iRecno=-1);
	}
/*	Function	:	DCxmlRecno()
**	Parameters	:	N/A
**	Returns		:	iRecno	-The last selected record indexOffset
**	Description	:
*/
function	DCxmlRecno()
		{
		return this.iRecno;
		}
/*	Function	:	DCxmlCatcher()
**	Parameters	:	oXML
**	Returns		:	N/A
**	Description	:	This is a callback function for those XML 
**			calls that have some duration and produce a callback event 
*/
oDCxmllib.aState=[	"0 uninitialized",
			"1 loading",
			"2 loaded",
			"3 interactive",
			"4 complete"	]
function	DCxmlCatcher(oXML)
		{	
		if(oXML.szMethod!='FILE')
			{
//			DCstatus("XML reception state ["+oDCxmllib.aState[oXML.xmlHTTP.readyState]+"]")
			if(oXML.xmlHTTP.readyState != 4)return
			oXML.xmlDoc=oXML.xmlHTTP.responseXML
			}else{

			}
		oXML.bReady=true;
		if(	typeof oXML.fXMLnotify=='undefined')return;
		DCstatus("Done...")
		oXML.fXMLnotify(oXML)
		}
/*	Function	:	DCxmlFauxOnload()
**	Parameters	:	pL
**	Returns		:	N/A
**	Description	:
*/
function	DCxmlFauxOnload(pL)
	{
	oL=DCok(pL)
		DCstatus("Done...")
	oL.DCxml.xmlDoc=oL.getElementsByTagName('iframe')[0].contentWindow.document
	oL.DCxml.xmlCatcher	(oL.DCxml	);
	}
/*	Function	:	DCxmlFauxLoad()
**	Parameters	:	szFile
**	Returns		:	N/A
**	Description	:
*/
function	DCxmlFauxLoad(szFile)
	{
	this.DCxml.szFaux="oFaux"+"_"+this.DCxml.szXMLurl.split("/").pop().split(".").join("_")
	self.DCxmlFaux=DCcreate("self.document.all."+this.DCxml.szFaux,-500,5,100,100,"#ffffcc")
	self.DCxmlFaux.DCxml=this.DCxml
	DCsetContent(self.DCxmlFaux,'<iframe src="'+szFile+'" onload="DCxmlFauxOnload(\''+this.DCxml.szFaux+'\')"></iframe>')
	}
/*	Function	:	DCxmlDOMopen()
**	Parameters	:	N/A
**	Returns		:	N/A
**	Description	:
*/
function	DCxmlDOMopen()
	{
	if(typeof this.xmlDoc.load=='undefined')
		{
		this.xmlDoc.load=this.fFauxLoad
		this.xmlDoc.DCxml=this;
		}
	try	{
		if(this.xmlDoc.bNS)
			{
			this.szNScatch = "self."+this.szXMLurl.split("/").pop().split(".").join("_")
			this.xmlDoc.load(this.szXMLurl);
		DCstatus("Done...")

 			eval(this.szNScatch+"=this");
			this.xmlDoc.onload=new Function("DCxmlCatcher("+this.szNScatch+")")
			}else{
			this.xmlDoc.load(this.szXMLurl	);
			this.xmlCatcher	(this		);
			}// ENDIF
		}catch(e)
		{
		alert("jsXMLlib.js:DCxml():\n"+DCo2a(e).split(",").join("\n"))
		this.bFailed	=true	;
		this.eFailed	=e	;
		}//*** End try catch
	}
/*	Function	:	DCxmlHTTPopen()
**	Parameters	:	N/A
**	Returns		:
**	Description	:
*/
function	DCxmlHTTPopen()
	{
	szNScatch = "self.DCrssCatch"+this.szXMLurl.split("/").pop().split(".").join("_").split("?")[0].split(".").join("").split(",").join("")
	eval(szNScatch+"=this");
	this.xmlDoc.onreadystatechange=new Function("DCxmlCatcher("+szNScatch+")")
	try	{
		this.xmlDoc.open (this.szMethod, this.szXMLurl, true);
		this.xmlDoc.send (this.szSoap);
		}catch(e)
		{
		alert("jsXMLlib.js:DCxml->DCxmlHTTPopen():\n"+DCo2a(e).split(",").join("\n"))
		this.bFailed	=true	;
		this.eFailed	=e	;
		}//*** End try catch
	}
/*	Function	:	DCgetXMLvalue()
**	Parameters	:	oObject
**				szChildName
**				oDefault
**	Returns		:	oChildValue
**	Description	:
*/
function	DCgetXMLvalue(oObject,szChildName,oDefault)
	{
	oChildValue	=(typeof oDefault=='undefined')?null:oDefault;
	aChildren	=oObject.getElementsByTagName(szChildName);
	if(aChildren			)
	if(aChildren.length		)
	if(aChildren[0].firstChild	)oChildValue=aChildren[0].firstChild.nodeValue
	return oChildValue
	}
/*	CONSTRUCTOR	:	DCxml()
**	Parameters	:	szXMLurl	-
**				fXMLnotify	-
**				szMethod	-
**				szSoap		-		
**	Returns		:
**	Description	:
*/
function	DCxml(szXMLurl,fXMLnotify,szMethod,szSoap)
	{
	this.szMethod	=(typeof szMethod	== 'string')?szMethod	:'GET'	;
	this.szSoap	=(typeof szSoap		== 'string')?szSoap	:''	;
	this.xmlHTTP	={status:0,responseText:""};
	this.xmlDoc	={}		;
	this.bFailed	=false		;
	this.eFailed	=null		;
	this.bReady	=false		;
	this.iRecno	=0		;
	this.fFauxLoad	=DCxmlFauxLoad	;
	this.szXMLurl	=szXMLurl	;
	this.getUrl	=new Function("","return this.szXMLurl")
	this.getStatus	=new Function("","return this.xmlHTTP.status")
	this.getResponse=new Function("","return this.xmlHTTP.responseText")
	this.fXMLnotify	=fXMLnotify	;
	this.xmlCatcher	=DCxmlCatcher	;
	this.find	=DCxmlFind	;
	this.recno	=DCxmlRecno	;
	if(this.szXMLurl.indexOf("http://")==0)
		{
		this.xmlHTTP	=DCxmlCreateHTTP()	;// Create xml handle via browser object sniff
		this.xmlDoc	=this.xmlHTTP
		this.open	=DCxmlHTTPopen
		}else{
		this.szMethod	='FILE'
		this.xmlDoc	=DCxmlCreateDOM()	;// Create xml handle via browser object sniff
		this.open	=DCxmlDOMopen
		}	
	if(!this.xmlDoc)
		{	alert("jsXMLlib.js::DCxml("+szXMLurl+") No XML Support");return;
		}else{	this.open();		}
	}

