// crossbrowser javascript lib written by Adrian Scripca aka benishor
// benny@incremental.ro

var isIE = document.all ? true : false;
var isNN = document.layers ? true : false;
var isDOM = document.getElementById ? true : false;

function GetObjectByID( anID )
{
	return ( isIE ? document.all( anID ) : ( isNN ? document.layers[anID] : document.getElementById( anID ) ) );
}

function SetObjectPosition( anID, anX, anY )
{
	theObject = GetObjectByID( anID );

	if ( isIE )
	{
		theObject.style.pixelLeft = anX;
		theObject.style.pixelTop  = anY;

	} else if ( isNN )
	{
		theObject.left = anX;
		theObject.top  = anY;

	} else if ( isDOM )
	{
		theObject.style.left = anX;
		theObject.style.top  = anY;
	}
}


function SetObjectHeight( anID, aHeight )
{
	theObject = GetObjectByID( anID );
	theObject.offsetHeight = aHeight;
}

function SetObjectWidth( anID, aWidth )
{
	theObject = GetObjectByID( anID );
	theObject.offsetWidth = aWidth;
}

function GetObjectHeight( anID )
{
	theObject = GetObjectByID( anID );
	return theObject.offsetHeight;
}

function GetObjectWidth( anID )
{
	theObject = GetObjectByID( anID );
	return theObject.offsetWidth;
}

function GetObjectTop( anID )
{
	theObject = GetObjectByID( anID );
	return GetAbsoluteTop( theObject );
}

function GetObjectLeft( anID )
{
	theObject = GetObjectByID( anID );
	return GetAbsoluteLeft( theObject );
}

function GetAbsoluteLeft( anObject )
{
	if ( anObject.x ) return anObject.x;
	else
	{
		thePos = 0;
		while ( anObject != null )
		{
			thePos += anObject["offsetLeft"];
			anObject = anObject["offsetParent"];
		}
		return thePos;
	}
}

function GetAbsoluteTop( anObject )
{
	if ( anObject.y ) return anObject.y;
	else
	{
		thePos = 0;
		while ( anObject != null )
		{
			thePos += anObject["offsetTop"];
			anObject = anObject.offsetParent;
		}
		return thePos;
	}
}

function SetObjectVisibility( anID, isVisible )
{
	theObject = GetObjectByID( anID );
	if ( !theObject ) return;

	if ( isIE || isDOM ) theObject.style.visibility = isVisible ? 'visible' : 'hidden';
	if ( isNN ) theObject.visibility = isVisible ? 'visible' : 'hidden';
}

function IsObjectVisible( anID, isVisible )
{
	theObject = GetObjectByID( anID );
	return ( ( isIE || isDOM ) ? ( theObject.style.visibility == 'visible' ) : ( theObject.visibility == 'visible' ) );
}

function ToggleVisibility( anID )
{
	SetObjectVisibility( anID, IsObjectVisible( anID ) ? false : true );
}