/*
' Start Header-----------------------------------------------------------
'
'     Kodak Graphic Communications Canada Company
'     Burnaby, BC, Canada
'     V5G 4M1
'
'     Copyright (c)2008 Kodak Graphic Communications Canada Company
'     Reproduction or disclosure of this file or its contents without
'     the prior written consent of Kodak is prohibited.
'
'     File Name:   incINTL_MenuUtils.js
'
'     Purpose:     JavaScript functions to provide support for DHTML
'                  menus using image maps.
'
'     Language(s): JavaScript
'
'     Platform:    IIS 5.0 on Windows 2000
'
'     Project:     ICW
'
' End Header-------------------------------------------------------------
*/

/************************************************************ INTL_MenuUtils_ImageSwap()
*
* Swaps in the correct image and clips out
* everything but the item we need.
*
************************************************************/
function INTL_MenuUtils_ImageSwap
(
    objEvent,
    strMenuId
)
{
  
  switch (objEvent.type)
  {
    case "mouseout" :
        document.getElementById( strMenuId ).style.visibility = "hidden";
        break;
      
    case "mouseover" :
        var objMenuElement = (objEvent.target) ? objEvent.target : objEvent.srcElement;
        var arrCoords = objMenuElement.coords.split(",");
        var strClipVal = "rect(" + arrCoords[1] + "px " +
                                   arrCoords[2] + "px " +
                                   arrCoords[3] + "px " +
                                   arrCoords[0] + "px)";
        var objImageStyle = document.getElementById( strMenuId ).style;
        objImageStyle.clip = strClipVal;
        objImageStyle.visibility = "visible";
        break;
  }
  objEvent.cancelBubble = true;
  return false;
  
} // INTL_MenuUtils_ImageSwap


/************************************************************ INTL_MenuUtils_ToggleMenu()
*
* Shows or hides the menu, depending on its current 
* visibility.
*
************************************************************/
function INTL_MenuUtils_ToggleMenu 
(
    strMenuIdRegularState, 
    strMenuIdHoverState
)
{
  var objMenuElementRegularState = document.getElementById( strMenuIdRegularState );
  var objMenuElementHoverState = document.getElementById( strMenuIdHoverState );
  
  if ( ( objMenuElementRegularState.style.visibility == "visible" ) ||
       ( objMenuElementHoverState.style.visibility == "visible" ) )
  {
    INTL_MenuUtils_HideMenu( strMenuIdRegularState, strMenuIdHoverState );
  }
  else
  {
    objMenuElementRegularState.style.visibility = "visible";
  }
    
} // INTL_MenuUtils_ToggleMenu

/************************************************************ INTL_MenuUtils_HideMenu()
*
* Hides the menu.
*
************************************************************/
function INTL_MenuUtils_HideMenu 
(
    strMenuIdRegularState,
    strMenuIdHoverState 
)
{
  
  document.getElementById( strMenuIdRegularState ).style.visibility = "hidden";
  document.getElementById( strMenuIdHoverState ).style.visibility = "hidden";
  
} //INTL_MenuUtils_HideMenu

/************************************************************* INTL_MenuUtils_HideMenuFromCanvas()
*
* Causes the menu to be hidden when the user clicks in the
* page but outside of the menu.
*
* Called from the onClick handler in <BODY>.
*
* See incINTL_LanguageSelection.asp for a function to write
* an onClick handler for the <BODY> tag that calls this function.
*
*************************************************************/
function INTL_MenuUtils_HideMenuFromCanvas
(
    objEvent,
    strSelectedLanguageImageId,
    strMenuIdRegularState,
    strMenuIdHoverState
)
{
  var objMenuElement;
  var strEventSourceId;

  objMenuElement = (objEvent.target) ? objEvent.target : objEvent.srcElement;
  strEventSourceId = objMenuElement.id;

  if ( strEventSourceId == null )
  {
      INTL_MenuUtils_HideMenu( strMenuIdRegularState, strMenuIdHoverState );
  }
  else if ( strEventSourceId != strSelectedLanguageImageId )
  {
      INTL_MenuUtils_HideMenu( strMenuIdRegularState, strMenuIdHoverState );
  }
} // INTL_MenuUtils_HideMenuFromCanvas

