// <script language="Javascript" type="text/javascript">
// <!-- Copyright 2003 - Alexa Internet
// Author: Aaron C. Stewart
// Desc: abstract XML class

function XMLObj(sUrl) {
	var o = new JSObj(); o.oType = "XMLObj";
	o.url = sUrl;
	if (o.url.indexOf("?")) { o.url = o.url.substring(o.url.indexOf("?"+1)); }
	o.object = null; o.xml = null;
	o.load = XMLObj_load; o.loadstring = XMLObject_loadstring; o.get = XMLObj_get; o.ready = XMLObj_ready;
	if (isIE()) {
		o.createXMLObject = XMLObj_createXMLObject_IE;
	}
	o.transform = XMLObj_transform;
	o.create(); return o;
	function XMLObj_createXMLObject_IE() {
//		this.object = new ActiveXObject("msxml2.FreeThreadedDomDocument");
		this.object = new ActiveXObject("Microsoft.XMLDOM");
		this.object.async = true;
		eval("function "+this.oType+"_onreadystatechange_"+this.oID+"() { jsAll.objects."+this.oType+"['"+this.oID+"'].ready(); }");
		this.object.onreadystatechange = eval(this.oType+"_onreadystatechange_"+this.oID);
	}
	function XMLObj_createXMLObject_NS() {
		this.object		= new XMLHttpRequest();
		eval("function "+this.oType+"_onreadystatechange_"+this.oID+"() { jsAll.objects."+this.oType+"['"+this.oID+"'].ready(); }");
		this.object.attachEvent("load", eval(this.oType+"_onreadystatechange_"+this.oID), false);
	}
	function XMLObj_load() {
		if ((!this.xml) && (!this.bLoading)) {
			try {
				this.bLoading = true;
				this.createXMLObject();
				if (isIE())
				{
					this.object.load(ALEXA_XML_SOURCE + unescape(this.url));
				} else {
					this.object.open(ALEXA_XML_SOURCE + unescape(this.url));
					this.object.send(null);
				}
			} catch (ex) {
				if (disable_debug_handler == true) { debug(ex); }
				// netscape?
			}
		} else {
			// already have data
		}
	}
	function XMLObject_loadstring(sStr) {
		if (sStr) {
			try {
				this.createXMLObject();
				this.object.loadXML(sStr);
			} catch(ex) {
				if (disable_debug_handler == true) { debug(ex); }
			}
			return true;
		}
		return false;
	}
	function XMLObj_get(sXPath) {
		var oNodeList;
		var oNode;
		var aReturn = new Array();
		var oItems;
		var oItem;
		var oAttributes;
		var oAttribute;
		var nItems = 0;
		if ( !this.object.parsed ) {
			return null;
		}
		oNodeList = this.object.selectNodes(sXPath);
		if ( oNodeList.length == 0 ) {
			return '';
		}
		oItems = new Enumerator(oNodeList);
		for (oItems.moveFirst(); !oItems.atEnd(); oItems.moveNext()) {
			oItem = oItems.item();
			if ( oItem.attributes ) {
				oAttributes = new Enumerator(oItem.attributes);
				aReturn[nItems] = new Object();
				var count = 0;
				for (oAttributes.moveFirst(); !oAttributes.atEnd(); oAttributes.moveNext()) {
					count++; 
					var oAttribute = oAttributes.item(); 
					aReturn[nItems][oAttribute.name.toLowerCase()] = oAttribute.value; 
				}
				if ((count == 0) && (oItem.text != '')) {
					return oItem.text; 
				}
			} else {
				return oItem.text; 
			}
			nItems++;
		}
		return aReturn;
	}
	function XMLObj_transform(oStyleXMLDOM) {
		if ( oStyleXMLDOM.xml == '' ) { 
			return ''; 
		}
		try {
			var sResult = this.object.transformNode(oStyleXMLDOM);
		} catch(ex) {
			if (disable_debug_handler == true) { debug(ex); }
			// bad stylesheet or out of disk space.
			var sResult = "";
		}
		return sResult;
	}

	function XMLObj_ready() {
		if (this.object.readyState != 4) { 
			return false; 
		} else { 
			this.bLoading = false; return true; 
		} 
	}
}
function PopupXMLObj(oParent) {
	var sUrl = "";
	var o = new XMLObj(sUrl); o.oType = "PopupXMLObj";
	o.parent = oParent;
	o.callback = null;
	o._ready = o.ready; o.ready = PopupXMLObj_ready;
	o._load = o.load; o.load = PopupXMLObj_load;
	o.setUrl = PopupXMLObj_setUrl;
	o.setCallback = PopupXMLObj_setCallback;

	o.create(); return o;
	function PopupXMLObj_ready() {
		if (this._ready() == false) {
			return false;
		}
		try {
			// attach the url to the dad stream

			var oNode = this.object.selectSingleNode("FIX1");
			var sPassedUrl = unescape(this.url);
			if (sPassedUrl.indexOf("FIX2") == 0) {
				sPassedUrl = sPassedUrl.substring(7);
			}
			oNode.setAttribute("REALURL", sPassedUrl);
		} catch(ex) { if (disable_debug_handler == true) { debug(ex); } }
		try {
			this.parent.contentObj.hasData = true;
			this.parent.contentObj.show();
		} catch(ex) { if (disable_debug_handler == true) { debug(ex); } }
	}

	function PopupXMLObj_load() {

		this.setUrl(oDataA[this.parent.nDataA].href);
		return this._load();
	}
	function PopupXMLObj_setUrl(sUrl) {
		this.url = sUrl;
		if (this.url.indexOf("?")) { this.url = this.url.substring(this.url.indexOf("?")+1); }
	}
	function PopupXMLObj_setCallback(oFncCallback)
	{
		this.callback = oFncCallback;
	}
}
