// pragma page ""
// pragma page "Global::Declarations::Globals"
////////////////////////////////////////////////////////////////
//
// Global variable declarations
//
////////////////////////////////////////////////////////////////
var gbTimer				= false;
var gTimeOut			= 1000;
var gTimerId			= null;
var gsFontSize			= "";


// pragma page ""
// pragma page "Global::Function::anchorItemUnderline"
////////////////////////////////////////////////////////////////
//
// Underline anchor item
//
////////////////////////////////////////////////////////////////
function anchorItemUnderline(
  rRef
, bUdln
)
{
	var obj = null;

	if( typeof( rRef ) == "string" )
	{
		obj = document.getElementById( rRef );
	}
	else
	if( typeof( rRef ) == "object" )
	{
		obj = rRef;
	}

	if( obj == null )
	{
		return;
	}

	if ( bUdln )
	{
		obj.style.textDecoration = "underline";
	}
	else
	{
		obj.style.textDecoration = "none";
	}
}

// pragma page "Global::Function::hide"
////////////////////////////////////////////////////////////////
//
// Hides inputted visible layer
//
////////////////////////////////////////////////////////////////
function show(
  rIds
, bShow
)
{
	for( var i = 0; i < rIds.length; i++ )
	{
		var obj = document.getElementById( rIds[ i ] );

		if( obj == null )
		{
			continue;
		}

		if ( bShow )
		{
			obj.style.visibility = "visible";
		}
		else
		{
			obj.style.visibility = "hidden";
		}
	}
}

// pragma page "Global::Function::menuItemHighlight"
////////////////////////////////////////////////////////////////
//
// Highlights inputted row/cell
//
////////////////////////////////////////////////////////////////
function menuItemHighlight(
  rRef
, bHilt
)
{
	var obj = null;

	if( typeof( rRef ) == "string" )
	{
		obj = document.getElementById( rRef );
	}
	else
	if( typeof( rRef ) == "object" )
	{
		obj = rRef;
	}

	if( obj == null )
	{
		return;
	}

	if ( bHilt )
	{
		if( ( obj.className.indexOf( 'Sub'		) != -1 ) ||
			( obj.className.indexOf( 'DropDown' ) != -1 ) )
		{
			obj.style.backgroundColor = "#fdfaf7";
		}
		else
		if( obj.className.indexOf( 'FlyOut' ) != -1 )
		{
			obj.style.backgroundColor = "#ede3c7";
		}
	}
	else
	{
		if( obj.className.indexOf( 'DropDown' ) )
		{
			obj.style.backgroundColor = "";
		}
		else
		if( obj.className.indexOf( 'FlyOut' ) )
		{
			obj.style.backgroundColor = "";
		}
	}
}

// pragma page "Global::Function::menuHideAll"
////////////////////////////////////////////////////////////////
//
// Hides all visible layers
//
////////////////////////////////////////////////////////////////
function menuHideAll()
{
	show( new Array( 'idMenuWho' , 'idMenuWhat' , 'idMenuWhere' , 'idMenuNews' , 'idMenuInfo' ) , false );

	menuHideAllSub();
}

// pragma page "Global::Function::menuHideAllSub"
////////////////////////////////////////////////////////////////
//
// Hides all visible layers
//
////////////////////////////////////////////////////////////////
function menuHideAllSub()
{
	show( new Array( 'idMenuWhatSub0' , 'idMenuWhatSub1' , 'idMenuWhatSub2' ) , false );

	menuItemHighlight( 'idMenuWhat0' , false );
	menuItemHighlight( 'idMenuWhat1' , false );
	menuItemHighlight( 'idMenuWhat2' , false );
}

// pragma page "Global::Function::menuStartTime"
////////////////////////////////////////////////////////////////
//
// Starts timeout timer
//
////////////////////////////////////////////////////////////////
function menuStartTime()
{
	//
	// If has timed out
	//
	if ( gbTimer == false )
	{
		gTimerId	= setTimeout( "menuHideAll()" , gTimeOut );
		gbTimer		= true;
	}
}


// pragma page "Global::Function::menuStopTime"
////////////////////////////////////////////////////////////////
//
// Stops timeout timer
//
////////////////////////////////////////////////////////////////
function menuStopTime()
{
	//
	// If timer is active
	//
	if ( gbTimer )
	{
		clearTimeout( gTimerId );
		gTimerId	= null;
		gbTimer		= false;
	}
}

function createCookie(
  name
, value
, vDays
)
{
	if( vDays )
	{
		var date = new Date();
		date.setTime( date.getTime() + ( vDays * 24 * 60 * 60 * 1000 ) );

		var expires = "; expires=" + date.toGMTString();
	}
	else
	{
		var expires = "";
	}

	document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(
  name
)
{
	var									nameEQ	= name + "=";
	var									ca		= document.cookie.split( ';' );

	for( var i = 0 ; i < ca.length; i++ )
	{
		var								c = ca[ i ];
		while( c.charAt( 0 ) == ' ' )
		{
			c = c.substring( 1 , c.length );
		}

		if( c.indexOf( nameEQ ) == 0 )
		{
			return c.substring( nameEQ.length , c.length );
		}
	}

	return null;
}

function setFontSize(
  rRef
, sSize
)
{
	var obj		= null;
	var sPad	= "";

	if( typeof( rRef ) == "string" )
	{
		obj = document.getElementById( rRef );
	}
	else
	if( typeof( rRef ) == "object" )
	{
		obj = rRef;
	}

	if( sSize == null )
	{
		sSize = readCookie( 'font-size' );

		if( sSize == null )
		{
			sSize = "12";
		}
	}

	gsFontSize = sSize;

	createCookie( 'font-size' , sSize , 30 );

	switch( sSize )
	{
	case "11":
		sPad = "0px 20px 0px 0px";
		break;
	case "12":
		sPad = "0px 20px 10px 0px";
		break;
	case "13":
		sPad = "0px 20px 20px 0px";
		break;
	}

	obj.style.fontSize	= sSize + "px";
	obj.style.padding	= sPad;

	if( document.getElementById( "aFontSize11" ) != null )
	{
		document.getElementById( "aFontSize11" ).style.fontWeight = "normal";
		document.getElementById( "aFontSize12" ).style.fontWeight = "normal";
		document.getElementById( "aFontSize13" ).style.fontWeight = "normal";

		document.getElementById( "aFontSize" + sSize ).style.fontWeight = "bold";
	}
}

function getFontSizeString(
  rRefHdr
, rRefBody
)
{
	var objHdr	= null;
	var objBody	= null;

	if( typeof( rRefHdr ) == "string" )
	{
		objHdr = document.getElementById( rRefHdr );
	}
	else
	if( typeof( rRefHdr ) == "object" )
	{
		objHdr = rRefHdr;
	}

	if( typeof( rRefBody ) == "string" )
	{
		objBody = document.getElementById( rRefBody );
	}
	else
	if( typeof( rRefBody ) == "object" )
	{
		objBody = rRefBody;
	}

	setFontSize( objBody );
	var sObj11 = "";
	var sObj12 = "";
	var sObj13 = "";

	for( var i = 2; i < arguments.length; i++ )
	{

		setFontSize( arguments[ i ] );
		sObj11 += " setFontSize( '" + arguments[ i ] + "' , '11' );";
		sObj12 += " setFontSize( '" + arguments[ i ] + "' , '12' );";
		sObj13 += " setFontSize( '" + arguments[ i ] + "' , '13' );";
	}

	var s11 = "font-weight: normal";
	var s12 = "font-weight: normal";
	var s13 = "font-weight: normal";

	switch( gsFontSize )
	{
	case "11":
		s11 = "font-weight: bold";
		break;
	case "12":
		s12 = "font-weight: bold";
		break;
	case "13":
		s13 = "font-weight: bold";
		break;
	}

	var sHtml = "";

	sHtml += '<div style="width: 500px;">';
	sHtml += '<b><i>Font size:</i></b>&#160;&#160;';
	sHtml += '<a id="aFontSize11" style="font-size: 11px; ' + s11 + ';" href="javascript: setFontSize( \'' + objBody.id + '\' , \'11\' ); ' + sObj11 + '" onmouseover="anchorItemUnderline( this , true );" onmouseout="anchorItemUnderline( this , false );">A</a>&#160;&#160;';
	sHtml += '<a id="aFontSize12" style="font-size: 12px; ' + s12 + ';" href="javascript: setFontSize( \'' + objBody.id + '\' , \'12\' ); ' + sObj12 + '" onmouseover="anchorItemUnderline( this , true );" onmouseout="anchorItemUnderline( this , false );">A</a>&#160;&#160;';
	sHtml += '<a id="aFontSize13" style="font-size: 13px; ' + s13 + ';" href="javascript: setFontSize( \'' + objBody.id + '\' , \'13\' ); ' + sObj13 + '" onmouseover="anchorItemUnderline( this , true );" onmouseout="anchorItemUnderline( this , false );">A</a>&#160;&#160;';
	sHtml += '</div>';

	objHdr.innerHTML = sHtml;
}
