	

/* http://isaacschlueter.com/2006/10/msie-memory-leaks/ */
	function dbQuery() {
		this.callbackObject = null;
		this.rowArray = new Array();
		this.POLL_INTERVAL = 100;
	}
	dbQuery.prototype.requestData = function(scriptURL,callbackObject,callbackMethod) {
		this.scriptURL = scriptURL;
		this.callbackObject = callbackObject;
		this.callbackMethod = callbackMethod;
		this.req = null;
		if (window.XMLHttpRequest) {
			this.req = new XMLHttpRequest();
		}       
		else if (window.ActiveXObject) {
			this.req = new ActiveXObject("Microsoft.XMLHTTP");
		}


		this.req.open('GET', scriptURL);
	// 	var myParent = this;
		this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

// trying to polll to avoid circular references!
		var L=this;
		var M=function(){L.checkState();};
		this._interval=setInterval(M,this.POLL_INTERVAL);
/*
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
 				myParent.loadData(req);		
			}
		}
*/
		this.req.send(null);
	}
	dbQuery.prototype.checkState = function() {
		if (this.req.readyState == 4) {
 			this.loadData();		
			clearInterval(this._interval);
		}
	}
	dbQuery.prototype.loadData = function() {
		try  {
			try {
				var response = this.req.responseXML.documentElement;	
			}
			catch (excep) {
// if we don't get a response, we should still call the callback object
				debug("dbquery response is incorrect");
				if ((this.callbackObject)&&(this.callbackMethod)) {
					this.callbackObject[this.callbackMethod](this);
				}
			}
			for (var i=0;i<response.childNodes.length;i++) {
				var newRow = new dbObject(response.childNodes[i]);
				//var newRow = new dbObject();
				newRow.nodeName = response.childNodes[i].nodeName;
				for (var j=0;j<response.childNodes[i].childNodes.length;j++) {
					var currentNode = response.childNodes[i].childNodes[j];
					if (currentNode.childNodes.length > 0) {
						newRow.addProperty(currentNode.nodeName, currentNode.firstChild.nodeValue);
					}
				}
					this.rowArray.push(newRow);
			}
			if ((this.callbackObject)&&(this.callbackMethod)) {
				this.callbackObject[this.callbackMethod](this);
			}
		}
		catch (excep) {
			debug("excep: "+excep+" "+this.callbackMethod);
/*
			if ((this.callbackObject)&&(this.callbackMethod)) {
				this.callbackObject[this.callbackMethod](this);
			}
*/
		}	
		try { 
			delete this;
			// this = null;
		}
		catch (excep) {
		}
	}
	dbQuery.prototype.getRecordCount = function() {
		return  this.rowArray.length;
	}
	dbQuery.prototype.getRecord = function(recordPosition) {
		return  this.rowArray[recordPosition];
	}
	dbQuery.prototype.getRecords = function() {
		return this.rowArray;
	}
