/*******************************************************************************
* $Workfile: Menus.js $
*
* $Revision: 6 $
* $Author: Pms $
*
* ------------------------------------------------------------------------------
* $History: Menus.js $
* 
* *****************  Version 6  *****************
* User: Pms          Date: 10-03-04   Time: 18:39
* Updated in $/dev/InternetBanking/Website/Retail/Lf2/style
* Make horizontal menu work on login page
* 
* *****************  Version 5  *****************
* User: Pms          Date: 10-03-04   Time: 15:56
* Updated in $/dev/InternetBanking/Website/Retail/Lf1/style
* Moved some functions into the aspx because they're different in lf1 and
* lf2
* 
* *****************  Version 4  *****************
* User: Pms          Date: 1-03-04    Time: 18:19
* Updated in $/dev/InternetBanking/Website/Retail/Lf1/style
* Hide navigation submenu when mailbox is clicked
* 
* *****************  Version 3  *****************
* User: Pms          Date: 22-02-04   Time: 19:33
* Updated in $/dev/InternetBanking/Website/Retail/Lf1/style
* Retail1 and Corporate1 v1
* 
* *****************  Version 1  *****************
* User: Pms          Date: 18-02-04   Time: 12:37
* Created in $/deployment/current/Retail/Lf1/Website/style
* Created
* 
* *****************  Version 1  *****************
* User: Cfm          Date: 12-01-04   Time: 14:23
* Created in $/dependencies/BBCP/InternetBanking/Website/Retail/STYLE
* 
* *****************  Version 14  *****************
* User: Rcp          Date: 9-01-04    Time: 18:04
* Updated in $/deployment/current/Frontend/Retail/style
* Added support on QuartzStartProcess to changed start frame
* 
* *****************  Version 13  *****************
* User: Dpn          Date: 15-12-03   Time: 18:46
* Updated in $/deployment/current/InternetBanking/Retail/style
* Added unselect horizontal menu when "Mailbox" option is selected
* 
* *****************  Version 12  *****************
* User: Lft          Date: 10-12-03   Time: 22:09
* Updated in $/deployment/current/InternetBanking/Retail/style
* * Fix #295: Inline all of the CSS
* 
* *****************  Version 11  *****************
* User: Lft          Date: 27-10-03   Time: 19:45
* Updated in $/deployment/current/InternetBanking/Retail/style
* * Fix: Tentative attempt of fixing IE's cross-site scripting error. Is
* working Ok in both ie6/moz, but further testing is recommended to
* assure browser compliance from older IE
* * Todo: The wait message isn't being shown on moz based browsers. Must
* find alternative display mechanism.
* 
* *****************  Version 10  *****************
* User: Rcp          Date: 27-10-03   Time: 18:43
* Updated in $/deployment/current/InternetBanking/Retail/style
* Added pageOpen method
* 
* *****************  Version 9  *****************
* User: Lft          Date: 8-10-03    Time: 19:53
* Updated in $/dev/InternetBanking/Website/Retail/style
* * Change: Write a temporary document.
* 
* *****************  Version 8  *****************
* User: Lft          Date: 24/09/03   Time: 8:10p
* Updated in $/deployment/current/InternetBanking/Retail/style
* Add: ibPrint() method.
* 
* *****************  Version 7  *****************
* User: Lft          Date: 24/09/03   Time: 7:26p
* Updated in $/dev/InternetBanking/Website/Retail/style
* Fix: In mailInbox() don't use hard-coded value, instead use global var
* defined in document.
* 
* *****************  Version 6  *****************
* User: Lft          Date: 16/09/03   Time: 8:28p
* Updated in $/deployment/current/InternetBanking/Retail/style
* Add: Start Mail process on Inbox click
* Remove: menuApoioClicked() doesn't need to execute cmd (already done!)
* Change: quartzStartProcess() now only takes on single argument
* 
* *****************  Version 5  *****************
* User: Lft          Date: 16/09/03   Time: 11:16a
* Updated in $/dev/InternetBanking/Website/Retail/style
* Change: Whenever the user clicks on the Inbox menu then the message
* must be reset to default.
* 
* *****************  Version 4  *****************
* User: Lft          Date: 15/09/03   Time: 4:10p
* Updated in $/dev/InternetBanking/Website/Retail/style
* Change [MAJOR!]: Refactored the whole site. New aux methods coded,
* added full saf4 documentation.
* 
* *****************  Version 3  *****************
* User: Lft          Date: 8/09/03    Time: 5:28p
* Updated in $/dev/InternetBanking/Website/Retail/style
* Change: Added method to raise a current frame to the top.
* 
* *****************  Version 2  *****************
* User: Lft          Date: 8/09/03    Time: 3:42p
* Updated in $/dev/InternetBanking/Website/Retail/style
* Add: Versioning header
* Change: Removed start process
* 
*******************************************************************************/


/*
 * Helpers methods to handle Sub Menu
 */
 
 
/// <method name="menuApoioOver">
/// <summary>
/// Function that is executed when the mouse hovers over an horizontal
/// menu image. Removes the onOver handler and creates the onOut. It then
/// changes the source of the image to the hover one.
/// </summary>
/// <param name="option" type="element">
/// Reference to IMG element.
/// </param>
/// </method>
function menuApoioOver( option )
{
	option.onmouseover = "";
	option.onmouseout  = new Function( 'menuApoioOut( this );' );
	option.src = option.getAttribute( 'srcHover' );
}

/// <method name="menuApoioOut">
/// <summary>
/// Function that is executed when the mouse leaves a horizontal
/// menu image. Removes the onOut handler and creates the onHover
/// handler only if the element has a hover image. Finally, changes 
/// the source of the image to the normal one.
/// </summary>
/// <param name="option" type="element">
/// Reference to IMG element.
/// </param>
/// </method>
function menuApoioOut( option )
{
	option.onmouseout = "";
	
	if ( option.getAttribute( 'srcHover' ) != undefined )
		option.onmouseover = new Function( 'menuApoioOver( this );' );

	option.src = option.getAttribute( 'srcNormal' );
}

/// <method name="unselectMenuApoio">
/// <summary>
/// Resets the current selection of the horizontal menu (if any) 
/// to it's normal state.
/// </summary>
/// </method>
function unselectMenuApoio()
{
	var current = document.getElementById( 'menuApoioCurrent' );
	if ( current != undefined )
	{
		menuApoioOut( current );
		current.id = '';
	}
}



/*
 * Additional helpers to handle/provide support for Vertical Menu
 */
 
/// <method name="menuVerticalClicked">
/// <summary>
/// Helper function to process clicks on the vertical menu.
/// Hides the sub menu and resets any selection in the 
/// horizontal menu.
/// </summary>
/// </method>
function menuVerticalClicked()
{
	hideSubMenu();
	unselectMenuApoio();
}


function showNavigationSubMenu(name)
{
	var subMenu = document.getElementById( name );
    subMenu.style.display = '';
}	


/*
 * Helpers methods to handle Sub Menu
 */

/// <method name="showSubMenu">
/// <summary>
/// Shows the horizontal sub menu.
/// </summary>
/// </method>
function showSubMenu()
{
	var subMenu = document.getElementById( 'subMenu' );
    subMenu.style.display = 'block';

	unselectSubMenu();
}	



/// <method name="hideSubMenu">
/// <summary>
/// Hides the horizontal sub menu.
/// </summary>
/// </method>
function hideSubMenu()
{
	var subMenu = document.getElementById( 'subMenu' );
	if(subMenu != null)
	{
		subMenu.style.display = 'none';
	}
}	


/// <method name="selectSubMenuOption">
/// <summary>
/// Selects an option from the horizontal submenu.
/// </summary>
/// <param name="option" type="element">
/// Reference to the selected option.
/// </param>
/// </method>
function selectSubMenuOption( option )
{
	unselectSubMenu();
	option.id = 'subMenuCurrent';
}	


/// <method name="unselectSubMenu">
/// <summary>
/// Unselects the current sub menu option.
/// </summary>
/// </method>
function unselectSubMenu()
{
	var current = document.getElementById( 'subMenuCurrent' );
	if ( current != undefined )
		current.id = '';
}



/*
 * Helpers methods to invoke content retrieval
 */

/// <method name="quartzStartProcess">
/// <summary>
/// Starts the Quartz process.
/// </summary>
/// <param name="processName" type="string">
/// Name of Quartz process.
/// </param>
/// </method>

function quartzStartProcess( processName, sURL )
{

 if (sURL != null)
	pageOpen( sURL, "ContentVertical" );

	setLocation( "Flow.aspx?page=" + processName, "QuartzFrame" );


}

/// <method name="pageOpen">
/// <summary>
/// Open external link.
/// </summary>
/// <param name="sURL" type="string">
/// Link to be followed.
/// </param>
/// <param name="sFrame" type="string">
/// Frame.
/// </param>
/// </method>
function pageOpen( sURL, sFrame )
{
	setLocation( sURL, sFrame );
}


function setLocation( page, sFrame )
{
	var quartzFrame = document.getElementsByName( sFrame )[ 0 ];
	quartzFrame.contentWindow.location = "about:blank";
	
	if ( quartzFrame.readyState == undefined )
	{
		// Moz based
		loadPage( page, sFrame );
	}
	else
	{
		// IE based
		locationCallback( page, sFrame );
	}
}

function locationCallback( page, sFrame )
{
	var quartzFrame = document.getElementsByName( sFrame )[ 0 ];
	if (  quartzFrame.readyState != "complete" )
		window.setTimeout( "locationCallback( '" + page + "', '" + sFrame + "' );", 100 );
	else
		loadPage( page, sFrame );
}

function loadPage( page, sFrame )
{
	var quartzFrame = document.getElementsByName( sFrame )[ 0 ];
 	quartzFrame.contentWindow.document.write( '<html><style>BODY{font-family:Verdana,sans-serif;color:#CCC;background-color:#FFF;margin:0px;font-size:11px;}</style><body><div>' + waitMessage + '</div></html>' );
	quartzFrame.contentWindow.location = page;
}


/*
 * Special handling of Inbox icon/class. Enhancement of user interface
 * that enabled the user to identify the "target".
 */


/// <method name="mailInbox">
/// <summary>
/// The onClick() handler of the Mail DIV. Forces a stripping of the
/// 'hasMail' attribute from the current element. 
/// </summary>
/// <param name="field" type="element">
/// Reference to mail DIV.
/// </param>
/// </method>
function mailInbox( field )
{
	unselectAllMenus();
	field.removeAttribute( 'hasMail' );
	field.getElementsByTagName( 'span' )[ 0 ].innerHTML = mailbox;
	hideSubMenu();
	quartzStartProcess( 'Inbox', null );
}


/// <method name="onOverInbox">
/// <summary>
/// The onOver() handler. Used to enhance the user interface by
/// changing the mail icon and the text class.
/// </summary>
/// <param name="field" type="element">
/// Reference to mail DIV.
/// </param>
/// </method>
function onOverInbox( field )
{
	field.onmouseover = "";
	field.onmouseout = new Function( 'onOutInbox( this );' );

	field.getElementsByTagName( 'span' )[ 0 ].className = 'hover';
	field.getElementsByTagName( 'img'  )[ 0 ].src = 'images/email.HIGH.gif';
}


/// <method name="onOutInbox">
/// <summary>
/// The onOut() handler. Used to enhance the user interface by
/// changing the mail icon and the text class. Checks the
/// 'hasMail' attribute of the element to select the appropriate
/// reset icon.
/// </summary>
/// <param name="field" type="element">
/// Reference to mail DIV.
/// </param>
/// </method>
function onOutInbox( field )
{
	field.onmouseout = "";
	field.onmouseover = new Function( 'onOverInbox( this );' );

	field.getElementsByTagName( 'span' )[ 0 ].className = 'label';
	
	if ( field.getAttribute( 'hasMail' ) == 'true' )
		field.getElementsByTagName( 'img'  )[ 0 ].src = 'images/email.BLINK.gif';
	else
		field.getElementsByTagName( 'img'  )[ 0 ].src = 'images/email.LOW.gif';
}




/// <method name="ibPrint">
/// <summary>
/// Prints the 'internet banking' zone! =)
/// </summary>
/// </method>
function ibPrint()
{
	var quartzFrame = window.frames.QuartzFrame;
	quartzFrame.focus();
	quartzFrame.print();
}


/* eof */
