//	test
vmargin		= 0;

function InitTabs( groupid, opentab )
{
	//	Keep track of which item is tallest
	maxheight	= 0;

	//	Get the height of the container block
	objheight	= getOffsetHeight( groupid );

	//	Number of tabs
	tabcount	= eval( groupid + "count" );

	//	Static sizing
	static_size	= eval( groupid + "static_size" );

	if( static_size )
	{
		//	Process each
		for( tab_num = 1; tab_num <= tabcount; tab_num++ )
		{
			//	Tab-page ID
			contentid	= groupid + tab_num;

			//	Get the object
			contentObj	= document.getElementById( contentid );

			//	How big is it?
			itemheight	= getOffsetHeight( contentid );

			//	Bigger than previous?
			if( itemheight > ( maxheight + vmargin ))
			{
				//	Yes, reset new maximum
				maxheight	= itemheight - vmargin;
			}
		}
	
		//	Adjust container (group) object height
		document.getElementById( groupid ).style.height	= ( maxheight + vmargin ) + 'px';
	
		//	Adjust individual page object heights
		for( tab_num = 1; tab_num <= tabcount; tab_num++ )
		{
			contentid				= groupid + tab_num;
			contentObj	= document.getElementById( contentid );
			contentObj.style.height	= ( maxheight + vmargin ) + 'px';
		}
	}

	//	Go to first (or specified) page
	SwitchTab( groupid, opentab );
}

//=============================================================================
//-----------------------------------------------------------------------------
//	Change tab
//-----------------------------------------------------------------------------
//=============================================================================
function SwitchTab( groupid, itemid )
{
	//	How many in this group
	tabcount	= eval( groupid + "count" );

	//	Get the page object to be switched to
	contentid	= groupid + itemid;
	contentObj	= document.getElementById( contentid );
	
	//	Make it visible and at top of stack
	contentObj.style.visibility	= "visible";
	contentObj.style.zIndex		= 49;

	//	Static sizing
	static_size	= eval( groupid + "static_size" );

	if( !static_size )
	{
		//	Adjust container (group) object height
		//		Add 2 px for border
		document.getElementById( groupid ).style.height	= parseInt( 2 + getOffsetHeight( contentid )) + 'px';
	}

//	contentObj.style.height		= maxheight + "px";

	//	Get the tabs list
	tabcontainer	= groupid + "tabs";
	tabcontainerObj	= document.getElementById( tabcontainer );

	//	Get the list items within the tabs list
	tabs	= tabcontainerObj.getElementsByTagName('li');

	//	Process each one
	for( tab_num = 1; tab_num <= tabcount; tab_num++ )
	{
		//	If currently selected
		if( tab_num == itemid )
		{
			//	Set style to active
			tabs[ tab_num - 1 ].className	= "tab1";
			continue;
		}

		//	Get the page object
		tab_id	= groupid + tab_num;
		tab_obj	= document.getElementById( tab_id );

		//	Hide it
		tab_obj.style.visibility	= "hidden";

		//	Make its tab inactive
		tabs[ tab_num - 1 ].className	= "tab0";

	
		tab_obj.style.zIndex		= 48;
	}

}


