function ckDHTMLObj() {
	this.mouseX = 0; //see trackMousePosition() 
	this.mouseY = 0;

	return this;
	
}

ckDHTMLObj.prototype = {
	
	getTopPos : function(oEl) {
		var returnValue = parseInt(oEl.offsetTop);

		while((oEl = oEl.offsetParent) != null){
			if(oEl.tagName!='HTML'){
				returnValue += oEl.offsetTop;
				if(document.all)returnValue+=oEl.clientTop;
			}
		} 
		return returnValue;

	},
	
	getLeftPos : function(oEl) {
		var returnValue = parseInt(oEl.offsetLeft);
		while((oEl = oEl.offsetParent) != null){
		  	if(oEl.tagName!='HTML'){
		  		returnValue += oEl.offsetLeft;
		  		if(document.all)returnValue+=oEl.clientLeft;
		  	}
	  	}
	  	return returnValue;
	},
	
	getRightPos : function(oEl) {
		var leftPos = this.getLeftPos(oEl);
		return leftPos + (oEl.offsetWidth); //untested
	},
	
	
	hitTest : function (oTarget,mouseX, mouseY) {
		//oTarget is a reference to an HTML element on the screen
		var bHit = false;
		if (oTarget) {
			var mouseX = this.getMouseX();
			var mouseY = this.getMouseY();
			
			var leftPosEl = this.getLeftPos(oTarget);
			var topPosEl = this.getTopPos(oTarget);
			var widthEl = oTarget.offsetWidth;
			var heightEl = oTarget.offsetHeight;
			
			bHit = (mouseX > leftPosEl && mouseX < (leftPosEl + widthEl) && mouseY > topPosEl && mouseY < (topPosEl + heightEl))
		}
		return bHit;		
	},
	
	seekWithin : function(oContainer,tagName,id) {
		//given an outer container and a tagname, find the element with the specified id.  
		var oEl = null;
		if (oContainer) {
			var aEl = oContainer.getElementsByTagName(tagName.toUpperCase());
			for (var index=0; index < aEl.length; index++) {
				if (aEl[index].id==id) {
					oEl = aEl[index];
					break;
				}
			}	
		}
		return oEl;
	},
	
	seekParentTag: function(oObj,tagName) {
		if (oObj) {
			try {
				tagName = tagName.toUpperCase();
				var oParent = oObj.parentNode; //parentNode required for Firefox compatibility
				while (oParent && oParent.tagName.toUpperCase() != tagName) {
					oParent = oParent.parentNode;
				}
			
			} catch(e) {
				throwConsoleError("oDHTML.seekParentTag",e)
			}
			return oParent;
		}
	},
	
	isChildOfParentID: function(oObj,parentID) {
		var bChild = false;
		var oParent;
		if (oObj) {
			try {
				oParent = oObj.parentNode;
				while (oParent && !bChild) {
					bChild = (oParent.id == parentID) 
					oParent = oParent.parentNode;
				}		
			} catch(e) {}
		}
		return bChild;
	},

	
	_recordMousePos : function(e){
		if (!e) var e = (window.event||window.Event);

		if(typeof(e.pageX) != 'undefined') {
			oDHTML.mouseX = e.pageX; //assumes global oDHTML object
			oDHTML.mouseY = e.pageY;
		} else {
			oDHTML.mouseX = e.clientX + document.body.scrollLeft;
			oDHTML.mouseY = e.clientY + document.body.scrollTop;
		}
	},
	
	trackMousePosition : function() {
		//must be called before attempting to retrieve mouseX or mouseY properties. This is so we're not constantly tracking when we don't need to be
		//if(window.Event && document.captureEvents) document.captureEvents(Event.MOUSEMOVE); //Tell Mozilla to start listening...not needed
		addEvent(document,"mousemove",this._recordMousePos);
		
	}


	
}
