
/*
//The event object will be null if called across frames (ie, parent.mousex), and will return an incorrect result.
//In order to minimise code repetition, this code is defined here and included in each frame where the functions are required.
*/

//These return mouse position relative to frame.  Top left corner of each embedded frame is 0,0.
function mousex (e) {
	if (e)
		return (e.pageX);
	else
		return (window.event.clientX);
}

function mousey (e) {
	if (e)
		return (e.pageY);
	else
		return (window.event.clientY);
}

//These functions are used to navigate around table and other dom structures with relative references.
//It seems mozilla will interpret blank space as a previous sibling.  For layout simplicity, i use this function
//to make sure the node type is the proper one before returning it.  3 is the text node type.
//Referenced in MapDisplay/default.asp, MapDisplay/AssetRequest.asp, MapDisplay/Quotes.asp, and Admin/Buildings.asp.
//Since this is a generalised series of functions, it should actually be in lib/javascript and not MapDisplay/lib/javascript.  Fix later.
function previous (node) {
	if (node != null) {
		if (node.previousSibling != null)
			if (node.previousSibling.nodeType == 3)
				return (previous (node.previousSibling));
			else
				return (node.previousSibling);
	}
}

function next(node){
	if (node != null) {
		if (node.nextSibling != null)
			if (node.nextSibling.nodeType == 3)
				return (next (node.nextSibling));
			else
				return (node.nextSibling);
	}
}

function firstchild(node) {
	if (node != null) {
		if (node.firstChild != null)
			if (node.firstChild.nodeType == 3)
				return next(node.firstChild);
			else
				return (node.firstChild);
	}
}
