/*
	Used by the index page of Cogent Applicant Processing Systems to control the height of an IFRAME for contents and provide some navigation functions.
*/
var gbIsIE = ( navigator.userAgent.match( /MSIE/ ) == "MSIE" );
var gbIsFirefox = navigator.userAgent.match( /Firefox/ );
var goContent;
var gnDefaultHeight = 580;
var gnMarginOffset = 40;

window.onload = Init;

function Init()
{
	goContent = document.getElementById("idContent");
	goContent.scrolling = "no";

	if ( !gbIsIE )
		goContent.onload = ResizeContent;
	else
		goContent.onreadystatechange = function()
		{
			if ( this.readyState == "complete" )
				ResizeContent();
		};

	SetFrameHeightByContent();
}

function ResizeContent()
{
	try
	{
		SetFrameHeightByContent();
	}
	catch(e)
	{
		setTimeout( "SetFrameHeight(" + gnDefaultHeight + ")", 100 );
	}
}

function SetFrameHeightByContent()
{
	if ( !gbIsIE )
	{
		if ( goContent.contentWindow.location.href.match( /\.pdf$/i ) )
			goContent.style.height = gnDefaultHeight;
		else
		{
			if (goContent.contentWindow.document.body.offsetHeight > gnDefaultHeight)
				goContent.style.height = goContent.contentWindow.document.body.offsetHeight + gnMarginOffset;
			else
				goContent.style.height = gnDefaultHeight;
		}
	}
	else
	{
		if (goContent.contentWindow.document.body.scrollHeight > gnDefaultHeight)
			goContent.style.height = goContent.contentWindow.document.body.scrollHeight + gnMarginOffset;
		else
			goContent.style.height = gnDefaultHeight;
	}
}

function SetFrameHeight( nSize )
{
	goContent.style.height = nSize;
}

function GoHome()
{
	location.href = '/';
}

function GoBack()
{
	goContent.contentWindow.history.go( -1 );
}

function GoMIHome()
{
	location.href = '/mi/index.htm';
}
