// ----------------------------------------------------------------------------------
//	Java Scroll Code
// ----------------------------------------------------------------------------------

// Global variable to hold the width of the contents area (divContent).
// Call function GetWidthOfContentsArea to retrieve this value.
var g_intWidthOfContents = 0;

// Global variable to hold the height of the contents area (divContent).
// Call function GetHeightOfContentsArea to retrieve this value.
var g_intHeightOfContents = 0;

function InitialseJSScrollItems()
{
	if(IsPageDisplayedInPageContentsWindow() == true)
	{
		DisplayPageWithScrollControls();
	}
	else
	{
		DisplayPageWithoutScrollControls();
	};
}

function DisplayPageWithoutScrollControls(intPageHeight)
{
	var objContainer = document.all.item("divContainer");
	var objContent	 = document.all.item("divContent");
	
	var intWidth  = (screen.availWidth - 10);
	var intHeight = objContent.scrollHeight;
	
	objContainer.style.height = intHeight;
	objContent.style.height   = intHeight;
	objContainer.style.clip   = "rect(0," + intWidth + "," + intHeight + ",0)";
}

function DisplayPageWithScrollControls()
{
	var objPageContents = document.parentWindow.parent.document.all.item("PageContents");
	var intFrameHeight	= (objPageContents.offsetHeight - objPageContents.offsetTop);
	var intFrameWidth	= (objPageContents.offsetWidth  - objPageContents.offsetLeft);
	
	var intScrollButtonWidth	   = 16;
	var intScrollButtonHeight	   = 22;
	var intScrollButtonMargins	   = 0;
	var intGapBetweenScrollButtons = 5;
	
	var intButtonSpaces	= (intScrollButtonHeight + intGapBetweenScrollButtons) ;

	var intLeft		= intFrameWidth  - (intScrollButtonWidth + intScrollButtonMargins);
	var intTop		= intScrollButtonMargins + 4;
	var intWidth	= intFrameWidth  - (intScrollButtonWidth + (intScrollButtonMargins * 2)) + 5;
	var	intHeight	= intFrameHeight - intScrollButtonMargins - intGapBetweenScrollButtons;

	moveButton("divUpControl"		, intTop							, intLeft);
	moveButton("divUpMediumControl"	, intTop + intButtonSpaces			, intLeft);
	moveButton("divUpSlowControl"	, intTop + (intButtonSpaces * 2)	, intLeft);
	
	intTop		= intFrameHeight - (intButtonSpaces * 3) - intGapBetweenScrollButtons + 3;
	
	moveButton("divDownSlowControl"		, intTop							, intLeft);
	moveButton("divDownMediumControl"	, intTop + intButtonSpaces			, intLeft);
	moveButton("divDownControl"			, intTop + + (intButtonSpaces * 2)	, intLeft);
		
	// Resize containers
	var objContainer = document.all.item("divContainer");
	var objContent	 = document.all.item("divContent");
				
	objContainer.style.width  = intWidth;
	objContainer.style.height = intHeight;
	
	objContent.style.width	  = intWidth;
	
	g_intWidthOfContents	  = intWidth;
	g_intHeightOfContents	  = intHeight;
	
	objContainer.style.clip   = "rect(0," + intWidth + "," + intHeight + ",0)"
	
	document.frames('JScrollCode').InitJavaScroll(0,intHeight);
}

function moveButton(strButtonName, intTop, intLeft)
{
	objButton = document.all.item(strButtonName);
	objButton.style.left = intLeft;
	objButton.style.top = intTop;
}

function IsPageDisplayedInPageContentsWindow()
{
	return (document.parentWindow.name == "PageContents");
}

// Returns the width of the contents area (divContents).
//
function GetWidthOfContentsArea()
{
	return g_intWidthOfContents;
}

// Returns the height of the contents area (divContents).
//
function GetHeightOfContentsArea()
{
	return g_intHeightOfContents;
}

// The function hides div divHidePageContents, which is used to hide the
// contents of the page until it is fully loaded.
//
function DisplayPageContents()
{
	var objDiv = document.all.item("divHidePageContents");
	
	if(objDiv != null)
	{
		document.all.item("divHidePageContents").style.visibility = "hidden" ;
	}
	else
	{
		alert("ERROR DisplayPageContents\n\ndivHidePageContents does not exist in the current page.");
	};	
}
