//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
function PositionSubMenu( topnavid )
{
	subMenu		= document.getElementById("nav-section");

	subMenu.style.left = getOffsetLeft( topnavid ) + parseInt( getOffsetWidth( topnavid ) / 2 ) +  'px';
	subMenu.style.top  = ( getOffsetTop( topnavid ) + getOffsetHeight( topnavid )) + 2 + 'px';
}

//*******************************************************************************************************
//	modified uber menu functions
//*******************************************************************************************************
var previous_menu = 'nav-section';
//-------------------------------------------------------------------------------------------------------
//	MODIFIED: Show menus
//-------------------------------------------------------------------------------------------------------
function ITGshow(group,item,imgId,imgBase,topnavid)
{
	if( !document.getElementById )
	{
		return;
	}

	menuCount	= eval("m_" + group);
	
	mainMenu	= document.getElementById("m" + group + "0");
	subMenu		= document.getElementById("m" + group + item);

	//	Does object exist?
	if( !subMenu )
	{
		//	No, don't process
		return false;
	}
	
	if( imgId != 'NULL' )
	{
		imgObj	= document.getElementById( imgId );
		imgObj.setAttribute( 'base', imgBase );
		imgObj.setAttribute( 'src', imgBase );
	}
	
	mainMenu.style.visibility	= "visible";
	
	//	Position the menu based on the top nav'd position
	if ( topnavid )
	{
		subMenu.style.left = getOffsetLeft( topnavid ) + parseInt( getOffsetWidth( topnavid ) / 2 ) + 'px';
		subMenu.style.top  = ( getOffsetTop( topnavid ) + getOffsetHeight( topnavid )) + 1 + 'px';
	}

	if ((mainMenu != subMenu) && (item != 0))
	{
		subMenu.style.visibility	= "visible";
		for (i = 1; i <= menuCount; i++)
		{
			if (i != item)
			{
				document.getElementById("m" + group + i).style.visibility	= "hidden";
			}
		}
	}

	//	Get ID of parent item
	pid	= 'p' + group + item;

	//	Highlight the parent item
	tmpClassName	= document.getElementById( pid ).className;
	document.getElementById( pid ).setAttribute( "tmpClassName", tmpClassName )

//	document.getElementById( pid ).className	= 'highlight';

	//	Make sure it gets displayed
	subMenu.style.display	= "block";

	//	Hide the main nav so it doesn't show through
//	document.getElementById( 'nav-section' ).style.visibility	= "hidden";

	if( previous_menu != ( "m" + group + "0" ))
	{
		//	Hide previous menu so it doesn't show through
		document.getElementById( previous_menu ).style.display	= "none";
	}

	//	Previous = current (to hide on next show)
	previous_menu	= "m" + group + "0";
}


function PickRandomFile( filesarray )
{
	eval( "count	= " + filesarray + ".length;" );

	index	= Math.random() * count;
	index	= Math.round( index );


	eval( "url	= " + filesarray + "[" + index + "];" );

	return( url );
}
