/*---------------------------------------------------------------------
	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;
}



/*-------------------------------
	Flash Functions
---------------------------------*/

function PlaceFlash(bFlashEnabled, sID, iWidth, iHeight, sPath, sBaseFileName, sBGColor, sHref, sTarget)
{
	if ( bFlashEnabled ) {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=3,0,0,0" ');
		document.write(' id="' + sID + '" width="' + iWidth + '" height="' + iHeight + '" align="">');
		document.write(' <param name="movie" value="' + sPath + sBaseFileName +'.swf" />');
		document.write(' <param name="quality" value="high" />');
		document.write(' <param name="wmode" value="opaque" />');
		if (sBGColor != null) {
			document.write(' <param name="bgcolor" value="#' + sBGColor + '" />  ');
			document.write(' <embed src="' + sPath + sBaseFileName +'.swf" quality="high" wmode="opaque" bgcolor="#' + sBGColor + '"  ');
		} else {
			document.write(' <embed src="' + sPath + sBaseFileName +'.swf" quality="high" wmode="opaque"  ');
		}
		document.write(' swLiveConnect="FALSE" width="' + iWidth + '" height="' + iHeight + '" name="' + sID + '" align=""');
		document.write(' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
		document.write(' </embed>');
		document.write(' </object>');

	}
	else{
		if (sTarget != null) {
			document.write('<a href="' + sHref + '" target="' + sTarget + '"><img src="' + sPath + sBaseFileName +'.gif" width="' + iWidth + '" height="' + iHeight + '" border="0" alt="' + sID + '" /></a>');
		} else {
			document.write('<a href="' + sHref + '"><img src="' + sPath + sBaseFileName +'.gif" width="' + iWidth + '" height="' + iHeight + '" border="0" alt="' + sID + '" /></a>');
		}
	}
}
