// AU3utilities.js
// (c) 2007 ISoftData Systems, Inc.
// Brian Roy
// Last modified: 5/31/07

// This library contains a set of common utility functions for use in the
//	AU3Ajax project.  These are general purpose utilities with no specific
//	Ajax requirements.
//////////////////////////////////////////////////////
// Utility functions
/////////////////////////////////////////////////////

// findPosX( objid )
// Input: the id to an object
// Return: the x coordinate position of the object
// This function finds the x coordinate position of an object, given the 
//	object's id.  Pretty straight forward.
function findPosX( objid )
{
	var obj = document.getElementById( objid );
	var currentLeft = 0;

	// adjust our current left position to the position of the object's parent
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			currentLeft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
	{
		// adjust our left position by the object's actual x position
		currentLeft += obj.x;
	}
	return currentLeft;
}

// findPosY( objid )
// Input: the id to an object
// Return: the y coordinate position of the object
// This function finds the y coordinate position of an object, given the 
//	object's id.  Pretty straight forward.
function findPosY( objid )
{
	var obj = document.getElementById( objid );
	var currentTop = 0;

	// adjust our current top position to the position of the object's parent
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			currentTop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
	{
		// adjust our top position by the object's actual y position
		currentTop += obj.y;
	}
	return currentTop;
}

// setValue( objid, newValue )
// Input: an id to an object, data to set that object's value parameter to
// Return: none
// This function is also straight-forward.  It simply sets the value of a 
//	specified object to some input data.
function setValue( objid, newValue )
{
	var obj = document.getElementById( objid );
	obj.value = newValue;
}

// hideObj( objid )
// Input: an id to an object
// Return: none
// This function simply hides an object, which is idenfied by its id.
//	The object is also shrunk to a size of 0x0, to prevent flow problems and
//	ensure the object's invisibility.
function hideObj( objid )
{
	var obj = document.getElementById( objid );
	obj.style.visibility = "hidden";
	obj.style.height = "0px";
	obj.style.width = "0px";
}
