/*---------------------------------------------------------------------
	File to contain general functions
-----------------------------------------------------------------------*/

/*-------------------------------
	Positioning Functions
---------------------------------*/
function MoveToByID(ID, x, y) {
	var node = document.getElementById(ID);
	MoveToByNode(node, x, y);
}
function MoveToByNode(node, x, y) {
	SetAbsPos(node, x, y);
}

function GetAbsXPosByID(ID) {
	var node = document.getElementById(ID);
	return GetAbsXPosByNode(node);
}
function GetAbsYPosByID(ID) {
	var node = document.getElementById(ID);
	return GetAbsYPosByNode(node);
}

function GetAbsXPosByNode(node) {
	nodeLeft = node.offsetLeft
	while(node.offsetParent!=null) {
		nodeParent = node.offsetParent
		nodeLeft += nodeParent.offsetLeft
		node = nodeParent
	}
	return nodeLeft;
}
function GetAbsYPosByNode(node) {
	nodeTop = node.offsetTop
	while(node.offsetParent!=null) {
		nodeParent = node.offsetParent
		nodeTop += nodeParent.offsetTop
		node = nodeParent
	}
	return nodeTop;
}

function SetAbsPos(node, x, y) {
	SetAbsXPos(node, x);
	SetAbsYPos(node, y);
}
function SetAbsXPos(node, x) {
	node.style.position = "absolute";
	node.style.left = x + "px";
}
function SetAbsYPos(node, y) {
	node.style.position = "absolute";
	node.style.top = y + "px";
}



function GetHeightByID(ID) {
	var node = document.getElementById(ID);
	GetHeightByNode(node);
}
function GetWidthByID(ID) {
	var node = document.getElementById(ID);
	GetWidthByNode(node);
}

function GetHeightByNode(node) {
	return node.offsetHeight;
}
function GetWidthByNode(node) {
	return node.offsetWidth;
}

/*-------------------------------
	DOM Whitespace Functions
---------------------------------*/

function getFirstChild(currentNode) { 
	var checkNode = currentNode.firstChild;
	while (checkNode && checkNode.nodeType != 1) {
		checkNode = checkNode.nextSibling;
	}
	return checkNode;
}

function getNextSibling(currentNode)
{
	var checkNode = currentNode.nextSibling;
	while (checkNode && checkNode.nodeType != 1) {
		checkNode = checkNode.nextSibling;
	}
	return checkNode;
}